Commit df2b09b3 authored by Leigh Stoller's avatar Leigh Stoller

First version that people can probably play with safely, I think.

parent d8fad8b2
......@@ -22,7 +22,7 @@ include Makeconf
#
SUBDIRS = lib db assign @optional_subdirs@ ipod security sensors \
pxe tbsetup account tmcd utils www tip capture ipod vis \
sensors os install/newnode_sshkeys
sensors os xmlrpc install/newnode_sshkeys
all: all-subdirs
......@@ -64,6 +64,7 @@ ops-install:
@$(MAKE) -C tbsetup control-install
@$(MAKE) -C utils control-install
@$(MAKE) -C event control-install
@$(MAKE) -C xmlrpc control-install
install-mkdirs:
-mkdir -p $(INSTALL_TOPDIR)/opsdir
......
......@@ -1462,7 +1462,9 @@ outfiles="$outfiles Makeconf GNUmakefile \
$eventfiles \
$winfiles \
apache/GNUmakefile apache/httpd.conf \
xmlrpc/GNUmakefile \
xmlrpc/GNUmakefile xmlrpc/emulabclient.py xmlrpc/emulabserver.py \
xmlrpc/sshxmlrpc_client.py xmlrpc/sshxmlrpc_server.py \
xmlrpc/webxmlrpc \
install/ops-install install/boss-install \
install/newnode_sshkeys/GNUmakefile "
......
......@@ -507,7 +507,9 @@ outfiles="$outfiles Makeconf GNUmakefile \
$eventfiles \
$winfiles \
apache/GNUmakefile apache/httpd.conf \
xmlrpc/GNUmakefile \
xmlrpc/GNUmakefile xmlrpc/emulabclient.py xmlrpc/emulabserver.py \
xmlrpc/sshxmlrpc_client.py xmlrpc/sshxmlrpc_server.py \
xmlrpc/webxmlrpc \
install/ops-install install/boss-install \
install/newnode_sshkeys/GNUmakefile "
......
......@@ -17,24 +17,30 @@ SBIN_SCRIPTS = sshxmlrpc_server.py
LIB_STUFF = sshxmlrpc.py emulabserver.py emulabclient.py
LIBEXEC_STUFF = webxmlrpc
WWW_STUFF = xmlrpcapi.php3
DOWNLOAD_STUFF = sshxmlrpc.py sshxmlrpc_client.py emulabclient.py
DEBUG_STUFF = experiment
#
# These are the ones installed on plastic (users, control, etc).
#
USERBINS = sshxmlrpc_client.py
CLIENTBIN = sshxmlrpc_client.py
USERLIBS = sshxmlrpc.py emulabclient.py
#
# Force dependencies on the scripts so that they will be rerun through
# configure if the .in file is changed.
#
all: $(BIN_SCRIPTS) $(SBIN_SCRIPTS) $(LIB_STUFF) $(LIBEXEC_STUFF)
all: $(BIN_SCRIPTS) $(SBIN_SCRIPTS) $(LIB_STUFF) $(LIBEXEC_STUFF) \
$(DOWNLOAD_STUFF) $(DEBUG_STUFF)
include $(TESTBED_SRCDIR)/GNUmakerules
install: $(addprefix $(INSTALL_BINDIR)/, $(BIN_SCRIPTS)) \
$(addprefix $(INSTALL_SBINDIR)/, $(SBIN_SCRIPTS)) \
$(addprefix $(INSTALL_SBINDIR)/xmlrpc/, $(DEBUG_STUFF)) \
$(addprefix $(INSTALL_LIBEXECDIR)/, $(LIBEXEC_STUFF)) \
$(addprefix $(INSTALL_WWWDIR)/, $(WWW_STUFF)) \
$(addprefix $(INSTALL_WWWDIR)/downloads/xmlrpc/, $(DOWNLOAD_STUFF)) \
$(addprefix $(INSTALL_LIBDIR)/, $(LIB_STUFF))
$(INSTALL_WWWDIR)/%: %
......@@ -42,19 +48,20 @@ $(INSTALL_WWWDIR)/%: %
-mkdir -p $(patsubst %/,%,$(dir $@))
$(INSTALL_DATA) $(subst $$,\$$,$<) $(subst $$,\$$,$@)
$(INSTALL_WWWDIR)/downloads/xmlrpc/%: %
@echo "Installing $<"
-mkdir -p $(patsubst %/,%,$(dir $@))
$(INSTALL_DATA) $(subst $$,\$$,$<) $(subst $$,\$$,$@)
$(INSTALL_SBINDIR)/xmlrpc/%: %
@echo "Installing $<"
-mkdir -p $(INSTALL_SBINDIR)/xmlrpc
$(INSTALL_PROGRAM) $< $@
#
# Control node installation (okay, plastic)
#
ifneq ($(UNIFIED),1)
LINKS= cd $(INSTALL_BINDIR) && \
list='$(USERBINS)'; for file in $$list; do \
rm -f $$file; \
ln -s plasticwrap $$file; \
done;
endif
control-install:
$(LINKS)
control-install: $(addprefix $(INSTALL_LIBDIR)/, $(USERLIBS)) \
$(addprefix $(INSTALL_BINDIR)/, $(CLIENTBIN))
clean:
......@@ -15,11 +15,17 @@ MAXNSFILESIZE = (1024 * 512)
#
# This class defines a simple structure to return back to the caller.
# It includes the exit status of the command, and any output that it
# wants to send back. Why not return a tuple? Well, it appears that the
# python xmlrpc library requires that a singleton be returned from the
# server, and I do not want to depend on the "Fault" structure that XML
# defines for return values.
# It includes a basic response code (success, failure, badargs, etc),
# as well as a return "value" which can be any valid datatype that can
# be represented in XML (int, string, hash, float, etc). You can also
# send back some output (a string with embedded newlines) to print out
# to the user.
#
# Why not return a tuple? Well, it appears that the python xmlrpc
# library requires that a singleton be returned from the server.
#
# Note that XMLRPC does not actually return a "class" to the caller; It gets
# converted to a hashed array (Python Dictionary).
#
RESPONSE_SUCCESS = 0
RESPONSE_BADARGS = 1
......@@ -29,11 +35,11 @@ RESPONSE_BADVERSION = 4
RESPONSE_SERVERERROR = 5
RESPONSE_TOOBIG = 6
class ResponseBlock:
class EmulabResponse:
def __init__(self, code, value=0, output=None):
self.code = code
self.value = value
self.output = output
self.code = code # A RESPONSE code
self.value = value # A return value; any valid XML type.
self.output = output # Pithy output to print
return
#
......
This diff is collapsed.
#!/bin/sh
DIR=@prefix@/sbin/
exec $DIR/sshxmlrpc_server.py experiment
......@@ -172,9 +172,12 @@ class SSHTransport:
# @param verbose unused.
# @return The value returned
#
def request(self, host, handler, request_body, verbose=0):
def request(self, host, handler, request_body, verbose=0, path=None):
# Strip the leading slash in the handler, if there is one.
if handler.startswith('/'):
if path:
handler = path + handler
pass
elif handler.startswith('/'):
handler = handler[1:]
pass
......@@ -347,7 +350,7 @@ class SSHServerProxy:
# @param encoding Content encoding.
# @param verbose unused.
#
def __init__(self, uri, transport=None, encoding=None, verbose=0):
def __init__(self, uri, transport=None, encoding=None, verbose=0, path=None):
type, uri = urllib.splittype(uri)
if type not in ("ssh", ):
raise IOError, "unsupported XML-RPC protocol"
......@@ -362,6 +365,7 @@ class SSHServerProxy:
self.__encoding = encoding
self.__verbose = verbose
self.__path = path
return
##
......@@ -379,7 +383,8 @@ class SSHServerProxy:
self.__host,
self.__handler,
request,
verbose=self.__verbose
verbose=self.__verbose,
path=self.__path
)
# ... ensure there was a valid reply.
......
......@@ -32,6 +32,10 @@ module = "experiment"
# Debugging output.
debug = 0
# For admin people.
SERVER_PATH = "/usr/testbed/sbin/"
path = None
##
# Print the usage statement to stdout.
#
......@@ -74,7 +78,7 @@ def do_method(server, method_and_args):
#
params = {}
for param in method_and_args:
plist = string.split(param, "=")
plist = string.split(param, "=", 1)
if len(plist) != 2:
print "Parameters are of the form: param=value!"
return -1
......@@ -89,7 +93,7 @@ def do_method(server, method_and_args):
response = apply(meth, meth_args)
#
# Parse the Response, which is a Dictionary. See ResponseBlock in the
# Parse the Response, which is a Dictionary. See EmulabResponse in the
# emulabclient.py module. The XML standard converts classes to a plain
# Dictionary, hence the code below.
#
......@@ -116,7 +120,7 @@ def do_method(server, method_and_args):
try:
# Parse the options,
opts, req_args = getopt.getopt(sys.argv[1:],
"dhVs:l:",
"dhVs:l:a",
[ "help", "version", "server=", "login=", ])
# ... act on them appropriately, and
for opt, val in opts:
......@@ -137,9 +141,12 @@ try:
elif opt in ("-m", "--module"):
module = val
pass
elif opt in ("-d"):
elif opt in ("-d", "--debug"):
debug = 1
pass
elif opt in ("-a", "--admin"):
path = SERVER_PATH
pass
pass
pass
except getopt.error, e:
......@@ -150,7 +157,7 @@ except getopt.error, e:
# Get a handle on the server,
server = SSHServerProxy("ssh://" + login_id + "@" + xmlrpc_server +
"/xmlrpc/" + module)
"/xmlrpc/" + module, path=path)
if len(req_args):
# Method and args are on the command line.
......@@ -160,7 +167,7 @@ else:
try:
while True:
line = raw_input("$ ")
tokens = line.split(" ", 1)
tokens = line.split(" ")
if len(tokens) >= 1 and len(tokens[0]) > 0:
try:
print str(do_method(server, tokens))
......
This diff is collapsed.
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