X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fplanetlab%2Fplslices.py;h=ec60f36e99d4eb2b5d7642c43963878028810689;hb=ad6e6a07af006740c39cfbf091f7514dc7f8e507;hp=16d9bc33f70222e3c845748567ea9171b88ebed9;hpb=ab323f56e4e20f8b210572274b09136c15050904;p=sfa.git diff --git a/sfa/planetlab/plslices.py b/sfa/planetlab/plslices.py index 16d9bc33..ec60f36e 100644 --- a/sfa/planetlab/plslices.py +++ b/sfa/planetlab/plslices.py @@ -180,7 +180,7 @@ class PlSlices: return leases - def verify_slice_nodes(self, slice, rspec_nodes, peer): + def verify_slice_nodes(self, slice_urn, slice, rspec_nodes, peer): slivers = {} for node in rspec_nodes: @@ -222,7 +222,8 @@ class PlSlices: sliver_hrn = '%s.%s-%s' % (self.driver.hrn, slice['slice_id'], node['node_id']) sliver_id = Xrn(sliver_hrn, type='sliver').urn record = SliverAllocation(sliver_id=sliver_id, client_id=client_id, - component_id=component_id, + component_id=component_id, + slice_urn = slice_urn, allocation_state='geni_allocated') record.sync() return resulting_nodes @@ -371,11 +372,12 @@ class PlSlices: return site - def verify_slice(self, slice_hrn, slice_record, peer, sfa_peer, options={}): + def verify_slice(self, slice_hrn, slice_record, peer, sfa_peer, expiration, options={}): slicename = hrn_to_pl_slicename(slice_hrn) parts = slicename.split("_") login_base = parts[0] slices = self.driver.shell.GetSlices([slicename]) + expires = int(datetime_to_epoch(utcparse(expiration))) if not slices: slice = {'name': slicename, 'url': 'No Url', @@ -385,18 +387,19 @@ class PlSlices: slice['node_ids'] = [] slice['person_ids'] = [] if peer and slice_record: - slice['peer_slice_id'] = slice_record.get('slice_id', None) + slice['peer_slice_id'] = slice_record.get('slice_id', None) + # set the expiration + self.driver.shell.UpdateSlice(slice['slice_id'], {'expires': expires}) else: slice = slices[0] if peer and slice_record: slice['peer_slice_id'] = slice_record.get('slice_id', None) # unbind from peer so we can modify if necessary. Will bind back later self.driver.shell.UnBindObjectFromPeer('slice', slice['slice_id'], peer['shortname']) - #Update existing record (e.g. expires field) it with the latest info. - if slice_record and slice_record.get('expires'): - requested_expires = int(datetime_to_epoch(utcparse(slice_record['expires']))) - if requested_expires and slice['expires'] != requested_expires: - self.driver.shell.UpdateSlice( slice['slice_id'], {'expires' : requested_expires}) + + #Update expiration if necessary + if slice['expires'] != expires: + self.driver.shell.UpdateSlice( slice['slice_id'], {'expires' : expires}) return slice