3961ac8ddd6ff24d0bacf7cfae5aa150143c01d7
[sfa.git] / sfa / methods / get_slices.py
1 ### $Id$
2 ### $URL$
3
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
11
12 class get_slices(Method):
13     """
14     Get a list of instantiated slices at this authority.      
15
16     @param cred credential string specifying the rights of the caller
17     @return list of human readable slice names (hrn).  
18     """
19
20     interfaces = ['aggregate', 'slicemgr']
21     
22     accepts = [
23         Parameter(str, "Credential string"),
24         Mixed(Parameter(str, "Request hash"),
25               Parameter(None, "Request hash not specified")),
26         Parameter(str, "Callers credential string")
27         ]
28
29     returns = [Parameter(str, "Human readable slice name (hrn)")]
30     
31     def call(self, cred, request_hash=None, caller_cred=None):
32         import pdb
33         pdb.set_trace()
34         self.api.auth.authenticateCred(cred, [cred], request_hash) 
35         self.api.auth.check(cred, 'listslices')
36         if caller_cred==None:
37            caller_cred=cred
38         
39         #log the call
40         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))
41         slices = Slices(self.api)
42         slices.refresh()
43         return slices['hrn']