0842c14aadea022e80023c2e542f08599e3ca189
[sfa.git] / sfa / methods / SliverStatus.py
1 from sfa.util.faults import *
2 from sfa.util.namespace import urn_to_hrn
3 from sfa.util.method import Method
4 from sfa.util.parameter import Parameter, Mixed
5
6 class SliverStatus(Method):
7     """
8     Get the status of a sliver
9     
10     @param slice_urn (string) URN of slice to allocate to
11     
12     """
13     interfaces = ['aggregate', 'slicemgr', 'component']
14     accepts = [
15         Parameter(str, "Slice URN"),
16         Mixed(Parameter(str, "Credential string"),
17               Parameter(type([str]), "List of credentials")),
18         ]
19     returns = Parameter(dict, "Status details")
20
21     def call(self, slice_xrn, creds):
22         hrn, type = urn_to_hrn(slice_xrn)
23         valid_creds = self.api.auth.checkCredentials(creds, 'sliverstatus', hrn)
24
25         self.api.logger.info("interface: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, hrn, self.name))
26     
27         manager = self.api.get_interface_manager()
28         status = manager.slice_status(self.api, hrn, valid_creds)
29
30         return status
31