4 from sfa.util.faults import *
5 from sfa.util.misc import *
6 from sfa.util.method import Method
7 from sfa.util.parameter import Parameter, Mixed
8 from sfa.trust.auth import Auth
9 from sfa.trust.credential import Credential
11 from sfa.plc.slices import Slices
13 class delete_slice(Method):
15 Remove the slice from all nodes.
17 @param cred credential string specifying the rights of the caller
18 @param hrn human readable name specifying the slice to delete
19 @return 1 if successful, faults otherwise
22 interfaces = ['aggregate', 'slicemgr']
25 Parameter(str, "Credential string"),
26 Parameter(str, "Human readable name of slice to delete"),
27 Mixed(Parameter(str, "Request hash"),
28 Parameter(None, "Request hash not specified"))
31 returns = Parameter(int, "1 if successful")
33 def call(self, cred, hrn, request_hash=None, caller_cred=None):
38 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, Credential(string=caller_cred).get_gid_caller().get_hrn(), hrn, self.name))
40 # This cred will be an slice cred, not a user, so we cant use it to
41 # authenticate the caller's request_hash. Let just get the caller's gid
42 # from the cred and authenticate using that
43 client_gid = Credential(string=cred).get_gid_caller()
44 client_gid_str = client_gid.save_to_string(save_parents=True)
45 self.api.auth.authenticateGid(client_gid_str, [cred, hrn], request_hash)
46 self.api.auth.check(cred, 'deleteslice')
47 slices = Slices(self.api, caller_cred=caller_cred)
48 slices.delete_slice(hrn)