Commit 2cf799cd authored by David Johnson's avatar David Johnson

Add gateway, dns, and boot_method (static or dhcp) fields to

widearea_nodeinfo in support of widearea nodes that need their networks
to be configured statically.  Also the plab sync support for this, and a
sync bugfix.
parent c6144e42
......@@ -3850,6 +3850,9 @@ CREATE TABLE `widearea_nodeinfo` (
`bwlimit` varchar(32) default NULL,
`privkey` varchar(128) default NULL,
`IP` varchar(15) default NULL,
`gateway` varchar(15) NOT NULL default '',
`dns` tinytext NOT NULL,
`boot_method` enum('static','dhcp','') NOT NULL default '',
PRIMARY KEY (`node_id`),
KEY `IP` (`IP`),
KEY `privkey` (`privkey`)
......
......@@ -4420,3 +4420,16 @@ last_net_act,last_cpu_act,last_ext_act);
where last_activity is NULL;
4.145: Fix error in previous revision; skip to next entry;
4.146: Add columns in widearea_nodeinfo to specify a boot method (i.e., static
IP or DHCP), a default gateway, and dns servers, for widearea nodes:
alter table widearea_nodeinfo
add column `gateway` varchar(15) NOT NULL default '' after `IP`;
alter table widearea_nodeinfo
add column `dns` tinytext NOT NULL default '' after `gateway`;
alter table widearea_nodeinfo
add column `boot_method` enum('static','dhcp','') NOT NULL
default '' after `dns`;
......@@ -2090,22 +2090,96 @@ class EmulabPlcObjTranslator:
# XXX will eventually need more than just one public interface, but
# this will do the trick for now...
qres = DBQueryFatal("select wa.hostname,wa.bwlimit,wa.IP" \
qres = DBQueryFatal("select wa.hostname,wa.bwlimit,wa.IP," \
" i.mask,i.mac,wa.boot_method,wa.gateway,wa.dns" \
" from widearea_nodeinfo as wa" \
" left join interfaces as i on wa.IP=i.IP" \
" where wa.node_id=%s and i.node_id=%s",
(nodeid,nodeid))
if len(qres) != 1:
raise RuntimeError("could not find Emulab node '%s'" % nodeid)
(hostname,bwlimit,IP) = qres[0]
#
# XXX: assume ipv4 for now
#
(hostname,bwlimit,IP,netmask,mac,boot_method,gateway,dns) = qres[0]
# ensure boot_method is something sane.
if not boot_method or boot_method == '':
boot_method = 'dhcp'
pass
if not dns or dns == '':
raise RuntimeError("translateNode: must set WA DNS!")
# netmask must be set!
if not netmask or netmask == '':
raise RuntimeError("translateNode: ctrl netmask must be set!")
elif dns.find(','):
# allow multiple dns servers
dns = dns.split(',')
pass
if mac == '':
mac = None
pass
else:
# translate from string sans colons
mac = mac[0:2] + ":" + mac[2:4] + ":" + mac[4:6] + ":" + \
mac[6:8] + ":" + mac[8:10] + ":" + mac[10:12]
pass
sip = IP.split('.')
smask = netmask.split('.')
if not len(sip) == 4:
raise RuntimeError("translateNode: improper WA IP!")
else:
sip = map(lambda(x): int(x),sip)
pass
if not len(smask) == 4:
raise RuntimeError("translateNode: improper WA netmask!")
else:
smask = map(lambda(x): int(x),smask)
pass
n_network = "%s.%s.%s.%s" % (sip[0] & smask[0],sip[1] & smask[1],
sip[2] & smask[2],sip[3] & smask[3])
# keep the network bits but set host bits to 1s
n_bcast = "%s.%s.%s.%s" % ((sip[0] & smask[0]) | (~smask[0] & 0xff),
(sip[1] & smask[1]) | (~smask[1] & 0xff),
(sip[2] & smask[2]) | (~smask[2] & 0xff),
(sip[3] & smask[3]) | (~smask[3] & 0xff),)
retval['hostname'] = hostname
networks = [ { 'ip':IP,'bwlimit':bwlimit,'dns1':BOSSNODE_IP,
'network':CONTROL_NETWORK,'netmask':CONTROL_NETMASK,
'gateway':CONTROL_ROUTER,
'method':'dhcp','type':'ipv4','is_primary':True } ]
retval['networks'] = networks
ctrl_network = { 'ip':IP,'bwlimit':bwlimit,'method':boot_method,
'network':n_network,'netmask':netmask,
'type':'ipv4','is_primary':True }
# set the gateway and bcast addr if we're static:
if boot_method == 'static':
if not gateway or gateway == "":
raise RuntimeError("translateNode: must set gateway when" \
" boot_method=static!")
else:
ctrl_network['gateway'] = gateway
ctrl_network['broadcast'] = n_bcast
pass
pass
# setup dns
if type(dns) == list:
ctrl_network['dns1'] = dns[0]
if len(dns) > 1:
ctrl_network['dns2'] = dns[1]
pass
pass
else:
ctrl_network['dns1'] = dns
pass
# add mac if we have it (which we always do!)
if mac:
ctrl_network['mac'] = mac
pass
retval['networks'] = [ ctrl_network ]
# put all nodes in the emulabops site
retval['__emulab_pids'] = ['emulab-ops']
retval['site'] = self.__translateProject('emulab-ops')['name']
......
......@@ -471,7 +471,8 @@ class PLCagent:
pass
pass
if len(ad.keys()) > 0:
self.__server.UpdateNodeNetwork(exni['nodenetwork_id'],ad)
self.__server.UpdateNodeNetwork(self.auth,
exni['nodenetwork_id'],ad)
pass
pass
pass
......
......@@ -1043,6 +1043,9 @@ class Node
$country = $row["country"];
$hostname = $row["hostname"];
$site = $row["site"];
$boot_method = $row["boot_method"];
$gateway = $row["gateway"];
$dns = $row["dns"];
if (! ($user = User::Lookup($contact_uid))) {
# This is not an error since the field is set to "nobody" when
......@@ -1106,6 +1109,21 @@ class Node
<td class=left>$hostname</td>
</tr>\n";
echo "<tr>
<td>Boot Method:</td>
<td class=left>$boot_method</td>
</tr>\n";
echo "<tr>
<td>Gateway:</td>
<td class=left>$gateway</td>
</tr>\n";
echo "<tr>
<td>DNS:</td>
<td class=left>$dns</td>
</tr>\n";
echo "<tr>
<td>Site:</td>
<td class=left>$site</td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment