Commit 49d1e106 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Oops, forgot the rest of the V2 api stuff.

parent cd7d6d02
......@@ -107,6 +107,7 @@ else:
print "Creating the Sliver ..."
params = {}
params["credentials"] = (myslice,)
params["slice_urn"] = SLICEURN
params["rspec"] = rspec
params["keys"] = mykeys
params["impotent"] = impotent
......@@ -125,7 +126,8 @@ valid_until = time.strftime("%Y%m%dT%H:%M:%S",time.gmtime(time.time() + 6000));
print "Renewing the Sliver until " + valid_until
params = {}
params["credentials"] = (sliver,)
params["slice_urn"] = SLICEURN
params["credentials"] = (sliver,)
params["valid_until"] = valid_until
rval,response = do_method("cmv2", "RenewSliver", params)
if rval:
......
#! /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 re
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 my SA credential. Looking for slice ..."
#
# Lookup slice, delete before proceeding.
#
myslice = resolve_slice( SLICENAME, mycredential )
print "Found the slice, asking for a credential ..."
#
# Get the slice credential.
#
slicecred = get_slice_credential( myslice, mycredential )
print "Got the slice credential"
#
# Delete the Slice
#
print "Deleting the slice"
params = {}
params["credentials"] = (slicecred,)
params["slice_urn"] = SLICEURN
rval,response = do_method("cmv2", "DeleteSlice", params)
if rval:
Fatal("Could not delete slice")
pass
print "Slice has been deleted."
......@@ -44,11 +44,30 @@ 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["credentials"] = (slicecred,)
params["slice_urn"] = SLICEURN
rval,response = do_method("cmv2", "GetSliver", params)
if rval:
Fatal("Could not get Sliver credential")
......@@ -61,10 +80,13 @@ print "Got the sliver credential, deleting the sliver";
#
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);
#! /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" )
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.
#
mycredential = get_self_credential()
print "Got my SA credential, looking up " + SLICENAME
#
# Lookup slice.
#
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["hrn"] = SLICENAME
rval,response = do_method("sa", "Resolve", params)
if rval:
#
# Create a slice.
#
print "Creating new slice called " + SLICENAME
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["hrn"] = SLICENAME
rval,response = do_method("sa", "Register", params)
if rval:
Fatal("Could not create new slice")
pass
myslice = response["value"]
print "New slice created"
pass
else:
#
# Get the slice credential.
#
print "Asking for slice credential for " + SLICENAME
myslice = get_slice_credential( response[ "value" ], mycredential )
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 local CM"
params = {}
params["slice_urn"] = SLICEURN
params["credentials"] = (myslice,)
params["rspec"] = rspec
params["impotent"] = 0
rval,response = do_method("cmv2", "GetTicket", params)
if rval:
Fatal("Could not get ticket")
pass
ticket = response["value"]
#print str(ticket)
#
# Update the ticket.
#
print "Got the ticket, doing a update on it. "
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 str(ticket)
<rspec xmlns="http://protogeni.net/resources/rspec/0.1">
<node virtual_id="geni1"
virtualization_type="emulab-vnode"
exclusive="1">
<interface virtual_id="virt0"/>
</node>
<node virtual_id="geni2"
virtualization_type="emulab-vnode"
exclusive="1">
<interface virtual_id="virt0"/>
</node>
<link virtual_id="link0">
<interface_ref
virtual_interface_id="virt0"
virtual_node_id="geni1"
/>
<interface_ref
virtual_interface_id="virt0"
virtual_node_id="geni2"
/>
</link>
</rspec>
#! /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
ACCEPTSLICENAME=1
debug = 0
impotent = 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 my SA credential"
#
# Lookup my ssh keys.
#
params = {}
params["credential"] = mycredential
rval,response = do_method("sa", "GetKeys", params)
if rval:
Fatal("Could not get my keys")
pass
mykeys = response["value"]
if debug: print str(mykeys)
#
# Lookup slice.
#
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["hrn"] = SLICENAME
rval,response = do_method("sa", "Resolve", params)
if rval:
Fatal("No such slice at SA");
pass
else:
#
# Get the slice credential.
#
print "Asking for slice credential for " + SLICENAME
myslice = response["value"]
slicecred = get_slice_credential( myslice, mycredential )
print "Got the slice credential"
pass
#
# Do a resolve to get the ticket 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 "ticket_urn" in myslice:
Fatal("No ticket exists for slice")
pass
#
# Get the ticket with another call to resolve.
#
print "Asking for the ticket"
params = {}
params["credentials"] = (slicecred,)
params["urn"] = myslice["ticket_urn"]
rval,response = do_method("cmv2", "Resolve", params)
if rval:
Fatal("Could not get the ticket")
pass
ticket = response["value"]
print "Got the ticket"
#
# And redeem the ticket.
#
print "Redeeming the ticket"
params = {}
params["credentials"] = (slicecred,)
params["ticket"] = ticket
params["slice_urn"] = SLICEURN
params["keys"] = mykeys
rval,response = do_method("cmv2", "RedeemTicket", params)
if rval:
Fatal("Could not redeem the ticket")
pass
sliver,manifest = response["value"]
print "Created the sliver"
print str(manifest)
#! /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
ACCEPTSLICENAME=1
debug = 0
impotent = 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 my SA credential"
#
# Lookup slice.
#
params = {}
params["credential"] = mycredential
params["type"] = "Slice"
params["hrn"] = SLICENAME
rval,response = do_method("sa", "Resolve", params)
if rval:
Fatal("No such slice at SA");
pass
else:
#
# Get the slice credential.
#
print "Asking for slice credential for " + SLICENAME
myslice = response["value"]
slicecred = get_slice_credential( myslice, mycredential )
print "Got the slice credential"
pass
#
# Do a resolve to get the ticket 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 "ticket_urn" in myslice:
Fatal("No ticket exists for slice")
pass
#
# Get the ticket with another call to resolve.
#
print "Asking for the ticket"
params = {}
params["credentials"] = (slicecred,)
params["urn"] = myslice["ticket_urn"]
rval,response = do_method("cmv2", "Resolve", params)
if rval:
Fatal("Could not get the ticket")
pass
ticket = response["value"]
print "Got the ticket"
#
# And release the ticket.
#
print "Releasing the ticket"
params = {}
params["ticket"] = ticket
rval,response = do_method("cmv2", "ReleaseTicket", params)
if rval:
Fatal("Could not release the ticket")
pass
print "The ticket has been released"
......@@ -40,6 +40,7 @@ else:
mycredential = get_self_credential()
print "Got my SA credential"
print "Resolving at the local CM"
params = {}
params["credentials"] = (mycredential,)
......
#! /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 re
ACCEPTSLICENAME=1
execfile( "../test-common.py" )
if len(REQARGS) != 1:
print >> sys.stderr, "Must provide the action (start/stop/restart)"
sys.exit(1)
else:
action = REQARGS[0]
if action != "start" and action != "stop" and action != "restart":
print >> sys.stderr, "Action must be one of start/stop/restart"
sys.exit(1)
pass
pass
#
# Get a credential for myself, that allows me to do things at the SA.
#
mycredential = get_self_credential()
print "Got my SA credential. Looking for slice ..."
#
# Lookup slice, delete before proceeding.
#
myslice = resolve_slice( SLICENAME, mycredential )
print "Found the slice, asking for a credential ..."
#
# Get the slice credential.
#
slicecred = get_slice_credential( myslice, mycredential )
print "Got the slice credential, asking for a sliver credential ..."
#
# Get the sliver credential.
#
params = {}
params["credentials"] = (slicecred,)
params["slice_urn"] = SLICEURN
rval,response = do_method("cmv2", "GetSliver", params)
if rval:
Fatal("Could not get Sliver credential")
pass
slivercred = response["value"]
if action == "start":
method = "StartSliver"
elif action == "stop":
method = "StopSliver"
else:
method = "RestartSliver"
pass
#
# Start the sliver.
#
print "Got the sliver credential, calling " + method + " on the sliver";
params = {}
params["credentials"] = (slivercred,)
params["slice_urn"] = SLICEURN
rval,response = do_method("cmv2", method, params)
if rval:
Fatal("Could not start sliver")
pass
print "Sliver has been " + action + "'ed."
......@@ -48,6 +48,7 @@ print "Got the slice credential, asking for a sliver credential ..."
# Get the sliver credential.
#
params = {}
params["slice_urn"] = SLICEURN
params["credentials"] = (slicecred,)
rval,response = do_method("cmv2", "GetSliver", params)
if rval:
......@@ -60,6 +61,7 @@ print "Got the sliver credential, asking for sliver status";
# Get the sliver status
#
params = {}
params["slice_urn"] = SLICEURN
params["credentials"] = (slivercred,)
rval,response = do_method("cmv2", "SliverStatus", params)
if rval:
......