sshxmlrpc_server.py.in 1.26 KB
Newer Older
1
#!/usr/local/bin/python
2 3 4 5 6 7
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004 University of Utah and the Flux Group.
# All rights reserved.
#
import sys
8
import getopt
9
sys.path.append("@prefix@/lib")
10 11
import socket
import sshxmlrpc
12 13
from emulabserver import *

14 15 16 17 18 19
#
# By default, run a wrapper class that includes all off the modules.
# The client can invoke methods of the form experiment.swapexp when
# the server is invoked in this manner.
# 
DEFAULT_MODULE = "EmulabServer"
20
module         = DEFAULT_MODULE
21 22 23 24 25 26 27 28 29
ReadOnly       = 0;

#
# Optional argument indicating read-only privs.
#
if len(sys.argv) > 1 and sys.argv[1] == "-ro":
    ReadOnly = 1;
    sys.argv = sys.argv[1:]
    pass
30 31

#
32 33
# Optional argument indicates the specific module the server wants to use.
# This form should be deprecated, I think. 
34 35 36 37
#
if len(sys.argv) > 1:
    module = sys.argv[1]
    pass
38 39

#
40 41 42 43
# This is invoked inside an SSH, typically from the paperbag shell.
# We use stdin/stdout to read/write the request/response. We handle
# just a single request this way, and then exit. 
# 
44
# Construct and wrap our object.
45
server  = eval(module + "(readonly=" + str(ReadOnly) + ")")
46
wrapper = sshxmlrpc.SSHServerWrapper(server, module)
47
# Handle the request on stdin and send the response to stdout.
48
wrapper.serve_stdio_forever()
49
sys.exit(0)