1 |
< |
from Scheduler import Scheduler |
1 |
> |
from SchedulerGrid import SchedulerGrid |
2 |
|
from crab_logger import Logger |
3 |
|
from crab_exceptions import * |
4 |
|
from crab_util import * |
5 |
+ |
from EdgConfig import * |
6 |
+ |
from BlackWhiteListParser import BlackWhiteListParser |
7 |
|
import common |
8 |
|
|
9 |
|
import os, sys, time |
10 |
|
|
11 |
< |
class SchedulerEdg(Scheduler): |
11 |
> |
class SchedulerEdg(SchedulerGrid): |
12 |
|
def __init__(self): |
13 |
< |
Scheduler.__init__(self,"EDG") |
14 |
< |
self.states = [ "Acl", "cancelReason", "cancelling","ce_node","children", \ |
15 |
< |
"children_hist","children_num","children_states","condorId","condor_jdl", \ |
16 |
< |
"cpuTime","destination", "done_code","exit_code","expectFrom", \ |
17 |
< |
"expectUpdate","globusId","jdl","jobId","jobtype", \ |
18 |
< |
"lastUpdateTime","localId","location", "matched_jdl","network_server", \ |
19 |
< |
"owner","parent_job", "reason","resubmitted","rsl","seed",\ |
20 |
< |
"stateEnterTime","stateEnterTimes","subjob_failed", \ |
21 |
< |
"user tags" , "status" , "status_code","hierarchy"] |
22 |
< |
return |
23 |
< |
|
24 |
< |
def configure(self, cfg_params): |
25 |
< |
|
26 |
< |
try: self.edg_config = cfg_params["EDG.config"] |
27 |
< |
except KeyError: self.edg_config = '' |
28 |
< |
|
29 |
< |
try: self.edg_config_vo = cfg_params["EDG.config_vo"] |
30 |
< |
except KeyError: self.edg_config_vo = '' |
29 |
< |
|
30 |
< |
try: self.LCG_version = cfg_params["EDG.lcg_version"] |
31 |
< |
except KeyError: self.LCG_version = '2' |
32 |
< |
|
33 |
< |
try: self.EDG_requirements = cfg_params['EDG.requirements'] |
34 |
< |
except KeyError: self.EDG_requirements = '' |
35 |
< |
|
36 |
< |
try: self.EDG_retry_count = cfg_params['EDG.retry_count'] |
37 |
< |
except KeyError: self.EDG_retry_count = '' |
38 |
< |
|
39 |
< |
try: self.VO = cfg_params['EDG.virtual_organization'] |
40 |
< |
except KeyError: self.VO = 'cms' |
41 |
< |
|
42 |
< |
try: self.return_data = cfg_params['USER.return_data'] |
43 |
< |
except KeyError: self.return_data = '' |
44 |
< |
|
45 |
< |
try: |
46 |
< |
self.copy_data = cfg_params["USER.copy_data"] |
47 |
< |
try: |
48 |
< |
self.SE = cfg_params['USER.storage_element'] |
49 |
< |
self.SE_PATH = cfg_params['USER.storage_path'] |
50 |
< |
except KeyError: |
51 |
< |
msg = "Error. The [USER] section does not have 'storage_element'" |
52 |
< |
msg = msg + " and/or 'storage_path' entries, necessary to copy the output" |
53 |
< |
common.logger.message(msg) |
54 |
< |
raise CrabException(msg) |
55 |
< |
except KeyError: self.copy_data = '' |
56 |
< |
|
57 |
< |
try: |
58 |
< |
self.register_data = cfg_params["USER.register_data"] |
59 |
< |
try: |
60 |
< |
self.LFN = cfg_params['USER.lfn_dir'] |
61 |
< |
except KeyError: |
62 |
< |
msg = "Error. The [USER] section does not have 'lfn_dir' value" |
63 |
< |
msg = msg + " it's necessary for RLS registration" |
64 |
< |
common.logger.message(msg) |
65 |
< |
raise CrabException(msg) |
66 |
< |
except KeyError: self.register_data= '' |
67 |
< |
|
68 |
< |
try: self.EDG_requirements = cfg_params['EDG.requirements'] |
69 |
< |
except KeyError: self.EDG_requirements = '' |
70 |
< |
|
71 |
< |
try: self.EDG_retry_count = cfg_params['EDG.retry_count'] |
72 |
< |
except KeyError: self.EDG_retry_count = '' |
73 |
< |
|
74 |
< |
try: self.EDG_clock_time = cfg_params['EDG.max_wall_clock_time'] |
75 |
< |
except KeyError: self.EDG_clock_time= '' |
76 |
< |
|
77 |
< |
try: self.EDG_cpu_time = cfg_params['EDG.max_cpu_time'] |
78 |
< |
except KeyError: self.EDG_cpu_time = '' |
79 |
< |
|
80 |
< |
# Add EDG_WL_LOCATION to the python path |
81 |
< |
|
82 |
< |
try: |
83 |
< |
path = os.environ['EDG_WL_LOCATION'] |
84 |
< |
except: |
85 |
< |
msg = "Error: the EDG_WL_LOCATION variable is not set." |
86 |
< |
raise CrabException(msg) |
87 |
< |
|
88 |
< |
libPath=os.path.join(path, "lib") |
89 |
< |
sys.path.append(libPath) |
90 |
< |
libPath=os.path.join(path, "lib", "python") |
91 |
< |
sys.path.append(libPath) |
92 |
< |
|
93 |
< |
self.proxyValid=0 |
94 |
< |
return |
95 |
< |
|
13 |
> |
SchedulerGrid.__init__(self,"EDG") |
14 |
> |
|
15 |
> |
def configure(self,cfg_params): |
16 |
> |
SchedulerGrid.configure(self, cfg_params) |
17 |
> |
self.environment_unique_identifier = 'EDG_WL_JOBID' |
18 |
> |
|
19 |
> |
def rb_configure(self, RB): |
20 |
> |
edg_config = None |
21 |
> |
edg_config_vo = None |
22 |
> |
rb_param_file = None |
23 |
> |
|
24 |
> |
edgConfig = EdgConfig(RB) |
25 |
> |
edg_config = edgConfig.config() |
26 |
> |
edg_config_vo = edgConfig.configVO() |
27 |
> |
|
28 |
> |
if (edg_config and edg_config_vo): |
29 |
> |
rb_param_file = 'RBconfig = "'+edg_config+'";\nRBconfigVO = "'+edg_config_vo+'";\n' |
30 |
> |
return rb_param_file |
31 |
|
|
32 |
|
def sched_parameter(self): |
33 |
|
""" |
34 |
< |
Returns file with scheduler-specific parameters |
34 |
> |
Returns file with requirements and scheduler-specific parameters |
35 |
|
""" |
36 |
< |
|
37 |
< |
if (self.edg_config and self.edg_config_vo != ''): |
38 |
< |
self.param='sched_param.clad' |
104 |
< |
param_file = open(common.work_space.shareDir()+'/'+self.param, 'w') |
105 |
< |
param_file.write('RBconfig = "'+self.edg_config+'";\n') |
106 |
< |
param_file.write('RBconfigVO = "'+self.edg_config_vo+'";') |
107 |
< |
param_file.close() |
108 |
< |
return 1 |
109 |
< |
else: |
110 |
< |
return 0 |
36 |
> |
index = int(common.jobDB.nJobs()) - 1 |
37 |
> |
job = common.job_list[index] |
38 |
> |
jbt = job.type() |
39 |
|
|
40 |
< |
def wsSetupEnvironment(self): |
41 |
< |
""" |
42 |
< |
Returns part of a job script which does scheduler-specific work. |
43 |
< |
""" |
40 |
> |
lastBlock=-1 |
41 |
> |
first = [] |
42 |
> |
for n in range(common.jobDB.nJobs()): |
43 |
> |
currBlock=common.jobDB.block(n) |
44 |
> |
if (currBlock!=lastBlock): |
45 |
> |
lastBlock = currBlock |
46 |
> |
first.append(n) |
47 |
> |
|
48 |
> |
req = '' |
49 |
> |
req = req + jbt.getRequirements() |
50 |
> |
|
51 |
> |
if self.EDG_requirements: |
52 |
> |
if (req == ' '): |
53 |
> |
req = req + self.EDG_requirements |
54 |
> |
else: |
55 |
> |
req = req + ' && ' + self.EDG_requirements |
56 |
|
|
57 |
< |
txt = '' |
58 |
< |
if self.copy_data: |
59 |
< |
if self.SE: |
60 |
< |
txt += 'export SE='+self.SE+'\n' |
61 |
< |
txt += 'echo "SE = $SE"\n' |
62 |
< |
if self.SE_PATH: |
63 |
< |
if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/' |
64 |
< |
txt += 'export SE_PATH='+self.SE_PATH+'\n' |
65 |
< |
txt += 'echo "SE_PATH = $SE_PATH"\n' |
66 |
< |
|
67 |
< |
if self.register_data: |
68 |
< |
if self.VO: |
129 |
< |
txt += 'export VO='+self.VO+'\n' |
130 |
< |
if self.LFN: |
131 |
< |
txt += 'export LFN='+self.LFN+'\n' |
132 |
< |
txt += '\n' |
133 |
< |
txt += 'CloseCEs=`edg-brokerinfo getCE`\n' |
134 |
< |
txt += 'echo "CloseCEs = $CloseCEs"\n' |
135 |
< |
txt += 'CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
136 |
< |
txt += 'echo "CE = $CE"\n' |
137 |
< |
return txt |
57 |
> |
if self.EDG_ce_white_list: |
58 |
> |
ce_white_list = string.split(self.EDG_ce_white_list,',') |
59 |
> |
for i in range(len(ce_white_list)): |
60 |
> |
if i == 0: |
61 |
> |
if (req == ' '): |
62 |
> |
req = req + '((RegExp("' + string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))' |
63 |
> |
else: |
64 |
> |
req = req + ' && ((RegExp("' + string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))' |
65 |
> |
pass |
66 |
> |
else: |
67 |
> |
req = req + ' || (RegExp("' + string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))' |
68 |
> |
req = req + ')' |
69 |
|
|
70 |
< |
def wsCopyOutput(self): |
71 |
< |
""" |
72 |
< |
Write a CopyResults part of a job script, e.g. |
73 |
< |
to copy produced output into a storage element. |
74 |
< |
""" |
75 |
< |
txt = '' |
76 |
< |
if self.copy_data: |
77 |
< |
copy = 'globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file' |
78 |
< |
txt += '#\n' |
79 |
< |
txt += '# Copy output to SE = $SE\n' |
80 |
< |
txt += '#\n' |
81 |
< |
#### per orca l'exit_status non e' affidabile..... |
82 |
< |
#txt += 'if [ $executable_exit_status -eq 0 ]; then\n' |
152 |
< |
txt += 'if [ $exe_result -eq 0 ]; then\n' |
153 |
< |
txt += ' for out_file in $file_list ; do\n' |
154 |
< |
txt += ' echo "Trying to copy output file to $SE "\n' |
155 |
< |
txt += ' echo "'+copy+'"\n' |
156 |
< |
txt += ' '+copy+' 2>&1\n' |
157 |
< |
txt += ' copy_exit_status=$?\n' |
158 |
< |
txt += ' echo "COPY_EXIT_STATUS = $copy_exit_status"\n' |
159 |
< |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
160 |
< |
txt += ' if [ $copy_exit_status -ne 0 ]; then \n' |
161 |
< |
txt += ' echo "Problems with SE= $SE" \n' |
162 |
< |
txt += ' else \n' |
163 |
< |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
164 |
< |
txt += ' fi \n' |
165 |
< |
txt += ' done\n' |
166 |
< |
txt += 'fi \n' |
167 |
< |
return txt |
70 |
> |
if self.EDG_ce_black_list: |
71 |
> |
ce_black_list = string.split(self.EDG_ce_black_list,',') |
72 |
> |
for ce in ce_black_list: |
73 |
> |
if (req == ' '): |
74 |
> |
req = req + '(!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))' |
75 |
> |
else: |
76 |
> |
req = req + ' && (!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))' |
77 |
> |
pass |
78 |
> |
if self.EDG_clock_time: |
79 |
> |
if (req == ' '): |
80 |
> |
req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
81 |
> |
else: |
82 |
> |
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
83 |
|
|
84 |
< |
def wsRegisterOutput(self): |
85 |
< |
""" |
86 |
< |
Returns part of a job script which does scheduler-specific work. |
87 |
< |
""" |
84 |
> |
if self.EDG_cpu_time: |
85 |
> |
if (req == ' '): |
86 |
> |
req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
87 |
> |
else: |
88 |
> |
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
89 |
|
|
90 |
< |
txt = '' |
91 |
< |
if self.register_data: |
92 |
< |
txt += '#\n' |
93 |
< |
txt += '# Register output to RLS\n' |
178 |
< |
txt += '#\n' |
179 |
< |
### analogo |
180 |
< |
#txt += 'if [[ $executable_exit_status -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
181 |
< |
txt += 'if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
182 |
< |
txt += ' for out_file in $file_list ; do\n' |
183 |
< |
txt += ' echo "Trying to register the output file into RLS"\n' |
184 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n' |
185 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
186 |
< |
txt += ' register_exit_status=$?\n' |
187 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
188 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
189 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
190 |
< |
txt += ' echo "Problems with the registration to RLS" \n' |
191 |
< |
txt += ' echo "Try with srm protocol" \n' |
192 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n' |
193 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n' |
194 |
< |
txt += ' register_exit_status=$?\n' |
195 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
196 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
197 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
198 |
< |
txt += ' echo "Problems with the registration into RLS" \n' |
199 |
< |
txt += ' fi \n' |
200 |
< |
txt += ' else \n' |
201 |
< |
txt += ' echo "output registered to RLS"\n' |
202 |
< |
txt += ' fi \n' |
203 |
< |
txt += ' done\n' |
204 |
< |
txt += 'elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n' |
205 |
< |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
206 |
< |
txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
207 |
< |
txt += ' for out_file in $file_list ; do\n' |
208 |
< |
txt += ' echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n' |
209 |
< |
txt += ' lcg-cr -v -l lfn:${LFN}/$out_file -d $SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file 2>&1 \n' |
210 |
< |
txt += ' register_exit_status=$?\n' |
211 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
212 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
213 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
214 |
< |
txt += ' echo "Problems with CloseSE" \n' |
215 |
< |
txt += ' else \n' |
216 |
< |
txt += ' echo "The program was successfully executed"\n' |
217 |
< |
txt += ' echo "SE = $CLOSE_SE"\n' |
218 |
< |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
219 |
< |
txt += ' fi \n' |
220 |
< |
txt += ' done\n' |
221 |
< |
txt += 'else\n' |
222 |
< |
txt += ' echo "Problem with the executable"\n' |
223 |
< |
txt += 'fi \n' |
224 |
< |
return txt |
225 |
< |
##################### |
90 |
> |
for i in range(len(first)): # Add loop DS |
91 |
> |
groupReq = req |
92 |
> |
self.param='sched_param_'+str(i)+'.clad' |
93 |
> |
param_file = open(common.work_space.shareDir()+'/'+self.param, 'w') |
94 |
|
|
95 |
< |
def loggingInfo(self, id): |
96 |
< |
""" |
97 |
< |
retrieve the logging info from logging and bookkeeping and return it |
98 |
< |
""" |
99 |
< |
self.checkProxy() |
100 |
< |
# id = common.jobDB.jobId(nj) |
101 |
< |
cmd = 'edg-job-get-logging-info -v 2 ' + self.configOpt_() + id |
102 |
< |
cmd_out = runCommand(cmd) |
103 |
< |
return cmd_out |
95 |
> |
itr4=self.findSites_(first[i]) |
96 |
> |
for arg in itr4: |
97 |
> |
groupReq = groupReq + ' && anyMatch(other.storage.CloseSEs, ('+str(arg)+'))' |
98 |
> |
param_file.write('Requirements = '+groupReq +';\n') |
99 |
> |
|
100 |
> |
if (self.rb_param_file): |
101 |
> |
param_file.write(self.rb_param_file) |
102 |
> |
|
103 |
> |
if self.EDG_addJdlParam: |
104 |
> |
if self.EDG_addJdlParam[-1] == '': self.EDG_addJdlParam= self.EDG_addJdlParam[:-1] |
105 |
> |
for p in self.EDG_addJdlParam: |
106 |
> |
param_file.write(string.strip(p)+';\n') |
107 |
|
|
108 |
< |
def listMatch(self, nj): |
238 |
< |
""" |
239 |
< |
Check the compatibility of available resources |
240 |
< |
""" |
241 |
< |
self.checkProxy() |
242 |
< |
jdl = common.job_list[nj].jdlFilename() |
243 |
< |
cmd = 'edg-job-list-match ' + self.configOpt_() + jdl |
244 |
< |
cmd_out = runCommand(cmd) |
245 |
< |
return self.parseListMatch_(cmd_out, jdl) |
108 |
> |
param_file.close() |
109 |
|
|
247 |
– |
def parseListMatch_(self, out, jdl): |
248 |
– |
reComment = re.compile( r'^\**$' ) |
249 |
– |
reEmptyLine = re.compile( r'^$' ) |
250 |
– |
reVO = re.compile( r'Selected Virtual Organisation name.*' ) |
251 |
– |
reCE = re.compile( r'CEId.*\n((.*:.*)\n)*' ) |
252 |
– |
reNO = re.compile( r'No Computing Element matching' ) |
253 |
– |
reRB = re.compile( r'Connecting to host' ) |
254 |
– |
next = 0 |
255 |
– |
CEs=[] |
256 |
– |
Match=0 |
257 |
– |
|
258 |
– |
if reNO.match( out ): |
259 |
– |
common.logger.debug(5,out) |
260 |
– |
self.noMatchFound_(jdl) |
261 |
– |
Match=0 |
262 |
– |
pass |
263 |
– |
if reVO.match( out ): |
264 |
– |
VO =reVO.match( out ).group() |
265 |
– |
common.logger.debug(5, 'VO :'+VO) |
266 |
– |
pass |
267 |
– |
|
268 |
– |
if reRB.match( out ): |
269 |
– |
RB =reRB.match(out).group() |
270 |
– |
common.logger.debug(5, 'Using RB :'+RB) |
271 |
– |
pass |
272 |
– |
|
273 |
– |
if reCE.search( out ): |
274 |
– |
groups=reCE.search(out).groups() |
275 |
– |
for CE in groups: |
276 |
– |
tmp = string.strip(CE) |
277 |
– |
CEs.append(tmp) |
278 |
– |
common.logger.debug(5, 'Matched CE :'+tmp) |
279 |
– |
Match=Match+1 |
280 |
– |
pass |
281 |
– |
|
282 |
– |
return Match |
283 |
– |
|
284 |
– |
def noMatchFound_(self, jdl): |
285 |
– |
reReq = re.compile( r'Requirements' ) |
286 |
– |
reString = re.compile( r'"\S*"' ) |
287 |
– |
f = file(jdl,'r') |
288 |
– |
for line in f.readlines(): |
289 |
– |
line= line.strip() |
290 |
– |
if reReq.match(line): |
291 |
– |
for req in reString.findall(line): |
292 |
– |
if re.search("VO",req): |
293 |
– |
common.logger.message( "SW required: "+req) |
294 |
– |
continue |
295 |
– |
if re.search('"\d+',req): |
296 |
– |
common.logger.message("Other req : "+req) |
297 |
– |
continue |
298 |
– |
common.logger.message( "CE required: "+req) |
299 |
– |
break |
300 |
– |
pass |
301 |
– |
raise CrabException("No compatible resources found!") |
110 |
|
|
111 |
< |
def submit(self, nj): |
111 |
> |
def loggingInfo(self, id): |
112 |
|
""" |
113 |
< |
Submit one EDG job. |
113 |
> |
retrieve the logging info from logging and bookkeeping and return it |
114 |
|
""" |
307 |
– |
|
115 |
|
self.checkProxy() |
116 |
< |
jid = None |
310 |
< |
jdl = common.job_list[nj].jdlFilename() |
311 |
< |
|
312 |
< |
cmd = 'edg-job-submit ' + self.configOpt_() + jdl |
116 |
> |
cmd = 'edg-job-get-logging-info -v 2 ' + id |
117 |
|
cmd_out = runCommand(cmd) |
118 |
< |
if cmd_out != None: |
315 |
< |
reSid = re.compile( r'https.+' ) |
316 |
< |
jid = reSid.search(cmd_out).group() |
317 |
< |
pass |
318 |
< |
return jid |
319 |
< |
|
320 |
< |
def getExitStatus(self, id): |
321 |
< |
return self.getStatusAttribute_(id, 'exit_code') |
322 |
< |
|
323 |
< |
def queryStatus(self, id): |
324 |
< |
return self.getStatusAttribute_(id, 'status') |
325 |
< |
|
326 |
< |
def queryDest(self, id): |
327 |
< |
return self.getStatusAttribute_(id, 'destination') |
328 |
< |
|
329 |
< |
|
330 |
< |
def getStatusAttribute_(self, id, attr): |
331 |
< |
""" Query a status of the job with id """ |
332 |
< |
|
333 |
< |
self.checkProxy() |
334 |
< |
hstates = {} |
335 |
< |
Status = importName('edg_wl_userinterface_common_LbWrapper', 'Status') |
336 |
< |
# Bypass edg-job-status interfacing directly to C++ API |
337 |
< |
# Job attribute vector to retrieve status without edg-job-status |
338 |
< |
level = 0 |
339 |
< |
# Instance of the Status class provided by LB API |
340 |
< |
jobStat = Status() |
341 |
< |
st = 0 |
342 |
< |
jobStat.getStatus(id, level) |
343 |
< |
err, apiMsg = jobStat.get_error() |
344 |
< |
if err: |
345 |
< |
print 'Error caught', apiMsg |
346 |
< |
common.log.message(apiMsg) |
347 |
< |
return None |
348 |
< |
else: |
349 |
< |
for i in range(len(self.states)): |
350 |
< |
# Fill an hash table with all information retrieved from LB API |
351 |
< |
hstates[ self.states[i] ] = jobStat.loadStatus(st)[i] |
352 |
< |
result = jobStat.loadStatus(st)[ self.states.index(attr) ] |
353 |
< |
return result |
118 |
> |
return cmd_out |
119 |
|
|
120 |
|
def queryDetailedStatus(self, id): |
121 |
|
""" Query a detailed status of the job with id """ |
123 |
|
cmd_out = runCommand(cmd) |
124 |
|
return cmd_out |
125 |
|
|
126 |
< |
def getOutput(self, id): |
127 |
< |
""" |
128 |
< |
Get output for a finished job with id. |
129 |
< |
Returns the name of directory with results. |
130 |
< |
""" |
131 |
< |
|
132 |
< |
self.checkProxy() |
133 |
< |
cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() + ' ' + id |
134 |
< |
cmd_out = runCommand(cmd) |
135 |
< |
|
136 |
< |
# Determine the output directory name |
137 |
< |
dir = common.work_space.resDir() |
138 |
< |
dir += os.getlogin() |
139 |
< |
dir += '_' + os.path.basename(id) |
140 |
< |
return dir |
141 |
< |
|
142 |
< |
def cancel(self, id): |
143 |
< |
""" Cancel the EDG job with id """ |
144 |
< |
self.checkProxy() |
145 |
< |
cmd = 'edg-job-cancel --noint ' + id |
146 |
< |
cmd_out = runCommand(cmd) |
147 |
< |
return cmd_out |
148 |
< |
|
149 |
< |
def createSchScript(self, nj): |
150 |
< |
""" |
386 |
< |
Create a JDL-file for EDG. |
387 |
< |
""" |
388 |
< |
|
389 |
< |
job = common.job_list[nj] |
390 |
< |
jbt = job.type() |
391 |
< |
inp_sandbox = jbt.inputSandbox(nj) |
392 |
< |
out_sandbox = jbt.outputSandbox(nj) |
393 |
< |
inp_storage_subdir = '' |
394 |
< |
|
395 |
< |
title = '# This JDL was generated by '+\ |
396 |
< |
common.prog_name+' (version '+common.prog_version_str+')\n' |
397 |
< |
jt_string = '' |
398 |
< |
|
399 |
< |
|
400 |
< |
|
401 |
< |
SPL = inp_storage_subdir |
402 |
< |
if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/' |
403 |
< |
|
404 |
< |
jdl_fname = job.jdlFilename() |
405 |
< |
jdl = open(jdl_fname, 'w') |
406 |
< |
jdl.write(title) |
407 |
< |
|
408 |
< |
script = job.scriptFilename() |
409 |
< |
jdl.write('Executable = "' + os.path.basename(script) +'";\n') |
410 |
< |
jdl.write(jt_string) |
411 |
< |
|
412 |
< |
### only one .sh JDL has arguments: |
413 |
< |
firstEvent = common.jobDB.firstEvent(nj) |
414 |
< |
maxEvents = common.jobDB.maxEvents(nj) |
415 |
< |
jdl.write('Arguments = "' + str(nj+1)+' '+str(firstEvent)+' '+str(maxEvents)+'";\n') |
416 |
< |
|
417 |
< |
inp_box = 'InputSandbox = { ' |
418 |
< |
inp_box = inp_box + '"' + script + '",' |
419 |
< |
|
420 |
< |
if inp_sandbox != None: |
421 |
< |
for fl in inp_sandbox: |
422 |
< |
inp_box = inp_box + ' "' + fl + '",' |
423 |
< |
pass |
424 |
< |
pass |
425 |
< |
|
426 |
< |
#if common.use_jam: |
427 |
< |
# inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",' |
428 |
< |
|
429 |
< |
for addFile in jbt.additional_inbox_files: |
430 |
< |
addFile = os.path.abspath(addFile) |
431 |
< |
inp_box = inp_box+' "'+addFile+'",' |
432 |
< |
pass |
433 |
< |
|
434 |
< |
if inp_box[-1] == ',' : inp_box = inp_box[:-1] |
435 |
< |
inp_box = inp_box + ' };\n' |
436 |
< |
jdl.write(inp_box) |
437 |
< |
|
438 |
< |
jdl.write('StdOutput = "' + job.stdout() + '";\n') |
439 |
< |
jdl.write('StdError = "' + job.stderr() + '";\n') |
440 |
< |
|
441 |
< |
|
442 |
< |
if job.stdout() == job.stderr(): |
443 |
< |
out_box = 'OutputSandbox = { "' + \ |
444 |
< |
job.stdout() + '", ".BrokerInfo",' |
445 |
< |
else: |
446 |
< |
out_box = 'OutputSandbox = { "' + \ |
447 |
< |
job.stdout() + '", "' + \ |
448 |
< |
job.stderr() + '", ".BrokerInfo",' |
449 |
< |
|
450 |
< |
if self.return_data : |
451 |
< |
if out_sandbox != None: |
452 |
< |
for fl in out_sandbox: |
453 |
< |
out_box = out_box + ' "' + fl + '",' |
454 |
< |
pass |
455 |
< |
pass |
456 |
< |
pass |
457 |
< |
|
458 |
< |
if out_box[-1] == ',' : out_box = out_box[:-1] |
459 |
< |
out_box = out_box + ' };' |
460 |
< |
jdl.write(out_box+'\n') |
461 |
< |
|
462 |
< |
### if at least a CE exists ... |
463 |
< |
if common.analisys_common_info['sites']: |
464 |
< |
if common.analisys_common_info['sw_version']: |
465 |
< |
req='Requirements = ' |
466 |
< |
req=req + 'Member("VO-cms-' + \ |
467 |
< |
common.analisys_common_info['sw_version'] + \ |
468 |
< |
'", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
469 |
< |
if len(common.analisys_common_info['sites'])>0: |
470 |
< |
req = req + ' && (' |
471 |
< |
for i in range(len(common.analisys_common_info['sites'])): |
472 |
< |
req = req + 'other.GlueCEInfoHostName == "' \ |
473 |
< |
+ common.analisys_common_info['sites'][i] + '"' |
474 |
< |
if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ): |
475 |
< |
req = req + ' || ' |
476 |
< |
req = req + ')' |
126 |
> |
def findSites_(self, n): |
127 |
> |
itr4 =[] |
128 |
> |
sites = common.jobDB.destination(n) |
129 |
> |
if len(sites)>0 and sites[0]=="": |
130 |
> |
return itr4 |
131 |
> |
|
132 |
> |
itr = '' |
133 |
> |
if sites != [""]:#CarlosDaniele |
134 |
> |
##Addedd Daniele |
135 |
> |
replicas = self.blackWhiteListParser.checkBlackList(sites,n) |
136 |
> |
if len(replicas)!=0: |
137 |
> |
replicas = self.blackWhiteListParser.checkWhiteList(replicas,n) |
138 |
> |
|
139 |
> |
if len(replicas)==0: |
140 |
> |
itr = itr + 'target.GlueSEUniqueID=="NONE" ' |
141 |
> |
#msg = 'No sites remaining that host any part of the requested data! Exiting... ' |
142 |
> |
#raise CrabException(msg) |
143 |
> |
##### |
144 |
> |
# for site in sites: |
145 |
> |
for site in replicas: |
146 |
> |
#itr = itr + 'target.GlueSEUniqueID=="'+site+'" || ' |
147 |
> |
itr = itr + 'target.GlueSEUniqueID=="'+site+'" || ' |
148 |
> |
itr = itr[0:-4] |
149 |
> |
itr4.append( itr ) |
150 |
> |
return itr4 |
151 |
|
|
152 |
< |
#### and USER REQUIREMENT |
153 |
< |
if self.EDG_requirements: |
480 |
< |
req = req + ' && ' + self.EDG_requirements |
481 |
< |
if self.EDG_clock_time: |
482 |
< |
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
483 |
< |
if self.EDG_cpu_time: |
484 |
< |
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
485 |
< |
req = req + ';\n' |
486 |
< |
jdl.write(req) |
487 |
< |
|
488 |
< |
jdl.write('VirtualOrganisation = "' + self.VO + '";\n') |
489 |
< |
|
490 |
< |
if ( self.EDG_retry_count ): |
491 |
< |
jdl.write('RetryCount = '+self.EDG_retry_count+';\n') |
492 |
< |
pass |
152 |
> |
def tOut(self, list): |
153 |
> |
return 120 |
154 |
|
|
494 |
– |
jdl.close() |
495 |
– |
return |
155 |
|
|
497 |
– |
def checkProxy(self): |
498 |
– |
""" |
499 |
– |
Function to check the Globus proxy. |
500 |
– |
""" |
501 |
– |
if (self.proxyValid): return |
502 |
– |
timeleft = -999 |
503 |
– |
minTimeLeft=10 # in hours |
504 |
– |
cmd = 'grid-proxy-info -e -v '+str(minTimeLeft)+':00' |
505 |
– |
try: cmd_out = runCommand(cmd,0) |
506 |
– |
except: print cmd_out |
507 |
– |
if (cmd_out == None or cmd_out=='1'): |
508 |
– |
common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 100h\n") |
509 |
– |
cmd = 'grid-proxy-init -valid 100:00' |
510 |
– |
try: |
511 |
– |
out = os.system(cmd) |
512 |
– |
if (out>0): raise CrabException("Unable to create a valid proxy!\n") |
513 |
– |
except: |
514 |
– |
msg = "Unable to create a valid proxy!\n" |
515 |
– |
raise CrabException(msg) |
516 |
– |
cmd = 'grid-proxy-info -timeleft' |
517 |
– |
cmd_out = runCommand(cmd,0) |
518 |
– |
#print cmd_out, time.time() |
519 |
– |
#time.time(cms_out) |
520 |
– |
pass |
521 |
– |
self.proxyValid=1 |
522 |
– |
return |
523 |
– |
|
524 |
– |
def configOpt_(self): |
525 |
– |
edg_ui_cfg_opt = ' ' |
526 |
– |
if self.edg_config: |
527 |
– |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
528 |
– |
if self.edg_config_vo: |
529 |
– |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
530 |
– |
return edg_ui_cfg_opt |