6b9009648b8fcec5406a5178dc0203851c30d544
[sfa.git] / sfa / methods / SliverStatus.py
1 from sfa.util.faults import *
2 from sfa.util.namespace import *
3 from sfa.util.method import Method
4 from sfa.util.parameter import Parameter
5 from sfa.server.aggregate import Aggregates
6
7 class SliverStatus(Method):
8     """
9     Get the status of a sliver
10     
11     @param slice_urn (string) URN of slice to allocate to
12     
13     """
14     interfaces = ['geni_am']
15     accepts = [
16         Parameter(str, "Slice URN"),
17         ]
18     returns = Parameter(bool, "Success or Failure")
19
20     def call(self, slice_xrn, creds):
21         hrn, type = urn_to_hrn(slice_xrn)
22         
23         # Make sure that this is a geni_aggregate talking to us
24         geni_aggs = Aggregates(self.api, '/etc/sfa/geni_aggregates.xml')
25         if not hrn in [agg['hrn'] for agg in geni_aggs]:
26             raise SfaPermissionDenied("Only GENI Aggregates may make this call")
27
28         self.api.logger.info("interface: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, hrn, self.name))
29
30         manager_base = 'sfa.managers'
31
32         if self.api.interface in ['geni_am']:
33             mgr_type = self.api.config.SFA_GENI_AGGREGATE_TYPE
34             manager_module = manager_base + ".geni_am_%s" % mgr_type
35             manager = __import__(manager_module, fromlist=[manager_base])
36             return manager.SliverStatus(self.api, slice_xrn)
37
38         return ''
39