4 from sfa.util.faults import *
5 from sfa.util.namespace 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 class stop_slice(Method):
13 Stop the specified slice
15 @param cred credential string specifying the rights of the caller
16 @param xrn human readable name of slice to instantiate (hrn or urn)
17 @return 1 is successful, faults otherwise
20 interfaces = ['aggregate', 'slicemgr', 'component']
23 Parameter(str, "Credential string"),
24 Parameter(str, "Human readable name of slice to instantiate (hrn or urn)"),
25 Mixed(Parameter(str, "Human readable name of the original caller"),
26 Parameter(None, "Origin hrn not specified"))
29 returns = Parameter(int, "1 if successful")
31 def call(self, cred, xrn, origin_hrn=None):
32 hrn, type = urn_to_hrn(xrn)
33 user_cred = Credential(string=cred)
37 origin_hrn = user_cred.get_gid_caller().get_hrn()
38 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
41 self.api.auth.check(cred, 'stopslice')
43 # send the call to the right manager
44 manager_base = 'sfa.managers'
45 if self.api.interface in ['component']:
46 mgr_type = self.api.config.SFA_CM_TYPE
47 manager_module = manager_base + ".component_manager_%s" % mgr_type
48 manager = __import__(manager_module, fromlist=[manager_base])
49 manager.stop_slice(self.api, xrn)
50 elif self.api.interface in ['aggregate']:
51 mgr_type = self.api.config.SFA_AGGREGATE_TYPE
52 manager_module = manager_base + ".aggregate_manager_%s" % mgr_type
53 manager = __import__(manager_module, fromlist=[manager_base])
54 manager.stop_slice(self.api, xrn)
55 elif self.api.interface in ['slicemgr']:
56 mgr_type = self.api.config.SFA_SM_TYPE
57 manager_module = manager_base + ".slice_manager_%s" % mgr_type
58 manager = __import__(manager_module, fromlist=[manager_base])
59 manager.stop_slice(self.api, xrn)