Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-devel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
143
Issues
143
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
emulab
emulab-devel
Commits
12804432
Commit
12804432
authored
Aug 23, 2017
by
Leigh B Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete more incredibly obsolete files to avoid messing with card/port
stuff in them.
parent
5ceed4c0
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
7 additions
and
1583 deletions
+7
-1583
configure
configure
+1
-1
configure.ac
configure.ac
+1
-1
db/GNUmakefile.in
db/GNUmakefile.in
+2
-2
db/newwanode.in
db/newwanode.in
+0
-371
utils/GNUmakefile.in
utils/GNUmakefile.in
+3
-3
utils/wanodecheckin.in
utils/wanodecheckin.in
+0
-264
utils/wanodecreate.in
utils/wanodecreate.in
+0
-380
www/cdromcheckin.php3
www/cdromcheckin.php3
+0
-470
www/wanodecheckin.php
www/wanodecheckin.php
+0
-91
No files found.
configure
View file @
12804432
...
...
@@ -6946,7 +6946,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
db/nalloc db/nfree db/if2port db/backup
\
db/webcontrol db/node_status db/genelists db/genelists.proxy
\
db/dumperrorlog.proxy
\
db/setsitevar db/
newwanode db/
audit db/changeuid db/changepid
\
db/setsitevar db/audit db/changeuid db/changepid
\
db/libdb.pm db/libtbdb.pm db/inuse db/avail db/nodeip db/showgraph
\
db/emdb.pm db/emdbi.pm db/emutil.pm
\
db/dhcpd_makeconf db/nodelog db/unixgroups
\
...
...
configure.ac
View file @
12804432
...
...
@@ -1278,7 +1278,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
db/nalloc db/nfree db/if2port db/backup \
db/webcontrol db/node_status db/genelists db/genelists.proxy \
db/dumperrorlog.proxy \
db/setsitevar db/
newwanode db/
audit db/changeuid db/changepid \
db/setsitevar db/audit db/changeuid db/changepid \
db/libdb.pm db/libtbdb.pm db/inuse db/avail db/nodeip db/showgraph \
db/emdb.pm db/emdbi.pm db/emutil.pm \
db/dhcpd_makeconf db/nodelog db/unixgroups \
...
...
db/GNUmakefile.in
View file @
12804432
...
...
@@ -32,13 +32,13 @@ SUBBOSS_SBIN_SCRIPTS = subboss_dhcpd_makeconf
BIN_SCRIPTS = nalloc nfree nodeip readycount
SBIN_SCRIPTS = avail inuse showgraph if2port backup webcontrol node_status \
genelists genelists.proxy dhcpd_makeconf nodelog unixgroups \
dbcheck interswitch dbboot grabron stategraph
newwanode
\
dbcheck interswitch dbboot grabron stategraph \
idletimes idlemail setsitevar audit changeuid changepid \
elabinelab_bossinit update_permissions mysqld_watchdog \
dumperrorlog changeleader checkstats changecreator \
dbupdate geni_control subboss_sync showvlans updatewires
WEB_SBIN_SCRIPTS= webnodelog web
newwanode web
idlemail webchangeuid \
WEB_SBIN_SCRIPTS= webnodelog webidlemail webchangeuid \
webchangeleader
WEB_BIN_SCRIPTS = webnfree
LIBEXEC_SCRIPTS = $(WEB_BIN_SCRIPTS) $(WEB_SBIN_SCRIPTS) xmlconvert
...
...
db/newwanode.in
deleted
100644 → 0
View file @
5ceed4c0
#!/usr/bin/perl -wT
#
# Copyright (c) 2000-2008 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
use
English
;
use
Getopt::
Std
;
#
# Add a new node to the DB. Strictly for widearea nodes right now.
#
sub
usage
()
{
print
"
Usage:
"
.
"
newwanode [-w] [-n nickname] -t <nodetype> -i <ip address>
\n
";
exit
(
1
);
}
sub
fatal
($);
my
$optlist
=
"
wt:i:a:n:
";
#
# Configure variables
#
my
$TB
=
"
@prefix
@
";
my
$TBOPS
=
"
@TBOPSEMAIL
@
";
my
$TBLOGS
=
"
@TBLOGSEMAIL
@
";
my
$named_setup
=
"
$TB
/sbin/named_setup
";
# un-taint path
$ENV
{'
PATH
'}
=
'
/bin:/usr/bin:/usr/local/bin:/usr/site/bin
';
delete
@ENV
{'
IFS
',
'
CDPATH
',
'
ENV
',
'
BASH_ENV
'};
#
# Turn off line buffering on output
#
$|
=
1
;
# Load the Testbed support stuff.
use
lib
"
@prefix
@/lib
";
use
libdb
;
use
libtestbed
;
use
NodeType
;
#
# This is run from the web page, but tbadmins can run it from the command
# line.
#
if
(
$UID
!=
getpwnam
("
nobody
")
&&
!
TBAdmin
(
$UID
))
{
die
("
*** $0:
\n
"
.
"
You do not have permission to run this script!
\n
");
}
my
$nodetype
;
my
$nodeip
;
my
$fromweb
=
0
;
my
$reuse
=
0
;
my
$nickname
;
my
$nodename
;
my
$nodevtype
;
my
$nodeauxtype
;
my
$nodevname
;
my
$pid
;
my
$eid
;
my
$nextid
;
my
$nextpri
;
#
# Parse command arguments. Once we return from getopts, all that should be
# left are the required arguments.
#
%options
=
();
if
(
!
getopts
(
$optlist
,
\
%options
))
{
usage
();
}
if
(
defined
(
$options
{"
w
"}))
{
$fromweb
=
1
;
}
if
(
defined
(
$options
{"
i
"}))
{
$nodeip
=
$options
{"
i
"};
}
if
(
defined
(
$options
{"
t
"}))
{
$nodetype
=
$options
{"
t
"};
}
if
(
defined
(
$options
{"
a
"}))
{
$nodeauxtype
=
$options
{"
a
"};
}
if
(
defined
(
$options
{"
n
"}))
{
$nickname
=
$options
{"
n
"};
}
if
(
!
defined
(
$nodeip
)
||
!
defined
(
$nodetype
))
{
usage
();
}
#
# Taint check.
#
if
(
$nodetype
=~
/^([\w]+)$/
)
{
$nodetype
=
$
1
;
}
else
{
die
("
*** Bad data in
$nodetype
\n
");
}
if
(
$nodeip
=~
/^([\d\.]+)$/
)
{
$nodeip
=
$
1
;
}
else
{
die
("
*** Bad data in
$nodeip
\n
");
}
if
(
defined
(
$nodeauxtype
))
{
if
(
$nodeauxtype
=~
/^([\w]+)$/
)
{
$nodeauxtype
=
$
1
;
}
else
{
die
("
*** Bad data in
$nodeauxtype
\n
");
}
}
if
(
defined
(
$nickname
))
{
if
(
$nickname
=~
/^([-\w]+)$/
)
{
$nickname
=
$
1
;
}
else
{
die
("
*** Bad data in
$nickname
\n
");
}
}
#
# Must be a valid type.
#
my
$typeinfo
=
NodeType
->
Lookup
(
$nodetype
);
if
(
!
defined
(
$typeinfo
))
{
fatal
("
*** $0:
\n
"
.
"
No such nodetype
$nodetype
is defined in the DB!
\n
");
}
my
(
$defosid
,
$control_iface
);
if
(
$typeinfo
->
default_osid
(
\
$defosid
)
||
!
$defosid
)
{
fatal
("
*** $0:
\n
"
.
"
No default OSID for
$nodetype
is defined in the DB!
\n
");
}
if
(
$typeinfo
->
control_interface
(
\
$control_iface
)
||
!
$control_iface
)
{
fatal
("
*** $0:
\n
"
.
"
No control interface for
$nodetype
is defined in the DB!
\n
");
}
#
# For now, just pcwa/pcron is allowed until we have more DB state that says
# how to build the virtual nodes, although that is temporary as well.
#
if
(
$nodetype
ne
"
pcwa
"
&&
$nodetype
ne
"
pcron
")
{
fatal
("
Can only handle pcwa/pcron nodetype right now!
");
}
#
# Create the virtual type name. Again, this is bogus.
#
if
(
$nodetype
eq
"
pcwa
")
{
$nodevtype
=
"
pcvwa
";
$nodeauxtype
=
"
pcvwainet
"
if
(
!
defined
(
$nodeauxtype
));
}
else
{
$nodevtype
=
"
pcvron
";
$nodeauxtype
=
"
pcvroninet
"
if
(
!
defined
(
$nodeauxtype
));
}
#
# Again, this is bogus.
#
if
(
$nodetype
eq
"
pcwa
")
{
$pid
=
"
emulab-ops
";
$eid
=
"
widearea-nodes
";
}
else
{
$pid
=
"
ron
";
$eid
=
"
all
";
}
my
$exptidx
;
if
(
!
TBExptIDX
(
$pid
,
$eid
,
\
$exptidx
))
{
fatal
("
*** $0:
\n
"
.
"
No such experiment
$pid
/
$eid
!
\n
");
}
#
# Lets see if a known IP. If so we want to reuse the existing record.
#
if
(
TBIPtoNodeID
(
$nodeip
,
\
$nodename
))
{
#
# We need the existing priority for creating the vnodes below.
#
$query_result
=
DBQueryFatal
("
select priority from nodes where node_id='
$nodename
'
");
my
%row
=
$query_result
->
fetchhash
();
$nextpri
=
$row
{'
priority
'};
$reuse
=
1
;
}
else
{
#
# We need the next id and priority.
#
DBQueryFatal
("
lock tables nextfreenode write
");
$query_result
=
DBQueryFatal
("
select nextid,nextpri from nextfreenode
"
.
"
where nodetype='
$nodetype
'
");
if
(
!
$query_result
->
numrows
)
{
fatal
("
nodetype
$nodetype
is not in the nextfreenode table!
");
}
my
%row
=
$query_result
->
fetchhash
();
$nextid
=
$row
{'
nextid
'};
$nextpri
=
$row
{'
nextpri
'};
DBQueryFatal
("
update nextfreenode
"
.
"
set nextid=nextid+1,nextpri=nextpri+1
"
.
"
where nodetype='
$nodetype
'
");
DBQueryFatal
("
unlock tables
");
#
# Form a new node name! Bogus. need more DB state.
#
if
(
$nodetype
=~
/^pc(\w+)$/
)
{
$nodename
=
"
${
1
}${nextid}
";
}
else
{
fatal
("
Could not determine a name from type for
$nodetype
!
");
}
}
if
(
!
defined
(
$nickname
))
{
$nickname
=
$nodename
;
}
#
# Enter the records
#
if
(
$reuse
)
{
print
"
Reusing exiting record for
$nodename
. IP=
$nodeip
\n
";
}
else
{
print
"
Creating widearea node
$nodename
...
\n
";
DBQueryFatal
("
insert into nodes
"
.
"
(node_id, type, phys_nodeid, role, priority,
"
.
"
op_mode, def_boot_osid)
"
.
"
values ('
$nodename
', '
$nodetype
', '
$nodename
',
"
.
"
'testnode',
$nextpri
, 'NORMAL',
"
.
"
'
$defosid
')
");
DBQueryFatal
("
insert into node_hostkeys (node_id)
"
.
"
values ('
$nodename
')
");
DBQueryFatal
("
insert into node_auxtypes
"
.
"
(node_id, type, count)
"
.
"
values ('
$nodename
', '
$nodeauxtype
', 20)
");
DBQueryFatal
("
insert into node_auxtypes
"
.
"
(node_id, type, count)
"
.
"
values ('
$nodename
', '
$nodevtype
', 20)
");
DBQueryFatal
("
replace into node_status
"
.
"
(node_id, status, status_timestamp)
"
.
"
values ('
$nodename
', 'down', now())
");
# Note that card/port are arbitrary for remote nodes since they are
# not connected to local switches!
my
$ifacerole
=
TBDB_IFACEROLE_CONTROL
();
DBQueryFatal
("
insert into interfaces
"
.
"
(node_id, card, port, IP, interface_type, iface, role)
"
.
"
values ('
$nodename
', 0, 1, '
$nodeip
',
"
.
"
'fxp', '
$control_iface
', '
$ifacerole
')
");
DBQueryFatal
("
insert into interface_state
"
.
"
(node_id, card, port, iface)
"
.
"
values ('
$nodename
', 0, 1, 'fxp')
");
DBQueryFatal
("
insert into reserved
"
.
"
(node_id, exptidx, pid, eid, rsrv_time, vname)
"
.
"
values ('
$nodename
',
$exptidx
,
"
.
"
'
$pid
', '
$eid
', now(), '
$nickname
')
");
}
#
# Always create these. I'll kill off the old ones as needed for now.
#
for
(
$i
=
1
;
$i
<
9
;
$i
++
)
{
my
$priority
=
(
$nextpri
*
100
)
+
$i
;
$nodevname
=
"
v
${nodename}
-
${i}
";
print
"
Creating widearea virtual node
$nodevname
...
\n
";
DBQueryFatal
("
insert into nodes
"
.
"
(node_id, type, phys_nodeid, role, priority,
"
.
"
op_mode, def_boot_osid, update_accounts)
"
.
"
values ('
$nodevname
', '
$nodevtype
', '
$nodename
',
"
.
"
'virtnode',
$priority
, 'NORMAL',
"
.
"
'
$defosid
', 1)
");
DBQueryFatal
("
insert into node_hostkeys (node_id)
"
.
"
values ('
$nodevname
')
");
}
#
# Lets log it.
#
my
$subject
;
my
$message
;
if
(
$reuse
)
{
$subject
=
"
Existing WA node has reinstalled
";
$message
=
"
Existing WA node has been reinstalled
";
}
else
{
$subject
=
"
New WA node created
";
$message
=
"
New Wide Area node has been created
";
}
SENDMAIL
(
$TBLOGS
,
$subject
,
"
$message
\n
"
.
"
\n
"
.
"
Type:
$nodetype
\n
"
.
"
Name:
$nodename
\n
"
.
"
IP:
$nodeip
\n
"
.
"
Vtype:
$nodevtype
\n
"
.
"
Auxtype:
$nodeauxtype
\n
"
.
"
Vname:
$nodevname
(actually the last vnode)
\n
"
.
"
Nickname:
$nickname
\n
",
$TBOPS
);
#
# update the named maps. Do it in the background since we do not
# want to hold up the caller.
#
print
"
Forcing a named map update ...
\n
";
my
$logname
=
TBMakeLogname
("
newwanode
");
if
(
TBBackGround
(
$logname
))
{
#
# Parent exits normally
#
exit
(
0
);
}
system
("
$named_setup
");
unlink
(
$logname
);
exit
(
0
);
sub
fatal
($)
{
my
(
$msg
)
=
@_
;
print
STDERR
"
$msg
\n
";
SENDMAIL
(
$TBOPS
,
"
Failure creating new WA node
",
$msg
,
$TBOPS
);
exit
(
1
);
}
utils/GNUmakefile.in
View file @
12804432
...
...
@@ -42,7 +42,7 @@ SBIN_SCRIPTS = vlandiff vlansync withadminprivs export_tables cvsupd.pl \
opsreboot deletenode node_statewait grabwebcams \
grabswitchconfig backupswitches cvsinit checkquota \
spewconlog opsdb_control newnode suchown archive_list \
wanodecheckin wanodecreate
spewimage \
spewimage \
anonsendmail epmodeset fixexpinfo node_traffic switch_traffic \
dumpdescriptor subboss_tftpboot_sync testbed-control \
archive-expinfo grantfeature emulabfeature addblob readblob \
...
...
@@ -61,7 +61,7 @@ SBIN_SCRIPTS = vlandiff vlansync withadminprivs export_tables cvsupd.pl \
deprecate_image pushrootkey addinterface addwire
WEB_SBIN_SCRIPTS= webnewnode webdeletenode webspewconlog webarchive_list \
web
wanodecheckin web
spewimage webdumpdescriptor webemulabfeature \
webspewimage webdumpdescriptor webemulabfeature \
webdelete_image websitecheckin webclone_image webgrantimage \
webreserve
WEB_BIN_SCRIPTS = webcreate_image websetdest weblinkmon_ctl webspewevents \
...
...
@@ -90,7 +90,7 @@ SETUID_SUEXEC_SCRIPTS = xlogin
#
all: $(BIN_SCRIPTS) $(SBIN_SCRIPTS) $(LIBEXEC_SCRIPTS) $(CTRLSBIN_SCRIPTS) \
$(SBSBIN_SCRIPTS) $(SETUID_BIN_SCRIPTS) $(SETUID_SBIN_SCRIPTS) \
$(SUBDIRS) firstuser setbuildinfo
$(SUBDIRS) firstuser setbuildinfo
cnetwatch
subboss: $(SBSBIN_SCRIPTS)
...
...
utils/wanodecheckin.in
deleted
100644 → 0
View file @
5ceed4c0
#!/usr/bin/perl -wT
#
# Copyright (c) 2003-2009 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
use
strict
;
use
English
;
use
Getopt::
Std
;
#
# Notes on the dongle boot:
#
# * Check /boot/loader.conf for comconsole or vga.
# * Need SSL version of tmcc, emulab.pem and pcwa.pem file.
# * Root public ssh key from boss.
# * New version of libtmcc with bootwhat def.
# * Create /etc/emulab/emulab-privkey to match what is in widearea_nodeinfo
# for each node (per node dongles).
# * Created /etc/emulab/bossnode pointing to boss.
# * touch /etc/emulab/isrem
#
#
# Widearea Node checkin.
#
# Note that the exit code from this script is propogated via the web
# interface to the remote node.
#
sub
usage
()
{
print
(
STDERR
"
Usage: wanodecheckin [-h <hostname>] <privkey> <IP>
\n
");
exit
(
-
1
);
}
my
$optlist
=
"
dh:
";
my
$debug
=
0
;
my
$hostname
;
#
# Configure variables
#
my
$TB
=
"
@prefix
@
";
my
$TBOPS
=
"
@TBOPSEMAIL
@
";
my
$TBLOGS
=
"
@TBLOGSEMAIL
@
";
my
$TBBASE
=
"
@TBBASE
@
";
my
$NAMED
=
"
$TB
/sbin/named_setup
";
my
$NALLOC
=
"
$TB
/bin/nalloc
";
# un-taint path
$ENV
{'
PATH
'}
=
'
/bin:/usr/bin:/usr/local/bin
';
delete
@ENV
{'
IFS
',
'
CDPATH
',
'
ENV
',
'
BASH_ENV
'};
# Turn off line buffering on output
$|
=
1
;
#
# Testbed Support libraries
#
use
lib
"
@prefix
@/lib
";
use
libdb
;
use
libtestbed
;
use
Experiment
;
use
Node
;
# Protos
sub
notify
($);
sub
fatal
($$$);
# These error codes must match whats in the client, but of course.
my
$WASTATUS_OKAY
=
0
;
my
$WASTATUS_MISSINGARGS
=
100
;
my
$WASTATUS_INVALIDARGS
=
101
;
my
$WASTATUS_BADPRIVKEY
=
102
;
my
$WASTATUS_BADIPADDR
=
103
;
my
$WASTATUS_BADREMOTEIP
=
104
;
my
$WASTATUS_IPADDRINUSE
=
105
;
my
$WASTATUS_MUSTUSESSL
=
106
;
my
$WASTATUS_OTHER
=
199
;
# Default initial experiment unless overridden.
my
$PID_HWDOWN
=
NODEDEAD_PID
();
my
$EID_HWDOWN
=
NODEDEAD_EID
();
# Parse options.
my
%options
=
();
if
(
!
getopts
(
$optlist
,
\
%options
))
{
usage
();
}
if
(
defined
(
$options
{"
d
"}))
{
$debug
=
1
;
}
if
(
defined
(
$options
{"
h
"}))
{
$hostname
=
$options
{"
h
"};
if
(
$hostname
=~
/^([-\w\.]+)$/
)
{
$hostname
=
$
1
;
}
else
{
fatal
(
$WASTATUS_INVALIDARGS
,
"
Bad data in hostname
",
0
);
}
}
usage
if
(
@ARGV
!=
2
);
my
$privkey
=
$ARGV
[
0
];
my
$IP
=
$ARGV
[
1
];
# untaint args.
if
(
$IP
=~
/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/
)
{
$IP
=
$
1
;
}
else
{
fatal
(
$WASTATUS_INVALIDARGS
,
"
Bad data in IP address
",
0
);
}
if
(
$privkey
=~
/^([\w]+)$/
)
{
$privkey
=
$
1
;
}
else
{
fatal
(
$WASTATUS_INVALIDARGS
,
"
Bad data in private key
",
1
);
}
#
# Lookup and see if privkey is valid and matches the IP. If so, all is
# good.
#
my
$query_result
=
DBQueryWarn
("
select node_id,IP,machine_type
"
.
"
from widearea_nodeinfo
"
.
"
where privkey='
$privkey
'
");
if
(
!
$query_result
)
{
fatal
(
$WASTATUS_OTHER
,
"
DB Error getting widearea_nodeinfo table
",
0
);
}
if
(
!
$query_result
->
numrows
)
{
#
# We are not going to do dynamic widearea nodes yet. If the privkey
# is not in the table, it is not a node we know/care about.
#
fatal
(
$WASTATUS_BADPRIVKEY
,
"
Unknown private key
",
1
);
}
my
(
$node_id
,
$known_IP
,
$machine_type
)
=
$query_result
->
fetchrow_array
();
$query_result
=
DBQueryWarn
("
SELECT n.node_id FROM nodes AS n LEFT
"
.
"
JOIN widearea_nodeinfo AS w ON n.node_id=w.node_id
"
.
"
WHERE w.node_id='
$node_id
'
");
if
(
!
$query_result
->
numrows
)
{
my
$experiment
=
Experiment
->
Lookup
(
$PID_HWDOWN
,
$EID_HWDOWN
);
#
# This is the first time we have heard from a partially-initialised node. Create it.
#
my
$node
=
Node
->
Create
(
$node_id
,
$experiment
,
{'
type
'
=>
$machine_type
,
'
role
'
=>
$
Node::
NODEROLE_TESTNODE
});
if
(
!
defined
(
$node
))
{
fatal
(
$WASTATUS_OTHER
,
"
Could not create new node:
$node_id
",
0
);
}
# Initialize the control interface.
my
$control_iface
=
$node
->
control_iface
();
if
(
!
defined
(
$control_iface
))
{
$control_iface
=
"
eth0
";
}
if
(
!
DBQueryWarn
("
replace into interfaces set
"
.
"
node_id='
$node_id
',
"
.
"
card=0, port=1,
"
.
"
interface_type='fxp',
"
.
"
iface='
$control_iface
',
"
.
"
role='
"
.
TBDB_IFACEROLE_CONTROL
()
.
"
',
"
.
"
IP='
$IP
'
"))
{
fatal
(
$WASTATUS_OTHER
,
"
Failed to insert new WA node into interfaces table
",
0
);
}
if
(
!
DBQueryWarn
("
update widearea_nodeinfo set IP='
$IP
'
"
.
(
defined
(
$hostname
)
?
"
,hostname='
$hostname
'
"
:
"")
.
"
where node_id='
$node_id
'
"))
{
fatal
(
$WASTATUS_OTHER
,
"
Failed to update IP in widearea_nodeinfo
",
0
);
}
notify
("
Widearea node
$node_id
has checked in for the firstime
"
.
"
with IP
$IP
");
}
elsif
(
$known_IP
eq
$IP
)
{
#
# If the IP has not changed, nothing to do unless the hostname changed.
#
if
(
defined
(
$hostname
))
{
DBQueryWarn
("
update widearea_nodeinfo set hostname='
$hostname
'
"
.
"
where node_id='
$node_id
'
");
}
exit
(
$WASTATUS_OKAY
);
}
else
{
#
# IP has changed, probably cause of dynamic DHCP. We have to
# change various tables and then regen the nameserver config.
#
if
(
!
(
DBQueryWarn
("
update interfaces set IP='
$IP
'
"
.
"
where node_id='
$node_id
' and card=0 and port=1
")
&&
DBQueryWarn
("
update widearea_nodeinfo set IP='
$IP
'
"
.
(
defined
(
$hostname
)
?
"
,hostname='
$hostname
'
"
:
"")
.
"
where node_id='
$node_id
'
")))
{
fatal
(
$WASTATUS_OTHER
,
"
Failed to update IP in DB
",
0
);
}
notify
("
Widearea node
$node_id
has changed its IP address from
$known_IP
"
.
"
to
$IP
");