Fixes to comply with the new return format of Getslices
authorSandrine Avakian <sandrine.avakian@inria.fr>
Wed, 8 Aug 2012 14:31:47 +0000 (16:31 +0200)
committerSandrine Avakian <sandrine.avakian@inria.fr>
Wed, 8 Aug 2012 14:31:47 +0000 (16:31 +0200)
(now returning a list).

sfa/senslab/slabaggregate.py
sfa/senslab/slabdriver.py
sfa/senslab/slabslices.py

index 40df86e..895c287 100644 (file)
@@ -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:
index 4ca3d4b..444f158 100644 (file)
@@ -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
index ec6d072..c45a6a4 100644 (file)
@@ -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 "\