2 from sfa.rspecs.version_manager import VersionManager
3 from sfa.util.version import version_core
4 from sfa.util.xrn import Xrn
5 from sfa.util.callids import Callids
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
14 def _rspec_versions(self):
15 version_manager = VersionManager()
16 ad_rspec_versions = []
17 request_rspec_versions = []
18 for rspec_version in version_manager.versions:
19 if rspec_version.content_type in ['*', 'ad']:
20 ad_rspec_versions.append(rspec_version.to_dict())
21 if rspec_version.content_type in ['*', 'request']:
22 request_rspec_versions.append(rspec_version.to_dict())
24 'testbed':self.testbed_name(),
25 'geni_request_rspec_versions': request_rspec_versions,
26 'geni_ad_rspec_versions': ad_rspec_versions,
29 def GetVersion(self, api, options):
31 version = version_core()
33 'testbed': self.driver.testbed_name(),
34 'interface':'aggregate',
38 'geni_api_versions': {'3': 'http://%s:%s' % (socket.gethostname(), api.config.sfa_aggregate_port)},
39 'geni_single_allocation': 0, # Accept operations that act on as subset of slivers in a given state.
40 'geni_allocate': 'geni_many',# Multiple slivers can exist and be incrementally added, including those which connect or overlap in some way.
41 'geni_best_effort': 'true',
42 'geni_credential_types': [{
43 'geni_type': 'geni_sfa',
47 version.update(version_generic)
48 testbed_version = self.driver.aggregate_version()
49 version.update(testbed_version)
52 def ListSlices(self, api, creds, options):
53 call_id = options.get('call_id')
54 if Callids().already_handled(call_id): return []
55 return self.driver.list_slices (creds, options)
57 def ListResources(self, api, creds, options):
58 call_id = options.get('call_id')
59 if Callids().already_handled(call_id): return ""
61 # get slice's hrn from options
62 slice_xrn = options.get('geni_slice_urn', None)
63 # pass None if no slice is specified
65 slice_hrn, slice_urn = None, None
68 slice_urn=xrn.get_urn()
69 slice_hrn=xrn.get_hrn()
70 return self.driver.list_resources (slice_urn, slice_hrn, creds, options)
72 def SliverStatus (self, api, xrn, creds, options):
73 call_id = options.get('call_id')
74 if Callids().already_handled(call_id): return {}
76 xrn = Xrn(xrn,'slice')
77 slice_urn=xrn.get_urn()
78 slice_hrn=xrn.get_hrn()
79 return self.driver.sliver_status (slice_urn, slice_hrn)
81 def CreateSliver(self, api, xrn, creds, rspec_string, users, options):
83 Create the sliver[s] (slice) at this aggregate.
84 Verify HRN and initialize the slice record in PLC if necessary.
86 call_id = options.get('call_id')
87 if Callids().already_handled(call_id): return ""
89 xrn = Xrn(xrn, 'slice')
90 slice_urn=xrn.get_urn()
91 slice_hrn=xrn.get_hrn()
93 return self.driver.create_sliver (slice_urn, slice_hrn, creds, rspec_string, users, options)
95 def DeleteSliver(self, api, xrn, creds, options):
96 call_id = options.get('call_id')
97 if Callids().already_handled(call_id): return True
99 xrn = Xrn(xrn, 'slice')
100 slice_urn=xrn.get_urn()
101 slice_hrn=xrn.get_hrn()
102 return self.driver.delete_sliver (slice_urn, slice_hrn, creds, options)
104 def RenewSliver(self, api, xrn, creds, expiration_time, options):
105 call_id = options.get('call_id')
106 if Callids().already_handled(call_id): return True
108 xrn = Xrn(xrn, 'slice')
109 slice_urn=xrn.get_urn()
110 slice_hrn=xrn.get_hrn()
111 return self.driver.renew_sliver (slice_urn, slice_hrn, creds, expiration_time, options)
113 ### these methods could use an options extension for at least call_id
114 def start_slice(self, api, xrn, creds):
116 slice_urn=xrn.get_urn()
117 slice_hrn=xrn.get_hrn()
118 return self.driver.start_slice (slice_urn, slice_hrn, creds)
120 def stop_slice(self, api, xrn, creds):
122 slice_urn=xrn.get_urn()
123 slice_hrn=xrn.get_hrn()
124 return self.driver.stop_slice (slice_urn, slice_hrn, creds)
126 def reset_slice(self, api, xrn):
128 slice_urn=xrn.get_urn()
129 slice_hrn=xrn.get_hrn()
130 return self.driver.reset_slice (slice_urn, slice_hrn)
132 def GetTicket(self, api, xrn, creds, rspec, users, options):
135 slice_urn=xrn.get_urn()
136 slice_hrn=xrn.get_hrn()
138 return self.driver.get_ticket (slice_urn, slice_hrn, creds, rspec, options)