236d34f93b60b801114f8d9ac3595789809f9954
[sfa.git] / sfa / methods / ListSlices.py
1 ### $Id: stop_slice.py 17732 2010-04-19 21:10:45Z tmack $
2 ### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/methods/stop_slice.py $
3
4 from sfa.util.faults import *
5 from sfa.util.namespace 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.trust.credential import Credential
10  
11 class ListSlices(Method):
12     """
13     List the slices instantiated at this interface       
14
15     @param cred credential string specifying the rights of the caller
16     @return 1 is successful, faults otherwise  
17     """
18
19     interfaces = ['aggregate', 'slicemgr', 'component']
20     
21     accepts = [
22         Mixed(Parameter(str, "Credential string"),
23               Parameter(type([str]), "List of credentials")),
24         ]
25
26     returns = Parameter(list, "List of slice names")
27     
28     def call(self, creds):
29         valid_creds = self.api.auth.checkCredentials(creds, 'listslices')
30
31         #log the call
32         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
33         self.api.logger.info("interface: %s\tcaller-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, self.name))
34
35         manager = self.api.get_interface_manager() 
36         return manager.get_slices(self.api, creds)
37