Package Ganga :: Package Lib :: Package MonitoringServices :: Package Dashboard :: Module CREAMUtil
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Lib.MonitoringServices.Dashboard.CREAMUtil

 1  """CREAM meta-data utilities. 
 2   
 3  N.B. This code is under development and should not generally be used or relied upon. 
 4   
 5  """ 
 6   
 7  from Ganga.Lib.MonitoringServices.Dashboard import CommonUtil 
 8   
 9  #----- client meta-data builders -----  
10  #TODO: add error handling code in following methods 
11   
12 -def cl_dest_ce(job):
13 """Build dest_ce. Only run on client.""" 14 return CommonUtil.strip_to_none(job.backend.actualCE)
15
16 -def cl_execution_backend(job):
17 """Build execution_backend. Only run on client.""" 18 return job.backend._name
19
20 -def cl_grid_exit_code(job):
21 """Build grid_exit_code. Only run on client.""" 22 return CommonUtil.strip_to_none(job.backend.exitcode_cream)
23
24 -def cl_grid_exit_reason(job):
25 """Build grid_exit_reason. Only run on client.""" 26 return CommonUtil.strip_to_none(job.backend.reason)
27
28 -def cl_grid_job_id(job):
29 """Build grid_job_id. Only run on client.""" 30 return CommonUtil.strip_to_none(job.backend.id)
31
32 -def cl_ownerdn():
33 """Build ownerdn. Only run on client.""" 34 from Ganga.GPIDev import Credentials 35 proxy = Credentials.getCredential('GridProxy') 36 ownerdn = proxy.info('-subject') 37 return CommonUtil.strip_to_none(ownerdn)
38
39 -def cl_grid_status(job):
40 """Build grid_status. Only run on client.""" 41 return CommonUtil.strip_to_none(job.backend.status)
42
43 -def cl_job_id_inside_the_task(job):
44 """Build job_id_inside_the_task. Only run on client.""" 45 if job.master is None: 46 job_id_inside_the_task = 0 47 else: 48 job_id_inside_the_task = job.id 49 return job_id_inside_the_task
50
51 -def cl_task_name(job):
52 """Build task_name. Only run on client.""" 53 # format: ganga:<job.info.uuid>:<job.name> 54 if job.master: 55 job = job.master 56 task_name = 'ganga:%s:%s' % (job.info.uuid, job.name,) 57 return task_name
58
59 -def cl_unique_job_id(job):
60 """Build unique_job_id. Only run on client.""" 61 return job.info.uuid
62 63 #todo : think here -> it should be different 64 #----- worker node meta-data builders ----- 65 #TODO: add error handling code in following methods 66
67 -def wn_dest_ce(ji):
68 """Build dest_ce. Only run on worker node.""" 69 dest_ce = CommonUtil.env('CE_ID') 70 return CommonUtil.strip_to_none(dest_ce)
71
72 -def wn_dest_site(ji):
73 """Build dest_site. Only run on worker node.""" 74 return CommonUtil.env('SITE_NAME')
75
76 -def wn_dest_wn():
77 """Build dest_wn. Only run on worker node.""" 78 return CommonUtil.hostname()
79 #gridJobId for CREAM
80 -def wn_grid_job_id(ji):
81 """Build grid_job_id. Only run on worker node.""" 82 grid_job_id = CommonUtil.env('CREAM_JOBID') 83 if not grid_job_id: 84 grid_job_id = CommonUtil.env('EDG_WL_JOBID') 85 if not grid_job_id: 86 grid_job_id = CommonUtil.env('GLITE_WMS_JOBID') 87 return grid_job_id
88