X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fplanetlab%2Fplslices.py;h=ec60f36e99d4eb2b5d7642c43963878028810689;hb=ad6e6a07af006740c39cfbf091f7514dc7f8e507;hp=0ee4fdad31b4d4d14368fa267b66a852053129a1;hpb=de06f1f7eb8480a7894ed6a1aa8665f032365892;p=sfa.git diff --git a/sfa/planetlab/plslices.py b/sfa/planetlab/plslices.py index 0ee4fdad..ec60f36e 100644 --- a/sfa/planetlab/plslices.py +++ b/sfa/planetlab/plslices.py @@ -180,18 +180,19 @@ 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: - hostname = None - client_id = node.get('client_id') - if node.get('component_name'): - hostname = node.get('component_name').strip() - elif node.get('component_id'): - hostname = xrn_to_hostname(node.get('component_id').strip()) + hostname = node.get('component_name') + client_id = node.get('client_id') + component_id = node.get('component_id').strip() if hostname: - slivers[hostname] = client_id + hostname = hostname.strip() + elif component_id: + hostname = xrn_to_hostname(component_id) + if hostname: + slivers[hostname] = {'client_id': client_id, 'component_id': component_id} nodes = self.driver.shell.GetNodes(slice['node_ids'], ['node_id', 'hostname', 'interface_ids']) current_slivers = [node['hostname'] for node in nodes] @@ -216,11 +217,14 @@ class PlSlices: # update sliver allocations for node in resulting_nodes: - client_id = slivers[node['hostname']] - logger.info(client_id) + client_id = slivers[node['hostname']]['client_id'] + component_id = slivers[node['hostname']]['component_id'] 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, allocation_state='geni_allocated') + record = SliverAllocation(sliver_id=sliver_id, client_id=client_id, + component_id=component_id, + slice_urn = slice_urn, + allocation_state='geni_allocated') record.sync() return resulting_nodes @@ -368,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', @@ -382,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