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.plc.slices import Slices
11 class start_slice(Method):
13 Start the specified slice
15 @param cred credential string specifying the rights of the caller
16 @param hrn human readable name of slice to instantiate
17 @return 1 is successful, faults otherwise
20 interfaces = ['aggregate', 'slicemgr', 'comonent']
23 Parameter(str, "Credential string"),
24 Parameter(str, "Human readable name of slice to instantiate"),
25 Mixed(Parameter(str, "Request hash"),
26 Parameter(None, "Request hash not specified"))
29 returns = [Parameter(int, "1 if successful")]
31 def call(self, cred, hrn, request_hash=None):
32 # This cred will be an slice cred, not a user, so we cant use it to
33 # authenticate the caller's request_hash. Let just get the caller's gid
34 # from the cred and authenticate using that
35 client_gid = Credential(string=cred).get_gid_caller()
36 client_gid_str = client_gid.save_to_string(save_parents=True)
37 self.api.auth.authenticateGid(client_gid_str, [cred, hrn], request_hash)
38 self.api.auth.check(cred, 'startslice')
40 # send the call to the right manager
41 manager_base = 'sfa.managers'
42 if self.api.interface in ['component']:
43 mgr_type = self.api.config.SFA_CM_TYPE
44 manager_module = manger_base+= ".component_manager_%s" % mgr_type
45 manager = __import__(manager_module, manager_base)
46 manager.start_slice(self.api, hrn)
47 elif self.api.interface in ['aggregate']:
48 mgr_type = self.api.config.SFA_AGGREGATE_TYPE
49 manager_module = manger_base+= ".agregate_manager_%s" % mgr_type
50 manager = __import__(manager_module, manager_base)
51 manager.start_slice(self.api, hrn)
52 elif self.api.interface in ['slicemngr']:
53 mgr_type = self.api.config.SFA_SM_TYPE
54 manager_module = manger_base+= ".slice_manager_%s" % mgr_type
55 manager = __import__(manager_module, manager_base)
56 manager.start_slice(self.api, hrn)