group db-related stuff in sfa/storage
[sfa.git] / sfa / methods / SliverStatus.py
1 from sfa.util.xrn import urn_to_hrn
2 from sfa.util.method import Method
3
4 from sfa.storage.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         Parameter(dict, "Options")
19         ]
20     returns = Parameter(dict, "Status details")
21
22     def call(self, slice_xrn, creds, options={}):
23         hrn, type = urn_to_hrn(slice_xrn)
24         valid_creds = self.api.auth.checkCredentials(creds, 'sliverstatus', hrn)
25
26         self.api.logger.info("interface: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, hrn, self.name))
27     
28         status = self.api.manager.SliverStatus(self.api, hrn, valid_creds, options)
29
30         return status
31