From: Sandrine Avakian Date: Wed, 8 Aug 2012 14:31:47 +0000 (+0200) Subject: Fixes to comply with the new return format of Getslices X-Git-Tag: sfa-2.1-24~3^2~101 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=354b3d2a3cdee55528f5d156d4ed2615efb916eb;p=sfa.git Fixes to comply with the new return format of Getslices (now returning a list). --- diff --git a/sfa/senslab/slabaggregate.py b/sfa/senslab/slabaggregate.py index 40df86e0..895c287b 100644 --- a/sfa/senslab/slabaggregate.py +++ b/sfa/senslab/slabaggregate.py @@ -68,27 +68,28 @@ class SlabAggregate: %(slices)) if not slices: return (sfa_slice, slivers) - if isinstance(sfa_slice, list): - sfa_slice = slices[0] - else: - sfa_slice = slices + #if isinstance(sfa_slice, list): + #sfa_slice = slices[0] + #else: + #sfa_slice = slices # sort slivers by node id , if there is a job #and therfore, node allocated to this slice - if sfa_slice['oar_job_id'] is not -1: - try: - - for node_id in sfa_slice['node_ids']: - #node_id = self.driver.root_auth + '.' + node_id - sliver = Sliver({'sliver_id': urn_to_sliver_id(slice_urn, \ - sfa_slice['record_id_slice'], node_id), - 'name': sfa_slice['slice_hrn'], - 'type': 'slab-node', - 'tags': []}) - slivers[node_id] = sliver - except KeyError: - logger.log_exc("SLABAGGREGATE \t \ - get_slice_and_slivers KeyError ") + for sfa_slice in slices: + if sfa_slice['oar_job_id'] is not -1: + try: + + for node_id in sfa_slice['node_ids']: + #node_id = self.driver.root_auth + '.' + node_id + sliver = Sliver({'sliver_id': urn_to_sliver_id(slice_urn, \ + sfa_slice['record_id_slice'], node_id), + 'name': sfa_slice['slice_hrn'], + 'type': 'slab-node', + 'tags': []}) + slivers[node_id] = sliver + except KeyError: + logger.log_exc("SLABAGGREGATE \t \ + get_slice_and_slivers KeyError ") ## sort sliver attributes by node id ##tags = self.driver.GetSliceTags({'slice_tag_id': slice['slice_tag_ids']}) ##for tag in tags: diff --git a/sfa/senslab/slabdriver.py b/sfa/senslab/slabdriver.py index 4ca3d4b8..444f1584 100644 --- a/sfa/senslab/slabdriver.py +++ b/sfa/senslab/slabdriver.py @@ -808,14 +808,15 @@ class SlabDriver(Driver): #the slice record rslt = self.GetJobsResources(slicerec_dict['oar_job_id'], \ username = login) - + logger.debug("SLABDRIVER.PY \tGetSlices rslt fromn GetJobsResources %s"\ + %(rslt)) if rslt : slicerec_dict.update(rslt) slicerec_dict.update({'hrn':\ str(slicerec_dict['slice_hrn'])}) - #If GetJobsResources is empty, this means the job is - #now in the 'Terminated' state - #Update the slice record + #If GetJobsResources is empty, this means the job is + #now in the 'Terminated' state + #Update the slice record else : self.db.update_job(slice_filter, job_id = -1) slicerec_dict['oar_job_id'] = -1 diff --git a/sfa/senslab/slabslices.py b/sfa/senslab/slabslices.py index ec6d072a..c45a6a41 100644 --- a/sfa/senslab/slabslices.py +++ b/sfa/senslab/slabslices.py @@ -331,27 +331,28 @@ class SlabSlices: #login_base = slice_hrn.split(".")[0] slicename = slice_hrn - sl = self.driver.GetSlices(slice_filter = slicename, \ + slices_list = self.driver.GetSlices(slice_filter = slicename, \ slice_filter_type = 'slice_hrn') - if sl: - - logger.debug("SLABSLICE \tverify_slice slicename %s sl %s \ - slice_record %s"%(slicename, sl, slice_record)) - sfa_slice = sl - sfa_slice.update(slice_record) - #del slice['last_updated'] - #del slice['date_created'] - #if peer: - #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.UnBindObjectFromPeer('slice', slice['slice_id'], \ - #peer['shortname']) - #Update existing record (e.g. expires field) - #it with the latest info. - ##if slice_record and slice['expires'] != slice_record['expires']: - ##self.driver.UpdateSlice( slice['slice_id'], {'expires' : \ - #slice_record['expires']}) + if slices_list: + for sl in slices_list: + + logger.debug("SLABSLICE \tverify_slice slicename %s sl %s \ + slice_record %s"%(slicename, sl, slice_record)) + sfa_slice = sl + sfa_slice.update(slice_record) + #del slice['last_updated'] + #del slice['date_created'] + #if peer: + #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.UnBindObjectFromPeer('slice', slice['slice_id'], \ + #peer['shortname']) + #Update existing record (e.g. expires field) + #it with the latest info. + ##if slice_record and slice['expires'] != slice_record['expires']: + ##self.driver.UpdateSlice( slice['slice_id'], {'expires' : \ + #slice_record['expires']}) else: logger.debug(" SLABSLICES \tverify_slice Oups \ slice_record %s peer %s sfa_peer %s "\