2 from sfa.util.version import version_core
3 from sfa.util.xrn import Xrn
4 from sfa.util.callids import Callids
5 from sfa.server.api_versions import ApiVersions
7 class AggregateManager:
9 def __init__ (self, config): pass
11 # essentially a union of the core version, the generic version (this code) and
12 # whatever the driver needs to expose
13 def GetVersion(self, api, options):
15 version = version_core()
16 geni_api_versions = ApiVersions().get_versions()
17 geni_api_versions['2'] = 'http://%s:%s' % (api.config.SFA_AGGREGATE_HOST, api.config.SFA_AGGREGATE_PORT)
19 'interface':'aggregate',
22 'geni_api_versions': geni_api_versions,
26 version.update(version_generic)
27 testbed_version = self.driver.aggregate_version()
28 version.update(testbed_version)
31 def ListSlices(self, api, creds, options):
32 call_id = options.get('call_id')
33 if Callids().already_handled(call_id): return []
34 return self.driver.list_slices (creds, options)
36 def ListResources(self, api, creds, options):
37 call_id = options.get('call_id')
38 if Callids().already_handled(call_id): return ""
40 # get slice's hrn from options
41 slice_xrn = options.get('geni_slice_urn', None)
42 # pass None if no slice is specified
44 slice_hrn, slice_urn = None, None
47 slice_urn=xrn.get_urn()
48 slice_hrn=xrn.get_hrn()
49 return self.driver.list_resources (slice_urn, slice_hrn, creds, options)
51 def SliverStatus (self, api, xrn, creds, options):
52 call_id = options.get('call_id')
53 if Callids().already_handled(call_id): return {}
55 xrn = Xrn(xrn,'slice')
56 slice_urn=xrn.get_urn()
57 slice_hrn=xrn.get_hrn()
58 return self.driver.sliver_status (slice_urn, slice_hrn)
60 def CreateSliver(self, api, xrn, creds, rspec_string, users, options):
62 Create the sliver[s] (slice) at this aggregate.
63 Verify HRN and initialize the slice record in PLC if necessary.
65 call_id = options.get('call_id')
66 if Callids().already_handled(call_id): return ""
68 xrn = Xrn(xrn, 'slice')
69 slice_urn=xrn.get_urn()
70 slice_hrn=xrn.get_hrn()
72 return self.driver.create_sliver (slice_urn, slice_hrn, creds, rspec_string, users, options)
74 def DeleteSliver(self, api, xrn, creds, options):
75 call_id = options.get('call_id')
76 if Callids().already_handled(call_id): return True
78 xrn = Xrn(xrn, 'slice')
79 slice_urn=xrn.get_urn()
80 slice_hrn=xrn.get_hrn()
81 return self.driver.delete_sliver (slice_urn, slice_hrn, creds, options)
83 def RenewSliver(self, api, xrn, creds, expiration_time, options):
84 call_id = options.get('call_id')
85 if Callids().already_handled(call_id): return True
87 xrn = Xrn(xrn, 'slice')
88 slice_urn=xrn.get_urn()
89 slice_hrn=xrn.get_hrn()
90 return self.driver.renew_sliver (slice_urn, slice_hrn, creds, expiration_time, options)
92 ### these methods could use an options extension for at least call_id
93 def start_slice(self, api, xrn, creds):
95 slice_urn=xrn.get_urn()
96 slice_hrn=xrn.get_hrn()
97 return self.driver.start_slice (slice_urn, slice_hrn, creds)
99 def stop_slice(self, api, xrn, creds):
101 slice_urn=xrn.get_urn()
102 slice_hrn=xrn.get_hrn()
103 return self.driver.stop_slice (slice_urn, slice_hrn, creds)
105 def reset_slice(self, api, xrn):
107 slice_urn=xrn.get_urn()
108 slice_hrn=xrn.get_hrn()
109 return self.driver.reset_slice (slice_urn, slice_hrn)
111 def GetTicket(self, api, xrn, creds, rspec, users, options):
114 slice_urn=xrn.get_urn()
115 slice_hrn=xrn.get_hrn()
117 # xxx sounds like GetTicket is dead, but if that gets resurrected we might wish
118 # to pass 'users' over to the driver as well
119 return self.driver.get_ticket (slice_urn, slice_hrn, creds, rspec, options)