3 from sfa.util.version import version_core
4 from sfa.util.xrn import Xrni
5 from sfa.util.sfatime import utcpase, adjust_datetime
6 from sfa.util.callids import Callids
7 from sfa.server.api_versions import ApiVersions
9 class AggregateManager:
11 def __init__ (self, config): pass
13 # essentially a union of the core version, the generic version (this code) and
14 # whatever the driver needs to expose
15 def GetVersion(self, api, options):
16 xrn=Xrn(api.hrn, type='authority+am')
17 version = version_core()
18 geni_api_versions = ApiVersions().get_versions()
19 geni_api_versions['2'] = 'http://%s:%s' % (api.config.SFA_AGGREGATE_HOST, api.config.SFA_AGGREGATE_PORT)
21 'interface':'aggregate',
24 'geni_api_versions': geni_api_versions,
28 version.update(version_generic)
29 testbed_version = self.driver.aggregate_version()
30 version.update(testbed_version)
33 def ListSlices(self, api, creds, options):
34 call_id = options.get('call_id')
35 if Callids().already_handled(call_id): return []
36 return self.driver.list_slices (creds, options)
38 def ListResources(self, api, creds, options):
39 call_id = options.get('call_id')
40 if Callids().already_handled(call_id): return ""
42 # get slice's hrn from options
43 slice_xrn = options.get('geni_slice_urn', None)
44 # pass None if no slice is specified
46 slice_hrn, slice_urn = None, None
49 slice_urn=xrn.get_urn()
50 slice_hrn=xrn.get_hrn()
51 return self.driver.list_resources (slice_urn, slice_hrn, creds, options)
53 def SliverStatus (self, api, xrn, creds, options):
54 call_id = options.get('call_id')
55 if Callids().already_handled(call_id): return {}
57 xrn = Xrn(xrn,'slice')
58 slice_urn=xrn.get_urn()
59 slice_hrn=xrn.get_hrn()
60 return self.driver.sliver_status (slice_urn, slice_hrn)
62 def CreateSliver(self, api, xrn, creds, rspec_string, users, options):
64 Create the sliver[s] (slice) at this aggregate.
65 Verify HRN and initialize the slice record in PLC if necessary.
67 call_id = options.get('call_id')
68 if Callids().already_handled(call_id): return ""
70 xrn = Xrn(xrn, 'slice')
71 slice_urn=xrn.get_urn()
72 slice_hrn=xrn.get_hrn()
74 return self.driver.create_sliver (slice_urn, slice_hrn, creds, rspec_string, users, options)
76 def DeleteSliver(self, api, xrn, creds, options):
77 call_id = options.get('call_id')
78 if Callids().already_handled(call_id): return True
80 xrn = Xrn(xrn, 'slice')
81 slice_urn=xrn.get_urn()
82 slice_hrn=xrn.get_hrn()
83 return self.driver.delete_sliver (slice_urn, slice_hrn, creds, options)
85 def RenewSliver(self, api, xrn, creds, expiration_time, options):
86 call_id = options.get('call_id')
87 if Callids().already_handled(call_id): return True
89 xrn = Xrn(xrn, 'slice')
90 slice_urn=xrn.get_urn()
91 slice_hrn=xrn.get_hrn()
93 if options.get('geni_extend_alap'):
94 now = datetime.datetime.now()
95 requested = utcparse(expiration_time)
96 max = adjust_datetime(now, days=30)
100 return self.driver.renew_sliver (slice_urn, slice_hrn, creds, expiration_time, options)
102 ### these methods could use an options extension for at least call_id
103 def start_slice(self, api, xrn, creds):
105 slice_urn=xrn.get_urn()
106 slice_hrn=xrn.get_hrn()
107 return self.driver.start_slice (slice_urn, slice_hrn, creds)
109 def stop_slice(self, api, xrn, creds):
111 slice_urn=xrn.get_urn()
112 slice_hrn=xrn.get_hrn()
113 return self.driver.stop_slice (slice_urn, slice_hrn, creds)
115 def reset_slice(self, api, xrn):
117 slice_urn=xrn.get_urn()
118 slice_hrn=xrn.get_hrn()
119 return self.driver.reset_slice (slice_urn, slice_hrn)
121 def GetTicket(self, api, xrn, creds, rspec, users, options):
124 slice_urn=xrn.get_urn()
125 slice_hrn=xrn.get_hrn()
127 # xxx sounds like GetTicket is dead, but if that gets resurrected we might wish
128 # to pass 'users' over to the driver as well
129 return self.driver.get_ticket (slice_urn, slice_hrn, creds, rspec, options)