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