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