Commit 98a77cf7 authored by Gary Wong's avatar Gary Wong

Add tutorial scripts, handout and slides.

This version was the one used at GEC 8.
parent c1c1bce2
#! /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 xml.dom.minidom
ACCEPTSLICENAME=1
debug = 0
impotent = 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\" " +\
" startup_command=\"/bin/ls > /tmp/foo\"> " +\
" </node>" +\
"</rspec>"
#
# Get a credential for myself, that allows me to do things at the SA.
#
print "Obtaining SA credential..."
mycredential = get_self_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)
keyfile = open( os.environ[ "HOME" ] + "/.ssh/id_rsa.pub" )
emulabkey = keyfile.readline().strip()
keyfile.close()
mykeys.append( { 'type' : 'ssh', 'key' : emulabkey } )
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:
#
# 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 = response["value"]
myslice = get_slice_credential( myslice, mycredential )
print "Got the slice credential."
pass
#
# Create the sliver.
#
print "Creating the sliver..."
params = {}
params["credentials"] = (myslice,)
params["slice_urn"] = SLICEURN
params["rspec"] = rspec
params["keys"] = mykeys
params["impotent"] = impotent
rval,response = do_method("cm", "CreateSliver", params, version="2.0")
if rval:
Fatal("Could not create sliver")
pass
sliver,manifest = response["value"]
print "Received the manifest:"
doc = xml.dom.minidom.parseString( manifest )
for node in doc.getElementsByTagName( "node" ):
print " Node " + node.getAttribute( "virtual_id" ) + " is " + node.getAttribute( "hostname" )
print "Waiting until sliver is ready",
sys.stdout.flush()
#
# Poll for the sliver status. It would be nice to use WaitForStatus
# here, but SliverStatus is more general (since it falls in the minimal
# subset).
#
params = {}
params["slice_urn"] = SLICEURN
params["credentials"] = (sliver,)
while True: # #@(%ing Python doesn't have do loops
rval,response = do_method("cm", "SliverStatus", params, quiet=True, version="2.0")
if rval:
sys.stdout.write( "*" )
sys.stdout.flush()
time.sleep( 3 )
elif response[ "value" ][ "status" ] == "ready":
break
elif response[ "value" ][ "status" ] == "changing" or response[ "value" ][ "status" ] == "mixed":
sys.stdout.write( "." ) # #@(%ing stupid Python #@(%s up the
# whitespace if you try "print"
sys.stdout.flush()
time.sleep( 3 )
else:
print
Fatal( "Sliver status is " + response[ "value" ][ "status" ] )
print
print "Sliver is ready."
<rspec xmlns="http://protogeni.net/resources/rspec/0.1">
<node virtual_id="mypc"
virtualization_type="emulab-vnode"
exclusive="1">
</node>
</rspec>
<rspec xmlns="http://protogeni.net/resources/rspec/0.1">
<node virtual_id="bbg1"
component_urn="urn:publicid:IDN+emulab.net+node+bbg1"
virtualization_type="emulab-vnode"
exclusive="1">
<interface virtual_id="virt0"/>
</node>
<node virtual_id="bbg2"
component_urn="urn:publicid:IDN+emulab.net+node+bbg2"
virtualization_type="emulab-vnode"
exclusive="1">
<interface virtual_id="virt0"/>
</node>
<link virtual_id="link0">
<bandwidth>1000000</bandwidth>
<interface_ref
virtual_interface_id="virt0"
virtual_node_id="bbg1"
/>
<interface_ref
virtual_interface_id="virt0"
virtual_node_id="bbg2"
/>
</link>
</rspec>
#! /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
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( SLICEURN, mycredential )
print "Resolved slice " + SLICEURN
#
# 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"
<rspec xmlns="http://www.protogeni.net/resources/rspec/0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.protogeni.net/resources/rspec/0.1
http://www.protogeni.net/resources/rspec/0.1/request.xsd" type="request">
<node virtual_id="my-node" virtualization_type="emulab-vnode"
exclusive="1">
<node_type type_name="pc850" type_slots="1"/>
<interface virtual_id="control"/>
</node>
</rspec>
\ No newline at end of file
#! /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
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()
#
# Ask the clearinghouse for a list of slices
#
params = {}
params["credential"] = mycredential
params["type"] = "slices"
rval,response = do_method("ch", "List", params)
if rval:
Fatal("Could not get the list from the ClearingHouse")
pass
print str(response["value"])
#
# Ask the clearinghouse for a list of authorities
#
params = {}
params["credential"] = mycredential
params["type"] = "authorities"
rval,response = do_method("ch", "List", params)
if rval:
Fatal("Could not get the list from the ClearingHouse")
pass
print str(response["value"])
#! /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
ACCEPTSLICENAME=1
debug = 0
impotent = 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\" " +\
" startup_command=\"/bin/ls > /tmp/foo\"> " +\
" </node>" +\
"</rspec>"
#
# 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:
#
# 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 = response["value"]
myslice = get_slice_credential( myslice, mycredential )
print "Got the slice credential"
pass
#
# Create the sliver.
#
print "Creating the Sliver ..."
params = {}
params["credentials"] = (myslice,)
params["slice_urn"] = SLICEURN
params["rspec"] = rspec
params["keys"] = mykeys
params["impotent"] = impotent
rval,response = do_method("cm", "CreateSliver", params, version="2.0")
if rval:
Fatal("Could not create sliver")
pass
sliver,manifest = response["value"]
print "Created the sliver"
print str(manifest)
This diff is collapsed.
#! /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 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("cm", "DeleteSlice", params, version="2.0")
if rval:
Fatal("Could not delete slice")
pass
print "Slice has been deleted."
#! /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 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, 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("cm", "Resolve", params, version="2.0")
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("cm", "GetSliver", params, version="2.0")
if rval:
Fatal("Could not get Sliver credential")
pass
slivercred = response["value"]
print "Got the sliver credential, deleting the sliver";
#
# Delete the sliver.
#
params = {}
params["credentials"] = (slivercred,)
params["sliver_urn"] = myslice["sliver_urn"]
rval,response = do_method("cm", "DeleteSliver", params, version="2.0")
if rval:
Fatal("Could not delete sliver")
pass
print "Sliver has been deleted. Ticket for remaining time:"
ticket = response["value"]
print str(ticket);
#! /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 re
execfile( "test-common.py" )
if len(REQARGS) > 1:
Usage()
sys.exit( 1 )
elif len(REQARGS) == 1:
CMURI = REQARGS[0]
if CMURI[-2:] == "cm":
CMURI = CMURI[:-3]
pass
pass
#
# Get a credential for myself, that allows me to do things at the SA.
#
mycredential = get_self_credential()
#
# Ask manager for its list.
#
params = {}
params["credentials"] = (mycredential,)
rval,response = do_method("cm", "DiscoverResources", params, version="2.0")
if rval:
Fatal("Could not get a list of resources")
pass
print response[ "value" ]
#! /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
import xmlrpclib
from M2Crypto import X509
execfile( "test-common.py" )
if not os.path.exists( PASSPHRASEFILE ):
Fatal( "No passphrase is currently stored." )
os.unlink( PASSPHRASEFILE )
<rspec xmlns="http://protogeni.net/resources/rspec/0.1">
<node virtual_id="geni1"
virtualization_type="emulab-vnode"
exclusive="1">
</node>
<needsfirewall>1</needsfirewall>
</rspec>
<!-- The namespace of an rspec determines its version. -->
<!-- type="request" - This is a request rspec for asking for resources. -->
<rspec xmlns="http://www.protogeni.net/resources/rspec/0.2" type="request">
<!-- rspecs contain a list of nodes and links which make up a topology. -->
<!-- virtual_id="client" - The virtual_id of a node is the name you come up with to refer to it. When talking about what nodes link to other nodes, the virtual_id uniquely refers to a node. -->
<!-- component_manager_id - This is the URN of the component manager you want this node to be allocated on. In this case, the Utah Emulab. -->
<!-- exclusive="1" - This says you want sole use of the resource and don't want to share the same physical hardware with other experimenters. -->
<!-- virtualization_type="emulab-vnode" - For now, all nodes should have this virtualization type. -->
<!-- virtualization_subtype="raw" - This says you want a whole physical PC rather than a virtual container. -->
<node virtual_id="client"
component_manager_uuid="urn:publicid:IDN+emulab.net+authority+cm"
exclusive="1"
virtualization_type="emulab-vnode"
virtualization_subtype="raw">
<!-- Interfaces are connected together by links. Declare interfaces inside the node declaration and refer to them in links. -->