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: |
41 |
+ |
self.role = cfg_params["EDG.role"] |
42 |
+ |
except KeyError: |
43 |
+ |
self.role = None |
44 |
+ |
|
45 |
|
try: self.LCG_version = cfg_params["EDG.lcg_version"] |
46 |
|
except KeyError: self.LCG_version = '2' |
47 |
|
|
51 |
|
try: self.EDG_retry_count = cfg_params['EDG.retry_count'] |
52 |
|
except KeyError: self.EDG_retry_count = '' |
53 |
|
|
54 |
+ |
try: |
55 |
+ |
self.EDG_ce_black_list = cfg_params['EDG.ce_black_list'] |
56 |
+ |
#print "self.EDG_ce_black_list = ", self.EDG_ce_black_list |
57 |
+ |
except KeyError: |
58 |
+ |
self.EDG_ce_black_list = '' |
59 |
+ |
|
60 |
+ |
try: |
61 |
+ |
self.EDG_ce_white_list = cfg_params['EDG.ce_white_list'] |
62 |
+ |
#print "self.EDG_ce_white_list = ", self.EDG_ce_white_list |
63 |
+ |
except KeyError: self.EDG_ce_white_list = '' |
64 |
+ |
|
65 |
|
try: self.VO = cfg_params['EDG.virtual_organization'] |
66 |
|
except KeyError: self.VO = 'cms' |
67 |
|
|
42 |
– |
try: |
43 |
– |
self.copy_input_data = common.analisys_common_info['copy_input_data'] |
44 |
– |
#print "self.copy_input_data = ", self.copy_input_data |
45 |
– |
except KeyError: self.copy_input_data = 0 |
46 |
– |
|
68 |
|
try: self.return_data = cfg_params['USER.return_data'] |
69 |
|
except KeyError: self.return_data = 1 |
70 |
|
|
71 |
+ |
# was set t o zero in cms_cmssw.py to deactivate only for cmssw |
72 |
+ |
# after CRAB_1_3_0, support for ORCA was dropped, so setting it here to zero and avoiding usage of non-existant analisys_common_info |
73 |
+ |
self.copy_input_data = 0 |
74 |
+ |
|
75 |
|
try: |
76 |
|
self.copy_data = cfg_params["USER.copy_data"] |
77 |
|
if int(self.copy_data) == 1: |
156 |
|
sys.path.append(libPath) |
157 |
|
|
158 |
|
self.proxyValid=0 |
159 |
+ |
|
160 |
+ |
try: |
161 |
+ |
self._taskId = cfg_params['taskId'] |
162 |
+ |
except: |
163 |
+ |
self._taskId = '' |
164 |
+ |
|
165 |
+ |
try: self.jobtypeName = cfg_params['CRAB.jobtype'] |
166 |
+ |
except KeyError: self.jobtypeName = '' |
167 |
+ |
|
168 |
+ |
try: self.schedulerName = cfg_params['CRAB.scheduler'] |
169 |
+ |
except KeyError: self.scheduler = '' |
170 |
+ |
|
171 |
|
return |
172 |
|
|
173 |
|
|
190 |
|
""" |
191 |
|
Returns part of a job script which does scheduler-specific work. |
192 |
|
""" |
156 |
– |
|
193 |
|
txt = '' |
194 |
+ |
txt += '# strip arguments\n' |
195 |
+ |
txt += 'echo "strip arguments"\n' |
196 |
+ |
txt += 'args=("$@")\n' |
197 |
+ |
txt += 'nargs=$#\n' |
198 |
+ |
txt += 'shift $nargs\n' |
199 |
+ |
txt += "# job number (first parameter for job wrapper)\n" |
200 |
+ |
#txt += "NJob=$1\n" |
201 |
+ |
txt += "NJob=${args[0]}\n" |
202 |
+ |
|
203 |
+ |
txt += '# job identification to DashBoard \n' |
204 |
+ |
txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n' |
205 |
+ |
txt += 'SyncGridJobId=`echo $EDG_WL_JOBID`\n' |
206 |
+ |
txt += 'MonitorID=`echo ' + self._taskId + '`\n' |
207 |
+ |
txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
208 |
+ |
txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n' |
209 |
+ |
txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
210 |
+ |
|
211 |
+ |
txt += 'echo "middleware discovery " \n' |
212 |
+ |
txt += 'if [ $GRID3_APP_DIR ]; then\n' |
213 |
+ |
txt += ' middleware=OSG \n' |
214 |
+ |
txt += ' echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n' |
215 |
+ |
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
216 |
+ |
txt += ' echo "middleware =$middleware" \n' |
217 |
+ |
txt += 'elif [ $OSG_APP ]; then \n' |
218 |
+ |
txt += ' middleware=OSG \n' |
219 |
+ |
txt += ' echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n' |
220 |
+ |
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
221 |
+ |
txt += ' echo "middleware =$middleware" \n' |
222 |
+ |
txt += 'elif [ $VO_CMS_SW_DIR ]; then \n' |
223 |
+ |
txt += ' middleware=LCG \n' |
224 |
+ |
txt += ' echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n' |
225 |
+ |
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
226 |
+ |
txt += ' echo "middleware =$middleware" \n' |
227 |
+ |
txt += 'else \n' |
228 |
+ |
txt += ' echo "SET_CMS_ENV 10030 ==> middleware not identified" \n' |
229 |
+ |
txt += ' echo "JOB_EXIT_STATUS = 10030" \n' |
230 |
+ |
txt += ' echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n' |
231 |
+ |
txt += ' dumpStatus $RUNTIME_AREA/$repo \n' |
232 |
+ |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
233 |
+ |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
234 |
+ |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
235 |
+ |
txt += ' exit 1 \n' |
236 |
+ |
txt += 'fi \n' |
237 |
+ |
|
238 |
+ |
txt += '# report first time to DashBoard \n' |
239 |
+ |
txt += 'dumpStatus $RUNTIME_AREA/$repo \n' |
240 |
+ |
txt += 'rm -f $RUNTIME_AREA/$repo \n' |
241 |
+ |
txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
242 |
+ |
txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
243 |
+ |
|
244 |
+ |
txt += '\n\n' |
245 |
+ |
|
246 |
|
if int(self.copy_data) == 1: |
247 |
|
if self.SE: |
248 |
|
txt += 'export SE='+self.SE+'\n' |
251 |
|
if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/' |
252 |
|
txt += 'export SE_PATH='+self.SE_PATH+'\n' |
253 |
|
txt += 'echo "SE_PATH = $SE_PATH"\n' |
254 |
< |
|
254 |
> |
|
255 |
|
txt += 'export VO='+self.VO+'\n' |
256 |
|
### FEDE: add some line for LFC catalog setting |
257 |
< |
txt += 'if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n' |
258 |
< |
txt += ' export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n' |
259 |
< |
txt += 'fi\n' |
260 |
< |
txt += 'if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n' |
261 |
< |
txt += 'export LFC_HOST='+self.lfc_host+'\n' |
262 |
< |
txt += 'fi\n' |
263 |
< |
txt += 'if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n' |
264 |
< |
txt += 'export LFC_HOME='+self.lfc_home+'\n' |
257 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
258 |
> |
txt += ' if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n' |
259 |
> |
txt += ' export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n' |
260 |
> |
txt += ' fi\n' |
261 |
> |
txt += ' if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n' |
262 |
> |
txt += ' export LFC_HOST='+self.lfc_host+'\n' |
263 |
> |
txt += ' fi\n' |
264 |
> |
txt += ' if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n' |
265 |
> |
txt += ' export LFC_HOME='+self.lfc_home+'\n' |
266 |
> |
txt += ' fi\n' |
267 |
> |
txt += 'elif [ $middleware == OSG ]; then\n' |
268 |
> |
txt += ' echo "LFC catalog setting to be implemented for OSG"\n' |
269 |
|
txt += 'fi\n' |
270 |
|
##### |
271 |
|
if int(self.register_data) == 1: |
272 |
< |
txt += 'export LFN='+self.LFN+'\n' |
273 |
< |
txt += 'lfc-ls $LFN\n' |
274 |
< |
txt += 'result=$?\n' |
275 |
< |
txt += 'echo $result\n' |
272 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
273 |
> |
txt += ' export LFN='+self.LFN+'\n' |
274 |
> |
txt += ' lfc-ls $LFN\n' |
275 |
> |
txt += ' result=$?\n' |
276 |
> |
txt += ' echo $result\n' |
277 |
|
### creation of LFN dir in LFC catalog, under /grid/cms dir |
278 |
< |
txt += 'if [ $result != 0 ]; then\n' |
279 |
< |
txt += ' lfc-mkdir $LFN\n' |
280 |
< |
txt += ' result=$?\n' |
281 |
< |
txt += ' echo $result\n' |
278 |
> |
txt += ' if [ $result != 0 ]; then\n' |
279 |
> |
txt += ' lfc-mkdir $LFN\n' |
280 |
> |
txt += ' result=$?\n' |
281 |
> |
txt += ' echo $result\n' |
282 |
> |
txt += ' fi\n' |
283 |
> |
txt += 'elif [ $middleware == OSG ]; then\n' |
284 |
> |
txt += ' echo " Files registration to be implemented for OSG"\n' |
285 |
|
txt += 'fi\n' |
286 |
|
txt += '\n' |
287 |
< |
txt += 'CloseCEs=`edg-brokerinfo getCE`\n' |
288 |
< |
txt += 'echo "CloseCEs = $CloseCEs"\n' |
289 |
< |
txt += 'CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
290 |
< |
txt += 'echo "CE = $CE"\n' |
287 |
> |
|
288 |
> |
if self.VO: |
289 |
> |
txt += 'export VO='+self.VO+'\n' |
290 |
> |
if self.LFN: |
291 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
292 |
> |
txt += ' export LFN='+self.LFN+'\n' |
293 |
> |
txt += 'fi\n' |
294 |
> |
txt += '\n' |
295 |
> |
|
296 |
> |
txt += 'if [ $middleware == LCG ]; then\n' |
297 |
> |
txt += ' CloseCEs=`edg-brokerinfo getCE`\n' |
298 |
> |
txt += ' echo "CloseCEs = $CloseCEs"\n' |
299 |
> |
txt += ' CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
300 |
> |
txt += ' echo "CE = $CE"\n' |
301 |
> |
txt += 'elif [ $middleware == OSG ]; then \n' |
302 |
> |
txt += ' if [ $OSG_JOB_CONTACT ]; then \n' |
303 |
> |
txt += ' CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n' |
304 |
> |
txt += ' else \n' |
305 |
> |
txt += ' echo "SET_CMS_ENV 10099 ==> OSG mode: ERROR in setting CE name from OSG_JOB_CONTACT" \n' |
306 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10099" \n' |
307 |
> |
txt += ' echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n' |
308 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo \n' |
309 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
310 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
311 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
312 |
> |
txt += ' exit 1 \n' |
313 |
> |
txt += ' fi \n' |
314 |
> |
txt += 'fi \n' |
315 |
> |
|
316 |
|
return txt |
317 |
|
|
318 |
|
def wsCopyInput(self): |
322 |
|
txt = '' |
323 |
|
try: |
324 |
|
self.copy_input_data = common.analisys_common_info['copy_input_data'] |
204 |
– |
#print "self.copy_input_data = ", self.copy_input_data |
325 |
|
except KeyError: self.copy_input_data = 0 |
326 |
|
if int(self.copy_input_data) == 1: |
327 |
< |
txt += '#\n' |
328 |
< |
txt += '# Copy Input Data from SE to this WN\n' |
329 |
< |
txt += '#\n' |
330 |
< |
### changed by georgia (put a loop copying more than one input files per jobs) |
331 |
< |
txt +='for input_file in $cur_file_list \n' |
332 |
< |
txt +='do \n' |
333 |
< |
txt +=' lcg-cp --vo $VO lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n' |
334 |
< |
txt +=' copy_input_exit_status=$?\n' |
335 |
< |
txt +=' echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n' |
336 |
< |
txt +=' if [ $copy_input_exit_status -ne 0 ]; then \n' |
337 |
< |
txt +=' echo "Problems with copying to WN" \n' |
338 |
< |
txt +=' else \n' |
339 |
< |
txt +=' echo "input copied into WN" \n' |
340 |
< |
txt +=' fi \n' |
341 |
< |
txt +='done \n' |
342 |
< |
### copy a set of PU ntuples (same for each jobs -- but accessed randomly) |
343 |
< |
txt +='for file in $cur_pu_list \n' |
344 |
< |
txt +='do \n' |
345 |
< |
txt +=' lcg-cp --vo $VO lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n' |
346 |
< |
txt +=' copy_input_exit_status=$?\n' |
347 |
< |
txt +=' echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n' |
348 |
< |
txt +=' if [ $copy_input_pu_exit_status -ne 0 ]; then \n' |
349 |
< |
txt +=' echo "Problems with copying pu to WN" \n' |
350 |
< |
txt +=' else \n' |
351 |
< |
txt +=' echo "input pu files copied into WN" \n' |
352 |
< |
txt +=' fi \n' |
353 |
< |
txt +='done \n' |
354 |
< |
txt +='\n' |
355 |
< |
txt +='### Check SCRATCH space available on WN : \n' |
356 |
< |
txt +='df -h \n' |
327 |
> |
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
328 |
> |
txt += 'if [ $middleware == OSG ]; then\n' |
329 |
> |
txt += ' #\n' |
330 |
> |
txt += ' # Copy Input Data from SE to this WN deactivated in OSG mode\n' |
331 |
> |
txt += ' #\n' |
332 |
> |
txt += ' echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n' |
333 |
> |
txt += 'elif [ $middleware == LCG ]; then \n' |
334 |
> |
txt += ' #\n' |
335 |
> |
txt += ' # Copy Input Data from SE to this WN\n' |
336 |
> |
txt += ' #\n' |
337 |
> |
### changed by georgia (put a loop copying more than one input files per jobs) |
338 |
> |
txt += ' for input_file in $cur_file_list \n' |
339 |
> |
txt += ' do \n' |
340 |
> |
txt += ' lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n' |
341 |
> |
txt += ' copy_input_exit_status=$?\n' |
342 |
> |
txt += ' echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n' |
343 |
> |
txt += ' if [ $copy_input_exit_status -ne 0 ]; then \n' |
344 |
> |
txt += ' echo "Problems with copying to WN" \n' |
345 |
> |
txt += ' else \n' |
346 |
> |
txt += ' echo "input copied into WN" \n' |
347 |
> |
txt += ' fi \n' |
348 |
> |
txt += ' done \n' |
349 |
> |
### copy a set of PU ntuples (same for each jobs -- but accessed randomly) |
350 |
> |
txt += ' for file in $cur_pu_list \n' |
351 |
> |
txt += ' do \n' |
352 |
> |
txt += ' lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n' |
353 |
> |
txt += ' copy_input_pu_exit_status=$?\n' |
354 |
> |
txt += ' echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n' |
355 |
> |
txt += ' if [ $copy_input_pu_exit_status -ne 0 ]; then \n' |
356 |
> |
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' |
365 |
> |
|
366 |
|
return txt |
367 |
|
|
368 |
|
def wsCopyOutput(self): |
375 |
|
txt += '#\n' |
376 |
|
txt += '# Copy output to SE = $SE\n' |
377 |
|
txt += '#\n' |
378 |
< |
txt += 'if [ $exe_result -eq 0 ]; then\n' |
378 |
> |
txt += ' if [ $middleware == OSG ]; then\n' |
379 |
> |
txt += ' echo "X509_USER_PROXY = $X509_USER_PROXY"\n' |
380 |
> |
txt += ' echo "source $OSG_APP/glite/setup_glite_ui.sh"\n' |
381 |
> |
txt += ' source $OSG_APP/glite/setup_glite_ui.sh\n' |
382 |
> |
txt += ' export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n' |
383 |
> |
txt += ' echo "export X509_CERT_DIR=$X509_CERT_DIR"\n' |
384 |
> |
txt += ' fi \n' |
385 |
|
txt += ' for out_file in $file_list ; do\n' |
386 |
< |
txt += ' echo "Trying to copy output file to $SE "\n' |
387 |
< |
txt += ' echo "lcg-cp --vo cms -t 1200 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
388 |
< |
# txt += ' echo "globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
389 |
< |
txt += ' exitstring=`lcg-cp --vo cms -t 1200 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
390 |
< |
# txt += ' exitstring=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
386 |
> |
txt += ' echo "Trying to copy output file to $SE using lcg-cp"\n' |
387 |
> |
if common.logger.debugLevel() >= 5: |
388 |
> |
txt += ' echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
389 |
> |
txt += ' exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
390 |
> |
else: |
391 |
> |
txt += ' echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
392 |
> |
txt += ' exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
393 |
|
txt += ' copy_exit_status=$?\n' |
394 |
< |
txt += ' echo "COPY_EXIT_STATUS = $copy_exit_status"\n' |
394 |
> |
txt += ' echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n' |
395 |
|
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
396 |
|
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
397 |
< |
txt += ' echo "Problems with SE = $SE"\n' |
397 |
> |
txt += ' echo "Possible problem with SE = $SE"\n' |
398 |
|
txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n' |
399 |
|
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
400 |
+ |
txt += ' echo "lcg-cp failed. For verbose lcg-cp output, use command line option -debug 5."\n' |
401 |
+ |
txt += ' echo "lcg-cp failed, attempting srmcp"\n' |
402 |
+ |
txt += ' echo "mkdir -p $HOME/.srmconfig"\n' |
403 |
+ |
txt += ' mkdir -p $HOME/.srmconfig\n' |
404 |
+ |
txt += ' if [ $middleware == LCG ]; then\n' |
405 |
+ |
txt += ' echo "srmcp -retry_num 5 -retry_timeout 480000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n' |
406 |
+ |
txt += ' exitstring=`srmcp -retry_num 5 -retry_timeout 480000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n' |
407 |
+ |
txt += ' elif [ $middleware == OSG ]; then\n' |
408 |
+ |
txt += ' echo "srmcp -retry_num 5 -retry_timeout 240000 -x509_user_trusted_certificates $X509_CERT_DIR file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n' |
409 |
+ |
txt += ' exitstring=`srmcp -retry_num 5 -retry_timeout 240000 -x509_user_trusted_certificates $X509_CERT_DIR file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n' |
410 |
+ |
txt += ' fi \n' |
411 |
+ |
txt += ' copy_exit_status=$?\n' |
412 |
+ |
txt += ' echo "COPY_EXIT_STATUS for srm = $copy_exit_status"\n' |
413 |
+ |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
414 |
+ |
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
415 |
+ |
txt += ' echo "Problems with SE = $SE"\n' |
416 |
+ |
txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n' |
417 |
+ |
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
418 |
+ |
txt += ' echo "lcg-cp and srm failed"\n' |
419 |
+ |
txt += ' echo "If storage_path in your config file contains a ? you may need a \? instead."\n' |
420 |
+ |
txt += ' else\n' |
421 |
+ |
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
422 |
+ |
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
423 |
+ |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
424 |
+ |
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
425 |
+ |
txt += ' echo "srmcp succeeded"\n' |
426 |
+ |
txt += ' fi\n' |
427 |
|
txt += ' else\n' |
428 |
|
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
429 |
|
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
430 |
|
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
431 |
|
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
432 |
+ |
txt += ' echo "lcg-cp succeeded"\n' |
433 |
|
txt += ' fi\n' |
434 |
|
txt += ' done\n' |
270 |
– |
txt += 'fi\n' |
435 |
|
return txt |
436 |
|
|
437 |
|
def wsRegisterOutput(self): |
441 |
|
|
442 |
|
txt = '' |
443 |
|
if int(self.register_data) == 1: |
444 |
+ |
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
445 |
+ |
txt += 'if [ $middleware == OSG ]; then\n' |
446 |
+ |
txt += ' #\n' |
447 |
+ |
txt += ' # Register output to LFC deactivated in OSG mode\n' |
448 |
+ |
txt += ' #\n' |
449 |
+ |
txt += ' echo "Register output to LFC deactivated in OSG mode"\n' |
450 |
+ |
txt += 'elif [ $middleware == LCG ]; then \n' |
451 |
|
txt += '#\n' |
452 |
|
txt += '# Register output to LFC\n' |
453 |
|
txt += '#\n' |
454 |
< |
txt += 'if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
455 |
< |
txt += ' for out_file in $file_list ; do\n' |
456 |
< |
txt += ' echo "Trying to register the output file into LFC"\n' |
457 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n' |
458 |
< |
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' |
454 |
> |
txt += ' if [ $copy_exit_status -eq 0 ]; then\n' |
455 |
> |
txt += ' for out_file in $file_list ; do\n' |
456 |
> |
txt += ' echo "Trying to register the output file into LFC"\n' |
457 |
> |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n' |
458 |
> |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
459 |
|
txt += ' register_exit_status=$?\n' |
460 |
|
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
461 |
|
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
462 |
|
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
463 |
< |
txt += ' echo "Problems with the registration into LFC" \n' |
463 |
> |
txt += ' echo "Problems with the registration to LFC" \n' |
464 |
> |
txt += ' echo "Try with srm protocol" \n' |
465 |
> |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n' |
466 |
> |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n' |
467 |
> |
txt += ' register_exit_status=$?\n' |
468 |
> |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
469 |
> |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
470 |
> |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
471 |
> |
txt += ' echo "Problems with the registration into LFC" \n' |
472 |
> |
txt += ' fi \n' |
473 |
> |
txt += ' else \n' |
474 |
> |
txt += ' echo "output registered to LFC"\n' |
475 |
|
txt += ' fi \n' |
476 |
< |
txt += ' else \n' |
477 |
< |
txt += ' echo "output registered to LFC"\n' |
478 |
< |
txt += ' fi \n' |
479 |
< |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
480 |
< |
txt += ' done\n' |
481 |
< |
txt += 'elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n' |
482 |
< |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
483 |
< |
txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
484 |
< |
txt += ' for out_file in $file_list ; do\n' |
485 |
< |
txt += ' echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n' |
486 |
< |
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' |
487 |
< |
txt += ' register_exit_status=$?\n' |
488 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
489 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
490 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
491 |
< |
txt += ' echo "Problems with CloseSE" \n' |
492 |
< |
txt += ' else \n' |
493 |
< |
txt += ' echo "The program was successfully executed"\n' |
494 |
< |
txt += ' echo "SE = $CLOSE_SE"\n' |
495 |
< |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
496 |
< |
txt += ' fi \n' |
497 |
< |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
324 |
< |
txt += ' done\n' |
325 |
< |
txt += 'else\n' |
326 |
< |
txt += ' echo "Problem with the executable"\n' |
476 |
> |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
477 |
> |
txt += ' done\n' |
478 |
> |
txt += ' else \n' |
479 |
> |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
480 |
> |
txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
481 |
> |
txt += ' for out_file in $file_list ; do\n' |
482 |
> |
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' |
483 |
> |
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' |
484 |
> |
txt += ' register_exit_status=$?\n' |
485 |
> |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
486 |
> |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
487 |
> |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
488 |
> |
txt += ' echo "Problems with CloseSE or Catalog" \n' |
489 |
> |
txt += ' else \n' |
490 |
> |
txt += ' echo "The program was successfully executed"\n' |
491 |
> |
txt += ' echo "SE = $CLOSE_SE"\n' |
492 |
> |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
493 |
> |
txt += ' fi \n' |
494 |
> |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
495 |
> |
txt += ' done\n' |
496 |
> |
txt += ' fi \n' |
497 |
> |
txt += ' exit_status=$register_exit_status\n' |
498 |
|
txt += 'fi \n' |
499 |
|
return txt |
500 |
|
|
508 |
|
cmd_out = runCommand(cmd) |
509 |
|
return cmd_out |
510 |
|
|
340 |
– |
def listMatch(self, nj): |
341 |
– |
""" |
342 |
– |
Check the compatibility of available resources |
343 |
– |
""" |
344 |
– |
self.checkProxy() |
345 |
– |
jdl = common.job_list[nj].jdlFilename() |
346 |
– |
cmd = 'edg-job-list-match ' + self.configOpt_() + jdl |
347 |
– |
cmd_out = runCommand(cmd,0,10) |
348 |
– |
if not cmd_out: |
349 |
– |
raise CrabException("ERROR: "+cmd+" failed!") |
350 |
– |
|
351 |
– |
return self.parseListMatch_(cmd_out, jdl) |
352 |
– |
|
353 |
– |
def parseListMatch_(self, out, jdl): |
354 |
– |
""" |
355 |
– |
Parse the f* output of edg-list-match and produce something sensible |
356 |
– |
""" |
357 |
– |
reComment = re.compile( r'^\**$' ) |
358 |
– |
reEmptyLine = re.compile( r'^$' ) |
359 |
– |
reVO = re.compile( r'Selected Virtual Organisation name.*' ) |
360 |
– |
reLine = re.compile( r'.*') |
361 |
– |
reCE = re.compile( r'(.*:.*)') |
362 |
– |
reCEId = re.compile( r'CEId.*') |
363 |
– |
reNO = re.compile( r'No Computing Element matching' ) |
364 |
– |
reRB = re.compile( r'Connecting to host' ) |
365 |
– |
next = 0 |
366 |
– |
CEs=[] |
367 |
– |
Match=0 |
368 |
– |
|
369 |
– |
#print out |
370 |
– |
lines = reLine.findall(out) |
371 |
– |
|
372 |
– |
i=0 |
373 |
– |
CEs=[] |
374 |
– |
for line in lines: |
375 |
– |
string.strip(line) |
376 |
– |
#print line |
377 |
– |
if reNO.match( line ): |
378 |
– |
common.logger.debug(5,line) |
379 |
– |
return 0 |
380 |
– |
pass |
381 |
– |
if reVO.match( line ): |
382 |
– |
VO =reVO.match( line ).group() |
383 |
– |
common.logger.debug(5,"VO "+VO) |
384 |
– |
pass |
385 |
– |
|
386 |
– |
if reRB.match( line ): |
387 |
– |
RB = reRB.match(line).group() |
388 |
– |
common.logger.debug(5,"RB "+RB) |
389 |
– |
pass |
390 |
– |
|
391 |
– |
if reCEId.search( line ): |
392 |
– |
for lineCE in lines[i:-1]: |
393 |
– |
if reCE.match( lineCE ): |
394 |
– |
CE = string.strip(reCE.search(lineCE).group(1)) |
395 |
– |
CEs.append(CE.split(':')[0]) |
396 |
– |
pass |
397 |
– |
pass |
398 |
– |
pass |
399 |
– |
i=i+1 |
400 |
– |
pass |
401 |
– |
|
402 |
– |
common.logger.debug(5,"All CE :"+str(CEs)) |
403 |
– |
|
404 |
– |
sites = [] |
405 |
– |
[sites.append(it) for it in CEs if not sites.count(it)] |
406 |
– |
|
407 |
– |
common.logger.debug(5,"All Sites :"+str(sites)) |
408 |
– |
return len(sites) |
409 |
– |
|
410 |
– |
def noMatchFound_(self, jdl): |
411 |
– |
reReq = re.compile( r'Requirements' ) |
412 |
– |
reString = re.compile( r'"\S*"' ) |
413 |
– |
f = file(jdl,'r') |
414 |
– |
for line in f.readlines(): |
415 |
– |
line= line.strip() |
416 |
– |
if reReq.match(line): |
417 |
– |
for req in reString.findall(line): |
418 |
– |
if re.search("VO",req): |
419 |
– |
common.logger.message( "SW required: "+req) |
420 |
– |
continue |
421 |
– |
if re.search('"\d+',req): |
422 |
– |
common.logger.message("Other req : "+req) |
423 |
– |
continue |
424 |
– |
common.logger.message( "CE required: "+req) |
425 |
– |
break |
426 |
– |
pass |
427 |
– |
raise CrabException("No compatible resources found!") |
428 |
– |
|
429 |
– |
def submit(self, nj): |
430 |
– |
""" |
431 |
– |
Submit one EDG job. |
432 |
– |
""" |
433 |
– |
|
434 |
– |
self.checkProxy() |
435 |
– |
jid = None |
436 |
– |
jdl = common.job_list[nj].jdlFilename() |
437 |
– |
|
438 |
– |
cmd = 'edg-job-submit ' + self.configOpt_() + jdl |
439 |
– |
cmd_out = runCommand(cmd) |
440 |
– |
if cmd_out != None: |
441 |
– |
reSid = re.compile( r'https.+' ) |
442 |
– |
jid = reSid.search(cmd_out).group() |
443 |
– |
pass |
444 |
– |
return jid |
445 |
– |
|
446 |
– |
def resubmit(self, nj_list): |
447 |
– |
""" |
448 |
– |
Prepare jobs to be submit |
449 |
– |
""" |
450 |
– |
return |
451 |
– |
|
511 |
|
def getExitStatus(self, id): |
512 |
|
return self.getStatusAttribute_(id, 'exit_code') |
513 |
|
|
539 |
|
for i in range(len(self.states)): |
540 |
|
# Fill an hash table with all information retrieved from LB API |
541 |
|
hstates[ self.states[i] ] = jobStat.loadStatus(st)[i] |
542 |
< |
result = jobStat.loadStatus(st)[ self.states.index(attr) ] |
542 |
> |
result = jobStat.loadStatus(st)[self.states.index(attr)] |
543 |
|
return result |
544 |
|
|
545 |
|
def queryDetailedStatus(self, id): |
548 |
|
cmd_out = runCommand(cmd) |
549 |
|
return cmd_out |
550 |
|
|
551 |
< |
def getOutput(self, id): |
551 |
> |
##### FEDE ###### |
552 |
> |
def findSites_(self, n_tot_job): |
553 |
> |
itr4 = [] |
554 |
> |
# print "n_tot_job = ", n_tot_job |
555 |
> |
for n in range(n_tot_job): |
556 |
> |
sites = common.jobDB.destination(n) |
557 |
> |
if len(sites)>0 and sites[0]=="Any": continue |
558 |
> |
|
559 |
> |
#job = common.job_list[n] |
560 |
> |
#jbt = job.type() |
561 |
> |
# print "common.jobDB.destination(n) = ", common.jobDB.destination(n) |
562 |
> |
# print "sites = ", sites |
563 |
> |
itr = '' |
564 |
> |
if sites != [""]:#CarlosDaniele |
565 |
> |
for site in sites: |
566 |
> |
#itr = itr + 'target.GlueSEUniqueID=="'+site+'" || ' |
567 |
> |
itr = itr + 'target.GlueSEUniqueID=="'+site+'" || ' |
568 |
> |
pass |
569 |
> |
# remove last || |
570 |
> |
itr = itr[0:-4] |
571 |
> |
itr4.append( itr ) |
572 |
> |
# remove last , |
573 |
> |
# print "itr4 = ", itr4 |
574 |
> |
return itr4 |
575 |
> |
|
576 |
> |
def createXMLSchScript(self, nj, argsList): |
577 |
> |
# def createXMLSchScript(self, nj): |
578 |
> |
""" |
579 |
> |
Create a XML-file for BOSS4. |
580 |
> |
""" |
581 |
> |
# job = common.job_list[nj] |
582 |
> |
""" |
583 |
> |
INDY |
584 |
> |
[begin] da rivedere: |
585 |
> |
in particolare passerei il jobType ed eliminerei le dipendenze da job |
586 |
> |
""" |
587 |
> |
index = nj - 1 |
588 |
> |
job = common.job_list[index] |
589 |
> |
jbt = job.type() |
590 |
> |
|
591 |
> |
inp_sandbox = jbt.inputSandbox(index) |
592 |
> |
out_sandbox = jbt.outputSandbox(index) |
593 |
|
""" |
594 |
< |
Get output for a finished job with id. |
495 |
< |
Returns the name of directory with results. |
594 |
> |
[end] da rivedere |
595 |
|
""" |
596 |
|
|
597 |
< |
self.checkProxy() |
598 |
< |
cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() + ' ' + id |
599 |
< |
cmd_out = runCommand(cmd) |
597 |
> |
|
598 |
> |
title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' |
599 |
> |
jt_string = '' |
600 |
> |
|
601 |
> |
xml_fname = str(self.jobtypeName)+'.xml' |
602 |
> |
xml = open(common.work_space.shareDir()+'/'+xml_fname, 'a') |
603 |
|
|
604 |
< |
# Determine the output directory name |
605 |
< |
dir = common.work_space.resDir() |
606 |
< |
dir += os.getlogin() |
607 |
< |
dir += '_' + os.path.basename(id) |
608 |
< |
return dir |
604 |
> |
#TaskName |
605 |
> |
dir = string.split(common.work_space.topDir(), '/') |
606 |
> |
taskName = dir[len(dir)-2] |
607 |
> |
|
608 |
> |
to_writeReq = '' |
609 |
> |
to_write = '' |
610 |
|
|
611 |
< |
def cancel(self, id): |
612 |
< |
""" Cancel the EDG job with id """ |
510 |
< |
self.checkProxy() |
511 |
< |
cmd = 'edg-job-cancel --noint ' + id |
512 |
< |
cmd_out = runCommand(cmd) |
513 |
< |
return cmd_out |
611 |
> |
req=' ' |
612 |
> |
req = req + jbt.getRequirements() |
613 |
|
|
515 |
– |
def createSchScript(self, nj): |
516 |
– |
""" |
517 |
– |
Create a JDL-file for EDG. |
518 |
– |
""" |
614 |
|
|
615 |
< |
job = common.job_list[nj] |
616 |
< |
jbt = job.type() |
617 |
< |
inp_sandbox = jbt.inputSandbox(nj) |
618 |
< |
out_sandbox = jbt.outputSandbox(nj) |
619 |
< |
inp_storage_subdir = '' |
615 |
> |
#sites = common.jobDB.destination(nj) |
616 |
> |
#if len(sites)>0 and sites[0]!="Any": |
617 |
> |
# req = req + ' && anyMatch(other.storage.CloseSEs, (_ITR4_))' |
618 |
> |
#req = req |
619 |
> |
|
620 |
> |
if self.EDG_requirements: |
621 |
> |
if (req == ' '): |
622 |
> |
req = req + self.EDG_requirements |
623 |
> |
else: |
624 |
> |
req = req + ' && ' + self.EDG_requirements |
625 |
> |
if self.EDG_ce_white_list: |
626 |
> |
ce_white_list = string.split(self.EDG_ce_white_list,',') |
627 |
> |
for i in range(len(ce_white_list)): |
628 |
> |
if i == 0: |
629 |
> |
if (req == ' '): |
630 |
> |
req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
631 |
> |
else: |
632 |
> |
req = req + ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
633 |
> |
pass |
634 |
> |
else: |
635 |
> |
req = req + ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
636 |
> |
req = req + ')' |
637 |
|
|
638 |
< |
title = '# This JDL was generated by '+\ |
639 |
< |
common.prog_name+' (version '+common.prog_version_str+')\n' |
640 |
< |
jt_string = '' |
638 |
> |
if self.EDG_ce_black_list: |
639 |
> |
ce_black_list = string.split(self.EDG_ce_black_list,',') |
640 |
> |
for ce in ce_black_list: |
641 |
> |
if (req == ' '): |
642 |
> |
req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))' |
643 |
> |
else: |
644 |
> |
req = req + ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))' |
645 |
> |
pass |
646 |
> |
if self.EDG_clock_time: |
647 |
> |
if (req == ' '): |
648 |
> |
req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
649 |
> |
else: |
650 |
> |
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
651 |
|
|
652 |
+ |
if self.EDG_cpu_time: |
653 |
+ |
if (req == ' '): |
654 |
+ |
req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
655 |
+ |
else: |
656 |
+ |
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
657 |
+ |
|
658 |
+ |
if ( self.EDG_retry_count ): |
659 |
+ |
to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n' |
660 |
+ |
pass |
661 |
|
|
662 |
+ |
to_write = to_write + 'MyProxyServer = ""' + self.proxyServer + '""\n' |
663 |
+ |
to_write = to_write + 'VirtualOrganisation = ""' + self.VO + '""\n' |
664 |
+ |
|
665 |
+ |
|
666 |
+ |
#TaskName |
667 |
+ |
dir = string.split(common.work_space.topDir(), '/') |
668 |
+ |
taskName = dir[len(dir)-2] |
669 |
+ |
|
670 |
+ |
xml.write(str(title)) |
671 |
+ |
xml.write('<task name="' +str(taskName)+'">\n') |
672 |
+ |
xml.write(jt_string) |
673 |
+ |
|
674 |
+ |
xml.write('<iterator>\n') |
675 |
+ |
xml.write('\t<iteratorRule name="ITR1">\n') |
676 |
+ |
xml.write('\t\t<ruleElement> 1:'+ str(nj) + ' </ruleElement>\n') |
677 |
+ |
xml.write('\t</iteratorRule>\n') |
678 |
+ |
xml.write('\t<iteratorRule name="ITR2">\n') |
679 |
+ |
for arg in argsList: |
680 |
+ |
xml.write('\t\t<ruleElement> <![CDATA[\n'+ arg + '\n\t\t]]> </ruleElement>\n') |
681 |
+ |
pass |
682 |
+ |
xml.write('\t</iteratorRule>\n') |
683 |
+ |
#print jobList |
684 |
+ |
xml.write('\t<iteratorRule name="ITR3">\n') |
685 |
+ |
xml.write('\t\t<ruleElement> 1:'+ str(nj) + ':1:6 </ruleElement>\n') |
686 |
+ |
xml.write('\t</iteratorRule>\n') |
687 |
+ |
|
688 |
+ |
''' |
689 |
+ |
indy: qui sotto ci sta itr4 |
690 |
+ |
''' |
691 |
|
|
692 |
< |
SPL = inp_storage_subdir |
693 |
< |
if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/' |
692 |
> |
itr4=self.findSites_(nj) |
693 |
> |
#print "--->>> itr4 = ", itr4 |
694 |
> |
if (itr4 != []): |
695 |
> |
xml.write('\t<iteratorRule name="ITR4">\n') |
696 |
> |
#print argsList |
697 |
> |
for arg in itr4: |
698 |
> |
xml.write('\t\t<ruleElement> <![CDATA[\n'+ arg + '\n\t\t]]> </ruleElement>\n') |
699 |
> |
pass |
700 |
> |
xml.write('\t</iteratorRule>\n') |
701 |
> |
req = req + ' && anyMatch(other.storage.CloseSEs, (_ITR4_))' |
702 |
> |
pass |
703 |
> |
# print "--->>> req= ", req |
704 |
> |
|
705 |
> |
if (to_write != ''): |
706 |
> |
xml.write('<extraTags\n') |
707 |
> |
xml.write(to_write) |
708 |
> |
xml.write('/>\n') |
709 |
> |
pass |
710 |
|
|
711 |
< |
jdl_fname = job.jdlFilename() |
712 |
< |
jdl = open(jdl_fname, 'w') |
537 |
< |
jdl.write(title) |
711 |
> |
xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n') |
712 |
> |
xml.write(jt_string) |
713 |
|
|
714 |
< |
script = job.scriptFilename() |
715 |
< |
jdl.write('Executable = "' + os.path.basename(script) +'";\n') |
716 |
< |
jdl.write(jt_string) |
714 |
> |
if (req != ' '): |
715 |
> |
req = req + '\n' |
716 |
> |
xml.write('<extraTags>\n') |
717 |
> |
xml.write('<Requirements>\n') |
718 |
> |
xml.write('<![CDATA[\n') |
719 |
> |
xml.write(req) |
720 |
> |
xml.write(']]>\n') |
721 |
> |
xml.write('</Requirements>\n') |
722 |
> |
xml.write('</extraTags>\n') |
723 |
> |
pass |
724 |
|
|
725 |
< |
### only one .sh JDL has arguments: |
544 |
< |
firstEvent = common.jobDB.firstEvent(nj) |
545 |
< |
maxEvents = common.jobDB.maxEvents(nj) |
546 |
< |
jdl.write('Arguments = "' + str(nj+1)+' '+str(firstEvent)+' '+str(maxEvents)+'";\n') |
725 |
> |
#executable |
726 |
|
|
727 |
< |
inp_box = 'InputSandbox = { ' |
728 |
< |
inp_box = inp_box + '"' + script + '",' |
727 |
> |
""" |
728 |
> |
INDY |
729 |
> |
script dipende dal jobType: dovrebbe essere semplice tirarlo fuori in altro modo |
730 |
> |
""" |
731 |
> |
script = job.scriptFilename() |
732 |
> |
xml.write('<program>\n') |
733 |
> |
xml.write('<exec> ' + os.path.basename(script) +' </exec>\n') |
734 |
> |
xml.write(jt_string) |
735 |
> |
|
736 |
> |
|
737 |
> |
### only one .sh JDL has arguments: |
738 |
> |
### Fabio |
739 |
> |
# xml.write('args = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'"\n') |
740 |
> |
xml.write('<args> <![CDATA[\n _ITR2_ \n]]> </args>\n') |
741 |
> |
xml.write('<program_types> crabjob </program_types>\n') |
742 |
> |
inp_box = script + ',' |
743 |
|
|
744 |
|
if inp_sandbox != None: |
745 |
|
for fl in inp_sandbox: |
746 |
< |
inp_box = inp_box + ' "' + fl + '",' |
746 |
> |
inp_box = inp_box + '' + fl + ',' |
747 |
|
pass |
748 |
|
pass |
749 |
|
|
750 |
< |
#if common.use_jam: |
751 |
< |
# inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",' |
752 |
< |
|
753 |
< |
# Marco (VERY TEMPORARY ML STUFF) |
754 |
< |
inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\ |
562 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\ |
563 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\ |
564 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"' |
565 |
< |
# End Marco |
750 |
> |
inp_box = inp_box + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + ',' +\ |
751 |
> |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + ','+\ |
752 |
> |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + ','+\ |
753 |
> |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + ','+\ |
754 |
> |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') |
755 |
|
|
756 |
|
if (not jbt.additional_inbox_files == []): |
757 |
< |
inp_box = inp_box + ', ' |
757 |
> |
inp_box = inp_box + ',' |
758 |
|
for addFile in jbt.additional_inbox_files: |
759 |
|
addFile = os.path.abspath(addFile) |
760 |
< |
inp_box = inp_box+' "'+addFile+'",' |
760 |
> |
inp_box = inp_box+''+addFile+',' |
761 |
|
pass |
762 |
|
|
763 |
|
if inp_box[-1] == ',' : inp_box = inp_box[:-1] |
764 |
< |
inp_box = inp_box + ' };\n' |
765 |
< |
jdl.write(inp_box) |
577 |
< |
|
578 |
< |
jdl.write('StdOutput = "' + job.stdout() + '";\n') |
579 |
< |
jdl.write('StdError = "' + job.stderr() + '";\n') |
764 |
> |
inp_box = '<infiles> <![CDATA[\n' + inp_box + '\n]]> </infiles>\n' |
765 |
> |
xml.write(inp_box) |
766 |
|
|
767 |
+ |
base = jbt.name() |
768 |
+ |
stdout = base + '__ITR3_.stdout' |
769 |
+ |
stderr = base + '__ITR3_.stderr' |
770 |
+ |
|
771 |
+ |
xml.write('<stderr> ' + stderr + '</stderr>\n') |
772 |
+ |
xml.write('<stdout> ' + stdout + '</stdout>\n') |
773 |
|
|
582 |
– |
if job.stdout() == job.stderr(): |
583 |
– |
out_box = 'OutputSandbox = { "' + \ |
584 |
– |
job.stdout() + '", ".BrokerInfo",' |
585 |
– |
else: |
586 |
– |
out_box = 'OutputSandbox = { "' + \ |
587 |
– |
job.stdout() + '", "' + \ |
588 |
– |
job.stderr() + '", ".BrokerInfo",' |
774 |
|
|
775 |
+ |
out_box = stdout + ',' + \ |
776 |
+ |
stderr + ',.BrokerInfo,' |
777 |
+ |
|
778 |
+ |
""" |
779 |
|
if int(self.return_data) == 1: |
780 |
|
if out_sandbox != None: |
781 |
|
for fl in out_sandbox: |
782 |
< |
out_box = out_box + ' "' + fl + '",' |
782 |
> |
out_box = out_box + '' + fl + ',' |
783 |
|
pass |
784 |
|
pass |
785 |
|
pass |
786 |
< |
|
598 |
< |
if out_box[-1] == ',' : out_box = out_box[:-1] |
599 |
< |
out_box = out_box + ' };' |
600 |
< |
jdl.write(out_box+'\n') |
786 |
> |
""" |
787 |
|
|
788 |
+ |
""" |
789 |
+ |
INDY |
790 |
+ |
qualcosa del genere andrebbe fatta per gli infiles |
791 |
+ |
""" |
792 |
+ |
if int(self.return_data) == 1: |
793 |
+ |
for fl in jbt.output_file: |
794 |
+ |
out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ',' |
795 |
+ |
pass |
796 |
+ |
pass |
797 |
|
|
798 |
< |
req='Requirements = ' |
799 |
< |
req = req + jbt.getRequirements() |
800 |
< |
# ### if at least a CE exists ... |
801 |
< |
# if common.analisys_common_info['sites']: |
802 |
< |
# if common.analisys_common_info['sw_version']: |
608 |
< |
# req='Requirements = ' |
609 |
< |
# req=req + 'Member("VO-cms-' + \ |
610 |
< |
# common.analisys_common_info['sw_version'] + \ |
611 |
< |
# '", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
612 |
< |
# if len(common.analisys_common_info['sites'])>0: |
613 |
< |
# req = req + ' && (' |
614 |
< |
# for i in range(len(common.analisys_common_info['sites'])): |
615 |
< |
# req = req + 'other.GlueCEInfoHostName == "' \ |
616 |
< |
# + common.analisys_common_info['sites'][i] + '"' |
617 |
< |
# if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ): |
618 |
< |
# req = req + ' || ' |
619 |
< |
# req = req + ')' |
620 |
< |
#### and USER REQUIREMENT |
621 |
< |
if self.EDG_requirements: |
622 |
< |
if (req == 'Requirement = '): |
623 |
< |
req = req + self.EDG_requirements |
624 |
< |
else: |
625 |
< |
req = req + ' && ' + self.EDG_requirements |
626 |
< |
if self.EDG_clock_time: |
627 |
< |
if (req == 'Requirement = '): |
628 |
< |
req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
629 |
< |
else: |
630 |
< |
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
631 |
< |
|
632 |
< |
if self.EDG_cpu_time: |
633 |
< |
if (req == 'Requirement = '): |
634 |
< |
req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
635 |
< |
else: |
636 |
< |
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
637 |
< |
if (req != 'Requirement = '): |
638 |
< |
req = req + ';\n' |
639 |
< |
jdl.write(req) |
640 |
< |
|
641 |
< |
jdl.write('VirtualOrganisation = "' + self.VO + '";\n') |
798 |
> |
if out_box[-1] == ',' : out_box = out_box[:-1] |
799 |
> |
out_box = '<outfiles> <![CDATA[\n' + out_box + '\n]]></outfiles>\n' |
800 |
> |
xml.write(out_box) |
801 |
> |
|
802 |
> |
xml.write('<BossAttr> crabjob.INTERNAL_ID=_ITR1_ </BossAttr>\n') |
803 |
|
|
804 |
< |
if ( self.EDG_retry_count ): |
805 |
< |
jdl.write('RetryCount = '+self.EDG_retry_count+';\n') |
806 |
< |
pass |
804 |
> |
xml.write('</program>\n') |
805 |
> |
xml.write('</chain>\n') |
806 |
> |
|
807 |
> |
xml.write('</iterator>\n') |
808 |
> |
xml.write('</task>\n') |
809 |
|
|
810 |
< |
jdl.close() |
810 |
> |
xml.close() |
811 |
|
return |
812 |
|
|
813 |
|
def checkProxy(self): |
816 |
|
""" |
817 |
|
if (self.proxyValid): return |
818 |
|
timeleft = -999 |
819 |
< |
minTimeLeft=10 # in hours |
820 |
< |
cmd = 'grid-proxy-info -e -v '+str(minTimeLeft)+':00' |
821 |
< |
# SL Here I have to use os.system since the stupid command exit with >0 if no valid proxy is found |
822 |
< |
cmd_out = os.system(cmd) |
823 |
< |
if (cmd_out>0): |
824 |
< |
common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 100h\n") |
825 |
< |
cmd = 'grid-proxy-init -valid 100:00' |
819 |
> |
minTimeLeft=10*3600 # in seconds |
820 |
> |
|
821 |
> |
minTimeLeftServer = 100 # in hours |
822 |
> |
|
823 |
> |
mustRenew = 0 |
824 |
> |
timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null') |
825 |
> |
timeLeftServer = -999 |
826 |
> |
if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal): |
827 |
> |
mustRenew = 1 |
828 |
> |
else: |
829 |
> |
timeLeftServer = runCommand('voms-proxy-info -actimeleft 2>/dev/null | head -1') |
830 |
> |
if not timeLeftServer or not isInt(timeLeftServer): |
831 |
> |
mustRenew = 1 |
832 |
> |
elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft: |
833 |
> |
mustRenew = 1 |
834 |
> |
pass |
835 |
> |
pass |
836 |
> |
|
837 |
> |
if mustRenew: |
838 |
> |
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") |
839 |
> |
cmd = 'voms-proxy-init -voms '+self.VO+' -valid 96:00' |
840 |
> |
if self.role: |
841 |
> |
cmd = 'voms-proxy-init -voms '+self.VO+':/'+self.VO+'/role='+self.role+' -valid 96:00' |
842 |
|
try: |
843 |
|
# SL as above: damn it! |
844 |
|
out = os.system(cmd) |
846 |
|
except: |
847 |
|
msg = "Unable to create a valid proxy!\n" |
848 |
|
raise CrabException(msg) |
670 |
– |
# cmd = 'grid-proxy-info -timeleft' |
671 |
– |
# cmd_out = runCommand(cmd,0,20) |
849 |
|
pass |
850 |
+ |
|
851 |
+ |
## now I do have a voms proxy valid, and I check the myproxy server |
852 |
+ |
renewProxy = 0 |
853 |
+ |
cmd = 'myproxy-info -d -s '+self.proxyServer |
854 |
+ |
cmd_out = runCommand(cmd,0,20) |
855 |
+ |
if not cmd_out: |
856 |
+ |
common.logger.message('No credential delegated to myproxy server '+self.proxyServer+' will do now') |
857 |
+ |
renewProxy = 1 |
858 |
+ |
else: |
859 |
+ |
# if myproxy exist but not long enough, renew |
860 |
+ |
reTime = re.compile( r'timeleft: (\d+)' ) |
861 |
+ |
#print "<"+str(reTime.search( cmd_out ).group(1))+">" |
862 |
+ |
if reTime.match( cmd_out ): |
863 |
+ |
time = reTime.search( line ).group(1) |
864 |
+ |
if time < minTimeLeftServer: |
865 |
+ |
renewProxy = 1 |
866 |
+ |
common.logger.message('No credential delegation will expire in '+time+' hours: renew it') |
867 |
+ |
pass |
868 |
+ |
pass |
869 |
+ |
|
870 |
+ |
# if not, create one. |
871 |
+ |
if renewProxy: |
872 |
+ |
cmd = 'myproxy-init -d -n -s '+self.proxyServer |
873 |
+ |
out = os.system(cmd) |
874 |
+ |
if (out>0): |
875 |
+ |
raise CrabException("Unable to delegate the proxy to myproxyserver "+self.proxyServer+" !\n") |
876 |
+ |
pass |
877 |
+ |
|
878 |
+ |
# cache proxy validity |
879 |
|
self.proxyValid=1 |
880 |
|
return |
881 |
< |
|
881 |
> |
|
882 |
|
def configOpt_(self): |
883 |
|
edg_ui_cfg_opt = ' ' |
884 |
|
if self.edg_config: |
885 |
< |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
885 |
> |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
886 |
|
if self.edg_config_vo: |
887 |
< |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
887 |
> |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
888 |
|
return edg_ui_cfg_opt |