Commit 0871cf29 authored by Gary Wong's avatar Gary Wong

Make the protogeni test scripts a bit friendlier: add command line options

for settings the user might want to vary, and try to make the output
helpful.
parent 3d97e870
......@@ -25,6 +25,8 @@ import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
execfile( "test-common.py" )
#
......
......@@ -24,6 +24,8 @@ import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
execfile( "test-common.py" )
#
......@@ -71,31 +73,31 @@ if rval:
pass
myslice = response["value"]
print "New slice created"
#print str(myslice);
if debug: print str(myslice)
##
## Lookup another user so we can bind them to the slice.
##
#params = {}
#params["hrn"] = "leebee"
#params["credential"] = mycredential
#params["type"] = "User"
#rval,response = do_method("sa", "Resolve", params)
#if rval:
# Fatal("Could not resolve leebee")
# pass
#leebee = response["value"]
#print "Found leebee record at the SA, binding to slice ..."
#
# Lookup another user so we can bind them to the slice.
#
params = {}
params["hrn"] = "leebee"
params["credential"] = mycredential
params["type"] = "User"
rval,response = do_method("sa", "Resolve", params)
if rval:
Fatal("Could not resolve leebee")
pass
leebee = response["value"]
print "Found leebee record at the SA, binding to slice ..."
#
# And bind the user to the slice so that he can get his own cred.
#
params = {}
params["uuid"] = leebee["uuid"]
params["credential"] = myslice
rval,response = do_method("sa", "BindToSlice", params)
if rval:
Fatal("Could not bind leebee to slice")
pass
leebee = response["value"]
print "Bound leebee to slice at the SA"
##
## And bind the user to the slice so that he can get his own cred.
##
#params = {}
#params["uuid"] = leebee["uuid"]
#params["credential"] = myslice
#rval,response = do_method("sa", "BindToSlice", params)
#if rval:
# Fatal("Could not bind leebee to slice")
# pass
#leebee = response["value"]
#print "Bound leebee to slice at the SA"
......@@ -25,6 +25,8 @@ import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
execfile( "test-common.py" )
#
......@@ -43,7 +45,7 @@ if rval:
Fatal("Could not get my keys")
pass
mykeys = response["value"]
#print str(mykeys);
if debug: print str(mykeys)
#
# Lookup slice.
......
......@@ -24,6 +24,8 @@ import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
execfile( "test-common.py" )
#
......
......@@ -24,6 +24,8 @@ import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
execfile( "test-common.py" )
#
......
......@@ -24,6 +24,8 @@ import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
execfile( "test-common.py" )
#
......
......@@ -25,6 +25,8 @@ import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
execfile( "test-common.py" )
#
......@@ -88,7 +90,7 @@ if rval:
pass
ticket = response["value"]
print "Got a ticket from the CM. Delaying a moment ..."
#print str(ticket)
if debug: print str(ticket)
time.sleep(5)
......
......@@ -25,6 +25,8 @@ import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
execfile( "test-common.py" )
#
......@@ -43,7 +45,7 @@ if rval:
Fatal("Could not get my keys")
pass
mykeys = response["value"]
#print str(mykeys);
if debug: print str(mykeys)
#
# Lookup slice.
......@@ -115,7 +117,7 @@ if rval:
pass
ticket = response["value"]
print "Got a ticket from the CM. Redeeming the ticket ..."
#print str(response["output"])
if debug: print str(response["output"])
#
# Create the sliver.
......
......@@ -40,7 +40,7 @@ rval,response = do_method("ch", "ListComponents", params)
if rval:
Fatal("Could not get a list of components from the ClearingHouse")
pass
#print str(response["value"])
if debug: print str(response["value"])
#
# Ask each manager for its list.
......
......@@ -44,7 +44,7 @@ if rval:
Fatal("Could not resolve geniuser")
pass
print "Found geniuser record at the SA"
#print str(response)
if debug: print str(response)
#
# Lookup my ssh keys.
......
......@@ -24,6 +24,8 @@ import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
execfile( "test-common.py" )
#
......
......@@ -24,6 +24,8 @@ import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
execfile( "test-common.py" )
#
......
......@@ -24,6 +24,8 @@ import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
execfile( "test-common.py" )
#
......
......@@ -39,23 +39,26 @@ if "Usage" not in dir():
def Usage():
print "usage: " + sys.argv[ 0 ] + " [option...]"
print """Options:
-c file, --credentials=file read self-credentials from file
[default: query from SA]
-d, --debug be verbose about XML methods invoked
-f file, --certificate=file read SSL certificate from file
[default: ~/.ssl/encrypted.pem]
-h, --help show options and usage
-p file, --passphrase=file read passphrase from file
[default: ~/.ssl/password]
-r file, --read-commands=file specify additional configuration file
-s file, --slicecredentials=file read slice credentials from file
[default: query from SA]"""
-c file, --credentials=file read self-credentials from file
[default: query from SA]
-d, --debug be verbose about XML methods invoked
-f file, --certificate=file read SSL certificate from file
[default: ~/.ssl/encrypted.pem]
-h, --help show options and usage"""
if "ACCEPTSLICENAME" in globals():
print """ -n name, --slicename=name specify human-readable name of slice
[default: mytestslice]"""
print """ -p file, --passphrase=file read passphrase from file
[default: ~/.ssl/password]
-r file, --read-commands=file specify additional configuration file
-s file, --slicecredentials=file read slice credentials from file
[default: query from SA]"""
try:
opts, args = getopt.getopt( sys.argv[ 1: ], "c:df:hp:r:s:",
opts, args = getopt.getopt( sys.argv[ 1: ], "c:df:hn:p:r:s:",
[ "credentials=", "debug", "certificate=",
"help", "passphrase=", "read-commands=",
"slicecredentials=" ] )
"slicecredentials=", "slicename=" ] )
except getopt.GetoptError, err:
print >> sys.stderr, str( err )
Usage()
......@@ -71,6 +74,8 @@ for opt, arg in opts:
elif opt in ( "-h", "--help" ):
Usage()
sys.exit( 0 )
elif opt in ( "-n", "--slicename" ):
SLICENAME = arg
elif opt in ( "-p", "--passphrase" ):
PASSPHRASEFILE = arg
elif opt in ( "-r", "--read-commands" ):
......@@ -168,9 +173,8 @@ def do_method(module, method, params, URI=None):
# emulabclient.py module. The XML standard converts classes to a plain
# Dictionary, hence the code below.
#
if len(response["output"]):
print >> sys.stderr, response["output"],
print >> sys.stderr, ": ",
if response[ "code" ] and len(response["output"]):
print >> sys.stderr, response["output"] + ":",
pass
rval = response["code"]
......@@ -204,7 +208,7 @@ def resolve_slice( name, selfcredential ):
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["hrn"] = SLICENAME
params["hrn"] = name
rval,response = do_method("sa", "Resolve", params)
if rval:
Fatal("Slice does not exist");
......
......@@ -28,6 +28,8 @@ import xml.sax
import string
from M2Crypto import X509
ACCEPTSLICENAME=1
execfile( "test-common.py" )
class findElement(ContentHandler):
......
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