Commit df2b09b3 authored by Leigh B. Stoller's avatar Leigh B. Stoller

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

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