Commit 57c2a270 authored by Gary Wong's avatar Gary Wong
Browse files

Make the version 2 CM tests the default.

parent d894e04e
#! /usr/bin/env python
#
# GENIPUBLIC-COPYRIGHT
# Copyright (c) 2008-2010 University of Utah and the Flux Group.
# Copyright (c) 2008-2009 University of Utah and the Flux Group.
# All rights reserved.
#
# Permission to use, copy, modify and distribute this software is hereby
......@@ -22,60 +22,20 @@ import getopt
import os
import time
import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
def Usage():
print "usage: " + sys.argv[ 0 ] + " [option...] [resource-specification]"
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
-k keyfile, --keys=keyfile read SSH keys from file
[default: query from SA]
-n name, --slicename=name specify human-readable name of slice
[default: mytestslice]
-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]
-u, --update perform an update after creation"""
update = False
# We're supposed to make a temporary copy of a list to iterate over it
# if we might also mutate it. Silly Python.
for arg in sys.argv[:]:
if arg == "-u" or ( len( arg ) >= 3 and "--update".find( arg ) == 0 ):
sys.argv.remove( arg )
update = True
# Gah. This case is even uglier, since we need to remove both the
# option and its mandator parameter. Don't bother addressing the
# case where the user specifies -k more than once: they are being silly.
keyfile = ""
for i in range( len( sys.argv ) ):
if sys.argv[ i ] == "-k" or ( len( sys.argv[ i ] ) >= 3 and "--key".find( sys.argv[ i ] ) == 0 ):
if i + 1 >= len( sys.argv ):
Usage()
sys.exit( 1 )
keyfile = sys.argv[ i + 1 ]
sys.argv[ i : i + 2 ] = [];
break
debug = 0
impotent = 1
execfile( "test-common.py" )
if len( args ) > 1:
if len(REQARGS) > 1:
Usage()
sys.exit( 1 )
elif len( args ) == 1:
elif len(REQARGS) == 1:
try:
rspecfile = open( args[ 0 ] )
rspecfile = open(REQARGS[0])
rspec = rspecfile.read()
rspecfile.close()
except IOError, e:
......@@ -100,20 +60,11 @@ print "Got my SA credential"
#
params = {}
params["credential"] = mycredential
if keyfile == "":
rval,response = do_method("sa", "GetKeys", params)
if rval:
Fatal("Could not get my keys")
pass
mykeys = response["value"]
else:
mykeys = []
f = open( keyfile )
for keyline in f:
if re.match( r"\s*#", keyline ):
continue
mykeys.append( { 'type' : 'ssh', 'key' : keyline } )
f.close()
rval,response = do_method("sa", "GetKeys", params)
if rval:
Fatal("Could not get my keys")
pass
mykeys = response["value"]
if debug: print str(mykeys)
#
......@@ -150,88 +101,37 @@ else:
print "Got the slice credential"
pass
#
# Get a ticket. We do not have a real resource discovery tool yet, so
# as a debugging aid, you can wildcard the uuid, and the CM will find
# a free node and fill it in.
#
print "Asking for a ticket from the CM"
params = {}
params["credential"] = myslice
params["rspec"] = rspec
rval,response = do_method("cm", "GetTicket", params)
if rval:
if response and response["value"]:
print >> sys.stderr, ""
print >> sys.stderr, str(response["value"])
print >> sys.stderr, ""
pass
Fatal("Could not get ticket")
pass
ticket = response["value"]
print "Got a ticket from the CM. Redeeming the ticket ..."
#
# Create the sliver.
#
print "Creating the Sliver ..."
params = {}
params["credential"] = myslice
params["ticket"] = ticket
params["keys"] = mykeys
params["impotent"] = impotent
rval,response = do_method("cm", "RedeemTicket", params)
params["credentials"] = (myslice,)
params["slice_urn"] = SLICEURN
params["rspec"] = rspec
params["keys"] = mykeys
params["impotent"] = impotent
rval,response = do_method("cmv2", "CreateSliver", params)
if rval:
Fatal("Could not redeem ticket")
Fatal("Could not create sliver")
pass
sliver,manifest = response["value"]
print "Created the sliver"
print str(manifest)
if update:
#
# Get an updated ticket using the manifest. Normally the user would
# actually change the contents.
#
print "Updating the original ticket ..."
params = {}
params["credential"] = myslice
params["ticket"] = ticket
params["rspec"] = manifest
rval,response = do_method("cm", "UpdateTicket", params)
if rval:
Fatal("Could not update the ticket")
pass
newticket = response["value"]
print "Got an updated ticket from the CM. Updating the sliver ..."
#
# Update the sliver
#
params = {}
params["credential"] = sliver
params["ticket"] = newticket
rval,response = do_method("cm", "UpdateSliver", params)
if rval:
Fatal("Could not update sliver on CM")
pass
manifest = response["value"]
print "Updated the sliver on the CM, asking for a ticket copy ..."
print str(manifest)
#
# Grab a sliver ticket just for the hell of it.
# Renew the sliver, for kicks
#
valid_until = time.strftime("%Y%m%dT%H:%M:%S",time.gmtime(time.time() + 6000));
print "Renewing the Sliver until " + valid_until
params = {}
params["credential"] = sliver
rval,response = do_method("cm", "SliverTicket", params)
params["slice_urn"] = SLICEURN
params["credentials"] = (sliver,)
params["valid_until"] = valid_until
rval,response = do_method("cmv2", "RenewSliver", params)
if rval:
Fatal("Could not get sliver ticket/manifest")
Fatal("Could not renew sliver")
pass
print "Got a new ticket"
ticket = response["value"]
print str(ticket);
print "Sliver has been renewed"
print ""
print "Start this sliver with startsliver.py"
print "Delete this sliver with deletesliver.py"
......@@ -24,7 +24,7 @@ import re
ACCEPTSLICENAME=1
execfile( "../test-common.py" )
execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
......
......@@ -21,8 +21,6 @@ import pwd
import getopt
import os
import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
......@@ -46,12 +44,31 @@ print "Found the slice, asking for a credential ..."
slicecred = get_slice_credential( myslice, mycredential )
print "Got the slice credential, asking for a sliver credential ..."
#
# Do a resolve to get the sliver urn.
#
print "Resolving the slice at the CM"
params = {}
params["credentials"] = (slicecred,)
params["urn"] = myslice["urn"]
rval,response = do_method("cmv2", "Resolve", params)
if rval:
Fatal("Could not resolve slice")
pass
myslice = response["value"]
print str(myslice)
if not "sliver_urn" in myslice:
Fatal("No sliver exists for slice")
pass
#
# Get the sliver credential.
#
params = {}
params["credential"] = slicecred
rval,response = do_method("cm", "GetSliver", params)
params["credentials"] = (slicecred,)
params["slice_urn"] = SLICEURN
rval,response = do_method("cmv2", "GetSliver", params)
if rval:
Fatal("Could not get Sliver credential")
pass
......@@ -62,11 +79,14 @@ print "Got the sliver credential, deleting the sliver";
# Delete the sliver.
#
params = {}
params["credential"] = slivercred
rval,response = do_method("cm", "DeleteSliver", params)
params["credentials"] = (slivercred,)
params["sliver_urn"] = myslice["sliver_urn"]
rval,response = do_method("cmv2", "DeleteSliver", params)
if rval:
Fatal("Could not delete sliver")
pass
print "Sliver has been deleted."
print "Sliver has been deleted. Ticket for remaining time:"
ticket = response["value"]
print str(ticket);
......@@ -21,8 +21,6 @@ import pwd
import getopt
import os
import re
import xmlrpclib
from M2Crypto import X509
execfile( "test-common.py" )
......@@ -35,8 +33,8 @@ mycredential = get_self_credential()
# Ask manager for its list.
#
params = {}
params["credential"] = mycredential
rval,response = do_method("cm", "DiscoverResources", params)
params["credentials"] = (mycredential,)
rval,response = do_method("cmv2", "DiscoverResources", params)
if rval:
Fatal("Could not get a list of resources")
pass
......
#! /usr/bin/env python
#
# GENIPUBLIC-COPYRIGHT
# Copyright (c) 2008-2010 University of Utah and the Flux Group.
# Copyright (c) 2008-2009 University of Utah and the Flux Group.
# All rights reserved.
#
# Permission to use, copy, modify and distribute this software is hereby
......@@ -29,6 +29,25 @@ ACCEPTSLICENAME=1
execfile( "test-common.py" )
if len(REQARGS) > 1:
Usage()
sys.exit( 1 )
elif len(REQARGS) == 1:
try:
rspecfile = open(REQARGS[0])
rspec = rspecfile.read()
rspecfile.close()
except IOError, e:
print >> sys.stderr, args[ 0 ] + ": " + e.strerror
sys.exit( 1 )
else:
rspec = "<rspec xmlns=\"http://protogeni.net/resources/rspec/0.1\"> " +\
" <node virtual_id=\"geni1\" "+\
" virtualization_type=\"emulab-vnode\"> " +\
" </node>" +\
"</rspec>"
pass
#
# Get a credential for myself, that allows me to do things at the SA.
#
......@@ -73,76 +92,33 @@ else:
# as a debugging aid, you can wildcard the uuid, and the CM will find
# a free node and fill it in.
#
print "Asking for a ticket from the CM"
print "Asking for a ticket from the local CM"
rspec = "<rspec xmlns=\"http://protogeni.net/resources/rspec/0.1\"> " +\
" <node virtual_id=\"geni1\" "+\
" virtualization_type=\"emulab-vnode\"> " +\
" </node>" +\
"</rspec>"
params = {}
params["credential"] = myslice
params["rspec"] = rspec
params["impotent"] = 0
rval,response = do_method("cm", "GetTicket", params)
params["slice_urn"] = SLICEURN
params["credentials"] = (myslice,)
params["rspec"] = rspec
params["impotent"] = 0
rval,response = do_method("cmv2", "GetTicket", params)
if rval:
if response and response["value"]:
print >> sys.stderr, ""
print >> sys.stderr, str(response["value"])
print >> sys.stderr, ""
pass
Fatal("Could not get ticket")
pass
ticket = response["value"]
print "Got a ticket from the CM. Delaying a moment ..."
if debug: print str(ticket)
#print str(ticket)
time.sleep(2)
print "Doing a ticket update ..."
#
# Update the ticket.
#
print "Got the ticket, doing a update on it. "
params = {}
params["credential"] = myslice
params["ticket"] = ticket
params["rspec"] = rspec
rval,response = do_method("cm", "UpdateTicket", params)
params["slice_urn"] = SLICEURN
params["ticket"] = ticket
params["credentials"] = (myslice,)
params["rspec"] = rspec
params["impotent"] = 0
rval,response = do_method("cmv2", "UpdateTicket", params)
if rval:
Fatal("Could not update ticket")
pass
ticket = response["value"]
print "Got an updated ticket from the CM. Delaying a moment ..."
if debug: print str(ticket)
#print str(ticket)
time.sleep(2)
print "Getting a list of all your tickets ..."
params = {}
params["credential"] = myslice
rval,response = do_method("cm", "ListTickets", params)
if rval:
Fatal("Could not get ticket list")
pass
tickets = response["value"]
print str(tickets);
print "Asking for a copy of the ticket ..."
params = {}
params["credential"] = myslice
params["uuid"] = tickets[0]["uuid"]
rval,response = do_method("cm", "GetTicket", params)
if rval:
Fatal("Could not get ticket list")
pass
ticketcopy = response["value"]
print "Releasing the ticket now ..."
params = {}
params["credential"] = myslice
params["ticket"] = ticketcopy
rval,response = do_method("cm", "ReleaseTicket", params)
if rval:
Fatal("Could not release ticket")
pass
print "Ticket has been released"
print str(ticket)
......@@ -28,7 +28,7 @@ ACCEPTSLICENAME=1
debug = 0
impotent = 1
execfile( "../test-common.py" )
execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
......
......@@ -28,7 +28,7 @@ ACCEPTSLICENAME=1
debug = 0
impotent = 1
execfile( "../test-common.py" )
execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
......
......@@ -23,7 +23,7 @@ import os
import time
import re
execfile("../test-common.py")
execfile("test-common.py")
URN = None
......
......@@ -25,7 +25,7 @@ import re
ACCEPTSLICENAME=1
URN = None
execfile( "../test-common.py" )
execfile( "test-common.py" )
if len(REQARGS) < 1:
print >> sys.stderr, "Must provide the action (start/stop/restart)"
......
......@@ -21,8 +21,6 @@ import pwd
import getopt
import os
import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
......@@ -50,8 +48,9 @@ print "Got the slice credential, asking for a sliver credential ..."
# Get the sliver credential.
#
params = {}
params["credential"] = slicecred
rval,response = do_method("cm", "GetSliver", params)
params["slice_urn"] = SLICEURN
params["credentials"] = (slicecred,)
rval,response = do_method("cmv2", "GetSliver", params)
if rval:
Fatal("Could not get Sliver credential")
pass
......@@ -62,8 +61,9 @@ print "Got the sliver credential, asking for sliver status";
# Get the sliver status
#
params = {}
params["credential"] = slivercred
rval,response = do_method("cm", "SliverStatus", params)
params["slice_urn"] = SLICEURN
params["credentials"] = (slivercred,)
rval,response = do_method("cmv2", "SliverStatus", params)
if rval:
Fatal("Could not get sliver status")
pass
......
......@@ -28,7 +28,7 @@ ACCEPTSLICENAME=1
debug = 0
impotent = 1
execfile( "../test-common.py" )
execfile( "test-common.py" )
if len(REQARGS) > 1:
Usage()
......
#! /usr/bin/env python
#
# GENIPUBLIC-COPYRIGHT
# Copyright (c) 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 time
import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
execfile( "test-common.py" )
#
# Get a credential for myself, that allows me to do things at the SA.
#
mycredential = get_self_credential()
print "Got self credential"
#
# Lookup slice.
#
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"] = slicecredential
rval,response = do_method("cm", "BindToSlice", params)
if rval:
Fatal("Could not bind myself to slice")
pass
print "Bound myself to slice"
#! /usr/bin/env python
#
# GENIPUBLIC-COPYRIGHT
# Copyright (c) 2008-2010 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 time
import re
import xmlrpclib
from M2Crypto import X509
ACCEPTSLICENAME=1
def Usage():
print "usage: " + sys.argv[ 0 ] + " [option...] [resource-specification]"
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
-k keyfile, --keys=keyfile read SSH keys from file
[default: query from SA]
-n name, --slicename=name specify human-readable name of slice
[default: mytestslice]
-p file, --passphrase=file read passphrase from file
[default: ~/.ssl/password]
-r file, --read-commands=file specify additional configuration file