Commit 0347520d authored by Robert Ricci's avatar Robert Ricci

Add an xmlrpc for tbuisp, so that it can be called from ops, users'

desktops, nodes, etc.

Thanks to Tim for actually writing most of this code.
parent 31f05051
......@@ -31,7 +31,7 @@ USERLIBS = sshxmlrpc.py emulabclient.py
SYMLINKS = node_admin node_reboot os_load create_image node_list \
delay_config link_config savelogs portstats eventsys_control \
readycount nscheck startexp batchexp startexp swapexp endexp \
modexp expinfo node_avail
modexp expinfo node_avail tbuisp
#
# Force dependencies on the scripts so that they will be rerun through
......
......@@ -2916,6 +2916,33 @@ class node:
return EmulabResponse(RESPONSE_SUCCESS, output=output)
def tbuisp(self, version, argdict):
if version != self.VERSION:
return EmulabResponse(RESPONSE_BADVERSION,
output="Client version mismatch!")
try:
checknologins()
pass
except NoLoginsError, e:
return EmulabResponse(RESPONSE_REFUSED, output=str(e))
argerror = CheckRequiredArgs(argdict, ("op", "filestr", "nodes"))
if (argerror):
return argerror
(fp, filename) = writensfile(argdict["filestr"].data)
argstr = escapeshellarg(argdict["op"])
argstr += " " + filename
argstr += " " + escapeshellarg(" ".join(argdict["nodes"]))
(exitval, output) = runcommand(TBDIR + "/bin/tbuisp " + argstr)
if exitval:
return EmulabResponse(RESPONSE_ERROR, exitval >> 8, output=output)
return EmulabResponse(RESPONSE_SUCCESS, output=output)
pass
......
......@@ -111,6 +111,8 @@ API = {
"help" : "Terminate an experiment" },
"expinfo" : { "func" : "expinfo",
"help" : "Get information about an experiment" },
"tbuisp" : { "func" : "tbuisp",
"help" : "Upload code to a mote" },
};
#
......@@ -1585,6 +1587,72 @@ class expinfo:
return
pass
class tbuisp:
def __init__(self, argv=None):
self.argv = argv
return
def apply(self):
params = {}
try:
opts, req_args = getopt.getopt(self.argv, "h", [
"help", ])
for opt, val in opts:
if opt in ("-h", "--help"):
self.usage();
return 0
pass
if len(req_args) < 3:
raise getopt.error(
"error: a file and one or more nodes must be specified")
pass
except getopt.error, e:
print e.args[0]
self.usage();
return -1;
params["op"] = req_args[0]
file = req_args[1]
params["nodes"] = req_args[2:]
try:
filestr = open(file).read()
pass
except:
print "Could not open file: " + file
return -1
# I don't know what is in the file, so we'll base64 encode before
# sending it over XML-RPC. On the receiving side you'll get a Binary
# object with the bits stored in the data field. In code:
#
# filestr = params["filestr"].data
#
# I think...
params["filestr"] = xmlrpclib.Binary(filestr)
rval,response = do_method("node", "tbuisp", params)
return rval
def usage(self):
print "tbuisp <operation> <file> <node1> [<node2> ...]"
print "where:"
print " operation - Operation to perform. Currently, only 'upload'"
print " is supported"
print " file - Name of the to upload to the mote"
print " nodeN - The physical node name ..."
print
print "example:"
print " $ tbuisp upload foo.srec mote1"
wrapperoptions()
return
pass
#
# Process program arguments. There are two ways we could be invoked.
# 1) as the wrapper, with the first required argument the name of the script.
......
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