group db-related stuff in sfa/storage
[sfa.git] / sfa / methods / ListSlices.py
1 from sfa.util.method import Method
2
3 from sfa.trust.credential import Credential
4  
5 from sfa.storage.parameter import Parameter, Mixed
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         Parameter(dict, "options"),
21         ]
22
23     returns = Parameter(list, "List of slice names")
24     
25     def call(self, creds, options={}):
26         valid_creds = self.api.auth.checkCredentials(creds, 'listslices')
27
28         #log the call
29         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
30         self.api.logger.info("interface: %s\tcaller-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, self.name))
31
32         return self.api.manager.ListSlices(self.api, creds, options)
33