last plc-dependent code moved to PlDriver
[sfa.git] / sfa / managers / aggregate_manager.py
1 from sfa.util.version import version_core
2 from sfa.util.xrn import Xrn
3 from sfa.util.callids import Callids
4
5 class AggregateManager:
6
7     def __init__ (self, config): pass
8     
9     # essentially a union of the core version, the generic version (this code) and
10     # whatever the driver needs to expose
11     def GetVersion(self, api, options):
12     
13         xrn=Xrn(api.hrn)
14         version = version_core()
15         version_generic = {'interface':'aggregate',
16                            'sfa': 2,
17                            'geni_api': 2,
18                            'hrn':xrn.get_hrn(),
19                            'urn':xrn.get_urn(),
20                            }
21         version.update(version_generic)
22         testbed_version = self.driver.aggregate_version()
23         version.update(testbed_version)
24         return version
25     
26     def ListSlices(self, api, creds, options):
27         call_id = options.get('call_id')
28         if Callids().already_handled(call_id): return []
29         return self.driver.list_slices (creds, options)
30
31     def ListResources(self, api, creds, options):
32         call_id = options.get('call_id')
33         if Callids().already_handled(call_id): return ""
34
35         # get slice's hrn from options
36         slice_xrn = options.get('geni_slice_urn', None)
37         # pass None if no slice is specified
38         if not slice_xrn:
39             slice_hrn, slice_urn = None, None
40         else:
41             xrn = Xrn(slice_xrn)
42             slice_urn=xrn.get_urn()
43             slice_hrn=xrn.get_hrn()
44
45         return self.driver.list_resources (slice_urn, slice_hrn, creds, options)
46     
47     def SliverStatus (self, api, xrn, creds, options):
48         call_id = options.get('call_id')
49         if Callids().already_handled(call_id): return {}
50     
51         xrn = Xrn(xrn)
52         slice_urn=xrn.get_urn()
53         slice_hrn=xrn.get_hrn()
54         return self.driver.sliver_status (slice_urn, slice_hrn)
55     
56     def CreateSliver(self, api, xrn, creds, rspec_string, users, options):
57         """
58         Create the sliver[s] (slice) at this aggregate.    
59         Verify HRN and initialize the slice record in PLC if necessary.
60         """
61         call_id = options.get('call_id')
62         if Callids().already_handled(call_id): return ""
63     
64         xrn = Xrn(xrn)
65         slice_urn=xrn.get_urn()
66         slice_hrn=xrn.get_hrn()
67
68         return self.driver.create_sliver (slice_urn, slice_hrn, creds, rspec_string, users, options)
69     
70     def DeleteSliver(self, api, xrn, creds, options):
71         call_id = options.get('call_id')
72         if Callids().already_handled(call_id): return True
73
74         xrn = Xrn(xrn)
75         slice_urn=xrn.get_urn()
76         slice_hrn=xrn.get_hrn()
77         return self.driver.delete_sliver (slice_urn, slice_hrn, creds, options)
78
79     def RenewSliver(self, api, xrn, creds, expiration_time, options):
80         call_id = options.get('call_id')
81         if Callids().already_handled(call_id): return True
82         
83         xrn = Xrn(xrn)
84         slice_urn=xrn.get_urn()
85         slice_hrn=xrn.get_hrn()
86         return self.driver.renew_sliver (slice_urn, slice_hrn, creds, expiration_time, options)
87     
88     ### these methods could use an options extension for at least call_id
89     def start_slice(self, api, xrn, creds):
90         xrn = Xrn(xrn)
91         slice_urn=xrn.get_urn()
92         slice_hrn=xrn.get_hrn()
93         return self.driver.start_slice (slice_urn, slice_hrn, creds)
94      
95     def stop_slice(self, api, xrn, creds):
96         xrn = Xrn(xrn)
97         slice_urn=xrn.get_urn()
98         slice_hrn=xrn.get_hrn()
99         return self.driver.stop_slice (slice_urn, slice_hrn, creds)
100
101     def reset_slice(self, api, xrn):
102         xrn = Xrn(xrn)
103         slice_urn=xrn.get_urn()
104         slice_hrn=xrn.get_hrn()
105         return self.driver.reset_slice (slice_urn, slice_hrn)
106
107     def GetTicket(self, api, xrn, creds, rspec, users, options):
108     
109         xrn = Xrn(xrn)
110         slice_urn=xrn.get_urn()
111         slice_hrn=xrn.get_hrn()
112
113         return self.driver.get_ticket (slice_urn, slice_hrn, creds, rspec, options)
114