2 |
|
from crab_logger import Logger |
3 |
|
from crab_exceptions import * |
4 |
|
from crab_util import * |
5 |
+ |
from EdgConfig import * |
6 |
|
import common |
7 |
|
|
8 |
|
import os, sys, time |
22 |
|
|
23 |
|
def configure(self, cfg_params): |
24 |
|
|
25 |
< |
try: self.edg_config = cfg_params["EDG.config"] |
26 |
< |
except KeyError: self.edg_config = '' |
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() |
30 |
> |
except KeyError: |
31 |
> |
self.edg_config = '' |
32 |
> |
self.edg_config_vo = '' |
33 |
|
|
34 |
< |
try: self.edg_config_vo = cfg_params["EDG.config_vo"] |
35 |
< |
except KeyError: self.edg_config_vo = '' |
34 |
> |
try: |
35 |
> |
self.proxyServer = cfg_params["EDG.proxy_server"] |
36 |
> |
except KeyError: |
37 |
> |
self.proxyServer = 'myproxy.cern.ch' |
38 |
> |
common.logger.debug(5,'Setting myproxy server to '+self.proxyServer) |
39 |
|
|
40 |
|
try: self.LCG_version = cfg_params["EDG.lcg_version"] |
41 |
|
except KeyError: self.LCG_version = '2' |
46 |
|
try: self.EDG_retry_count = cfg_params['EDG.retry_count'] |
47 |
|
except KeyError: self.EDG_retry_count = '' |
48 |
|
|
49 |
+ |
try: |
50 |
+ |
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 |
58 |
+ |
except KeyError: self.EDG_ce_white_list = '' |
59 |
+ |
|
60 |
|
try: self.VO = cfg_params['EDG.virtual_organization'] |
61 |
|
except KeyError: self.VO = 'cms' |
62 |
|
|
63 |
+ |
try: self.return_data = cfg_params['USER.return_data'] |
64 |
+ |
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 |
70 |
|
|
47 |
– |
try: self.return_data = cfg_params['USER.return_data'] |
48 |
– |
except KeyError: self.return_data = 1 |
49 |
– |
|
71 |
|
try: |
72 |
|
self.copy_data = cfg_params["USER.copy_data"] |
73 |
|
if int(self.copy_data) == 1: |
174 |
|
""" |
175 |
|
Returns part of a job script which does scheduler-specific work. |
176 |
|
""" |
156 |
– |
|
177 |
|
txt = '' |
178 |
+ |
txt += 'echo "middleware discovery " \n' |
179 |
+ |
txt += 'if [ $VO_CMS_SW_DIR ]; then\n' |
180 |
+ |
txt += ' middleware=LCG \n' |
181 |
+ |
txt += ' echo "middleware =$middleware" \n' |
182 |
+ |
txt += 'elif [ $GRID3_APP_DIR ]; then\n' |
183 |
+ |
txt += ' middleware=OSG \n' |
184 |
+ |
txt += ' echo "middleware =$middleware" \n' |
185 |
+ |
txt += 'elif [ $OSG_APP ]; then \n' |
186 |
+ |
txt += ' middleware=OSG \n' |
187 |
+ |
txt += ' echo "middleware =$middleware" \n' |
188 |
+ |
txt += 'else \n' |
189 |
+ |
txt += ' echo "SET_CMS_ENV 1 ==> middleware not identified" \n' |
190 |
+ |
txt += ' echo "JOB_EXIT_STATUS = 1"\n' |
191 |
+ |
txt += ' exit 1\n' |
192 |
+ |
txt += 'fi\n' |
193 |
+ |
|
194 |
+ |
txt += '\n\n' |
195 |
+ |
|
196 |
+ |
txt += 'if [ $middleware == LCG ]; then \n' |
197 |
+ |
txt += ' echo "SyncGridJobId=`echo $EDG_WL_JOBID`" | tee -a $RUNTIME_AREA/$repo\n' |
198 |
+ |
txt += 'fi\n' |
199 |
+ |
|
200 |
|
if int(self.copy_data) == 1: |
201 |
|
if self.SE: |
202 |
|
txt += 'export SE='+self.SE+'\n' |
205 |
|
if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/' |
206 |
|
txt += 'export SE_PATH='+self.SE_PATH+'\n' |
207 |
|
txt += 'echo "SE_PATH = $SE_PATH"\n' |
208 |
< |
|
208 |
> |
|
209 |
|
txt += 'export VO='+self.VO+'\n' |
210 |
|
### FEDE: add some line for LFC catalog setting |
211 |
< |
txt += 'if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n' |
212 |
< |
txt += ' export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n' |
213 |
< |
txt += 'fi\n' |
214 |
< |
txt += 'if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n' |
215 |
< |
txt += 'export LFC_HOST='+self.lfc_host+'\n' |
216 |
< |
txt += 'fi\n' |
217 |
< |
txt += 'if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n' |
218 |
< |
txt += 'export LFC_HOME='+self.lfc_home+'\n' |
211 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
212 |
> |
txt += ' if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n' |
213 |
> |
txt += ' export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n' |
214 |
> |
txt += ' fi\n' |
215 |
> |
txt += ' if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n' |
216 |
> |
txt += ' export LFC_HOST='+self.lfc_host+'\n' |
217 |
> |
txt += ' fi\n' |
218 |
> |
txt += ' if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n' |
219 |
> |
txt += ' export LFC_HOME='+self.lfc_home+'\n' |
220 |
> |
txt += ' fi\n' |
221 |
> |
txt += 'elif [ $middleware == OSG ]; then\n' |
222 |
> |
txt += ' echo "LFC catalog setting to be implemented for OSG"\n' |
223 |
|
txt += 'fi\n' |
224 |
|
##### |
225 |
|
if int(self.register_data) == 1: |
226 |
< |
txt += 'export LFN='+self.LFN+'\n' |
227 |
< |
txt += 'lfc-ls $LFN\n' |
228 |
< |
txt += 'result=$?\n' |
229 |
< |
txt += 'echo $result\n' |
226 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
227 |
> |
txt += ' export LFN='+self.LFN+'\n' |
228 |
> |
txt += ' lfc-ls $LFN\n' |
229 |
> |
txt += ' result=$?\n' |
230 |
> |
txt += ' echo $result\n' |
231 |
|
### creation of LFN dir in LFC catalog, under /grid/cms dir |
232 |
< |
txt += 'if [ $result != 0 ]; then\n' |
233 |
< |
txt += ' lfc-mkdir $LFN\n' |
234 |
< |
txt += ' result=$?\n' |
235 |
< |
txt += ' echo $result\n' |
232 |
> |
txt += ' if [ $result != 0 ]; then\n' |
233 |
> |
txt += ' lfc-mkdir $LFN\n' |
234 |
> |
txt += ' result=$?\n' |
235 |
> |
txt += ' echo $result\n' |
236 |
> |
txt += ' fi\n' |
237 |
> |
txt += 'elif [ $middleware == OSG ]; then\n' |
238 |
> |
txt += ' echo " Files registration to be implemented for OSG"\n' |
239 |
|
txt += 'fi\n' |
240 |
|
txt += '\n' |
241 |
< |
txt += 'CloseCEs=`edg-brokerinfo getCE`\n' |
242 |
< |
txt += 'echo "CloseCEs = $CloseCEs"\n' |
243 |
< |
txt += 'CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
244 |
< |
txt += 'echo "CE = $CE"\n' |
241 |
> |
|
242 |
> |
if self.VO: |
243 |
> |
txt += 'export VO='+self.VO+'\n' |
244 |
> |
if self.LFN: |
245 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
246 |
> |
txt += ' export LFN='+self.LFN+'\n' |
247 |
> |
txt += 'fi\n' |
248 |
> |
txt += '\n' |
249 |
> |
|
250 |
> |
txt += 'if [ $middleware == LCG ]; then\n' |
251 |
> |
txt += ' CloseCEs=`edg-brokerinfo getCE`\n' |
252 |
> |
txt += ' echo "CloseCEs = $CloseCEs"\n' |
253 |
> |
txt += ' CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
254 |
> |
txt += ' echo "CE = $CE"\n' |
255 |
> |
txt += 'elif [ $middleware == OSG ]; then \n' |
256 |
> |
txt += ' if [ $OSG_JOB_CONTACT ]; then \n' |
257 |
> |
txt += ' CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n' |
258 |
> |
txt += ' else \n' |
259 |
> |
txt += ' echo "SET_ENV 1 ==> ERROR in setting CE name - OSG mode -" \n' |
260 |
> |
txt += ' exit 1 \n' |
261 |
> |
txt += ' fi \n' |
262 |
> |
txt += 'fi \n' |
263 |
> |
|
264 |
|
return txt |
265 |
|
|
266 |
|
def wsCopyInput(self): |
273 |
|
#print "self.copy_input_data = ", self.copy_input_data |
274 |
|
except KeyError: self.copy_input_data = 0 |
275 |
|
if int(self.copy_input_data) == 1: |
276 |
< |
txt += '#\n' |
277 |
< |
txt += '# Copy Input Data from SE to this WN\n' |
278 |
< |
txt += '#\n' |
276 |
> |
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
277 |
> |
txt += 'if [ $middleware == OSG ]; then\n' |
278 |
> |
txt += ' #\n' |
279 |
> |
txt += ' # Copy Input Data from SE to this WN deactivated in OSG mode\n' |
280 |
> |
txt += ' #\n' |
281 |
> |
txt += ' echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n' |
282 |
> |
txt += 'elif [ $middleware == LCG ]; then \n' |
283 |
> |
txt += ' #\n' |
284 |
> |
txt += ' # Copy Input Data from SE to this WN\n' |
285 |
> |
txt += ' #\n' |
286 |
|
### changed by georgia (put a loop copying more than one input files per jobs) |
287 |
< |
txt +='for input_file in $cur_file_list \n' |
288 |
< |
txt +='do \n' |
289 |
< |
txt +=' lcg-cp --vo $VO lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n' |
290 |
< |
txt +=' copy_input_exit_status=$?\n' |
291 |
< |
txt +=' echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n' |
292 |
< |
txt +=' if [ $copy_input_exit_status -ne 0 ]; then \n' |
293 |
< |
txt +=' echo "Problems with copying to WN" \n' |
294 |
< |
txt +=' else \n' |
295 |
< |
txt +=' echo "input copied into WN" \n' |
296 |
< |
txt +=' fi \n' |
297 |
< |
txt +='done \n' |
287 |
> |
txt += ' for input_file in $cur_file_list \n' |
288 |
> |
txt += ' do \n' |
289 |
> |
txt += ' lcg-cp --vo $VO lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n' |
290 |
> |
txt += ' copy_input_exit_status=$?\n' |
291 |
> |
txt += ' echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n' |
292 |
> |
txt += ' if [ $copy_input_exit_status -ne 0 ]; then \n' |
293 |
> |
txt += ' echo "Problems with copying to WN" \n' |
294 |
> |
txt += ' else \n' |
295 |
> |
txt += ' echo "input copied into WN" \n' |
296 |
> |
txt += ' fi \n' |
297 |
> |
txt += ' done \n' |
298 |
|
### copy a set of PU ntuples (same for each jobs -- but accessed randomly) |
299 |
< |
txt +='for file in $cur_pu_list \n' |
300 |
< |
txt +='do \n' |
301 |
< |
txt +=' lcg-cp --vo $VO lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n' |
302 |
< |
txt +=' copy_input_exit_status=$?\n' |
303 |
< |
txt +=' echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n' |
304 |
< |
txt +=' if [ $copy_input_pu_exit_status -ne 0 ]; then \n' |
305 |
< |
txt +=' echo "Problems with copying pu to WN" \n' |
306 |
< |
txt +=' else \n' |
307 |
< |
txt +=' echo "input pu files copied into WN" \n' |
308 |
< |
txt +=' fi \n' |
309 |
< |
txt +='done \n' |
310 |
< |
txt +='\n' |
311 |
< |
txt +='### Check SCRATCH space available on WN : \n' |
312 |
< |
txt +='df -h \n' |
299 |
> |
txt += ' for file in $cur_pu_list \n' |
300 |
> |
txt += ' do \n' |
301 |
> |
txt += ' lcg-cp --vo $VO lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n' |
302 |
> |
txt += ' copy_input_exit_status=$?\n' |
303 |
> |
txt += ' echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n' |
304 |
> |
txt += ' if [ $copy_input_pu_exit_status -ne 0 ]; then \n' |
305 |
> |
txt += ' echo "Problems with copying pu to WN" \n' |
306 |
> |
txt += ' else \n' |
307 |
> |
txt += ' echo "input pu files copied into WN" \n' |
308 |
> |
txt += ' fi \n' |
309 |
> |
txt += ' done \n' |
310 |
> |
txt += ' \n' |
311 |
> |
txt += ' ### Check SCRATCH space available on WN : \n' |
312 |
> |
txt += ' df -h \n' |
313 |
> |
txt += 'fi \n' |
314 |
> |
|
315 |
|
return txt |
316 |
|
|
317 |
|
def wsCopyOutput(self): |
327 |
|
txt += 'if [ $exe_result -eq 0 ]; then\n' |
328 |
|
txt += ' for out_file in $file_list ; do\n' |
329 |
|
txt += ' echo "Trying to copy output file to $SE "\n' |
330 |
< |
txt += ' echo "lcg-cp --vo cms -t 1200 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
331 |
< |
# txt += ' echo "globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
332 |
< |
txt += ' exitstring=`lcg-cp --vo cms -t 1200 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
333 |
< |
# txt += ' exitstring=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
334 |
< |
txt += ' copy_exit_status=$?\n' |
330 |
> |
## OLI_Daniele globus-* for OSG, lcg-* for LCG |
331 |
> |
txt += ' if [ $middleware == OSG ]; then\n' |
332 |
> |
txt += ' echo "globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
333 |
> |
txt += ' copy_exit_status=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
334 |
> |
#txt += ' exitstring=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
335 |
> |
txt += ' elif [ $middleware == LCG ]; then \n' |
336 |
> |
txt += ' echo "lcg-cp --vo cms -t 1200 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
337 |
> |
txt += ' copy_exit_status=`lcg-cp --vo cms -t 1200 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
338 |
> |
#txt += ' exitstring=`lcg-cp --vo cms -t 30 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
339 |
> |
txt += ' fi \n' |
340 |
> |
#txt += ' copy_exit_status=$?\n' |
341 |
|
txt += ' echo "COPY_EXIT_STATUS = $copy_exit_status"\n' |
342 |
|
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
343 |
|
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
361 |
|
|
362 |
|
txt = '' |
363 |
|
if int(self.register_data) == 1: |
364 |
+ |
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
365 |
+ |
txt += 'if [ $middleware == OSG ]; then\n' |
366 |
+ |
txt += ' #\n' |
367 |
+ |
txt += ' # Register output to LFC deactivated in OSG mode\n' |
368 |
+ |
txt += ' #\n' |
369 |
+ |
txt += ' echo "Register output to LFC deactivated in OSG mode"\n' |
370 |
+ |
txt += 'elif [ $middleware == LCG ]; then \n' |
371 |
|
txt += '#\n' |
372 |
|
txt += '# Register output to LFC\n' |
373 |
|
txt += '#\n' |
374 |
< |
txt += 'if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
375 |
< |
txt += ' for out_file in $file_list ; do\n' |
376 |
< |
txt += ' echo "Trying to register the output file into LFC"\n' |
377 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n' |
378 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
288 |
< |
txt += ' register_exit_status=$?\n' |
289 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
290 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
291 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
292 |
< |
txt += ' echo "Problems with the registration to LFC" \n' |
293 |
< |
txt += ' echo "Try with srm protocol" \n' |
294 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n' |
295 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n' |
374 |
> |
txt += ' if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
375 |
> |
txt += ' for out_file in $file_list ; do\n' |
376 |
> |
txt += ' echo "Trying to register the output file into LFC"\n' |
377 |
> |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n' |
378 |
> |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
379 |
|
txt += ' register_exit_status=$?\n' |
380 |
|
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
381 |
|
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
382 |
|
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
383 |
< |
txt += ' echo "Problems with the registration into LFC" \n' |
383 |
> |
txt += ' echo "Problems with the registration to LFC" \n' |
384 |
> |
txt += ' echo "Try with srm protocol" \n' |
385 |
> |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n' |
386 |
> |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n' |
387 |
> |
txt += ' register_exit_status=$?\n' |
388 |
> |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
389 |
> |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
390 |
> |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
391 |
> |
txt += ' echo "Problems with the registration into LFC" \n' |
392 |
> |
txt += ' fi \n' |
393 |
> |
txt += ' else \n' |
394 |
> |
txt += ' echo "output registered to LFC"\n' |
395 |
|
txt += ' fi \n' |
396 |
< |
txt += ' else \n' |
397 |
< |
txt += ' echo "output registered to LFC"\n' |
398 |
< |
txt += ' fi \n' |
399 |
< |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
400 |
< |
txt += ' done\n' |
401 |
< |
txt += 'elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n' |
402 |
< |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
403 |
< |
txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
404 |
< |
txt += ' for out_file in $file_list ; do\n' |
405 |
< |
txt += ' echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n' |
406 |
< |
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' |
407 |
< |
txt += ' register_exit_status=$?\n' |
408 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
409 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
410 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
411 |
< |
txt += ' echo "Problems with CloseSE" \n' |
412 |
< |
txt += ' else \n' |
413 |
< |
txt += ' echo "The program was successfully executed"\n' |
414 |
< |
txt += ' echo "SE = $CLOSE_SE"\n' |
415 |
< |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
416 |
< |
txt += ' fi \n' |
417 |
< |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
418 |
< |
txt += ' done\n' |
325 |
< |
txt += 'else\n' |
326 |
< |
txt += ' echo "Problem with the executable"\n' |
396 |
> |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
397 |
> |
txt += ' done\n' |
398 |
> |
txt += ' elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n' |
399 |
> |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
400 |
> |
txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
401 |
> |
txt += ' for out_file in $file_list ; do\n' |
402 |
> |
txt += ' echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n' |
403 |
> |
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' |
404 |
> |
txt += ' register_exit_status=$?\n' |
405 |
> |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
406 |
> |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
407 |
> |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
408 |
> |
txt += ' echo "Problems with CloseSE" \n' |
409 |
> |
txt += ' else \n' |
410 |
> |
txt += ' echo "The program was successfully executed"\n' |
411 |
> |
txt += ' echo "SE = $CLOSE_SE"\n' |
412 |
> |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
413 |
> |
txt += ' fi \n' |
414 |
> |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
415 |
> |
txt += ' done\n' |
416 |
> |
txt += ' else\n' |
417 |
> |
txt += ' echo "Problem with the executable"\n' |
418 |
> |
txt += ' fi \n' |
419 |
|
txt += 'fi \n' |
420 |
|
return txt |
421 |
|
|
593 |
|
|
594 |
|
# Determine the output directory name |
595 |
|
dir = common.work_space.resDir() |
596 |
< |
dir += os.getlogin() |
596 |
> |
dir += os.environ['USER'] |
597 |
|
dir += '_' + os.path.basename(id) |
598 |
|
return dir |
599 |
|
|
651 |
|
|
652 |
|
# Marco (VERY TEMPORARY ML STUFF) |
653 |
|
inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\ |
654 |
+ |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + '", "'+\ |
655 |
|
os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\ |
656 |
|
os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\ |
657 |
|
os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"' |
716 |
|
req = req + self.EDG_requirements |
717 |
|
else: |
718 |
|
req = req + ' && ' + self.EDG_requirements |
719 |
+ |
#### FEDE ##### |
720 |
+ |
if self.EDG_ce_white_list: |
721 |
+ |
ce_white_list = string.split(self.EDG_ce_white_list,',') |
722 |
+ |
#print "req = ", req |
723 |
+ |
for i in range(len(ce_white_list)): |
724 |
+ |
if i == 0: |
725 |
+ |
if (req == 'Requirement = '): |
726 |
+ |
req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
727 |
+ |
else: |
728 |
+ |
req = req + ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
729 |
+ |
pass |
730 |
+ |
else: |
731 |
+ |
req = req + ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
732 |
+ |
req = req + ')' |
733 |
+ |
|
734 |
+ |
if self.EDG_ce_black_list: |
735 |
+ |
ce_black_list = string.split(self.EDG_ce_black_list,',') |
736 |
+ |
for ce in ce_black_list: |
737 |
+ |
if (req == 'Requirement = '): |
738 |
+ |
req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))' |
739 |
+ |
else: |
740 |
+ |
req = req + ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))' |
741 |
+ |
pass |
742 |
+ |
############### |
743 |
|
if self.EDG_clock_time: |
744 |
|
if (req == 'Requirement = '): |
745 |
|
req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
746 |
|
else: |
747 |
|
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
748 |
< |
|
748 |
> |
|
749 |
|
if self.EDG_cpu_time: |
750 |
|
if (req == 'Requirement = '): |
751 |
|
req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
761 |
|
jdl.write('RetryCount = '+self.EDG_retry_count+';\n') |
762 |
|
pass |
763 |
|
|
764 |
+ |
jdl.write('MyProxyServer = "' + self.proxyServer + '";\n') |
765 |
+ |
|
766 |
|
jdl.close() |
767 |
|
return |
768 |
|
|
772 |
|
""" |
773 |
|
if (self.proxyValid): return |
774 |
|
timeleft = -999 |
775 |
< |
minTimeLeft=10 # in hours |
776 |
< |
cmd = 'grid-proxy-info -e -v '+str(minTimeLeft)+':00' |
777 |
< |
# SL Here I have to use os.system since the stupid command exit with >0 if no valid proxy is found |
778 |
< |
cmd_out = os.system(cmd) |
779 |
< |
if (cmd_out>0): |
780 |
< |
common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 100h\n") |
781 |
< |
cmd = 'grid-proxy-init -valid 100:00' |
775 |
> |
minTimeLeft=10*3600 # in seconds |
776 |
> |
|
777 |
> |
minTimeLeftServer = 100 # in hours |
778 |
> |
|
779 |
> |
#cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00' |
780 |
> |
#cmd = 'voms-proxy-info -timeleft' |
781 |
> |
mustRenew = 0 |
782 |
> |
timeLeftLocal = runCommand('voms-proxy-info -timeleft') |
783 |
> |
timeLeftServer = -999 |
784 |
> |
if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal): |
785 |
> |
mustRenew = 1 |
786 |
> |
else: |
787 |
> |
timeLeftServer = runCommand('voms-proxy-info -actimeleft | head -1') |
788 |
> |
if not timeLeftServer or not isInt(timeLeftServer): |
789 |
> |
mustRenew = 1 |
790 |
> |
elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft: |
791 |
> |
mustRenew = 1 |
792 |
> |
pass |
793 |
> |
pass |
794 |
> |
|
795 |
> |
if mustRenew: |
796 |
> |
common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 24h\n") |
797 |
> |
cmd = 'voms-proxy-init -voms cms -valid 24:00' |
798 |
|
try: |
799 |
|
# SL as above: damn it! |
800 |
|
out = os.system(cmd) |
805 |
|
# cmd = 'grid-proxy-info -timeleft' |
806 |
|
# cmd_out = runCommand(cmd,0,20) |
807 |
|
pass |
808 |
+ |
|
809 |
+ |
## now I do have a voms proxy valid, and I check the myproxy server |
810 |
+ |
renewProxy = 0 |
811 |
+ |
cmd = 'myproxy-info -d -s '+self.proxyServer |
812 |
+ |
cmd_out = runCommand(cmd,0,20) |
813 |
+ |
if not cmd_out: |
814 |
+ |
common.logger.message('No credential delegated to myproxy server '+self.proxyServer+' will do now') |
815 |
+ |
renewProxy = 1 |
816 |
+ |
else: |
817 |
+ |
# if myproxy exist but not long enough, renew |
818 |
+ |
reTime = re.compile( r'timeleft: (\d+)' ) |
819 |
+ |
#print "<"+str(reTime.search( cmd_out ).group(1))+">" |
820 |
+ |
if reTime.match( cmd_out ): |
821 |
+ |
time = reTime.search( line ).group(1) |
822 |
+ |
if time < minTimeLeftServer: |
823 |
+ |
renewProxy = 1 |
824 |
+ |
common.logger.message('No credential delegation will expire in '+time+' hours: renew it') |
825 |
+ |
pass |
826 |
+ |
pass |
827 |
+ |
|
828 |
+ |
# if not, create one. |
829 |
+ |
if renewProxy: |
830 |
+ |
cmd = 'myproxy-init -d -n -s '+self.proxyServer |
831 |
+ |
out = os.system(cmd) |
832 |
+ |
if (out>0): |
833 |
+ |
raise CrabException("Unable to delegate the proxy to myproxyserver "+self.proxyServer+" !\n") |
834 |
+ |
pass |
835 |
+ |
|
836 |
+ |
# cache proxy validity |
837 |
|
self.proxyValid=1 |
838 |
|
return |
839 |
< |
|
839 |
> |
|
840 |
|
def configOpt_(self): |
841 |
|
edg_ui_cfg_opt = ' ' |
842 |
|
if self.edg_config: |
843 |
< |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
843 |
> |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
844 |
|
if self.edg_config_vo: |
845 |
< |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
845 |
> |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
846 |
|
return edg_ui_cfg_opt |