37 |
|
self.proxyServer = 'myproxy.cern.ch' |
38 |
|
common.logger.debug(5,'Setting myproxy server to '+self.proxyServer) |
39 |
|
|
40 |
+ |
try: |
41 |
+ |
self.group = cfg_params["EDG.group"] |
42 |
+ |
except KeyError: |
43 |
+ |
self.group = None |
44 |
+ |
|
45 |
+ |
try: |
46 |
+ |
self.role = cfg_params["EDG.role"] |
47 |
+ |
except KeyError: |
48 |
+ |
self.role = None |
49 |
+ |
|
50 |
|
try: self.LCG_version = cfg_params["EDG.lcg_version"] |
51 |
|
except KeyError: self.LCG_version = '2' |
52 |
|
|
71 |
|
except KeyError: self.VO = 'cms' |
72 |
|
|
73 |
|
try: self.return_data = cfg_params['USER.return_data'] |
74 |
< |
except KeyError: self.return_data = 1 |
65 |
< |
|
66 |
< |
try: |
67 |
< |
self.copy_input_data = common.analisys_common_info['copy_input_data'] |
68 |
< |
#print "self.copy_input_data = ", self.copy_input_data |
69 |
< |
except KeyError: self.copy_input_data = 0 |
74 |
> |
except KeyError: self.return_data = 0 |
75 |
|
|
76 |
|
try: |
77 |
|
self.copy_data = cfg_params["USER.copy_data"] |
163 |
|
except: |
164 |
|
self._taskId = '' |
165 |
|
|
166 |
+ |
try: self.jobtypeName = cfg_params['CRAB.jobtype'] |
167 |
+ |
except KeyError: self.jobtypeName = '' |
168 |
+ |
|
169 |
+ |
try: self.schedulerName = cfg_params['CRAB.scheduler'] |
170 |
+ |
except KeyError: self.scheduler = '' |
171 |
+ |
|
172 |
|
return |
173 |
|
|
174 |
|
|
175 |
|
def sched_parameter(self): |
176 |
|
""" |
177 |
< |
Returns file with scheduler-specific parameters |
177 |
> |
Returns file with requirements and scheduler-specific parameters |
178 |
|
""" |
179 |
< |
|
180 |
< |
if (self.edg_config and self.edg_config_vo != ''): |
181 |
< |
self.param='sched_param.clad' |
179 |
> |
index = int(common.jobDB.nJobs()) - 1 |
180 |
> |
job = common.job_list[index] |
181 |
> |
jbt = job.type() |
182 |
> |
|
183 |
> |
lastBlock=-1 |
184 |
> |
first = [] |
185 |
> |
for n in range(common.jobDB.nJobs()): |
186 |
> |
currBlock=common.jobDB.block(n) |
187 |
> |
if (currBlock!=lastBlock): |
188 |
> |
lastBlock = currBlock |
189 |
> |
first.append(n) |
190 |
> |
|
191 |
> |
req = '' |
192 |
> |
req = req + jbt.getRequirements() |
193 |
> |
|
194 |
> |
if self.EDG_requirements: |
195 |
> |
if (req == ' '): |
196 |
> |
req = req + self.EDG_requirements |
197 |
> |
else: |
198 |
> |
req = req + ' && ' + self.EDG_requirements |
199 |
> |
|
200 |
> |
if self.EDG_ce_white_list: |
201 |
> |
ce_white_list = string.split(self.EDG_ce_white_list,',') |
202 |
> |
for i in range(len(ce_white_list)): |
203 |
> |
if i == 0: |
204 |
> |
if (req == ' '): |
205 |
> |
req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
206 |
> |
else: |
207 |
> |
req = req + ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
208 |
> |
pass |
209 |
> |
else: |
210 |
> |
req = req + ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
211 |
> |
req = req + ')' |
212 |
> |
|
213 |
> |
if self.EDG_ce_black_list: |
214 |
> |
ce_black_list = string.split(self.EDG_ce_black_list,',') |
215 |
> |
for ce in ce_black_list: |
216 |
> |
if (req == ' '): |
217 |
> |
req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))' |
218 |
> |
else: |
219 |
> |
req = req + ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))' |
220 |
> |
pass |
221 |
> |
if self.EDG_clock_time: |
222 |
> |
if (req == ' '): |
223 |
> |
req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
224 |
> |
else: |
225 |
> |
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
226 |
> |
|
227 |
> |
if self.EDG_cpu_time: |
228 |
> |
if (req == ' '): |
229 |
> |
req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
230 |
> |
else: |
231 |
> |
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
232 |
> |
|
233 |
> |
for i in range(len(first)): # Add loop DS |
234 |
> |
self.param='sched_param_'+str(i)+'.clad' |
235 |
|
param_file = open(common.work_space.shareDir()+'/'+self.param, 'w') |
236 |
< |
param_file.write('RBconfig = "'+self.edg_config+'";\n') |
237 |
< |
param_file.write('RBconfigVO = "'+self.edg_config_vo+'";') |
236 |
> |
|
237 |
> |
itr4=self.findSites_(first[i]) |
238 |
> |
for arg in itr4: |
239 |
> |
req = req + ' && anyMatch(other.storage.CloseSEs, ('+str(arg)+'))' |
240 |
> |
param_file.write('Requirements = '+req +';\n') |
241 |
> |
|
242 |
> |
if (self.edg_config and self.edg_config_vo != ''): |
243 |
> |
param_file.write('RBconfig = "'+self.edg_config+'";\n') |
244 |
> |
param_file.write('RBconfigVO = "'+self.edg_config_vo+'";') |
245 |
> |
|
246 |
|
param_file.close() |
247 |
< |
return 1 |
176 |
< |
else: |
177 |
< |
return 0 |
247 |
> |
|
248 |
|
|
249 |
|
def wsSetupEnvironment(self): |
250 |
|
""" |
251 |
|
Returns part of a job script which does scheduler-specific work. |
252 |
|
""" |
253 |
|
txt = '' |
254 |
+ |
txt += '# strip arguments\n' |
255 |
+ |
txt += 'echo "strip arguments"\n' |
256 |
+ |
txt += 'args=("$@")\n' |
257 |
+ |
txt += 'nargs=$#\n' |
258 |
+ |
txt += 'shift $nargs\n' |
259 |
|
txt += "# job number (first parameter for job wrapper)\n" |
260 |
< |
txt += "NJob=$1\n" |
260 |
> |
#txt += "NJob=$1\n" |
261 |
> |
txt += "NJob=${args[0]}\n" |
262 |
|
|
263 |
|
txt += '# job identification to DashBoard \n' |
264 |
|
txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n' |
269 |
|
txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
270 |
|
|
271 |
|
txt += 'echo "middleware discovery " \n' |
272 |
< |
txt += 'if [ $VO_CMS_SW_DIR ]; then \n' |
197 |
< |
txt += ' middleware=LCG \n' |
198 |
< |
txt += ' echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n' |
199 |
< |
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
200 |
< |
txt += ' echo "middleware =$middleware" \n' |
201 |
< |
txt += 'elif [ $GRID3_APP_DIR ]; then\n' |
272 |
> |
txt += 'if [ $GRID3_APP_DIR ]; then\n' |
273 |
|
txt += ' middleware=OSG \n' |
274 |
|
txt += ' echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n' |
275 |
|
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
279 |
|
txt += ' echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n' |
280 |
|
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
281 |
|
txt += ' echo "middleware =$middleware" \n' |
282 |
+ |
txt += 'elif [ $VO_CMS_SW_DIR ]; then \n' |
283 |
+ |
txt += ' middleware=LCG \n' |
284 |
+ |
txt += ' echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n' |
285 |
+ |
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
286 |
+ |
txt += ' echo "middleware =$middleware" \n' |
287 |
|
txt += 'else \n' |
288 |
|
txt += ' echo "SET_CMS_ENV 10030 ==> middleware not identified" \n' |
289 |
|
txt += ' echo "JOB_EXIT_STATUS = 10030" \n' |
291 |
|
txt += ' dumpStatus $RUNTIME_AREA/$repo \n' |
292 |
|
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
293 |
|
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
218 |
– |
txt += ' echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n' |
294 |
|
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
295 |
|
txt += ' exit 1 \n' |
296 |
|
txt += 'fi \n' |
299 |
|
txt += 'dumpStatus $RUNTIME_AREA/$repo \n' |
300 |
|
txt += 'rm -f $RUNTIME_AREA/$repo \n' |
301 |
|
txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
227 |
– |
txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n' |
302 |
|
txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
303 |
|
|
304 |
|
txt += '\n\n' |
313 |
|
txt += 'echo "SE_PATH = $SE_PATH"\n' |
314 |
|
|
315 |
|
txt += 'export VO='+self.VO+'\n' |
316 |
< |
### FEDE: add some line for LFC catalog setting |
316 |
> |
### add some line for LFC catalog setting |
317 |
|
txt += 'if [ $middleware == LCG ]; then \n' |
318 |
|
txt += ' if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n' |
319 |
|
txt += ' export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n' |
368 |
|
txt += ' dumpStatus $RUNTIME_AREA/$repo \n' |
369 |
|
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
370 |
|
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
297 |
– |
txt += ' echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n' |
371 |
|
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
372 |
|
txt += ' exit 1 \n' |
373 |
|
txt += ' fi \n' |
380 |
|
Copy input data from SE to WN |
381 |
|
""" |
382 |
|
txt = '' |
383 |
< |
try: |
311 |
< |
self.copy_input_data = common.analisys_common_info['copy_input_data'] |
312 |
< |
#print "self.copy_input_data = ", self.copy_input_data |
313 |
< |
except KeyError: self.copy_input_data = 0 |
314 |
< |
if int(self.copy_input_data) == 1: |
383 |
> |
|
384 |
|
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
385 |
< |
txt += 'if [ $middleware == OSG ]; then\n' |
386 |
< |
txt += ' #\n' |
387 |
< |
txt += ' # Copy Input Data from SE to this WN deactivated in OSG mode\n' |
388 |
< |
txt += ' #\n' |
389 |
< |
txt += ' echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n' |
390 |
< |
txt += 'elif [ $middleware == LCG ]; then \n' |
391 |
< |
txt += ' #\n' |
392 |
< |
txt += ' # Copy Input Data from SE to this WN\n' |
393 |
< |
txt += ' #\n' |
394 |
< |
### changed by georgia (put a loop copying more than one input files per jobs) |
395 |
< |
txt += ' for input_file in $cur_file_list \n' |
396 |
< |
txt += ' do \n' |
397 |
< |
txt += ' lcg-cp --vo $VO lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n' |
398 |
< |
txt += ' copy_input_exit_status=$?\n' |
399 |
< |
txt += ' echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n' |
400 |
< |
txt += ' if [ $copy_input_exit_status -ne 0 ]; then \n' |
401 |
< |
txt += ' echo "Problems with copying to WN" \n' |
402 |
< |
txt += ' else \n' |
403 |
< |
txt += ' echo "input copied into WN" \n' |
404 |
< |
txt += ' fi \n' |
405 |
< |
txt += ' done \n' |
406 |
< |
### copy a set of PU ntuples (same for each jobs -- but accessed randomly) |
407 |
< |
txt += ' for file in $cur_pu_list \n' |
408 |
< |
txt += ' do \n' |
409 |
< |
txt += ' lcg-cp --vo $VO lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n' |
410 |
< |
txt += ' copy_input_exit_status=$?\n' |
411 |
< |
txt += ' echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n' |
412 |
< |
txt += ' if [ $copy_input_pu_exit_status -ne 0 ]; then \n' |
413 |
< |
txt += ' echo "Problems with copying pu to WN" \n' |
414 |
< |
txt += ' else \n' |
415 |
< |
txt += ' echo "input pu files copied into WN" \n' |
416 |
< |
txt += ' fi \n' |
417 |
< |
txt += ' done \n' |
418 |
< |
txt += ' \n' |
419 |
< |
txt += ' ### Check SCRATCH space available on WN : \n' |
420 |
< |
txt += ' df -h \n' |
421 |
< |
txt += 'fi \n' |
385 |
> |
txt += 'if [ $middleware == OSG ]; then\n' |
386 |
> |
txt += ' #\n' |
387 |
> |
txt += ' # Copy Input Data from SE to this WN deactivated in OSG mode\n' |
388 |
> |
txt += ' #\n' |
389 |
> |
txt += ' echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n' |
390 |
> |
txt += 'elif [ $middleware == LCG ]; then \n' |
391 |
> |
txt += ' #\n' |
392 |
> |
txt += ' # Copy Input Data from SE to this WN\n' |
393 |
> |
txt += ' #\n' |
394 |
> |
### changed by georgia (put a loop copying more than one input files per jobs) |
395 |
> |
txt += ' for input_file in $cur_file_list \n' |
396 |
> |
txt += ' do \n' |
397 |
> |
txt += ' lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n' |
398 |
> |
txt += ' copy_input_exit_status=$?\n' |
399 |
> |
txt += ' echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n' |
400 |
> |
txt += ' if [ $copy_input_exit_status -ne 0 ]; then \n' |
401 |
> |
txt += ' echo "Problems with copying to WN" \n' |
402 |
> |
txt += ' else \n' |
403 |
> |
txt += ' echo "input copied into WN" \n' |
404 |
> |
txt += ' fi \n' |
405 |
> |
txt += ' done \n' |
406 |
> |
### copy a set of PU ntuples (same for each jobs -- but accessed randomly) |
407 |
> |
txt += ' for file in $cur_pu_list \n' |
408 |
> |
txt += ' do \n' |
409 |
> |
txt += ' lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n' |
410 |
> |
txt += ' copy_input_pu_exit_status=$?\n' |
411 |
> |
txt += ' echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n' |
412 |
> |
txt += ' if [ $copy_input_pu_exit_status -ne 0 ]; then \n' |
413 |
> |
txt += ' echo "Problems with copying pu to WN" \n' |
414 |
> |
txt += ' else \n' |
415 |
> |
txt += ' echo "input pu files copied into WN" \n' |
416 |
> |
txt += ' fi \n' |
417 |
> |
txt += ' done \n' |
418 |
> |
txt += ' \n' |
419 |
> |
txt += ' ### Check SCRATCH space available on WN : \n' |
420 |
> |
txt += ' df -h \n' |
421 |
> |
txt += 'fi \n' |
422 |
|
|
423 |
|
return txt |
424 |
|
|
432 |
|
txt += '#\n' |
433 |
|
txt += '# Copy output to SE = $SE\n' |
434 |
|
txt += '#\n' |
435 |
< |
txt += 'if [ $exe_result -eq 0 ]; then\n' |
435 |
> |
txt += ' if [ $middleware == OSG ]; then\n' |
436 |
> |
txt += ' echo "X509_USER_PROXY = $X509_USER_PROXY"\n' |
437 |
> |
txt += ' echo "source $OSG_APP/glite/setup_glite_ui.sh"\n' |
438 |
> |
txt += ' source $OSG_APP/glite/setup_glite_ui.sh\n' |
439 |
> |
txt += ' export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n' |
440 |
> |
txt += ' echo "export X509_CERT_DIR=$X509_CERT_DIR"\n' |
441 |
> |
txt += ' fi \n' |
442 |
> |
|
443 |
|
txt += ' for out_file in $file_list ; do\n' |
444 |
< |
txt += ' echo "Trying to copy output file to $SE "\n' |
445 |
< |
## OLI_Daniele globus-* for OSG, lcg-* for LCG |
446 |
< |
txt += ' if [ $middleware == OSG ]; then\n' |
447 |
< |
txt += ' echo "globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
448 |
< |
txt += ' globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1 \n' |
449 |
< |
txt += ' copy_exit_status=$? \n' |
450 |
< |
txt += ' elif [ $middleware == LCG ]; then \n' |
451 |
< |
txt += ' echo "lcg-cp --vo cms -t 1200 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
452 |
< |
txt += ' lcg-cp --vo cms -t 1200 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1\n' |
453 |
< |
txt += ' copy_exit_status=$? \n' |
454 |
< |
txt += ' fi \n' |
455 |
< |
txt += ' echo "COPY_EXIT_STATUS = $copy_exit_status"\n' |
444 |
> |
txt += ' echo "Trying to copy output file to $SE using srmcp"\n' |
445 |
> |
txt += ' echo "mkdir -p $HOME/.srmconfig"\n' |
446 |
> |
txt += ' mkdir -p $HOME/.srmconfig\n' |
447 |
> |
txt += ' if [ $middleware == LCG ]; then\n' |
448 |
> |
txt += ' echo "srmcp -retry_num 3 -retry_timeout 480000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n' |
449 |
> |
txt += ' exitstring=`srmcp -retry_num 3 -retry_timeout 480000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n' |
450 |
> |
txt += ' elif [ $middleware == OSG ]; then\n' |
451 |
> |
txt += ' echo "srmcp -retry_num 3 -retry_timeout 240000 -x509_user_trusted_certificates $X509_CERT_DIR file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n' |
452 |
> |
txt += ' exitstring=`srmcp -retry_num 3 -retry_timeout 240000 -x509_user_trusted_certificates $X509_CERT_DIR file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n' |
453 |
> |
txt += ' fi \n' |
454 |
> |
txt += ' copy_exit_status=$?\n' |
455 |
> |
txt += ' echo "COPY_EXIT_STATUS for srmcp = $copy_exit_status"\n' |
456 |
|
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
457 |
+ |
|
458 |
|
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
459 |
< |
txt += ' echo "Problems with SE = $SE"\n' |
459 |
> |
txt += ' echo "Possible problem with SE = $SE"\n' |
460 |
|
txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n' |
461 |
|
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
462 |
+ |
txt += ' echo "srmcp failed, attempting lcg-cp."\n' |
463 |
+ |
if common.logger.debugLevel() >= 5: |
464 |
+ |
txt += ' echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
465 |
+ |
txt += ' exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
466 |
+ |
else: |
467 |
+ |
txt += ' echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
468 |
+ |
txt += ' exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
469 |
+ |
txt += ' copy_exit_status=$?\n' |
470 |
+ |
txt += ' echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n' |
471 |
+ |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
472 |
+ |
|
473 |
+ |
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
474 |
+ |
txt += ' echo "Problems with SE = $SE"\n' |
475 |
+ |
txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n' |
476 |
+ |
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
477 |
+ |
txt += ' echo "srmcp and lcg-cp and failed!"\n' |
478 |
+ |
txt += ' else\n' |
479 |
+ |
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
480 |
+ |
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
481 |
+ |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
482 |
+ |
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
483 |
+ |
txt += ' echo "lcg-cp succeeded"\n' |
484 |
+ |
txt += ' fi\n' |
485 |
|
txt += ' else\n' |
486 |
|
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
487 |
|
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
488 |
|
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
489 |
|
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
490 |
+ |
txt += ' echo "srmcp succeeded"\n' |
491 |
|
txt += ' fi\n' |
492 |
|
txt += ' done\n' |
392 |
– |
txt += 'fi\n' |
493 |
|
return txt |
494 |
|
|
495 |
|
def wsRegisterOutput(self): |
509 |
|
txt += '#\n' |
510 |
|
txt += '# Register output to LFC\n' |
511 |
|
txt += '#\n' |
512 |
< |
txt += ' if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
512 |
> |
txt += ' if [ $copy_exit_status -eq 0 ]; then\n' |
513 |
|
txt += ' for out_file in $file_list ; do\n' |
514 |
|
txt += ' echo "Trying to register the output file into LFC"\n' |
515 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n' |
516 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
515 |
> |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n' |
516 |
> |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
517 |
|
txt += ' register_exit_status=$?\n' |
518 |
|
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
519 |
|
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
520 |
|
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
521 |
|
txt += ' echo "Problems with the registration to LFC" \n' |
522 |
|
txt += ' echo "Try with srm protocol" \n' |
523 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n' |
524 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n' |
523 |
> |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n' |
524 |
> |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n' |
525 |
|
txt += ' register_exit_status=$?\n' |
526 |
|
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
527 |
|
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
533 |
|
txt += ' fi \n' |
534 |
|
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
535 |
|
txt += ' done\n' |
536 |
< |
txt += ' elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n' |
536 |
> |
txt += ' else \n' |
537 |
|
txt += ' echo "Trying to copy output file to CloseSE"\n' |
538 |
|
txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
539 |
|
txt += ' for out_file in $file_list ; do\n' |
540 |
< |
txt += ' echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n' |
541 |
< |
txt += ' lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file 2>&1 \n' |
540 |
> |
txt += ' echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://$RUNTIME_AREA/$out_file 2>&1" \n' |
541 |
> |
txt += ' lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://$RUNTIME_AREA/$out_file 2>&1 \n' |
542 |
|
txt += ' register_exit_status=$?\n' |
543 |
|
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
544 |
|
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
545 |
|
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
546 |
< |
txt += ' echo "Problems with CloseSE" \n' |
546 |
> |
txt += ' echo "Problems with CloseSE or Catalog" \n' |
547 |
|
txt += ' else \n' |
548 |
|
txt += ' echo "The program was successfully executed"\n' |
549 |
|
txt += ' echo "SE = $CLOSE_SE"\n' |
551 |
|
txt += ' fi \n' |
552 |
|
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
553 |
|
txt += ' done\n' |
454 |
– |
txt += ' else\n' |
455 |
– |
txt += ' echo "Problem with the executable"\n' |
554 |
|
txt += ' fi \n' |
555 |
+ |
txt += ' exit_status=$register_exit_status\n' |
556 |
|
txt += 'fi \n' |
557 |
|
return txt |
558 |
|
|
566 |
|
cmd_out = runCommand(cmd) |
567 |
|
return cmd_out |
568 |
|
|
470 |
– |
def listMatch(self, nj): |
471 |
– |
""" |
472 |
– |
Check the compatibility of available resources |
473 |
– |
""" |
474 |
– |
self.checkProxy() |
475 |
– |
jdl = common.job_list[nj].jdlFilename() |
476 |
– |
cmd = 'edg-job-list-match ' + self.configOpt_() + jdl |
477 |
– |
cmd_out = runCommand(cmd,0,10) |
478 |
– |
if not cmd_out: |
479 |
– |
raise CrabException("ERROR: "+cmd+" failed!") |
480 |
– |
|
481 |
– |
return self.parseListMatch_(cmd_out, jdl) |
482 |
– |
|
483 |
– |
def parseListMatch_(self, out, jdl): |
484 |
– |
""" |
485 |
– |
Parse the f* output of edg-list-match and produce something sensible |
486 |
– |
""" |
487 |
– |
reComment = re.compile( r'^\**$' ) |
488 |
– |
reEmptyLine = re.compile( r'^$' ) |
489 |
– |
reVO = re.compile( r'Selected Virtual Organisation name.*' ) |
490 |
– |
reLine = re.compile( r'.*') |
491 |
– |
reCE = re.compile( r'(.*:.*)') |
492 |
– |
reCEId = re.compile( r'CEId.*') |
493 |
– |
reNO = re.compile( r'No Computing Element matching' ) |
494 |
– |
reRB = re.compile( r'Connecting to host' ) |
495 |
– |
next = 0 |
496 |
– |
CEs=[] |
497 |
– |
Match=0 |
498 |
– |
|
499 |
– |
#print out |
500 |
– |
lines = reLine.findall(out) |
501 |
– |
|
502 |
– |
i=0 |
503 |
– |
CEs=[] |
504 |
– |
for line in lines: |
505 |
– |
string.strip(line) |
506 |
– |
#print line |
507 |
– |
if reNO.match( line ): |
508 |
– |
common.logger.debug(5,line) |
509 |
– |
return 0 |
510 |
– |
pass |
511 |
– |
if reVO.match( line ): |
512 |
– |
VO =reVO.match( line ).group() |
513 |
– |
common.logger.debug(5,"VO "+VO) |
514 |
– |
pass |
515 |
– |
|
516 |
– |
if reRB.match( line ): |
517 |
– |
RB = reRB.match(line).group() |
518 |
– |
common.logger.debug(5,"RB "+RB) |
519 |
– |
pass |
520 |
– |
|
521 |
– |
if reCEId.search( line ): |
522 |
– |
for lineCE in lines[i:-1]: |
523 |
– |
if reCE.match( lineCE ): |
524 |
– |
CE = string.strip(reCE.search(lineCE).group(1)) |
525 |
– |
CEs.append(CE.split(':')[0]) |
526 |
– |
pass |
527 |
– |
pass |
528 |
– |
pass |
529 |
– |
i=i+1 |
530 |
– |
pass |
531 |
– |
|
532 |
– |
common.logger.debug(5,"All CE :"+str(CEs)) |
533 |
– |
|
534 |
– |
sites = [] |
535 |
– |
[sites.append(it) for it in CEs if not sites.count(it)] |
536 |
– |
|
537 |
– |
common.logger.debug(5,"All Sites :"+str(sites)) |
538 |
– |
common.logger.message("Matched Sites :"+str(sites)) |
539 |
– |
return len(sites) |
540 |
– |
|
541 |
– |
def noMatchFound_(self, jdl): |
542 |
– |
reReq = re.compile( r'Requirements' ) |
543 |
– |
reString = re.compile( r'"\S*"' ) |
544 |
– |
f = file(jdl,'r') |
545 |
– |
for line in f.readlines(): |
546 |
– |
line= line.strip() |
547 |
– |
if reReq.match(line): |
548 |
– |
for req in reString.findall(line): |
549 |
– |
if re.search("VO",req): |
550 |
– |
common.logger.message( "SW required: "+req) |
551 |
– |
continue |
552 |
– |
if re.search('"\d+',req): |
553 |
– |
common.logger.message("Other req : "+req) |
554 |
– |
continue |
555 |
– |
common.logger.message( "CE required: "+req) |
556 |
– |
break |
557 |
– |
pass |
558 |
– |
raise CrabException("No compatible resources found!") |
559 |
– |
|
560 |
– |
def submit(self, nj): |
561 |
– |
""" |
562 |
– |
Submit one EDG job. |
563 |
– |
""" |
564 |
– |
|
565 |
– |
self.checkProxy() |
566 |
– |
jid = None |
567 |
– |
jdl = common.job_list[nj].jdlFilename() |
568 |
– |
|
569 |
– |
cmd = 'edg-job-submit ' + self.configOpt_() + jdl |
570 |
– |
cmd_out = runCommand(cmd) |
571 |
– |
if cmd_out != None: |
572 |
– |
reSid = re.compile( r'https.+' ) |
573 |
– |
jid = reSid.search(cmd_out).group() |
574 |
– |
pass |
575 |
– |
return jid |
576 |
– |
|
577 |
– |
def resubmit(self, nj_list): |
578 |
– |
""" |
579 |
– |
Prepare jobs to be submit |
580 |
– |
""" |
581 |
– |
return |
582 |
– |
|
569 |
|
def getExitStatus(self, id): |
570 |
|
return self.getStatusAttribute_(id, 'exit_code') |
571 |
|
|
588 |
|
# Instance of the Status class provided by LB API |
589 |
|
jobStat = Status() |
590 |
|
st = 0 |
591 |
+ |
#print id, level, attr, self.states.index(attr) |
592 |
|
jobStat.getStatus(id, level) |
593 |
+ |
#print jobStat.loadStatus(st) |
594 |
|
err, apiMsg = jobStat.get_error() |
595 |
|
if err: |
596 |
|
common.logger.debug(5,'Error caught' + apiMsg) |
599 |
|
for i in range(len(self.states)): |
600 |
|
# Fill an hash table with all information retrieved from LB API |
601 |
|
hstates[ self.states[i] ] = jobStat.loadStatus(st)[i] |
602 |
< |
result = jobStat.loadStatus(st)[ self.states.index(attr) ] |
602 |
> |
#print i, jobStat.loadStatus(st)[i] |
603 |
> |
result = jobStat.loadStatus(st)[self.states.index(attr)] |
604 |
> |
#print str(result) |
605 |
|
return result |
606 |
|
|
607 |
|
def queryDetailedStatus(self, id): |
610 |
|
cmd_out = runCommand(cmd) |
611 |
|
return cmd_out |
612 |
|
|
613 |
< |
def getOutput(self, id): |
613 |
> |
##### FEDE ###### |
614 |
> |
def findSites_(self, n): |
615 |
> |
itr4 =[] |
616 |
> |
sites = common.jobDB.destination(n) |
617 |
> |
if len(sites)>0 and sites[0]=="Any": |
618 |
> |
return itr4 |
619 |
> |
itr = '' |
620 |
> |
if sites != [""]:#CarlosDaniele |
621 |
> |
for site in sites: |
622 |
> |
#itr = itr + 'target.GlueSEUniqueID=="'+site+'" || ' |
623 |
> |
itr = itr + 'target.GlueSEUniqueID=="'+site+'" || ' |
624 |
> |
itr = itr[0:-4] |
625 |
> |
itr4.append( itr ) |
626 |
> |
return itr4 |
627 |
> |
|
628 |
> |
def createXMLSchScript(self, nj, argsList): |
629 |
> |
# def createXMLSchScript(self, nj): |
630 |
> |
|
631 |
> |
""" |
632 |
> |
Create a XML-file for BOSS4. |
633 |
|
""" |
634 |
< |
Get output for a finished job with id. |
635 |
< |
Returns the name of directory with results. |
634 |
> |
# job = common.job_list[nj] |
635 |
> |
""" |
636 |
> |
INDY |
637 |
> |
[begin] FIX-ME: |
638 |
> |
I would pass jobType instead of job |
639 |
> |
""" |
640 |
> |
index = nj - 1 |
641 |
> |
job = common.job_list[index] |
642 |
> |
jbt = job.type() |
643 |
> |
|
644 |
> |
inp_sandbox = jbt.inputSandbox(index) |
645 |
> |
out_sandbox = jbt.outputSandbox(index) |
646 |
> |
""" |
647 |
> |
[end] FIX-ME |
648 |
|
""" |
649 |
|
|
650 |
< |
self.checkProxy() |
651 |
< |
cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() + ' ' + id |
652 |
< |
cmd_out = runCommand(cmd) |
650 |
> |
|
651 |
> |
title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' |
652 |
> |
jt_string = '' |
653 |
> |
|
654 |
> |
xml_fname = str(self.jobtypeName)+'.xml' |
655 |
> |
xml = open(common.work_space.shareDir()+'/'+xml_fname, 'a') |
656 |
|
|
657 |
< |
# Determine the output directory name |
658 |
< |
dir = common.work_space.resDir() |
659 |
< |
dir += os.environ['USER'] |
660 |
< |
dir += '_' + os.path.basename(id) |
661 |
< |
return dir |
657 |
> |
#TaskName |
658 |
> |
dir = string.split(common.work_space.topDir(), '/') |
659 |
> |
taskName = dir[len(dir)-2] |
660 |
> |
|
661 |
> |
to_writeReq = '' |
662 |
> |
to_write = '' |
663 |
|
|
664 |
< |
def cancel(self, id): |
665 |
< |
""" Cancel the EDG job with id """ |
641 |
< |
self.checkProxy() |
642 |
< |
cmd = 'edg-job-cancel --noint ' + id |
643 |
< |
cmd_out = runCommand(cmd) |
644 |
< |
return cmd_out |
664 |
> |
req=' ' |
665 |
> |
req = req + jbt.getRequirements() |
666 |
|
|
646 |
– |
def createSchScript(self, nj): |
647 |
– |
""" |
648 |
– |
Create a JDL-file for EDG. |
649 |
– |
""" |
667 |
|
|
668 |
< |
job = common.job_list[nj] |
669 |
< |
jbt = job.type() |
670 |
< |
inp_sandbox = jbt.inputSandbox(nj) |
671 |
< |
out_sandbox = jbt.outputSandbox(nj) |
672 |
< |
inp_storage_subdir = '' |
668 |
> |
#sites = common.jobDB.destination(nj) |
669 |
> |
#if len(sites)>0 and sites[0]!="Any": |
670 |
> |
# req = req + ' && anyMatch(other.storage.CloseSEs, (_ITR4_))' |
671 |
> |
#req = req |
672 |
> |
|
673 |
> |
if self.EDG_requirements: |
674 |
> |
if (req == ' '): |
675 |
> |
req = req + self.EDG_requirements |
676 |
> |
else: |
677 |
> |
req = req + ' && ' + self.EDG_requirements |
678 |
> |
if self.EDG_ce_white_list: |
679 |
> |
ce_white_list = string.split(self.EDG_ce_white_list,',') |
680 |
> |
for i in range(len(ce_white_list)): |
681 |
> |
if i == 0: |
682 |
> |
if (req == ' '): |
683 |
> |
req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
684 |
> |
else: |
685 |
> |
req = req + ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
686 |
> |
pass |
687 |
> |
else: |
688 |
> |
req = req + ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
689 |
> |
req = req + ')' |
690 |
|
|
691 |
< |
title = '# This JDL was generated by '+\ |
692 |
< |
common.prog_name+' (version '+common.prog_version_str+')\n' |
693 |
< |
jt_string = '' |
691 |
> |
if self.EDG_ce_black_list: |
692 |
> |
ce_black_list = string.split(self.EDG_ce_black_list,',') |
693 |
> |
for ce in ce_black_list: |
694 |
> |
if (req == ' '): |
695 |
> |
req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))' |
696 |
> |
else: |
697 |
> |
req = req + ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))' |
698 |
> |
pass |
699 |
> |
if self.EDG_clock_time: |
700 |
> |
if (req == ' '): |
701 |
> |
req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
702 |
> |
else: |
703 |
> |
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
704 |
> |
|
705 |
> |
if self.EDG_cpu_time: |
706 |
> |
if (req == ' '): |
707 |
> |
req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
708 |
> |
else: |
709 |
> |
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
710 |
> |
|
711 |
> |
if ( self.EDG_retry_count ): |
712 |
> |
to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n' |
713 |
> |
pass |
714 |
|
|
715 |
+ |
to_write = to_write + 'MyProxyServer = ""' + self.proxyServer + '""\n' |
716 |
+ |
to_write = to_write + 'VirtualOrganisation = ""' + self.VO + '""\n' |
717 |
+ |
|
718 |
+ |
#TaskName |
719 |
+ |
dir = string.split(common.work_space.topDir(), '/') |
720 |
+ |
taskName = dir[len(dir)-2] |
721 |
+ |
|
722 |
+ |
xml.write(str(title)) |
723 |
+ |
xml.write('<task name="' +str(taskName)+'">\n') |
724 |
+ |
xml.write(jt_string) |
725 |
+ |
|
726 |
+ |
if (to_write != ''): |
727 |
+ |
xml.write('<extraTags\n') |
728 |
+ |
xml.write(to_write) |
729 |
+ |
xml.write('/>\n') |
730 |
+ |
pass |
731 |
|
|
732 |
+ |
xml.write('<iterator>\n') |
733 |
+ |
xml.write('\t<iteratorRule name="ITR1">\n') |
734 |
+ |
xml.write('\t\t<ruleElement> 1:'+ str(nj) + ' </ruleElement>\n') |
735 |
+ |
xml.write('\t</iteratorRule>\n') |
736 |
+ |
xml.write('\t<iteratorRule name="ITR2">\n') |
737 |
+ |
for arg in argsList: |
738 |
+ |
xml.write('\t\t<ruleElement> <![CDATA[\n'+ arg + '\n\t\t]]> </ruleElement>\n') |
739 |
+ |
pass |
740 |
+ |
xml.write('\t</iteratorRule>\n') |
741 |
+ |
#print jobList |
742 |
+ |
xml.write('\t<iteratorRule name="ITR3">\n') |
743 |
+ |
xml.write('\t\t<ruleElement> 1:'+ str(nj) + ':1:6 </ruleElement>\n') |
744 |
+ |
xml.write('\t</iteratorRule>\n') |
745 |
+ |
|
746 |
+ |
''' |
747 |
+ |
indy: here itr4 |
748 |
+ |
''' |
749 |
|
|
663 |
– |
SPL = inp_storage_subdir |
664 |
– |
if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/' |
750 |
|
|
751 |
< |
jdl_fname = job.jdlFilename() |
752 |
< |
jdl = open(jdl_fname, 'w') |
668 |
< |
jdl.write(title) |
751 |
> |
xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n') |
752 |
> |
xml.write(jt_string) |
753 |
|
|
754 |
< |
script = job.scriptFilename() |
671 |
< |
jdl.write('Executable = "' + os.path.basename(script) +'";\n') |
672 |
< |
jdl.write(jt_string) |
754 |
> |
#executable |
755 |
|
|
756 |
+ |
""" |
757 |
+ |
INDY |
758 |
+ |
script depends on jobType: it should be probably get in a different way |
759 |
+ |
""" |
760 |
+ |
script = job.scriptFilename() |
761 |
+ |
xml.write('<program>\n') |
762 |
+ |
xml.write('<exec> ' + os.path.basename(script) +' </exec>\n') |
763 |
+ |
xml.write(jt_string) |
764 |
+ |
|
765 |
+ |
|
766 |
|
### only one .sh JDL has arguments: |
675 |
– |
|
767 |
|
### Fabio |
768 |
< |
jdl.write('Arguments = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'";\n') |
769 |
< |
inp_box = 'InputSandbox = { ' |
770 |
< |
inp_box = inp_box + '"' + script + '",' |
768 |
> |
# xml.write('args = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'"\n') |
769 |
> |
xml.write('<args> <![CDATA[\n _ITR2_ \n]]> </args>\n') |
770 |
> |
xml.write('<program_types> crabjob </program_types>\n') |
771 |
> |
inp_box = script + ',' |
772 |
|
|
773 |
|
if inp_sandbox != None: |
774 |
|
for fl in inp_sandbox: |
775 |
< |
inp_box = inp_box + ' "' + fl + '",' |
775 |
> |
inp_box = inp_box + '' + fl + ',' |
776 |
|
pass |
777 |
|
pass |
778 |
|
|
779 |
< |
#if common.use_jam: |
780 |
< |
# inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",' |
781 |
< |
|
782 |
< |
# Marco (VERY TEMPORARY ML STUFF) |
783 |
< |
inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\ |
784 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + '", "'+\ |
693 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\ |
694 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\ |
695 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"' |
696 |
< |
# End Marco |
779 |
> |
inp_box = inp_box + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + ',' +\ |
780 |
> |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + ','+\ |
781 |
> |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + ','+\ |
782 |
> |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + ','+\ |
783 |
> |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + ','+\ |
784 |
> |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'parseCrabFjr.py') |
785 |
|
|
786 |
|
if (not jbt.additional_inbox_files == []): |
787 |
< |
inp_box = inp_box + ', ' |
787 |
> |
inp_box = inp_box + ',' |
788 |
|
for addFile in jbt.additional_inbox_files: |
789 |
|
addFile = os.path.abspath(addFile) |
790 |
< |
inp_box = inp_box+' "'+addFile+'",' |
790 |
> |
inp_box = inp_box+''+addFile+',' |
791 |
|
pass |
792 |
|
|
793 |
|
if inp_box[-1] == ',' : inp_box = inp_box[:-1] |
794 |
< |
inp_box = inp_box + ' };\n' |
795 |
< |
jdl.write(inp_box) |
708 |
< |
|
709 |
< |
jdl.write('StdOutput = "' + job.stdout() + '";\n') |
710 |
< |
jdl.write('StdError = "' + job.stderr() + '";\n') |
794 |
> |
inp_box = '<infiles> <![CDATA[\n' + inp_box + '\n]]> </infiles>\n' |
795 |
> |
xml.write(inp_box) |
796 |
|
|
797 |
+ |
base = jbt.name() |
798 |
+ |
stdout = base + '__ITR3_.stdout' |
799 |
+ |
stderr = base + '__ITR3_.stderr' |
800 |
|
|
801 |
< |
if job.stdout() == job.stderr(): |
802 |
< |
out_box = 'OutputSandbox = { "' + \ |
803 |
< |
job.stdout() + '", ".BrokerInfo",' |
804 |
< |
else: |
805 |
< |
out_box = 'OutputSandbox = { "' + \ |
806 |
< |
job.stdout() + '", "' + \ |
719 |
< |
job.stderr() + '", ".BrokerInfo",' |
801 |
> |
xml.write('<stderr> ' + stderr + '</stderr>\n') |
802 |
> |
xml.write('<stdout> ' + stdout + '</stdout>\n') |
803 |
> |
|
804 |
> |
|
805 |
> |
out_box = stdout + ',' + \ |
806 |
> |
stderr + ',.BrokerInfo,' |
807 |
|
|
808 |
+ |
""" |
809 |
|
if int(self.return_data) == 1: |
810 |
|
if out_sandbox != None: |
811 |
|
for fl in out_sandbox: |
812 |
< |
out_box = out_box + ' "' + fl + '",' |
812 |
> |
out_box = out_box + '' + fl + ',' |
813 |
|
pass |
814 |
|
pass |
815 |
|
pass |
816 |
< |
|
729 |
< |
if out_box[-1] == ',' : out_box = out_box[:-1] |
730 |
< |
out_box = out_box + ' };' |
731 |
< |
jdl.write(out_box+'\n') |
732 |
< |
|
816 |
> |
""" |
817 |
|
|
818 |
< |
req='Requirements = ' |
819 |
< |
noreq=req |
820 |
< |
req = req + jbt.getRequirements() |
821 |
< |
#### and USER REQUIREMENT |
822 |
< |
if self.EDG_requirements: |
823 |
< |
if (req != noreq): |
824 |
< |
req = req + ' && ' |
741 |
< |
req = req + self.EDG_requirements |
742 |
< |
#### FEDE ##### |
743 |
< |
if self.EDG_ce_white_list: |
744 |
< |
ce_white_list = string.split(self.EDG_ce_white_list,',') |
745 |
< |
#print "req = ", req |
746 |
< |
for i in range(len(ce_white_list)): |
747 |
< |
if i == 0: |
748 |
< |
if (req != noreq): |
749 |
< |
req = req + ' && ' |
750 |
< |
req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
751 |
< |
pass |
752 |
< |
else: |
753 |
< |
req = req + ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
754 |
< |
req = req + ')' |
755 |
< |
|
756 |
< |
if self.EDG_ce_black_list: |
757 |
< |
ce_black_list = string.split(self.EDG_ce_black_list,',') |
758 |
< |
for ce in ce_black_list: |
759 |
< |
if (req != noreq): |
760 |
< |
req = req + ' && ' |
761 |
< |
req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))' |
818 |
> |
""" |
819 |
> |
INDY |
820 |
> |
something similar should be also done for infiles (if it makes sense!) |
821 |
> |
""" |
822 |
> |
if int(self.return_data) == 1: |
823 |
> |
for fl in jbt.output_file: |
824 |
> |
out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ',' |
825 |
|
pass |
826 |
+ |
pass |
827 |
|
|
828 |
< |
############### |
829 |
< |
clockTime=480 |
830 |
< |
if self.EDG_clock_time: |
831 |
< |
clockTime= self.EDG_clock_time |
832 |
< |
if (req != noreq): |
769 |
< |
req = req + ' && ' |
770 |
< |
req = req + '((other.GlueCEPolicyMaxWallClockTime == 0) || (other.GlueCEPolicyMaxWallClockTime>='+str(clockTime)+'))' |
828 |
> |
if out_box[-1] == ',' : out_box = out_box[:-1] |
829 |
> |
out_box = '<outfiles> <![CDATA[\n' + out_box + '\n]]></outfiles>\n' |
830 |
> |
xml.write(out_box) |
831 |
> |
|
832 |
> |
xml.write('<BossAttr> crabjob.INTERNAL_ID=_ITR1_ </BossAttr>\n') |
833 |
|
|
834 |
< |
cpuTime=1000 |
835 |
< |
if self.EDG_cpu_time: |
774 |
< |
cpuTime=self.EDG_cpu_time |
775 |
< |
if (req != noreq): |
776 |
< |
req = req + ' && ' |
777 |
< |
req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))' |
778 |
< |
|
779 |
< |
if (req != noreq): |
780 |
< |
req = req + ';\n' |
781 |
< |
jdl.write(req) |
782 |
< |
|
783 |
< |
jdl.write('VirtualOrganisation = "' + self.VO + '";\n') |
834 |
> |
xml.write('</program>\n') |
835 |
> |
xml.write('</chain>\n') |
836 |
|
|
837 |
< |
if ( self.EDG_retry_count ): |
838 |
< |
jdl.write('RetryCount = '+self.EDG_retry_count+';\n') |
787 |
< |
pass |
837 |
> |
xml.write('</iterator>\n') |
838 |
> |
xml.write('</task>\n') |
839 |
|
|
840 |
< |
jdl.write('MyProxyServer = "' + self.proxyServer + '";\n') |
840 |
> |
xml.close() |
841 |
> |
|
842 |
|
|
791 |
– |
jdl.close() |
843 |
|
return |
844 |
|
|
845 |
|
def checkProxy(self): |
852 |
|
|
853 |
|
minTimeLeftServer = 100 # in hours |
854 |
|
|
804 |
– |
#cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00' |
805 |
– |
#cmd = 'voms-proxy-info -timeleft' |
855 |
|
mustRenew = 0 |
856 |
< |
timeLeftLocal = runCommand('voms-proxy-info -timeleft') |
856 |
> |
timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null') |
857 |
|
timeLeftServer = -999 |
858 |
|
if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal): |
859 |
|
mustRenew = 1 |
860 |
|
else: |
861 |
< |
timeLeftServer = runCommand('voms-proxy-info -actimeleft | head -1') |
861 |
> |
timeLeftServer = runCommand('voms-proxy-info -actimeleft 2>/dev/null | head -1') |
862 |
|
if not timeLeftServer or not isInt(timeLeftServer): |
863 |
|
mustRenew = 1 |
864 |
|
elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft: |
867 |
|
pass |
868 |
|
|
869 |
|
if mustRenew: |
870 |
< |
common.logger.message( "No valid proxy found or remaining time of validity of already existing proxy shorter than 10 hours!\n Creating a user proxy with default length of 96h\n") |
871 |
< |
cmd = 'voms-proxy-init -voms cms -valid 96:00' |
870 |
> |
common.logger.message( "No valid proxy found or remaining time of validity of already existing proxy shorter than 10 hours!\n Creating a user proxy with default length of 192h\n") |
871 |
> |
cmd = 'voms-proxy-init -voms '+self.VO |
872 |
> |
if self.group: |
873 |
> |
cmd += ':/'+self.VO+'/'+self.group |
874 |
> |
if self.role: |
875 |
> |
cmd += '/role='+self.role |
876 |
> |
cmd += ' -valid 192:00' |
877 |
|
try: |
878 |
|
# SL as above: damn it! |
879 |
+ |
common.logger.debug(10,cmd) |
880 |
|
out = os.system(cmd) |
881 |
|
if (out>0): raise CrabException("Unable to create a valid proxy!\n") |
882 |
|
except: |
883 |
|
msg = "Unable to create a valid proxy!\n" |
884 |
|
raise CrabException(msg) |
830 |
– |
# cmd = 'grid-proxy-info -timeleft' |
831 |
– |
# cmd_out = runCommand(cmd,0,20) |
885 |
|
pass |
886 |
|
|
887 |
|
## now I do have a voms proxy valid, and I check the myproxy server |