Fixed bug for sfi.py show slice record.
[sfa.git] / sfa / senslab / slabdriver.py
index 5ef99c8..95fa8d7 100644 (file)
@@ -1,7 +1,6 @@
 import subprocess
 
 from datetime import datetime
-from time import gmtime
 
 from sfa.util.faults import SliverDoesNotExist, UnknownSfaType
 from sfa.util.sfalogging import logger
@@ -16,7 +15,7 @@ from sfa.managers.driver import Driver
 from sfa.rspecs.version_manager import VersionManager
 from sfa.rspecs.rspec import RSpec
 
-from sfa.util.xrn import hrn_to_urn, urn_to_sliver_id, get_leaf
+from sfa.util.xrn import hrn_to_urn
 
 
 ## thierry: everything that is API-related (i.e. handling incoming requests) 
@@ -42,18 +41,20 @@ from sfa.senslab.slabslices import SlabSlices
 # GetNodes or GetSites sorts of calls directly
 # and thus minimize the differences in the managers with the pl version
 class SlabDriver(Driver):
-
+    """ Senslab Driver class inherited from Driver generic class.
+    
+    Contains methods compliant with the SFA standard and the testbed
+    infrastructure (calls to LDAP and OAR).
+    """
     def __init__(self, config):
         Driver.__init__ (self, config)
         self.config = config
         self.hrn = config.SFA_INTERFACE_HRN
-
         self.root_auth = config.SFA_REGISTRY_ROOT_AUTH
-
         self.oar = OARrestapi()
         self.ldap = LDAPapi()
         self.time_format = "%Y-%m-%d %H:%M:%S"
-        self.db = SlabDB(config,debug = True)
+        self.db = SlabDB(config, debug = True)
         self.cache = None
         
     
@@ -1261,15 +1262,19 @@ class SlabDriver(Driver):
                     record.update({'PI':[recuser.hrn],
                                 'researcher': [recuser.hrn],
                                 'name':record['hrn'], 
-                                'oar_job_id':[rec['oar_job_id'] for rec in recslice_list],
+                                'oar_job_id':[],
                                 'node_ids': [],
                                 'person_ids':[recslice_list[0]['record_id_user']],
                                 'geni_urn':'',  #For client_helper.py compatibility
                                 'keys':'',  #For client_helper.py compatibility
                                 'key_ids':''})  #For client_helper.py compatibility
+                    
+                    try:
+                        for rec in recslice_list:
+                            record['oar_job_id'].append(rec['oar_job_id'])
+                    except KeyError:
+                        pass
 
-                    #for rec in recslice_list:
-                        #record['oar_job_id'].append(rec['oar_job_id'])
                     logger.debug( "SLABDRIVER.PY \t fill_record_info SLICE \
                                                     recslice_list  %s \r\n \t RECORD %s \r\n \r\n" %(recslice_list,record)) 
                 if str(record['type']) == 'user':
@@ -1295,12 +1300,17 @@ class SlabDriver(Driver):
                         'researcher': [recuser.hrn],
                         'name':record['hrn'], 
                         'node_ids': [],
-                        'oar_job_id': [rec['oar_job_id'] for rec in recslice_list],
-                        'person_ids':[recslice_list[0]['record_id_user']]})
+                        'oar_job_id': [],
+                        'person_ids':[recslice_list[0]['record_id_user']]}) 
+                    try:
+                        for rec in recslice_list:
+                            recslice['oar_job_id'].append(rec['oar_job_id'])
+                    except KeyError:
+                        pass
+                            
                     recslice.update({'type':'slice', \
                                                 'hrn':recslice_list[0]['slice_hrn']})
-                    #for rec in recslice_list:
-                        #recslice['oar_job_id'].append(rec['oar_job_id'])
+
 
                     #GetPersons takes [] as filters 
                     #user_slab = self.GetPersons([{'hrn':recuser.hrn}])