registerslice.py 2.54 KB
Newer Older
1 2
#! /usr/bin/env python
#
3
# GENIPUBLIC-COPYRIGHT
4
# Copyright (c) 2008-2009 University of Utah and the Flux Group.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
# 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
25
from M2Crypto import X509
26

27 28
ACCEPTSLICENAME=1

29
execfile( "test-common.py" )
30 31 32 33

#
# Get a credential for myself, that allows me to do things at the SA.
#
34
mycredential = get_self_credential()
35 36 37 38 39 40 41 42
print "Got my SA credential"

#
# Lookup slice, delete before proceeding.
#
params = {}
params["credential"] = mycredential
params["type"]       = "Slice"
43
params["hrn"]        = SLICENAME
44 45
rval,response = do_method("sa", "Resolve", params)
if rval == 0:
Leigh B. Stoller's avatar
Leigh B. Stoller committed
46
    print "Deleting previously registered slice";
47 48 49
    params = {}
    params["credential"] = mycredential
    params["type"]       = "Slice"
50
    params["hrn"]        = SLICENAME
51 52 53 54 55 56 57 58 59
    rval,response = do_method("sa", "Remove", params)
    if rval:
        Fatal("Could not remove slice record")
        pass
    pass

#
# Create a slice. 
#
60
print "Creating new slice called " + SLICENAME
61 62 63
params = {}
params["credential"] = mycredential
params["type"]       = "Slice"
64
params["hrn"]        = SLICENAME
65 66 67
rval,response = do_method("sa", "Register", params)
if rval:
    Fatal("Could not get my slice")
68 69
    print str(rval)
    print str(response)
70 71 72
    pass
myslice = response["value"]
print "New slice created"
73
if debug: print str(myslice)
74

75 76 77 78 79 80 81 82 83 84 85 86 87
##
## 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 ..."
88
#
89 90 91 92 93 94 95 96 97 98 99 100
##
## 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"