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