def create_sliver (self, slice_urn, slice_hrn, creds, rspec_string, users, options): aggregate = NitosAggregate(self) slices = NitosSlices(self) sfa_peer = slices.get_sfa_peer(slice_hrn) slice_record=None if users: slice_record = users[0].get('slice_record', {}) # parse rspec rspec = RSpec(rspec_string, version='NITOS 1') # ensure slice record exists slice = slices.verify_slice(slice_hrn, slice_record, sfa_peer, options=options) # ensure user records exists users = slices.verify_users(slice_hrn, slice, users, sfa_peer, options=options) # add/remove leases (nodes and channels) # a lease in Nitos RSpec case is a reservation of nodes and channels grouped by (slice,timeslot) rspec_requested_nodes, rspec_requested_channels = rspec.version.get_leases() nodes = slices.verify_slice_leases_nodes(slice, rspec_requested_nodes) channels = slices.verify_slice_leases_channels(slice, rspec_requested_channels) return aggregate.get_rspec(slice_xrn=slice_urn, version=rspec.version)
def list_resources(self, slice_urn, slice_hrn, creds, options): cached_requested = options.get('cached', True) version_manager = VersionManager() # get the rspec's return format from options #rspec_version = version_manager.get_version(options.get('geni_rspec_version')) # rspec's return format for nitos aggregate is version NITOS 1 rspec_version = version_manager.get_version('NITOS 1') version_string = "rspec_%s" % (rspec_version) #panos adding the info option to the caching key (can be improved) if options.get('info'): version_string = version_string + "_" + options.get( 'info', 'default') # Adding the list_leases option to the caching key if options.get('list_leases'): version_string = version_string + "_" + options.get( 'list_leases', 'default') # Adding geni_available to caching key if options.get('geni_available'): version_string = version_string + "_" + str( options.get('geni_available')) # look in cache first if cached_requested and self.cache and not slice_hrn: rspec = self.cache.get(version_string) if rspec: logger.debug( "NitosDriver.ListResources: returning cached advertisement" ) return rspec #panos: passing user-defined options #print "manager options = ",options aggregate = NitosAggregate(self) rspec = aggregate.get_rspec(slice_xrn=slice_urn, version=rspec_version, options=options) # cache the result if self.cache and not slice_hrn: logger.debug( "NitosDriver.ListResources: stores advertisement in cache") self.cache.add(version_string, rspec) return rspec
def create_sliver(self, slice_urn, slice_hrn, creds, rspec_string, users, options): aggregate = NitosAggregate(self) slices = NitosSlices(self) sfa_peer = slices.get_sfa_peer(slice_hrn) slice_record = None if users: slice_record = users[0].get('slice_record', {}) # parse rspec rspec = RSpec(rspec_string, version='NITOS 1') # ensure slice record exists slice = slices.verify_slice(slice_hrn, slice_record, sfa_peer, options=options) # ensure user records exists users = slices.verify_users(slice_hrn, slice, users, sfa_peer, options=options) # add/remove leases (nodes and channels) # a lease in Nitos RSpec case is a reservation of nodes and channels grouped by (slice,timeslot) rspec_requested_leases = rspec.version.get_leases() rspec_requested_nodes = [] rspec_requested_channels = [] for lease in rspec_requested_leases: if lease['type'] == 'node': lease.pop('type', None) rspec_requested_nodes.append(lease) else: lease.pop('type', None) rspec_requested_channels.append(lease) nodes = slices.verify_slice_leases_nodes(slice, rspec_requested_nodes) channels = slices.verify_slice_leases_channels( slice, rspec_requested_channels) return aggregate.get_rspec(slice_xrn=slice_urn, version=rspec.version)
def list_resources (self, slice_urn, slice_hrn, creds, options): cached_requested = options.get('cached', True) version_manager = VersionManager() # get the rspec's return format from options #rspec_version = version_manager.get_version(options.get('geni_rspec_version')) # rspec's return format for nitos aggregate is version NITOS 1 rspec_version = version_manager.get_version('NITOS 1') version_string = "rspec_%s" % (rspec_version) #panos adding the info option to the caching key (can be improved) if options.get('info'): version_string = version_string + "_"+options.get('info', 'default') # Adding the list_leases option to the caching key if options.get('list_leases'): version_string = version_string + "_"+options.get('list_leases', 'default') # Adding geni_available to caching key if options.get('geni_available'): version_string = version_string + "_" + str(options.get('geni_available')) # look in cache first if cached_requested and self.cache and not slice_hrn: rspec = self.cache.get(version_string) if rspec: logger.debug("NitosDriver.ListResources: returning cached advertisement") return rspec #panos: passing user-defined options #print "manager options = ",options aggregate = NitosAggregate(self) rspec = aggregate.get_rspec(slice_xrn=slice_urn, version=rspec_version, options=options) # cache the result if self.cache and not slice_hrn: logger.debug("NitosDriver.ListResources: stores advertisement in cache") self.cache.add(version_string, rspec) return rspec