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
10 from sfa.trust.credential import Credential
12 class get_slices(Method):
14 Get a list of instantiated slices at this authority.
16 @param cred credential string specifying the rights of the caller
17 @return list of human readable slice names (hrn).
20 interfaces = ['aggregate', 'slicemgr', 'component']
23 Parameter(str, "Credential string"),
24 Mixed(Parameter(str, "Request hash"),
25 Parameter(None, "Request hash not specified")),
26 Parameter(str, "Callers credential string")
29 returns = [Parameter(str, "Human readable slice name (hrn)")]
31 def call(self, cred, request_hash=None):
32 self.api.auth.authenticateCred(cred, [cred], request_hash)
33 self.api.auth.check(cred, 'listslices')
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(), None, self.name))
42 # send the call to the right manager
43 manager_base = 'sfa.managers'
44 if self.api.interface in ['component']:
45 mgr_type = self.api.config.SFA_CM_TYPE
46 manager_module = manger_base + ".component_manager_%s" % mgr_type
47 manager = __import__(manager_module, manager_base)
48 slices = manager.get_slices(self.api)
49 elif self.api.interface in ['aggregate']:
50 mgr_type = self.api.config.SFA_AGGREGATE_TYPE
51 manager_module = manger_base + ".agregate_manager_%s" % mgr_type
52 manager = __import__(manager_module, manager_base)
53 slices = manager.get_slices(self.api)
54 elif self.api.interface in ['slicemngr']:
55 mgr_type = self.api.config.SFA_SM_TYPE
56 manager_module = manger_base + ".slice_manager_%s" % mgr_type
57 manager = __import__(manager_module, manager_base)
58 slices = manager.get_slices(self.api)