1 from sfa.util.faults import *
2 from sfa.util.xrn import urn_to_hrn
3 from sfa.util.method import Method
4 from sfa.util.parameter import Parameter, Mixed
5 from sfa.trust.auth import Auth
6 from sfa.plc.slices import Slices
8 class reset_slice(Method):
10 Reset the specified slice
12 @param cred credential string specifying the rights of the caller
13 @param xrn human readable name of slice to instantiate (hrn or urn)
14 @return 1 is successful, faults otherwise
17 interfaces = ['aggregate', 'slicemgr', 'component']
20 Parameter(str, "Credential string"),
21 Parameter(str, "Human readable name of slice to instantiate (hrn or urn)"),
22 Mixed(Parameter(str, "Human readable name of the original caller"),
23 Parameter(None, "Origin hrn not specified"))
26 returns = Parameter(int, "1 if successful")
28 def call(self, cred, xrn, origin_hrn=None):
29 hrn, type = urn_to_hrn(xrn)
30 self.api.auth.check(cred, 'resetslice', hrn)
31 # send the call to the right manager
32 manager_base = 'sfa.managers'
33 if self.api.interface in ['component']:
34 mgr_type = self.api.config.SFA_CM_TYPE
35 manager_module = manager_base + ".component_manager_%s" % mgr_type
36 manager = __import__(manager_module, fromlist=[manager_base])
37 manager.reset_slice(self.api, xrn)
38 elif self.api.interface in ['aggregate']:
39 mgr_type = self.api.config.SFA_AGGREGATE_TYPE
40 manager_module = manager_base + ".aggregate_manager_%s" % mgr_type
41 manager = __import__(manager_module, fromlist=[manager_base])
42 manager.reset_slice(self.api, xrn)
43 elif self.api.interface in ['slicemgr']:
44 mgr_type = self.api.config.SFA_SM_TYPE
45 manager_module = manager_base + ".slice_manager_%s" % mgr_type
46 manager = __import__(manager_module, fromlist=[manager_base])
47 manager.reset_slice(self.api, xrn)