deletesliver.py 2.31 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#! /usr/bin/env python
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004, 2008 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
25
from M2Crypto import X509
26

27
execfile( "test-common.py" )
28 29 30 31 32 33 34 35 36 37 38

#
# 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"]
Leigh B. Stoller's avatar
Leigh B. Stoller committed
39
print "Got my SA credential. Looking for slice ..."
40 41 42 43 44 45 46 47
#print str(mycredential);

#
# Lookup slice, delete before proceeding.
#
params = {}
params["credential"] = mycredential
params["type"]       = "Slice"
Leigh B. Stoller's avatar
Leigh B. Stoller committed
48
params["hrn"]        = "mytestslice"
49 50
rval,response = do_method("sa", "Resolve", params)
if rval:
Leigh B. Stoller's avatar
Leigh B. Stoller committed
51
    Fatal("Slice does not exist")
52 53
    pass
myslice = response["value"]
Leigh B. Stoller's avatar
Leigh B. Stoller committed
54 55
myuuid  = myslice["uuid"]
print "Found the slice, asking for a credential ..."
56 57

#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
58
# Get the slice credential.
59 60
#
params = {}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
61 62 63 64
params["credential"] = mycredential
params["type"]       = "Slice"
params["uuid"]       = myuuid
rval,response = do_method("sa", "GetCredential", params)
65
if rval:
Leigh B. Stoller's avatar
Leigh B. Stoller committed
66
    Fatal("Could not get Slice credential")
67
    pass
Leigh B. Stoller's avatar
Leigh B. Stoller committed
68 69
slicecred = response["value"]
print "Got the slice credential, asking for a sliver credential ..."
70 71

#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
72
# Get the sliver credential.
73 74
#
params = {}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
75 76
params["credential"] = slicecred
rval,response = do_method("cm", "GetSliver", params)
77
if rval:
Leigh B. Stoller's avatar
Leigh B. Stoller committed
78
    Fatal("Could not get Sliver credential")
79
    pass
Leigh B. Stoller's avatar
Leigh B. Stoller committed
80 81
slivercred = response["value"]
print "Got the sliver credential, deleting the sliver";
82 83 84 85 86

#
# Delete the sliver.
#
params = {}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
87 88
params["credential"] = slivercred
rval,response = do_method("cm", "DeleteSliver", params)
89
if rval:
Leigh B. Stoller's avatar
Leigh B. Stoller committed
90
    Fatal("Could not delete sliver")
91
    pass
Leigh B. Stoller's avatar
Leigh B. Stoller committed
92 93
print "Sliver has been deleted."

94