271bf9ed8b06f0d79e2591b6a3d0237960008e4e
[sfa.git] / sfa / methods / ListSlices.py
1 from sfa.util.faults import *
2 from sfa.util.method import Method
3 from sfa.util.parameter import Parameter, Mixed
4 from sfa.trust.auth import Auth
5 from sfa.trust.credential import Credential
6  
7 class ListSlices(Method):
8     """
9     List the slices instantiated at this interface       
10
11     @param cred credential string specifying the rights of the caller
12     @return 1 is successful, faults otherwise  
13     """
14
15     interfaces = ['aggregate', 'slicemgr', 'component']
16     
17     accepts = [
18         Mixed(Parameter(str, "Credential string"),
19               Parameter(type([str]), "List of credentials")),
20         ]
21
22     returns = Parameter(list, "List of slice names")
23     
24     def call(self, creds):
25         valid_creds = self.api.auth.checkCredentials(creds, 'listslices')
26
27         #log the call
28         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
29         self.api.logger.info("interface: %s\tcaller-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, self.name))
30
31         manager = self.api.get_interface_manager() 
32         return manager.get_slices(self.api, creds)
33