Commit 5207d7ed authored by David Johnson's avatar David Johnson

Add a method to the xmlrpc server to return widearea node info (to admins

only).  Also add a util script (meant to be used from a user's desktop)
that contacts the elab and plab xmlrpc servers for the config info, and
writes all that junk to the right places on a dongle or dongle img.
parent 49babb7a
This diff is collapsed.
......@@ -4035,6 +4035,75 @@ class node:
return EmulabResponse(RESPONSE_SUCCESS, value=retval, output=retval)
# Get widearea node configuration params, returned as a dict.
def waconfig(self, version, argdict):
if version != self.VERSION:
return EmulabResponse(RESPONSE_BADVERSION,
output="Client version mismatch!")
argerror = CheckRequiredArgs(argdict, ("node",))
if (argerror):
return argerror
if not re.match("^[-\w]*$", str(argdict["node"])):
return EmulabResponse(RESPONSE_BADARGS,
output="Improperly formed node value!")
if not CheckIsAdmin(self.uid):
return EmulabResponse(RESPONSE_ERROR,
output="No permission to access node: " +
res = DBQueryFatal("select wni.hostname,wni.bwlimit,wni.privkey,"
" wni.IP,wni.gateway,wni.dns,wni.boot_method,"
" i.mac,i.mask"
" from widearea_nodeinfo as wni"
" left join interfaces as i"
" on wni.node_id=i.node_id"
" where wni.node_id=%s and i.role=%s",
if len(res) == 0:
return EmulabResponse(RESPONSE_ERROR,
output="No such widearea node: %s" \
% (argdict["node"],))
elif len(res) > 1:
return EmulabResponse(RESPONSE_ERROR,
output="Multiple matches for node: %s" \
% (argdict["node"],))
row = res[0]
retval = dict({})
retval['WA_BOOTMETHOD'] = row[6]
retval['WA_HOSTNAME'] = row[0].split('.',1)[0]
retval['WA_HOSTNAME'] = row[0]
retval['WA_DOMAIN'] = row[0].split('.',1)[1]
retval['WA_DOMAIN'] = ""
if row[6] == 'static':
retval['WA_MAC'] = row[7]
retval['WA_IP_ADDR'] = row[3]
retval['WA_IP_NETMASK'] = row[8]
retval['WA_IP_GATEWAY'] = row[4]
retval['WA_IP_DNS1'] = row[5]
if row[1] and not row[1] == 0:
retval['WA_BWLIMIT'] = row[1]
retval['PRIVKEY'] = row[2]
return EmulabResponse(RESPONSE_SUCCESS,value=retval)
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