Commit 47b5b595 authored by Gary Wong's avatar Gary Wong

Added command line parameter allowing the user to present saved credentials

(for themself and the slice).  This shouldn't affect anybody else right now,
but is useful for me to test authenticating with delegated credentials.
parent 705d0ffb
......@@ -30,53 +30,26 @@ execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
#
params = {}
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get my credential")
pass
mycredential = response["value"]
print "Got my SA credential, looking up " + SLICENAME
#print str(mycredential);
mycredential = get_self_credential()
print "Got self credential"
#
# Lookup slice.
#
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["hrn"] = SLICENAME
rval,response = do_method("sa", "Resolve", params)
if rval:
#
# Create a slice.
#
Fatal("Slice does not exist");
pass
else:
#
# Get the slice credential.
#
print "Asking for slice credential for " + SLICENAME
myslice = response["value"]
myuuid = myslice["uuid"]
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["uuid"] = myuuid
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get Slice credential")
pass
myslice = response["value"]
print "Got the slice credential, binding myself to it"
pass
myslice = resolve_slice( SLICENAME, mycredential )
print "Resolved slice " + SLICENAME
#
# Get the slice credential.
#
slicecredential = get_slice_credential( myslice, mycredential )
print "Got slice credential"
#
# Bind to slice at the CM.
#
params = {}
params["credential"] = myslice
params["credential"] = slicecredential
rval,response = do_method("cm", "BindToSlice", params)
if rval:
Fatal("Could not bind myself to slice")
......
......@@ -29,15 +29,8 @@ execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
#
params = {}
params["uuid"] = "0b2eb97e-ed30-11db-96cb-001143e453fe"
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get my credential")
pass
mycredential = response["value"]
mycredential = get_self_credential()
print "Got my SA credential"
#print str(mycredential);
#
# Lookup slice, delete before proceeding.
......@@ -73,6 +66,8 @@ params["hrn"] = SLICENAME
rval,response = do_method("sa", "Register", params)
if rval:
Fatal("Could not get my slice")
print str(rval)
print str(response)
pass
myslice = response["value"]
print "New slice created"
......
......@@ -30,14 +30,8 @@ execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
#
params = {}
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get my credential")
pass
mycredential = response["value"]
mycredential = get_self_credential()
print "Got my SA credential"
#print str(mycredential);
#
# Lookup my ssh keys.
......@@ -81,16 +75,7 @@ else:
#
print "Asking for slice credential for " + SLICENAME
myslice = response["value"]
myuuid = myslice["uuid"]
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["uuid"] = myuuid
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get Slice credential")
pass
myslice = response["value"]
myslice = get_slice_credential( myslice, mycredential )
print "Got the slice credential"
pass
......
......@@ -29,36 +29,22 @@ execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
#
params = {}
params["uuid"] = "0b2eb97e-ed30-11db-96cb-001143e453fe"
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get my credential")
pass
mycredential = response["value"]
mycredential = get_self_credential()
print "Got my SA credential"
#print str(mycredential);
#
# Lookup slice, delete before proceeding.
# Lookup slice, and delete.
#
myslice = resolve_slice( SLICENAME, mycredential )
myuuid = myslice["uuid"]
print "Deleting previously registered slice";
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["hrn"] = SLICENAME
rval,response = do_method("sa", "Resolve", params)
if rval == 0:
myslice = response["value"]
myuuid = myslice["uuid"]
print "Deleting previously registered slice";
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["uuid"] = myuuid
rval,response = do_method("sa", "Remove", params)
if rval:
Fatal("Could not remove slice record")
pass
params["uuid"] = myuuid
rval,response = do_method("sa", "Remove", params)
if rval:
Fatal("Could not remove slice record")
pass
pass
......@@ -29,43 +29,20 @@ execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
#
params = {}
params["uuid"] = "0b2eb97e-ed30-11db-96cb-001143e453fe"
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get my credential")
pass
mycredential = response["value"]
mycredential = get_self_credential()
print "Got my SA credential. Looking for slice ..."
#print str(mycredential);
#
# Lookup slice, delete before proceeding.
#
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["hrn"] = SLICENAME
rval,response = do_method("sa", "Resolve", params)
if rval:
Fatal("Slice does not exist")
pass
myslice = response["value"]
myslice = resolve_slice( SLICENAME, mycredential )
myuuid = myslice["uuid"]
print "Found the slice, asking for a credential ..."
#
# Get the slice credential.
#
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["uuid"] = myuuid
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get Slice credential")
pass
slicecred = response["value"]
slicecred = get_slice_credential( myslice, mycredential )
print "Got the slice credential, asking for a sliver credential ..."
#
......
#! /usr/bin/env python
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004, 2008, 2009 University of Utah and the Flux Group.
# All rights reserved.
#
# Permission to use, copy, modify and distribute this software is hereby
# granted provided that (1) source code retains these copyright, permission,
# and disclaimer notices, and (2) redistributions including binaries
# reproduce the notices in supporting documentation.
#
# THE UNIVERSITY OF UTAH ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
# CONDITION. THE UNIVERSITY OF UTAH DISCLAIMS ANY LIABILITY OF ANY KIND
# FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
#
#
#
import sys
import pwd
import getopt
import os
import re
import xmlrpclib
from M2Crypto import X509
execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
#
mycredential = get_self_credential()
print mycredential
#! /usr/bin/env python
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004, 2008, 2009 University of Utah and the Flux Group.
# All rights reserved.
#
# Permission to use, copy, modify and distribute this software is hereby
# granted provided that (1) source code retains these copyright, permission,
# and disclaimer notices, and (2) redistributions including binaries
# reproduce the notices in supporting documentation.
#
# THE UNIVERSITY OF UTAH ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
# CONDITION. THE UNIVERSITY OF UTAH DISCLAIMS ANY LIABILITY OF ANY KIND
# FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
#
#
#
import sys
import pwd
import getopt
import os
import re
import xmlrpclib
from M2Crypto import X509
execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
#
mycredential = get_self_credential()
#
# Lookup slice.
#
myslice = resolve_slice( SLICENAME, mycredential )
#
# Get the slice credential.
#
slicecredential = get_slice_credential( myslice, mycredential )
print slicecredential
......@@ -30,15 +30,8 @@ execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
#
params = {}
params["uuid"] = "0b2eb97e-ed30-11db-96cb-001143e453fe"
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get my credential")
pass
mycredential = response["value"]
mycredential = get_self_credential()
print "Got my SA credential, looking up " + SLICENAME
#print str(mycredential);
#
# Lookup slice.
......@@ -69,17 +62,7 @@ else:
# Get the slice credential.
#
print "Asking for slice credential for " + SLICENAME
myslice = response["value"]
myuuid = myslice["uuid"]
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["uuid"] = myuuid
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get Slice credential")
pass
myslice = response["value"]
myslice = get_slice_credential( myslice, mycredential )
print "Got the slice credential"
pass
......
......@@ -30,14 +30,8 @@ execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
#
params = {}
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get my credential")
pass
mycredential = response["value"]
mycredential = get_self_credential()
print "Got my SA credential"
#print str(mycredential);
#
# Lookup my ssh keys.
......@@ -81,16 +75,7 @@ else:
#
print "Asking for slice credential for " + SLICENAME
myslice = response["value"]
myuuid = myslice["uuid"]
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["uuid"] = myuuid
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get Slice credential")
pass
myslice = response["value"]
myslice = get_slice_credential( myslice, mycredential )
print "Got the slice credential"
pass
......
......@@ -29,15 +29,7 @@ execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
#
params = {}
params["uuid"] = "0b2eb97e-ed30-11db-96cb-001143e453fe"
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get my credential")
pass
mycredential = response["value"]
print "Got my SA credential"
#print str(mycredential);
mycredential = get_self_credential()
#
# Ask the clearinghouse for a list of component managers.
......
......@@ -29,15 +29,8 @@ execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
#
params = {}
params["uuid"] = "0b2eb97e-ed30-11db-96cb-001143e453fe"
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get my credential")
pass
mycredential = response["value"]
mycredential = get_self_credential()
print "Got my SA credential"
#print str(mycredential);
#
# Lookup the geniuser user.
......
......@@ -29,40 +29,15 @@ execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
#
params = {}
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get my credential")
pass
mycredential = response["value"]
mycredential = get_self_credential()
print "Got my SA credential"
#print str(mycredential);
#
# Lookup slice, get credential.
#
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["hrn"] = SLICENAME
rval,response = do_method("sa", "Resolve", params)
if rval == 0:
print "Asking for slice credential for " + SLICENAME
myslice = response["value"]
myuuid = myslice["uuid"]
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["uuid"] = myuuid
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get Slice credential")
pass
myslice = response["value"]
print "Got the slice credential"
else:
Fatal("Could not lookup slice, must not exist");
pass
myslice = resolve_slice( SLICENAME, mycredential )
myslice = get_slice_credential( myslice, mycredential )
print "Got the slice credential"
print "Shutting down slice";
params = {}
......
......@@ -14,6 +14,10 @@
from urlparse import urlsplit, urlunsplit
from urllib import splitport
# Debugging output.
debug = 0
impotent = 0
HOME = os.environ["HOME"]
# Path to my certificate
CERTIFICATE = HOME + "/.ssl/encrypted.pem"
......@@ -21,8 +25,53 @@ CERTIFICATE = HOME + "/.ssl/encrypted.pem"
PASSPHRASEFILE = HOME + "/.ssl/password"
passphrase = ""
CONFIGFILE = ".protogeni-config.py"
GLOBALCONF = HOME + "/" + CONFIGFILE
LOCALCONF = CONFIGFILE
SLICENAME = "mytestslice"
selfcredentialfile = None
slicecredentialfile = None
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]
-s file, --slicecredentials=file read slice credentials from file
[default: query from SA]"""
try:
opts, args = getopt.getopt( sys.argv[ 1: ], "c:df:hp:s:",
[ "credentials=", "debug", "certificate=",
"help", "passphrase=", "slicecredentials=" ] )
except getopt.GetoptError, err:
print str( err )
Usage()
sys.exit( 1 )
for opt, arg in opts:
if opt in ( "-c", "--credentials" ):
selfcredentialfile = arg
elif opt in ( "-d", "--debug" ):
debug = 1
elif opt in ( "-f", "--certificate" ):
CERTIFICATE = arg
elif opt in ( "-h", "--help" ):
Usage()
sys.exit( 0 )
elif opt in ( "-p", "--passphrase" ):
PASSPHRASEFILE = arg
elif opt in ( "-s", "--slicecredentials" ):
slicecredentialfile = arg
cert = X509.load_cert( CERTIFICATE )
# XMLRPC server: use www.emulab.net for the clearinghouse, and
......@@ -31,14 +80,6 @@ XMLRPC_SERVER = { "ch" : "www.emulab.net",
"default" : cert.get_issuer().CN }
SERVER_PATH = { "default" : ":443/protogeni/xmlrpc/" }
# Debugging output.
debug = 0
impotent = 0
CONFIGFILE = ".protogeni-config.py"
GLOBALCONF = HOME + "/" + CONFIGFILE
LOCALCONF = CONFIGFILE
if os.path.exists( GLOBALCONF ):
execfile( GLOBALCONF )
if os.path.exists( LOCALCONF ):
......@@ -137,3 +178,46 @@ def do_method(module, method, params, URI=None):
pass
pass
return (rval, response)
def get_self_credential():
if selfcredentialfile:
f = open( selfcredentialfile )
c = f.read()
f.close()
return c
params = {}
params["uuid"] = "0b2eb97e-ed30-11db-96cb-001143e453fe"
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get my credential")
pass
return response["value"]
def resolve_slice( name, selfcredential ):
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["hrn"] = SLICENAME
rval,response = do_method("sa", "Resolve", params)
if rval:
Fatal("Slice does not exist");
pass
else:
return response["value"]
def get_slice_credential( slice, selfcredential ):
if slicecredentialfile:
f = open( slicecredentialfile )
c = f.read()
f.close()
return c
params = {}
params["credential"] = selfcredential
params["type"] = "Slice"
params["uuid"] = slice["uuid"]
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get Slice credential")
pass
return response["value"]
......@@ -68,15 +68,8 @@ class findElement(ContentHandler):
#
# Get a credential for myself, that allows me to do things at the SA.
#
params = {}
params["uuid"] = "0b2eb97e-ed30-11db-96cb-001143e453fe"
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get my credential")
pass
mycredential = response["value"]
mycredential = get_self_credential()
print "Got my SA credential"
#print str(mycredential);
#
# Lookup slice.
......@@ -108,16 +101,7 @@ else:
#
print "Asking for slice credential for " + SLICENAME
myslice = response["value"]
myuuid = myslice["uuid"]
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["uuid"] = myuuid
rval,response = do_method("sa", "GetCredential", params)
if rval:
Fatal("Could not get Slice credential")
pass
myslice = response["value"]
myslice = get_slice_credential( myslice, mycredential )
print "Got the slice credential"
pass
......
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