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 |
23 |
|
|
24 |
|
def configure(self, cfg_params): |
25 |
|
|
26 |
+ |
# init BlackWhiteListParser |
27 |
+ |
self.blackWhiteListParser = BlackWhiteListParser(cfg_params) |
28 |
+ |
|
29 |
+ |
self.proxyValid=0 |
30 |
+ |
try: self.dontCheckProxy=int(cfg_params["EDG.dont_check_proxy"]) |
31 |
+ |
except KeyError: self.dontCheckProxy = 0 |
32 |
+ |
|
33 |
|
try: |
34 |
< |
RB = cfg_params["EDG.rb"] |
35 |
< |
edgConfig = EdgConfig(RB) |
28 |
< |
self.edg_config = edgConfig.config() |
29 |
< |
self.edg_config_vo = edgConfig.configVO() |
34 |
> |
RB=cfg_params["EDG.rb"] |
35 |
> |
self.rb_param_file=self.rb_configure(RB) |
36 |
|
except KeyError: |
37 |
< |
self.edg_config = '' |
38 |
< |
self.edg_config_vo = '' |
33 |
< |
|
37 |
> |
self.rb_param_file='' |
38 |
> |
pass |
39 |
|
try: |
40 |
|
self.proxyServer = cfg_params["EDG.proxy_server"] |
41 |
|
except KeyError: |
55 |
|
try: self.LCG_version = cfg_params["EDG.lcg_version"] |
56 |
|
except KeyError: self.LCG_version = '2' |
57 |
|
|
53 |
– |
try: self.EDG_requirements = cfg_params['EDG.requirements'] |
54 |
– |
except KeyError: self.EDG_requirements = '' |
55 |
– |
|
56 |
– |
try: self.EDG_retry_count = cfg_params['EDG.retry_count'] |
57 |
– |
except KeyError: self.EDG_retry_count = '' |
58 |
– |
|
58 |
|
try: |
59 |
|
self.EDG_ce_black_list = cfg_params['EDG.ce_black_list'] |
61 |
– |
#print "self.EDG_ce_black_list = ", self.EDG_ce_black_list |
60 |
|
except KeyError: |
61 |
|
self.EDG_ce_black_list = '' |
62 |
|
|
63 |
|
try: |
64 |
|
self.EDG_ce_white_list = cfg_params['EDG.ce_white_list'] |
67 |
– |
#print "self.EDG_ce_white_list = ", self.EDG_ce_white_list |
65 |
|
except KeyError: self.EDG_ce_white_list = '' |
66 |
|
|
67 |
|
try: self.VO = cfg_params['EDG.virtual_organization'] |
68 |
|
except KeyError: self.VO = 'cms' |
69 |
|
|
70 |
+ |
try: self.copy_input_data = cfg_params["USER.copy_input_data"] |
71 |
+ |
except KeyError: self.copy_input_data = 0 |
72 |
+ |
|
73 |
|
try: self.return_data = cfg_params['USER.return_data'] |
74 |
|
except KeyError: self.return_data = 0 |
75 |
|
|
91 |
|
msg = msg + 'Please modify return_data and copy_data value in your crab.cfg file\n' |
92 |
|
raise CrabException(msg) |
93 |
|
|
94 |
+ |
########### FEDE FOR DBS2 ############################## |
95 |
+ |
try: |
96 |
+ |
self.publish_data = cfg_params["USER.publish_data"] |
97 |
+ |
self.checkProxy() |
98 |
+ |
if int(self.publish_data) == 1: |
99 |
+ |
try: |
100 |
+ |
self.publish_data_name = cfg_params['USER.publish_data_name'] |
101 |
+ |
except KeyError: |
102 |
+ |
msg = "Error. The [USER] section does not have 'publish_data_name'" |
103 |
+ |
raise CrabException(msg) |
104 |
+ |
try: |
105 |
+ |
tmp = runCommand("voms-proxy-info -identity") |
106 |
+ |
tmp = string.split(tmp,'/') |
107 |
+ |
reCN=re.compile(r'CN=') |
108 |
+ |
for t in tmp: |
109 |
+ |
if reCN.match(t): |
110 |
+ |
self.UserGridName=string.strip((t.replace('CN=','')).replace(' ','')) |
111 |
+ |
|
112 |
+ |
#self.UserGridName = string.strip(runCommand("voms-proxy-info -identity | awk -F\'CN\' \'{print $2$3$4}\' | tr -d \'=/ \'")) |
113 |
+ |
except: |
114 |
+ |
msg = "Error. Problem with voms-proxy-info -identity command" |
115 |
+ |
raise CrabException(msg) |
116 |
+ |
except KeyError: self.publish_data = 0 |
117 |
+ |
|
118 |
+ |
if ( int(self.copy_data) == 0 and int(self.publish_data) == 1 ): |
119 |
+ |
msg = 'Warning: publish_data = 1 must be used with copy_data = 1\n' |
120 |
+ |
msg = msg + 'Please modify copy_data value in your crab.cfg file\n' |
121 |
+ |
common.logger.message(msg) |
122 |
+ |
raise CrabException(msg) |
123 |
+ |
################################################# |
124 |
+ |
|
125 |
|
try: |
126 |
|
self.lfc_host = cfg_params['EDG.lfc_host'] |
127 |
|
except KeyError: |
164 |
|
|
165 |
|
try: self.EDG_requirements = cfg_params['EDG.requirements'] |
166 |
|
except KeyError: self.EDG_requirements = '' |
167 |
< |
|
167 |
> |
|
168 |
> |
try: self.EDG_addJdlParam = string.split(cfg_params['EDG.additional_jdl_parameters'],',') |
169 |
> |
except KeyError: self.EDG_addJdlParam = [] |
170 |
> |
|
171 |
|
try: self.EDG_retry_count = cfg_params['EDG.retry_count'] |
172 |
|
except KeyError: self.EDG_retry_count = '' |
173 |
< |
|
173 |
> |
|
174 |
> |
try: self.EDG_shallow_retry_count= cfg_params['EDG.shallow_retry_count'] |
175 |
> |
except KeyError: self.EDG_shallow_retry_count = '' |
176 |
> |
|
177 |
|
try: self.EDG_clock_time = cfg_params['EDG.max_wall_clock_time'] |
178 |
|
except KeyError: self.EDG_clock_time= '' |
179 |
< |
|
179 |
> |
|
180 |
|
try: self.EDG_cpu_time = cfg_params['EDG.max_cpu_time'] |
181 |
|
except KeyError: self.EDG_cpu_time = '' |
182 |
|
|
193 |
|
libPath=os.path.join(path, "lib", "python") |
194 |
|
sys.path.append(libPath) |
195 |
|
|
159 |
– |
self.proxyValid=0 |
160 |
– |
|
196 |
|
try: |
197 |
|
self._taskId = cfg_params['taskId'] |
198 |
|
except: |
207 |
|
return |
208 |
|
|
209 |
|
|
210 |
+ |
def rb_configure(self, RB): |
211 |
+ |
self.edg_config = '' |
212 |
+ |
self.edg_config_vo = '' |
213 |
+ |
self.rb_param_file = '' |
214 |
+ |
|
215 |
+ |
edgConfig = EdgConfig(RB) |
216 |
+ |
self.edg_config = edgConfig.config() |
217 |
+ |
self.edg_config_vo = edgConfig.configVO() |
218 |
+ |
|
219 |
+ |
if (self.edg_config and self.edg_config_vo != ''): |
220 |
+ |
self.rb_param_file = 'RBconfig = "'+self.edg_config+'";\nRBconfigVO = "'+self.edg_config_vo+'";\n' |
221 |
+ |
#print "rb_param_file = ", self.rb_param_file |
222 |
+ |
return self.rb_param_file |
223 |
+ |
|
224 |
+ |
|
225 |
|
def sched_parameter(self): |
226 |
|
""" |
227 |
|
Returns file with requirements and scheduler-specific parameters |
230 |
|
job = common.job_list[index] |
231 |
|
jbt = job.type() |
232 |
|
|
233 |
< |
lastDest='' |
233 |
> |
lastBlock=-1 |
234 |
|
first = [] |
185 |
– |
last = [] |
235 |
|
for n in range(common.jobDB.nJobs()): |
236 |
< |
currDest=common.jobDB.destination(n) |
237 |
< |
if (currDest!=lastDest): |
238 |
< |
lastDest = currDest |
236 |
> |
currBlock=common.jobDB.block(n) |
237 |
> |
if (currBlock!=lastBlock): |
238 |
> |
lastBlock = currBlock |
239 |
|
first.append(n) |
191 |
– |
if n != 0:last.append(n-1) |
192 |
– |
if len(first)>len(last) :last.append(common.jobDB.nJobs()) |
240 |
|
|
241 |
|
req = '' |
242 |
|
req = req + jbt.getRequirements() |
246 |
|
req = req + self.EDG_requirements |
247 |
|
else: |
248 |
|
req = req + ' && ' + self.EDG_requirements |
249 |
+ |
|
250 |
|
if self.EDG_ce_white_list: |
251 |
|
ce_white_list = string.split(self.EDG_ce_white_list,',') |
252 |
|
for i in range(len(ce_white_list)): |
253 |
|
if i == 0: |
254 |
|
if (req == ' '): |
255 |
< |
req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
255 |
> |
req = req + '((RegExp("' + string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))' |
256 |
|
else: |
257 |
< |
req = req + ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
257 |
> |
req = req + ' && ((RegExp("' + string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))' |
258 |
|
pass |
259 |
|
else: |
260 |
< |
req = req + ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
260 |
> |
req = req + ' || (RegExp("' + string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))' |
261 |
|
req = req + ')' |
262 |
|
|
263 |
|
if self.EDG_ce_black_list: |
264 |
|
ce_black_list = string.split(self.EDG_ce_black_list,',') |
265 |
|
for ce in ce_black_list: |
266 |
|
if (req == ' '): |
267 |
< |
req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))' |
267 |
> |
req = req + '(!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))' |
268 |
|
else: |
269 |
< |
req = req + ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))' |
269 |
> |
req = req + ' && (!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))' |
270 |
|
pass |
271 |
|
if self.EDG_clock_time: |
272 |
|
if (req == ' '): |
281 |
|
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
282 |
|
|
283 |
|
for i in range(len(first)): # Add loop DS |
284 |
+ |
groupReq = req |
285 |
|
self.param='sched_param_'+str(i)+'.clad' |
286 |
|
param_file = open(common.work_space.shareDir()+'/'+self.param, 'w') |
287 |
|
|
288 |
|
itr4=self.findSites_(first[i]) |
289 |
< |
if (itr4 != []): |
290 |
< |
req1='' |
291 |
< |
for arg in itr4: |
243 |
< |
req1 = req + ' && anyMatch(other.storage.CloseSEs, ('+str(arg)+'))' |
244 |
< |
param_file.write('Requirements = '+req1 +';\n') |
289 |
> |
for arg in itr4: |
290 |
> |
groupReq = groupReq + ' && anyMatch(other.storage.CloseSEs, ('+str(arg)+'))' |
291 |
> |
param_file.write('Requirements = '+groupReq +';\n') |
292 |
|
|
293 |
< |
if (self.edg_config and self.edg_config_vo != ''): |
294 |
< |
param_file.write('RBconfig = "'+self.edg_config+'";\n') |
295 |
< |
param_file.write('RBconfigVO = "'+self.edg_config_vo+'";') |
293 |
> |
if (self.rb_param_file != ''): |
294 |
> |
param_file.write(self.rb_param_file) |
295 |
> |
|
296 |
> |
if len(self.EDG_addJdlParam): |
297 |
> |
for p in self.EDG_addJdlParam: |
298 |
> |
param_file.write(p) |
299 |
|
|
300 |
|
param_file.close() |
301 |
|
|
335 |
|
txt += ' echo "middleware =$middleware" \n' |
336 |
|
txt += 'elif [ $VO_CMS_SW_DIR ]; then \n' |
337 |
|
txt += ' middleware=LCG \n' |
338 |
< |
txt += ' echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n' |
338 |
> |
# txt += ' echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n' |
339 |
> |
txt += ' echo "SyncCE=`glite-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n' |
340 |
|
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
341 |
|
txt += ' echo "middleware =$middleware" \n' |
342 |
|
txt += 'else \n' |
358 |
|
|
359 |
|
txt += '\n\n' |
360 |
|
|
361 |
< |
if int(self.copy_data) == 1: |
362 |
< |
if self.SE: |
363 |
< |
txt += 'export SE='+self.SE+'\n' |
364 |
< |
txt += 'echo "SE = $SE"\n' |
365 |
< |
if self.SE_PATH: |
366 |
< |
if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/' |
367 |
< |
txt += 'export SE_PATH='+self.SE_PATH+'\n' |
368 |
< |
txt += 'echo "SE_PATH = $SE_PATH"\n' |
361 |
> |
# if int(self.copy_data) == 1: |
362 |
> |
# if self.SE: |
363 |
> |
# txt += 'export SE='+self.SE+'\n' |
364 |
> |
# txt += 'echo "SE = $SE"\n' |
365 |
> |
# if self.SE_PATH: |
366 |
> |
# if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/' |
367 |
> |
# txt += 'export SE_PATH='+self.SE_PATH+'\n' |
368 |
> |
# txt += 'echo "SE_PATH = $SE_PATH"\n' |
369 |
|
|
370 |
|
txt += 'export VO='+self.VO+'\n' |
371 |
|
### add some line for LFC catalog setting |
409 |
|
txt += '\n' |
410 |
|
|
411 |
|
txt += 'if [ $middleware == LCG ]; then\n' |
412 |
< |
txt += ' CloseCEs=`edg-brokerinfo getCE`\n' |
412 |
> |
# txt += ' CloseCEs=`edg-brokerinfo getCE`\n' |
413 |
> |
txt += ' CloseCEs=`glite-brokerinfo getCE`\n' |
414 |
|
txt += ' echo "CloseCEs = $CloseCEs"\n' |
415 |
|
txt += ' CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
416 |
|
txt += ' echo "CE = $CE"\n' |
436 |
|
Copy input data from SE to WN |
437 |
|
""" |
438 |
|
txt = '' |
439 |
+ |
if not self.copy_input_data: return txt |
440 |
|
|
441 |
|
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
442 |
|
txt += 'if [ $middleware == OSG ]; then\n' |
484 |
|
Write a CopyResults part of a job script, e.g. |
485 |
|
to copy produced output into a storage element. |
486 |
|
""" |
487 |
< |
txt = '' |
435 |
< |
if int(self.copy_data) == 1: |
436 |
< |
txt += '#\n' |
437 |
< |
txt += '# Copy output to SE = $SE\n' |
438 |
< |
txt += '#\n' |
439 |
< |
txt += ' if [ $middleware == OSG ]; then\n' |
440 |
< |
txt += ' echo "X509_USER_PROXY = $X509_USER_PROXY"\n' |
441 |
< |
txt += ' echo "source $OSG_APP/glite/setup_glite_ui.sh"\n' |
442 |
< |
txt += ' source $OSG_APP/glite/setup_glite_ui.sh\n' |
443 |
< |
txt += ' export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n' |
444 |
< |
txt += ' echo "export X509_CERT_DIR=$X509_CERT_DIR"\n' |
445 |
< |
txt += ' fi \n' |
446 |
< |
|
447 |
< |
txt += ' for out_file in $file_list ; do\n' |
448 |
< |
txt += ' echo "Trying to copy output file to $SE using srmcp"\n' |
449 |
< |
txt += ' echo "mkdir -p $HOME/.srmconfig"\n' |
450 |
< |
txt += ' mkdir -p $HOME/.srmconfig\n' |
451 |
< |
txt += ' if [ $middleware == LCG ]; then\n' |
452 |
< |
txt += ' echo "srmcp -retry_num 3 -retry_timeout 480000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n' |
453 |
< |
txt += ' exitstring=`srmcp -retry_num 3 -retry_timeout 480000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n' |
454 |
< |
txt += ' elif [ $middleware == OSG ]; then\n' |
455 |
< |
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' |
456 |
< |
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' |
457 |
< |
txt += ' fi \n' |
458 |
< |
txt += ' copy_exit_status=$?\n' |
459 |
< |
txt += ' echo "COPY_EXIT_STATUS for srmcp = $copy_exit_status"\n' |
460 |
< |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
461 |
< |
|
462 |
< |
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
463 |
< |
txt += ' echo "Possible problem with SE = $SE"\n' |
464 |
< |
txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n' |
465 |
< |
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
466 |
< |
txt += ' echo "srmcp failed, attempting lcg-cp."\n' |
467 |
< |
if common.logger.debugLevel() >= 5: |
468 |
< |
txt += ' echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
469 |
< |
txt += ' exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
470 |
< |
else: |
471 |
< |
txt += ' echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
472 |
< |
txt += ' exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
473 |
< |
txt += ' copy_exit_status=$?\n' |
474 |
< |
txt += ' echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n' |
475 |
< |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
476 |
< |
|
477 |
< |
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
478 |
< |
txt += ' echo "Problems with SE = $SE"\n' |
479 |
< |
txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n' |
480 |
< |
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
481 |
< |
txt += ' echo "srmcp and lcg-cp and failed!"\n' |
482 |
< |
txt += ' else\n' |
483 |
< |
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
484 |
< |
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
485 |
< |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
486 |
< |
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
487 |
< |
txt += ' echo "lcg-cp succeeded"\n' |
488 |
< |
txt += ' fi\n' |
489 |
< |
txt += ' else\n' |
490 |
< |
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
491 |
< |
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
492 |
< |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
493 |
< |
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
494 |
< |
txt += ' echo "srmcp succeeded"\n' |
495 |
< |
txt += ' fi\n' |
496 |
< |
txt += ' done\n' |
497 |
< |
return txt |
487 |
> |
txt = '\n' |
488 |
|
|
489 |
< |
def wsRegisterOutput(self): |
490 |
< |
""" |
491 |
< |
Returns part of a job script which does scheduler-specific work. |
502 |
< |
""" |
489 |
> |
txt += '#\n' |
490 |
> |
txt += '# COPY OUTPUT FILE TO SE\n' |
491 |
> |
txt += '#\n\n' |
492 |
|
|
493 |
< |
txt = '' |
494 |
< |
if int(self.register_data) == 1: |
495 |
< |
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
496 |
< |
txt += 'if [ $middleware == OSG ]; then\n' |
497 |
< |
txt += ' #\n' |
498 |
< |
txt += ' # Register output to LFC deactivated in OSG mode\n' |
499 |
< |
txt += ' #\n' |
500 |
< |
txt += ' echo "Register output to LFC deactivated in OSG mode"\n' |
501 |
< |
txt += 'elif [ $middleware == LCG ]; then \n' |
502 |
< |
txt += '#\n' |
503 |
< |
txt += '# Register output to LFC\n' |
504 |
< |
txt += '#\n' |
505 |
< |
txt += ' if [ $copy_exit_status -eq 0 ]; then\n' |
506 |
< |
txt += ' for out_file in $file_list ; do\n' |
507 |
< |
txt += ' echo "Trying to register the output file into LFC"\n' |
508 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n' |
509 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
510 |
< |
txt += ' register_exit_status=$?\n' |
511 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
512 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
513 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
514 |
< |
txt += ' echo "Problems with the registration to LFC" \n' |
515 |
< |
txt += ' echo "Try with srm protocol" \n' |
516 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n' |
517 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n' |
518 |
< |
txt += ' register_exit_status=$?\n' |
519 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
520 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
521 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
522 |
< |
txt += ' echo "Problems with the registration into LFC" \n' |
523 |
< |
txt += ' fi \n' |
524 |
< |
txt += ' else \n' |
525 |
< |
txt += ' echo "output registered to LFC"\n' |
526 |
< |
txt += ' fi \n' |
527 |
< |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
528 |
< |
txt += ' done\n' |
529 |
< |
txt += ' else \n' |
530 |
< |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
531 |
< |
txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
532 |
< |
txt += ' for out_file in $file_list ; do\n' |
533 |
< |
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' |
534 |
< |
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' |
535 |
< |
txt += ' register_exit_status=$?\n' |
536 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
537 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
538 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
539 |
< |
txt += ' echo "Problems with CloseSE or Catalog" \n' |
540 |
< |
txt += ' else \n' |
552 |
< |
txt += ' echo "The program was successfully executed"\n' |
553 |
< |
txt += ' echo "SE = $CLOSE_SE"\n' |
554 |
< |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
555 |
< |
txt += ' fi \n' |
556 |
< |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
557 |
< |
txt += ' done\n' |
558 |
< |
txt += ' fi \n' |
559 |
< |
txt += ' exit_status=$register_exit_status\n' |
560 |
< |
txt += 'fi \n' |
493 |
> |
SE_PATH='' |
494 |
> |
if int(self.copy_data) == 1: |
495 |
> |
if self.SE: |
496 |
> |
txt += 'export SE='+self.SE+'\n' |
497 |
> |
txt += 'echo "SE = $SE"\n' |
498 |
> |
if self.SE_PATH: |
499 |
> |
if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/' |
500 |
> |
SE_PATH=self.SE_PATH |
501 |
> |
if int(self.publish_data) == 1: |
502 |
> |
txt += '### publish_data = 1 so the SE path where to copy the output is: \n' |
503 |
> |
path_add = self.UserGridName + '/' + self.publish_data_name +'_${PSETHASH}/' |
504 |
> |
SE_PATH = SE_PATH + path_add |
505 |
> |
txt += 'export SE_PATH='+SE_PATH+'\n' |
506 |
> |
txt += 'echo "SE_PATH = $SE_PATH"\n' |
507 |
> |
|
508 |
> |
txt += 'echo "####################################################"\n' |
509 |
> |
txt += 'echo "# Copy output files from WN = `hostname` to SE = $SE"\n' |
510 |
> |
txt += 'echo "####################################################"\n' |
511 |
> |
|
512 |
> |
txt += 'for out_file in $file_list ; do\n' |
513 |
> |
txt += ' echo "Trying to copy output file to $SE using srmcp"\n' |
514 |
> |
txt += ' cmscp $out_file ${SE} ${SE_PATH} $out_file $middleware\n' |
515 |
> |
txt += ' copy_exit_status=$?\n' |
516 |
> |
txt += ' echo "COPY_EXIT_STATUS for srmcp = $copy_exit_status"\n' |
517 |
> |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
518 |
> |
|
519 |
> |
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
520 |
> |
txt += ' echo "Problem copying $out_file to $SE $SE_PATH"\n' |
521 |
> |
txt += ' echo "StageOutExitStatus = $copy_exit_status " | tee -a $RUNTIME_AREA/$repo\n' |
522 |
> |
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
523 |
> |
txt += ' copy_exit_status=60307\n' |
524 |
> |
|
525 |
> |
txt += ' else\n' |
526 |
> |
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
527 |
> |
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
528 |
> |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
529 |
> |
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
530 |
> |
txt += ' echo "srmcp succeeded"\n' |
531 |
> |
txt += ' fi\n' |
532 |
> |
txt += 'done\n' |
533 |
> |
txt += 'if [ $copy_exit_status -ne 0 ]; then\n' |
534 |
> |
txt += ' SE=""\n' |
535 |
> |
txt += ' echo "SE = $SE"\n' |
536 |
> |
txt += ' SE_PATH=""\n' |
537 |
> |
txt += ' echo "SE_PATH = $SE_PATH"\n' |
538 |
> |
txt += 'fi\n' |
539 |
> |
txt += 'exit_status=$copy_exit_status\n' |
540 |
> |
pass |
541 |
|
return txt |
542 |
|
|
543 |
|
def loggingInfo(self, id): |
546 |
|
""" |
547 |
|
self.checkProxy() |
548 |
|
cmd = 'edg-job-get-logging-info -v 2 ' + id |
569 |
– |
#cmd_out = os.popen(cmd) |
549 |
|
cmd_out = runCommand(cmd) |
550 |
|
return cmd_out |
551 |
|
|
573 |
– |
def getExitStatus(self, id): |
574 |
– |
return self.getStatusAttribute_(id, 'exit_code') |
575 |
– |
|
576 |
– |
def queryStatus(self, id): |
577 |
– |
return self.getStatusAttribute_(id, 'status') |
578 |
– |
|
579 |
– |
def queryDest(self, id): |
580 |
– |
return self.getStatusAttribute_(id, 'destination') |
581 |
– |
|
582 |
– |
|
583 |
– |
def getStatusAttribute_(self, id, attr): |
584 |
– |
""" Query a status of the job with id """ |
585 |
– |
|
586 |
– |
self.checkProxy() |
587 |
– |
hstates = {} |
588 |
– |
Status = importName('edg_wl_userinterface_common_LbWrapper', 'Status') |
589 |
– |
# Bypass edg-job-status interfacing directly to C++ API |
590 |
– |
# Job attribute vector to retrieve status without edg-job-status |
591 |
– |
level = 0 |
592 |
– |
# Instance of the Status class provided by LB API |
593 |
– |
jobStat = Status() |
594 |
– |
st = 0 |
595 |
– |
jobStat.getStatus(id, level) |
596 |
– |
err, apiMsg = jobStat.get_error() |
597 |
– |
if err: |
598 |
– |
common.logger.debug(5,'Error caught' + apiMsg) |
599 |
– |
return None |
600 |
– |
else: |
601 |
– |
for i in range(len(self.states)): |
602 |
– |
# Fill an hash table with all information retrieved from LB API |
603 |
– |
hstates[ self.states[i] ] = jobStat.loadStatus(st)[i] |
604 |
– |
result = jobStat.loadStatus(st)[self.states.index(attr)] |
605 |
– |
return result |
606 |
– |
|
552 |
|
def queryDetailedStatus(self, id): |
553 |
|
""" Query a detailed status of the job with id """ |
554 |
|
cmd = 'edg-job-status '+id |
555 |
|
cmd_out = runCommand(cmd) |
556 |
|
return cmd_out |
557 |
|
|
613 |
– |
##### FEDE ###### |
558 |
|
def findSites_(self, n): |
559 |
|
itr4 =[] |
560 |
+ |
|
561 |
|
sites = common.jobDB.destination(n) |
562 |
< |
if len(sites)>0 and sites[0]=="Any": |
562 |
> |
|
563 |
> |
if len(sites)>0 and sites[0]=="": |
564 |
|
return itr4 |
565 |
+ |
|
566 |
|
itr = '' |
567 |
|
if sites != [""]:#CarlosDaniele |
568 |
< |
for site in sites: |
568 |
> |
##Addedd Daniele |
569 |
> |
replicas = self.blackWhiteListParser.checkBlackList(sites,n) |
570 |
> |
if len(replicas)!=0: |
571 |
> |
replicas = self.blackWhiteListParser.checkWhiteList(replicas,n) |
572 |
> |
|
573 |
> |
if len(replicas)==0: |
574 |
> |
msg = 'No sites remaining that host any part of the requested data! Exiting... ' |
575 |
> |
raise CrabException(msg) |
576 |
> |
##### |
577 |
> |
# for site in sites: |
578 |
> |
for site in replicas: |
579 |
|
#itr = itr + 'target.GlueSEUniqueID=="'+site+'" || ' |
580 |
|
itr = itr + 'target.GlueSEUniqueID=="'+site+'" || ' |
581 |
|
itr = itr[0:-4] |
583 |
|
return itr4 |
584 |
|
|
585 |
|
def createXMLSchScript(self, nj, argsList): |
629 |
– |
# def createXMLSchScript(self, nj): |
586 |
|
|
587 |
|
""" |
588 |
|
Create a XML-file for BOSS4. |
598 |
|
jbt = job.type() |
599 |
|
|
600 |
|
inp_sandbox = jbt.inputSandbox(index) |
601 |
< |
out_sandbox = jbt.outputSandbox(index) |
601 |
> |
#out_sandbox = jbt.outputSandbox(index) |
602 |
|
""" |
603 |
|
[end] FIX-ME |
604 |
|
""" |
614 |
|
dir = string.split(common.work_space.topDir(), '/') |
615 |
|
taskName = dir[len(dir)-2] |
616 |
|
|
661 |
– |
to_writeReq = '' |
617 |
|
to_write = '' |
618 |
|
|
619 |
|
req=' ' |
620 |
|
req = req + jbt.getRequirements() |
621 |
|
|
667 |
– |
|
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 |
– |
|
622 |
|
if self.EDG_requirements: |
623 |
|
if (req == ' '): |
624 |
|
req = req + self.EDG_requirements |
661 |
|
to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n' |
662 |
|
pass |
663 |
|
|
664 |
+ |
if ( self.EDG_shallow_retry_count ): |
665 |
+ |
to_write = to_write + 'ShallowRetryCount = "'+self.EDG_shallow_retry_count+'"\n' |
666 |
+ |
pass |
667 |
+ |
|
668 |
|
to_write = to_write + 'MyProxyServer = ""' + self.proxyServer + '""\n' |
669 |
|
to_write = to_write + 'VirtualOrganisation = ""' + self.VO + '""\n' |
670 |
|
|
671 |
< |
#TaskName |
671 |
> |
#TaskName |
672 |
|
dir = string.split(common.work_space.topDir(), '/') |
673 |
|
taskName = dir[len(dir)-2] |
674 |
|
|
675 |
|
xml.write(str(title)) |
676 |
< |
xml.write('<task name="' +str(taskName)+'">\n') |
676 |
> |
#xml.write('<task name="' +str(taskName)+'" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache">\n') |
677 |
> |
|
678 |
> |
#xml.write('<task name="' +str(taskName)+ '" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache"' + '" task_info="' + os.path.expandvars('X509_USER_PROXY') + '">\n') |
679 |
> |
x509_cmd = 'ls /tmp/x509up_u`id -u`' |
680 |
> |
x509=runCommand(x509_cmd).strip() |
681 |
> |
xml.write('<task name="' +str(taskName)+ '" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache"' + ' task_info="' + str(x509) + '">\n') |
682 |
|
xml.write(jt_string) |
683 |
|
|
684 |
|
if (to_write != ''): |
705 |
|
indy: here itr4 |
706 |
|
''' |
707 |
|
|
708 |
< |
|
709 |
< |
xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n') |
708 |
> |
xml.write('<chain name="' +str(taskName)+'__ITR1_" scheduler="'+str(self.schedulerName)+'">\n') |
709 |
> |
# xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n') |
710 |
|
xml.write(jt_string) |
711 |
|
|
712 |
|
#executable |
719 |
|
xml.write('<program>\n') |
720 |
|
xml.write('<exec> ' + os.path.basename(script) +' </exec>\n') |
721 |
|
xml.write(jt_string) |
722 |
< |
|
765 |
< |
|
766 |
< |
### only one .sh JDL has arguments: |
767 |
< |
### Fabio |
768 |
< |
# xml.write('args = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'"\n') |
722 |
> |
|
723 |
|
xml.write('<args> <![CDATA[\n _ITR2_ \n]]> </args>\n') |
724 |
|
xml.write('<program_types> crabjob </program_types>\n') |
725 |
< |
inp_box = script + ',' |
725 |
> |
inp_box = common.work_space.pathForTgz() + 'job/' + jbt.scriptName + ',' |
726 |
|
|
727 |
|
if inp_sandbox != None: |
728 |
|
for fl in inp_sandbox: |
730 |
|
pass |
731 |
|
pass |
732 |
|
|
733 |
< |
inp_box = inp_box + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + ',' +\ |
734 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + ','+\ |
735 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + ','+\ |
736 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + ','+\ |
737 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') |
738 |
< |
|
785 |
< |
if (not jbt.additional_inbox_files == []): |
786 |
< |
inp_box = inp_box + ',' |
787 |
< |
for addFile in jbt.additional_inbox_files: |
788 |
< |
addFile = os.path.abspath(addFile) |
789 |
< |
inp_box = inp_box+''+addFile+',' |
790 |
< |
pass |
733 |
> |
# if (not jbt.additional_inbox_files == []): |
734 |
> |
# inp_box = inp_box + ',' |
735 |
> |
# for addFile in jbt.additional_inbox_files: |
736 |
> |
# #addFile = os.path.abspath(addFile) |
737 |
> |
# inp_box = inp_box+''+addFile+',' |
738 |
> |
# pass |
739 |
|
|
740 |
|
if inp_box[-1] == ',' : inp_box = inp_box[:-1] |
741 |
|
inp_box = '<infiles> <![CDATA[\n' + inp_box + '\n]]> </infiles>\n' |
766 |
|
INDY |
767 |
|
something similar should be also done for infiles (if it makes sense!) |
768 |
|
""" |
769 |
+ |
# Stuff to be returned _always_ via sandbox |
770 |
+ |
for fl in jbt.output_file_sandbox: |
771 |
+ |
out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ',' |
772 |
+ |
pass |
773 |
+ |
pass |
774 |
+ |
|
775 |
+ |
# via sandbox iif required return_data |
776 |
|
if int(self.return_data) == 1: |
777 |
|
for fl in jbt.output_file: |
778 |
|
out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ',' |
801 |
|
Function to check the Globus proxy. |
802 |
|
""" |
803 |
|
if (self.proxyValid): return |
804 |
< |
timeleft = -999 |
804 |
> |
|
805 |
> |
### Just return if asked to do so |
806 |
> |
if (self.dontCheckProxy==1): |
807 |
> |
self.proxyValid=1 |
808 |
> |
return |
809 |
> |
|
810 |
|
minTimeLeft=10*3600 # in seconds |
811 |
|
|
812 |
|
minTimeLeftServer = 100 # in hours |
826 |
|
pass |
827 |
|
|
828 |
|
if mustRenew: |
829 |
< |
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") |
829 |
> |
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") |
830 |
|
cmd = 'voms-proxy-init -voms '+self.VO |
831 |
|
if self.group: |
832 |
|
cmd += ':/'+self.VO+'/'+self.group |
833 |
|
if self.role: |
834 |
|
cmd += '/role='+self.role |
835 |
< |
cmd += ' -valid 96:00' |
835 |
> |
cmd += ' -valid 192:00' |
836 |
|
try: |
837 |
|
# SL as above: damn it! |
838 |
|
common.logger.debug(10,cmd) |
855 |
|
reTime = re.compile( r'timeleft: (\d+)' ) |
856 |
|
#print "<"+str(reTime.search( cmd_out ).group(1))+">" |
857 |
|
if reTime.match( cmd_out ): |
858 |
< |
time = reTime.search( line ).group(1) |
858 |
> |
time = reTime.search( cmd_out ).group(1) |
859 |
|
if time < minTimeLeftServer: |
860 |
|
renewProxy = 1 |
861 |
|
common.logger.message('No credential delegation will expire in '+time+' hours: renew it') |
881 |
|
if self.edg_config_vo: |
882 |
|
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
883 |
|
return edg_ui_cfg_opt |
884 |
+ |
|
885 |
+ |
def submitTout(self, list): |
886 |
+ |
return 120 |
887 |
+ |
|
888 |
+ |
|