Getting reserved node now handles the case where reservation
authorSandrine Avakian <sandrine.avakian@inria.fr>
Fri, 27 Jul 2012 08:35:46 +0000 (10:35 +0200)
committerSandrine Avakian <sandrine.avakian@inria.fr>
Fri, 27 Jul 2012 08:35:46 +0000 (10:35 +0200)
are defined as "as soon as possible" and do not have information
on scheduled start and resources.
 Please enter the commit message for your changes. Lines starting

sfa/senslab/OARrestapi.py
sfa/senslab/slabdriver.py

index fe3ff8d..d2c8f98 100644 (file)
@@ -321,15 +321,24 @@ class OARGETParser:
         job = {}
         #Parse resources info
         for json_element in  self.raw_json['items']:
-            job['t_from'] = json_element['scheduled_start']
-            #Get resources id list for the job
-            job['resource_ids'] = \
-                [ node_dict['id'] for node_dict in json_element['resources'] ]
+            #In case it is a real reservation (not asap case)
+            if json_element['scheduled_start']:
+                job['t_from'] = json_element['scheduled_start']
+                job['t_until'] = int(json_element['scheduled_start']) + \
+                                                       int(json_element['walltime'])
+                #Get resources id list for the job
+                job['resource_ids'] = \
+                    [ node_dict['id'] for node_dict in json_element['resources'] ]
+            else:
+                job['t_from'] = "As soon as possible"
+                job['t_until'] = "As soon as possible"
+                job['resource_ids'] = ["Undefined"]
+                
            
             job['state'] = json_element['state'] 
             job['lease_id'] = json_element['id'] 
-            job['t_until'] = json_element['scheduled_start'] + \
-                                                    json_element['walltime']
+            
+            
             job['user'] = json_element['owner']
             #logger.debug("OARRestapi \tParseReservedNodes job %s" %(job))  
             reservation_list.append(job)
index e33f12c..f88e743 100644 (file)
@@ -648,10 +648,12 @@ class SlabDriver(Driver):
         hostname_list = []
         hostname_dict_list = [] 
         for resource_id in resource_id_list:
-            hostname_dict_list.append({'hostname' : \
-                    oar_id_node_dict[resource_id]['hostname'], 
-                    'site_id' :  oar_id_node_dict[resource_id]['site']})
-            
+            #Because jobs requested "asap" do not have defined resources
+            if resource_id is not "Undefined":
+                hostname_dict_list.append({'hostname' : \
+                        oar_id_node_dict[resource_id]['hostname'], 
+                        'site_id' :  oar_id_node_dict[resource_id]['site']})
+                
             #hostname_list.append(oar_id_node_dict[resource_id]['hostname'])
         return hostname_dict_list