From 495e16d82322fb14c49940c17394b32c26f0224a Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Tue, 24 Jan 2012 15:30:19 +0100 Subject: [PATCH] Removed unused functions in OARapi( Get*FromOARParse). Fixed update_senslab_slice in slabpostgres, updated GetJobs to update the job id in the slice table upon queries on terminated jobs. --- sfa/senslab/OARrestapi.py | 11 --------- sfa/senslab/slabdriver.py | 45 +++++++++++++++++++++---------------- sfa/senslab/slabpostgres.py | 10 +++++---- 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/sfa/senslab/OARrestapi.py b/sfa/senslab/OARrestapi.py index 4b36d389..655d799c 100644 --- a/sfa/senslab/OARrestapi.py +++ b/sfa/senslab/OARrestapi.py @@ -313,18 +313,7 @@ class OARGETParser: ('date_created', None), ('peer_id', None),] self.site_dict[node['site_login_base']] = dict(self.site_dict[node['site_login_base']]) - #print>>sys.stderr, "\r\n \r\n =============\t\t ParseSites site dict %s \r\n"%(self.site_dict) - - - def GetNodesFromOARParse(self): - #print>>sys.stderr, " \r\n =========GetNodesFromOARParse: node_dictlist %s "%(self.node_dictlist) - return self.node_dictlist - #def GetSitesFromOARParse(self): - #return self.site_dict - - def GetJobsFromOARParse(self): - return self.jobs_list OARrequests_uri_dict = { 'GET_version': {'uri':'/oarapi/version.json', 'parse_func': ParseVersion}, diff --git a/sfa/senslab/slabdriver.py b/sfa/senslab/slabdriver.py index 44edfe4c..a3d96e3c 100644 --- a/sfa/senslab/slabdriver.py +++ b/sfa/senslab/slabdriver.py @@ -361,36 +361,33 @@ class SlabDriver(Driver): def GetJobs(self,job_id= None, resources=True,return_fields=None, details = None): - job_resources=['reserved_resources', 'assigned_resources','job_id', 'job_uri', 'assigned_nodes',\ - 'api_timestamp'] - assigned_res = ['resource_id', 'resource_uri'] - assigned_n = ['node', 'node_uri'] + #job_resources=['reserved_resources', 'assigned_resources','job_id', 'job_uri', 'assigned_nodes',\ + #'api_timestamp'] + #assigned_res = ['resource_id', 'resource_uri'] + #assigned_n = ['node', 'node_uri'] if job_id and resources is False: job_info = self.oar.parser.SendRequest("GET_jobs_id", job_id) print>>sys.stderr, "\r\n \r\n \t\t GetJobs resources is False job_info %s" %(job_info) - + if job_id and resources : job_info = self.oar.parser.SendRequest("GET_jobs_id_resources", job_id) print>>sys.stderr, "\r\n \r\n \t\t GetJobs job_info %s" %(job_info) - return job_info - #node_dict = self.oar.parser.GetNodesFromOARParse() - #return_node_list = [] - - #if not (node_filter or return_fields): - #return_node_list = node_dict.values() - #return return_node_list - - #return_node_list= parse_filter(node_dict.values(),node_filter ,'node', return_fields) - #return return_node_list + + if job_info['state'] == 'Terminated': + print>>sys.stderr, "\r\n \r\n \t\t GetJobs TERMINELEBOUSIN " + return None + else: + return job_info + + def GetNodes(self,node_filter= None, return_fields=None): node_dict =self.oar.parser.SendRequest("GET_resources_full") - #node_dict = self.oar.parser.GetNodesFromOARParse() + return_node_list = [] - print>>sys.stderr, "\r\n \r\n \t\t GetNodes node_dict %s" %(node_dict) if not (node_filter or return_fields): return_node_list = node_dict.values() return return_node_list @@ -421,14 +418,24 @@ class SlabDriver(Driver): if not (slice_filter or return_fields) and sliceslist: for sl in sliceslist: if sl['oar_job_id'] is not -1: - print >>sys.stderr, " \r\n \r\n SLABDRIVER.PY GetSlices sl %s" %(sl) rslt = self.GetJobs( sl['oar_job_id'],resources=False) print >>sys.stderr, " \r\n \r\n SLABRIVER.PY GetSlices rslt %s" %(rslt) - sl.update(rslt) + if rslt : + sl.update(rslt) + #If GetJobs is empty, this means the job is now in the 'Terminated' state + #Update the slice record + else: + sl['oar_job_id'] = '-1' + + sl.update({'hrn':str(sl['slice_hrn'])}) + print >>sys.stderr, " \r\n \r\n SLABDRIVER.PY GetSlices TERMINATEDDFDDDDD %s" %(sl) + self.db.update_senslab_slice(sl) return_slice_list = sliceslist return return_slice_list return_slice_list = parse_filter(sliceslist, slice_filter,'slice', return_fields) + + for sl in return_slice_list: if sl['oar_job_id'] is not -1: print >>sys.stderr, " \r\n \r\n SLABDRIVER.PY GetSlices sl %s" %(sl) diff --git a/sfa/senslab/slabpostgres.py b/sfa/senslab/slabpostgres.py index 668c8c39..84c1a770 100644 --- a/sfa/senslab/slabpostgres.py +++ b/sfa/senslab/slabpostgres.py @@ -231,13 +231,15 @@ class SlabDB: def update_senslab_slice(self, slice_rec): sfatable = SfaTable() - userhrn = slice_rec['hrn'].strip('_slice') + hrn = str(slice_rec['hrn']) + userhrn = hrn.rstrip('_slice') userrecord = sfatable.find({'hrn': userhrn, 'type':'user'}) + print>>sys.stderr, " \r\n \r\n \t SLABPOSTGRES.PY update_senslab_slice : userrecord %s slice_rec %s userhrn %s" %( userrecord, slice_rec, userhrn) if (isinstance (userrecord, list)): userrecord = userrecord[0] - columns = [ 'record_user_id', 'oar_job_id'] - values = [slice_rec['record_user_id'],slice_rec['oar_job_id']] - self.update('slice',columns, values,'record_slice_id', slice_rec['record_slice_id']) + columns = [ 'record_id_user', 'oar_job_id'] + values = [slice_rec['record_id_user'],slice_rec['oar_job_id']] + self.update('slice',columns, values,'record_id_slice', slice_rec['record_id_slice']) return -- 2.47.0