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 |
+ |
except KeyError: |
52 |
+ |
self.EDG_ce_black_list = '' |
53 |
+ |
|
54 |
+ |
try: |
55 |
+ |
self.EDG_ce_white_list = cfg_params['EDG.ce_white_list'] |
56 |
+ |
except KeyError: self.EDG_ce_white_list = '' |
57 |
+ |
|
58 |
|
try: self.VO = cfg_params['EDG.virtual_organization'] |
59 |
|
except KeyError: self.VO = 'cms' |
60 |
|
|
61 |
|
try: self.return_data = cfg_params['USER.return_data'] |
62 |
< |
except KeyError: self.return_data = '' |
62 |
> |
except KeyError: self.return_data = 1 |
63 |
> |
|
64 |
> |
try: |
65 |
> |
self.copy_input_data = common.analisys_common_info['copy_input_data'] |
66 |
> |
except KeyError: self.copy_input_data = 0 |
67 |
|
|
68 |
|
try: |
69 |
|
self.copy_data = cfg_params["USER.copy_data"] |
70 |
< |
try: |
71 |
< |
self.SE = cfg_params['USER.storage_element'] |
72 |
< |
self.SE_PATH = cfg_params['USER.storage_path'] |
73 |
< |
except KeyError: |
74 |
< |
msg = "Error. The [USER] section does not have 'storage_element'" |
75 |
< |
msg = msg + " and/or 'storage_path' entries, necessary to copy the output" |
76 |
< |
common.logger.message(msg) |
77 |
< |
raise CrabException(msg) |
78 |
< |
except KeyError: self.copy_data = '' |
70 |
> |
if int(self.copy_data) == 1: |
71 |
> |
try: |
72 |
> |
self.SE = cfg_params['USER.storage_element'] |
73 |
> |
self.SE_PATH = cfg_params['USER.storage_path'] |
74 |
> |
except KeyError: |
75 |
> |
msg = "Error. The [USER] section does not have 'storage_element'" |
76 |
> |
msg = msg + " and/or 'storage_path' entries, necessary to copy the output" |
77 |
> |
common.logger.message(msg) |
78 |
> |
raise CrabException(msg) |
79 |
> |
except KeyError: self.copy_data = 0 |
80 |
> |
|
81 |
> |
if ( int(self.return_data) == 0 and int(self.copy_data) == 0 ): |
82 |
> |
msg = 'Warning: return_data = 0 and copy_data = 0 ==> your exe output will be lost\n' |
83 |
> |
msg = msg + 'Please modify return_data and copy_data value in your crab.cfg file\n' |
84 |
> |
raise CrabException(msg) |
85 |
|
|
86 |
+ |
try: |
87 |
+ |
self.lfc_host = cfg_params['EDG.lfc_host'] |
88 |
+ |
except KeyError: |
89 |
+ |
msg = "Error. The [EDG] section does not have 'lfc_host' value" |
90 |
+ |
msg = msg + " it's necessary to know the LFC host name" |
91 |
+ |
common.logger.message(msg) |
92 |
+ |
raise CrabException(msg) |
93 |
+ |
try: |
94 |
+ |
self.lcg_catalog_type = cfg_params['EDG.lcg_catalog_type'] |
95 |
+ |
except KeyError: |
96 |
+ |
msg = "Error. The [EDG] section does not have 'lcg_catalog_type' value" |
97 |
+ |
msg = msg + " it's necessary to know the catalog type" |
98 |
+ |
common.logger.message(msg) |
99 |
+ |
raise CrabException(msg) |
100 |
+ |
try: |
101 |
+ |
self.lfc_home = cfg_params['EDG.lfc_home'] |
102 |
+ |
except KeyError: |
103 |
+ |
msg = "Error. The [EDG] section does not have 'lfc_home' value" |
104 |
+ |
msg = msg + " it's necessary to know the home catalog dir" |
105 |
+ |
common.logger.message(msg) |
106 |
+ |
raise CrabException(msg) |
107 |
+ |
|
108 |
|
try: |
109 |
|
self.register_data = cfg_params["USER.register_data"] |
110 |
< |
try: |
111 |
< |
self.LFN = cfg_params['USER.lfn_dir'] |
112 |
< |
except KeyError: |
113 |
< |
msg = "Error. The [USER] section does not have 'lfn_dir' value" |
114 |
< |
msg = msg + " it's necessary for RLS registration" |
115 |
< |
common.logger.message(msg) |
116 |
< |
raise CrabException(msg) |
117 |
< |
except KeyError: self.register_data= '' |
110 |
> |
if int(self.register_data) == 1: |
111 |
> |
try: |
112 |
> |
self.LFN = cfg_params['USER.lfn_dir'] |
113 |
> |
except KeyError: |
114 |
> |
msg = "Error. The [USER] section does not have 'lfn_dir' value" |
115 |
> |
msg = msg + " it's necessary for LCF registration" |
116 |
> |
common.logger.message(msg) |
117 |
> |
raise CrabException(msg) |
118 |
> |
except KeyError: self.register_data = 0 |
119 |
> |
|
120 |
> |
if ( int(self.copy_data) == 0 and int(self.register_data) == 1 ): |
121 |
> |
msg = 'Warning: register_data = 1 must be used with copy_data = 1\n' |
122 |
> |
msg = msg + 'Please modify copy_data value in your crab.cfg file\n' |
123 |
> |
common.logger.message(msg) |
124 |
> |
raise CrabException(msg) |
125 |
|
|
126 |
|
try: self.EDG_requirements = cfg_params['EDG.requirements'] |
127 |
|
except KeyError: self.EDG_requirements = '' |
136 |
|
except KeyError: self.EDG_cpu_time = '' |
137 |
|
|
138 |
|
# Add EDG_WL_LOCATION to the python path |
81 |
– |
|
139 |
|
try: |
140 |
|
path = os.environ['EDG_WL_LOCATION'] |
141 |
|
except: |
148 |
|
sys.path.append(libPath) |
149 |
|
|
150 |
|
self.proxyValid=0 |
151 |
+ |
|
152 |
+ |
try: |
153 |
+ |
self._taskId = cfg_params['taskId'] |
154 |
+ |
except: |
155 |
+ |
self._taskId = '' |
156 |
+ |
|
157 |
+ |
try: self.jobtypeName = cfg_params['CRAB.jobtype'] |
158 |
+ |
except KeyError: self.jobtypeName = '' |
159 |
+ |
|
160 |
+ |
try: self.schedulerName = cfg_params['CRAB.scheduler'] |
161 |
+ |
except KeyError: self.scheduler = '' |
162 |
+ |
|
163 |
|
return |
164 |
|
|
165 |
|
|
167 |
|
""" |
168 |
|
Returns file with scheduler-specific parameters |
169 |
|
""" |
101 |
– |
|
170 |
|
if (self.edg_config and self.edg_config_vo != ''): |
171 |
|
self.param='sched_param.clad' |
172 |
|
param_file = open(common.work_space.shareDir()+'/'+self.param, 'w') |
181 |
|
""" |
182 |
|
Returns part of a job script which does scheduler-specific work. |
183 |
|
""" |
116 |
– |
|
184 |
|
txt = '' |
185 |
< |
if self.copy_data: |
185 |
> |
txt += "# job number (first parameter for job wrapper)\n" |
186 |
> |
txt += "NJob=$1\n" |
187 |
> |
|
188 |
> |
txt += '# job identification to DashBoard \n' |
189 |
> |
txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n' |
190 |
> |
txt += 'SyncGridJobId=`echo $EDG_WL_JOBID`\n' |
191 |
> |
txt += 'MonitorID=`echo ' + self._taskId + '`\n' |
192 |
> |
txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
193 |
> |
txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n' |
194 |
> |
txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
195 |
> |
|
196 |
> |
txt += 'echo "middleware discovery " \n' |
197 |
> |
txt += 'if [ $VO_CMS_SW_DIR ]; then \n' |
198 |
> |
txt += ' middleware=LCG \n' |
199 |
> |
txt += ' echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n' |
200 |
> |
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
201 |
> |
txt += ' echo "middleware =$middleware" \n' |
202 |
> |
txt += 'elif [ $GRID3_APP_DIR ]; then\n' |
203 |
> |
txt += ' middleware=OSG \n' |
204 |
> |
txt += ' echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | 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 [ $OSG_APP ]; then \n' |
208 |
> |
txt += ' middleware=OSG \n' |
209 |
> |
txt += ' echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n' |
210 |
> |
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
211 |
> |
txt += ' echo "middleware =$middleware" \n' |
212 |
> |
txt += 'else \n' |
213 |
> |
txt += ' echo "SET_CMS_ENV 10030 ==> middleware not identified" \n' |
214 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10030" \n' |
215 |
> |
txt += ' echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n' |
216 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo \n' |
217 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
218 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
219 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
220 |
> |
txt += ' exit 1 \n' |
221 |
> |
txt += 'fi \n' |
222 |
> |
|
223 |
> |
txt += '# report first time to DashBoard \n' |
224 |
> |
txt += 'dumpStatus $RUNTIME_AREA/$repo \n' |
225 |
> |
txt += 'rm -f $RUNTIME_AREA/$repo \n' |
226 |
> |
txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
227 |
> |
txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
228 |
> |
|
229 |
> |
txt += '\n\n' |
230 |
> |
|
231 |
> |
if int(self.copy_data) == 1: |
232 |
|
if self.SE: |
233 |
|
txt += 'export SE='+self.SE+'\n' |
234 |
|
txt += 'echo "SE = $SE"\n' |
236 |
|
if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/' |
237 |
|
txt += 'export SE_PATH='+self.SE_PATH+'\n' |
238 |
|
txt += 'echo "SE_PATH = $SE_PATH"\n' |
239 |
< |
|
240 |
< |
if self.register_data: |
239 |
> |
|
240 |
> |
txt += 'export VO='+self.VO+'\n' |
241 |
> |
### FEDE: add some line for LFC catalog setting |
242 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
243 |
> |
txt += ' if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n' |
244 |
> |
txt += ' export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n' |
245 |
> |
txt += ' fi\n' |
246 |
> |
txt += ' if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n' |
247 |
> |
txt += ' export LFC_HOST='+self.lfc_host+'\n' |
248 |
> |
txt += ' fi\n' |
249 |
> |
txt += ' if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n' |
250 |
> |
txt += ' export LFC_HOME='+self.lfc_home+'\n' |
251 |
> |
txt += ' fi\n' |
252 |
> |
txt += 'elif [ $middleware == OSG ]; then\n' |
253 |
> |
txt += ' echo "LFC catalog setting to be implemented for OSG"\n' |
254 |
> |
txt += 'fi\n' |
255 |
> |
##### |
256 |
> |
if int(self.register_data) == 1: |
257 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
258 |
> |
txt += ' export LFN='+self.LFN+'\n' |
259 |
> |
txt += ' lfc-ls $LFN\n' |
260 |
> |
txt += ' result=$?\n' |
261 |
> |
txt += ' echo $result\n' |
262 |
> |
### creation of LFN dir in LFC catalog, under /grid/cms dir |
263 |
> |
txt += ' if [ $result != 0 ]; then\n' |
264 |
> |
txt += ' lfc-mkdir $LFN\n' |
265 |
> |
txt += ' result=$?\n' |
266 |
> |
txt += ' echo $result\n' |
267 |
> |
txt += ' fi\n' |
268 |
> |
txt += 'elif [ $middleware == OSG ]; then\n' |
269 |
> |
txt += ' echo " Files registration to be implemented for OSG"\n' |
270 |
> |
txt += 'fi\n' |
271 |
> |
txt += '\n' |
272 |
> |
|
273 |
|
if self.VO: |
274 |
|
txt += 'export VO='+self.VO+'\n' |
275 |
|
if self.LFN: |
276 |
< |
txt += 'export LFN='+self.LFN+'\n' |
276 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
277 |
> |
txt += ' export LFN='+self.LFN+'\n' |
278 |
> |
txt += 'fi\n' |
279 |
|
txt += '\n' |
280 |
< |
txt += 'CloseCEs=`edg-brokerinfo getCE`\n' |
281 |
< |
txt += 'echo "CloseCEs = $CloseCEs"\n' |
282 |
< |
txt += 'CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
283 |
< |
txt += 'echo "CE = $CE"\n' |
280 |
> |
|
281 |
> |
txt += 'if [ $middleware == LCG ]; then\n' |
282 |
> |
txt += ' CloseCEs=`edg-brokerinfo getCE`\n' |
283 |
> |
txt += ' echo "CloseCEs = $CloseCEs"\n' |
284 |
> |
txt += ' CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
285 |
> |
txt += ' echo "CE = $CE"\n' |
286 |
> |
txt += 'elif [ $middleware == OSG ]; then \n' |
287 |
> |
txt += ' if [ $OSG_JOB_CONTACT ]; then \n' |
288 |
> |
txt += ' CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n' |
289 |
> |
txt += ' else \n' |
290 |
> |
txt += ' echo "SET_CMS_ENV 10099 ==> OSG mode: ERROR in setting CE name from OSG_JOB_CONTACT" \n' |
291 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10099" \n' |
292 |
> |
txt += ' echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n' |
293 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo \n' |
294 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
295 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
296 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
297 |
> |
txt += ' exit 1 \n' |
298 |
> |
txt += ' fi \n' |
299 |
> |
txt += 'fi \n' |
300 |
> |
|
301 |
> |
return txt |
302 |
> |
|
303 |
> |
def wsCopyInput(self): |
304 |
> |
""" |
305 |
> |
Copy input data from SE to WN |
306 |
> |
""" |
307 |
> |
txt = '' |
308 |
> |
try: |
309 |
> |
self.copy_input_data = common.analisys_common_info['copy_input_data'] |
310 |
> |
#print "self.copy_input_data = ", self.copy_input_data |
311 |
> |
except KeyError: self.copy_input_data = 0 |
312 |
> |
if int(self.copy_input_data) == 1: |
313 |
> |
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
314 |
> |
txt += 'if [ $middleware == OSG ]; then\n' |
315 |
> |
txt += ' #\n' |
316 |
> |
txt += ' # Copy Input Data from SE to this WN deactivated in OSG mode\n' |
317 |
> |
txt += ' #\n' |
318 |
> |
txt += ' echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n' |
319 |
> |
txt += 'elif [ $middleware == LCG ]; then \n' |
320 |
> |
txt += ' #\n' |
321 |
> |
txt += ' # Copy Input Data from SE to this WN\n' |
322 |
> |
txt += ' #\n' |
323 |
> |
### changed by georgia (put a loop copying more than one input files per jobs) |
324 |
> |
txt += ' for input_file in $cur_file_list \n' |
325 |
> |
txt += ' do \n' |
326 |
> |
#### FEDE |
327 |
> |
#txt += ' echo "which lcg-cp" \n' |
328 |
> |
#txt += ' which lcg-cp \n' |
329 |
> |
######### |
330 |
> |
txt += ' lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n' |
331 |
> |
txt += ' copy_input_exit_status=$?\n' |
332 |
> |
txt += ' echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n' |
333 |
> |
txt += ' if [ $copy_input_exit_status -ne 0 ]; then \n' |
334 |
> |
txt += ' echo "Problems with copying to WN" \n' |
335 |
> |
txt += ' else \n' |
336 |
> |
txt += ' echo "input copied into WN" \n' |
337 |
> |
txt += ' fi \n' |
338 |
> |
txt += ' done \n' |
339 |
> |
### copy a set of PU ntuples (same for each jobs -- but accessed randomly) |
340 |
> |
txt += ' for file in $cur_pu_list \n' |
341 |
> |
txt += ' do \n' |
342 |
> |
#### FEDE |
343 |
> |
#txt += ' echo "which lcg-cp" \n' |
344 |
> |
#txt += ' which lcg-cp \n' |
345 |
> |
######### |
346 |
> |
txt += ' lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n' |
347 |
> |
txt += ' copy_input_pu_exit_status=$?\n' |
348 |
> |
txt += ' echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n' |
349 |
> |
txt += ' if [ $copy_input_pu_exit_status -ne 0 ]; then \n' |
350 |
> |
txt += ' echo "Problems with copying pu to WN" \n' |
351 |
> |
txt += ' else \n' |
352 |
> |
txt += ' echo "input pu files copied into WN" \n' |
353 |
> |
txt += ' fi \n' |
354 |
> |
txt += ' done \n' |
355 |
> |
txt += ' \n' |
356 |
> |
txt += ' ### Check SCRATCH space available on WN : \n' |
357 |
> |
txt += ' df -h \n' |
358 |
> |
txt += 'fi \n' |
359 |
> |
|
360 |
|
return txt |
361 |
|
|
362 |
|
def wsCopyOutput(self): |
365 |
|
to copy produced output into a storage element. |
366 |
|
""" |
367 |
|
txt = '' |
368 |
< |
if self.copy_data: |
146 |
< |
copy = 'globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file' |
368 |
> |
if int(self.copy_data) == 1: |
369 |
|
txt += '#\n' |
370 |
|
txt += '# Copy output to SE = $SE\n' |
371 |
|
txt += '#\n' |
372 |
< |
txt += 'if [ $exe_result -eq 0 ]; then\n' |
373 |
< |
txt += ' for out_file in $file_list ; do\n' |
374 |
< |
txt += ' echo "Trying to copy output file to $SE "\n' |
375 |
< |
txt += ' echo "'+copy+'"\n' |
376 |
< |
txt += ' '+copy+' 2>&1\n' |
377 |
< |
txt += ' copy_exit_status=$?\n' |
378 |
< |
txt += ' echo "COPY_EXIT_STATUS = $copy_exit_status"\n' |
157 |
< |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
158 |
< |
txt += ' if [ $copy_exit_status -ne 0 ]; then \n' |
159 |
< |
txt += ' echo "Problems with SE= $SE" \n' |
160 |
< |
txt += ' else \n' |
161 |
< |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
372 |
> |
#txt += 'if [ $exe_result -eq 0 ]; then\n' |
373 |
> |
txt += ' if [ $middleware == OSG ]; then\n' |
374 |
> |
txt += ' echo "X509_USER_PROXY = $X509_USER_PROXY"\n' |
375 |
> |
txt += ' echo "source $OSG_APP/glite/setup_glite_ui.sh"\n' |
376 |
> |
txt += ' source $OSG_APP/glite/setup_glite_ui.sh\n' |
377 |
> |
txt += ' export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n' |
378 |
> |
txt += ' echo "export X509_CERT_DIR=$X509_CERT_DIR"\n' |
379 |
|
txt += ' fi \n' |
380 |
< |
txt += ' done\n' |
381 |
< |
txt += 'fi \n' |
380 |
> |
txt += ' for out_file in $file_list ; do\n' |
381 |
> |
txt += ' echo "Trying to copy output file to $SE using lcg-cp"\n' |
382 |
> |
txt += ' echo "lcg-cp --vo $VO -t 1200 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
383 |
> |
txt += ' exitstring=`lcg-cp --vo $VO -t 1200 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
384 |
> |
txt += ' copy_exit_status=$?\n' |
385 |
> |
txt += ' echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n' |
386 |
> |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
387 |
> |
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
388 |
> |
txt += ' echo "Possible problem with SE = $SE"\n' |
389 |
> |
txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n' |
390 |
> |
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
391 |
> |
txt += ' echo "lcg-cp failed, attempting srmcp"\n' |
392 |
> |
txt += ' echo "mkdir -p $HOME/.srmconfig"\n' |
393 |
> |
txt += ' mkdir -p $HOME/.srmconfig\n' |
394 |
> |
txt += ' if [ $middleware == LCG ]; then\n' |
395 |
> |
txt += ' echo "srmcp -retry_num 5 -retry_timeout 240000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n' |
396 |
> |
txt += ' exitstring=`srmcp -retry_num 5 -retry_timeout 240000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n' |
397 |
> |
txt += ' elif [ $middleware == OSG ]; then\n' |
398 |
> |
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' |
399 |
> |
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' |
400 |
> |
txt += ' fi \n' |
401 |
> |
txt += ' copy_exit_status=$?\n' |
402 |
> |
txt += ' echo "COPY_EXIT_STATUS for srm = $copy_exit_status"\n' |
403 |
> |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
404 |
> |
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
405 |
> |
txt += ' echo "Problems with SE = $SE"\n' |
406 |
> |
txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n' |
407 |
> |
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
408 |
> |
txt += ' echo "lcg-cp and srm failed"\n' |
409 |
> |
txt += ' echo "If storage_path in your config file contains a ? you may need a \? instead."\n' |
410 |
> |
txt += ' else\n' |
411 |
> |
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
412 |
> |
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
413 |
> |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
414 |
> |
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
415 |
> |
txt += ' echo "srmcp succeeded"\n' |
416 |
> |
txt += ' fi\n' |
417 |
> |
txt += ' else\n' |
418 |
> |
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
419 |
> |
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
420 |
> |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
421 |
> |
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
422 |
> |
txt += ' echo "lcg-cp succeeded"\n' |
423 |
> |
txt += ' fi\n' |
424 |
> |
txt += ' done\n' |
425 |
> |
#txt += 'fi\n' |
426 |
|
return txt |
427 |
|
|
428 |
|
def wsRegisterOutput(self): |
431 |
|
""" |
432 |
|
|
433 |
|
txt = '' |
434 |
< |
if self.register_data: |
434 |
> |
if int(self.register_data) == 1: |
435 |
> |
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
436 |
> |
txt += 'if [ $middleware == OSG ]; then\n' |
437 |
> |
txt += ' #\n' |
438 |
> |
txt += ' # Register output to LFC deactivated in OSG mode\n' |
439 |
> |
txt += ' #\n' |
440 |
> |
txt += ' echo "Register output to LFC deactivated in OSG mode"\n' |
441 |
> |
txt += 'elif [ $middleware == LCG ]; then \n' |
442 |
|
txt += '#\n' |
443 |
< |
txt += '# Register output to RLS\n' |
443 |
> |
txt += '# Register output to LFC\n' |
444 |
|
txt += '#\n' |
445 |
< |
txt += 'if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
446 |
< |
txt += ' for out_file in $file_list ; do\n' |
447 |
< |
txt += ' echo "Trying to register the output file into RLS"\n' |
448 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n' |
449 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
450 |
< |
txt += ' register_exit_status=$?\n' |
451 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
452 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
453 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
454 |
< |
txt += ' echo "Problems with the registration to RLS" \n' |
187 |
< |
txt += ' echo "Try with srm protocol" \n' |
188 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n' |
189 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n' |
445 |
> |
#txt += ' if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
446 |
> |
txt += ' if [ $copy_exit_status -eq 0 ]; then\n' |
447 |
> |
txt += ' for out_file in $file_list ; do\n' |
448 |
> |
txt += ' echo "Trying to register the output file into LFC"\n' |
449 |
> |
#### FEDE |
450 |
> |
#txt += ' echo "which lcg-rf" \n' |
451 |
> |
#txt += ' which lcg-rf \n' |
452 |
> |
######### |
453 |
> |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n' |
454 |
> |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
455 |
|
txt += ' register_exit_status=$?\n' |
456 |
|
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
457 |
|
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
458 |
|
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
459 |
< |
txt += ' echo "Problems with the registration into RLS" \n' |
459 |
> |
txt += ' echo "Problems with the registration to LFC" \n' |
460 |
> |
txt += ' echo "Try with srm protocol" \n' |
461 |
> |
#### FEDE |
462 |
> |
#txt += ' echo "which lcg-rf" \n' |
463 |
> |
#txt += ' which lcg-rf \n' |
464 |
> |
######### |
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 RLS"\n' |
478 |
< |
txt += ' fi \n' |
479 |
< |
txt += ' done\n' |
480 |
< |
txt += 'elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n' |
481 |
< |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
482 |
< |
txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
483 |
< |
txt += ' for out_file in $file_list ; do\n' |
484 |
< |
txt += ' echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n' |
485 |
< |
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' |
486 |
< |
txt += ' register_exit_status=$?\n' |
487 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
488 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
489 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
490 |
< |
txt += ' echo "Problems with CloseSE" \n' |
491 |
< |
txt += ' else \n' |
492 |
< |
txt += ' echo "The program was successfully executed"\n' |
493 |
< |
txt += ' echo "SE = $CLOSE_SE"\n' |
494 |
< |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
495 |
< |
txt += ' fi \n' |
496 |
< |
txt += ' done\n' |
497 |
< |
txt += 'else\n' |
498 |
< |
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 += ' elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n' |
479 |
> |
txt += ' else \n' |
480 |
> |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
481 |
> |
txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
482 |
> |
txt += ' for out_file in $file_list ; do\n' |
483 |
> |
#### FEDE |
484 |
> |
#txt += ' echo "which lcg-cr" \n' |
485 |
> |
#txt += ' which lcg-cr \n' |
486 |
> |
######### |
487 |
> |
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' |
488 |
> |
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' |
489 |
> |
txt += ' register_exit_status=$?\n' |
490 |
> |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
491 |
> |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
492 |
> |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
493 |
> |
txt += ' echo "Problems with CloseSE or Catalog" \n' |
494 |
> |
txt += ' else \n' |
495 |
> |
txt += ' echo "The program was successfully executed"\n' |
496 |
> |
txt += ' echo "SE = $CLOSE_SE"\n' |
497 |
> |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
498 |
> |
txt += ' fi \n' |
499 |
> |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
500 |
> |
txt += ' done\n' |
501 |
> |
#txt += ' else\n' |
502 |
> |
#txt += ' echo "Problem with the executable"\n' |
503 |
> |
txt += ' fi \n' |
504 |
> |
txt += ' exit_status=$register_exit_status\n' |
505 |
|
txt += 'fi \n' |
506 |
|
return txt |
507 |
|
|
510 |
|
retrieve the logging info from logging and bookkeeping and return it |
511 |
|
""" |
512 |
|
self.checkProxy() |
227 |
– |
# id = common.jobDB.jobId(nj) |
513 |
|
cmd = 'edg-job-get-logging-info -v 2 ' + id |
514 |
< |
cmd_out = os.popen(cmd) |
515 |
< |
# cmd_out = runCommand(cmd) |
514 |
> |
#cmd_out = os.popen(cmd) |
515 |
> |
cmd_out = runCommand(cmd) |
516 |
|
return cmd_out |
517 |
|
|
518 |
|
def listMatch(self, nj): |
520 |
|
Check the compatibility of available resources |
521 |
|
""" |
522 |
|
self.checkProxy() |
523 |
< |
jdl = common.job_list[nj].jdlFilename() |
524 |
< |
cmd = 'edg-job-list-match ' + self.configOpt_() + jdl |
525 |
< |
myCmd = os.popen(cmd) |
526 |
< |
cmd_out = myCmd.readlines() |
527 |
< |
myCmd.close() |
523 |
> |
jdl = common.work_space.shareDir()+"fake.jdl" |
524 |
> |
cmd = 'edg-job-list-match ' + self.configOpt_() + str(jdl) |
525 |
> |
cmd_out = runCommand(cmd,0,10) |
526 |
> |
if not cmd_out: |
527 |
> |
raise CrabException("ERROR: "+cmd+" failed!") |
528 |
> |
|
529 |
|
return self.parseListMatch_(cmd_out, jdl) |
530 |
|
|
531 |
|
def parseListMatch_(self, out, jdl): |
532 |
< |
|
532 |
> |
""" |
533 |
> |
Parse the f* output of edg-list-match and produce something sensible |
534 |
> |
""" |
535 |
|
reComment = re.compile( r'^\**$' ) |
536 |
|
reEmptyLine = re.compile( r'^$' ) |
537 |
|
reVO = re.compile( r'Selected Virtual Organisation name.*' ) |
538 |
< |
reCE = re.compile( r'CEId' ) |
538 |
> |
reLine = re.compile( r'.*') |
539 |
> |
reCE = re.compile( r'(.*:.*)') |
540 |
> |
reCEId = re.compile( r'CEId.*') |
541 |
|
reNO = re.compile( r'No Computing Element matching' ) |
542 |
|
reRB = re.compile( r'Connecting to host' ) |
543 |
|
next = 0 |
544 |
|
CEs=[] |
545 |
|
Match=0 |
546 |
|
|
547 |
< |
for line in out: |
548 |
< |
line = line.strip() |
549 |
< |
if reComment.match( line ): |
550 |
< |
next = 0 |
551 |
< |
continue |
552 |
< |
if reEmptyLine.match(line): |
553 |
< |
continue |
547 |
> |
#print out |
548 |
> |
lines = reLine.findall(out) |
549 |
> |
|
550 |
> |
i=0 |
551 |
> |
CEs=[] |
552 |
> |
for line in lines: |
553 |
> |
string.strip(line) |
554 |
> |
#print line |
555 |
> |
if reNO.match( line ): |
556 |
> |
common.logger.debug(5,line) |
557 |
> |
return 0 |
558 |
> |
pass |
559 |
|
if reVO.match( line ): |
560 |
< |
VO =line.split()[-1] |
561 |
< |
common.logger.debug(5, 'VO :'+VO) |
560 |
> |
VO =reVO.match( line ).group() |
561 |
> |
common.logger.debug(5,"VO "+VO) |
562 |
|
pass |
563 |
+ |
|
564 |
|
if reRB.match( line ): |
565 |
< |
RB =line.split()[3] |
566 |
< |
common.logger.debug(5, 'Using RB :'+RB) |
565 |
> |
RB = reRB.match(line).group() |
566 |
> |
common.logger.debug(5,"RB "+RB) |
567 |
|
pass |
568 |
< |
if reCE.search( line ): |
569 |
< |
next = 1 |
570 |
< |
continue |
571 |
< |
if next: |
572 |
< |
CE=line.split(':')[0] |
573 |
< |
if (CEs.count(CE) > 0): |
574 |
< |
pass |
575 |
< |
else: |
280 |
< |
CEs.append(CE) |
281 |
< |
Match=Match+1 |
282 |
< |
common.logger.debug(5, 'Matched CE :'+CE) |
283 |
< |
pass |
284 |
< |
if reNO.match( line ): |
285 |
< |
common.logger.debug(5,line) |
286 |
< |
self.noMatchFound_(jdl) |
287 |
< |
Match=0 |
568 |
> |
|
569 |
> |
if reCEId.search( line ): |
570 |
> |
for lineCE in lines[i:-1]: |
571 |
> |
if reCE.match( lineCE ): |
572 |
> |
CE = string.strip(reCE.search(lineCE).group(1)) |
573 |
> |
CEs.append(CE.split(':')[0]) |
574 |
> |
pass |
575 |
> |
pass |
576 |
|
pass |
577 |
< |
return Match |
577 |
> |
i=i+1 |
578 |
> |
pass |
579 |
> |
|
580 |
> |
common.logger.debug(5,"All CE :"+str(CEs)) |
581 |
> |
|
582 |
> |
sites = [] |
583 |
> |
[sites.append(it) for it in CEs if not sites.count(it)] |
584 |
> |
|
585 |
> |
common.logger.debug(5,"All Sites :"+str(sites)) |
586 |
> |
common.logger.message("Matched Sites :"+str(sites)) |
587 |
> |
return len(sites) |
588 |
|
|
589 |
|
def noMatchFound_(self, jdl): |
590 |
|
reReq = re.compile( r'Requirements' ) |
622 |
|
pass |
623 |
|
return jid |
624 |
|
|
625 |
+ |
def resubmit(self, nj_list): |
626 |
+ |
""" |
627 |
+ |
Prepare jobs to be submit |
628 |
+ |
""" |
629 |
+ |
return |
630 |
+ |
|
631 |
|
def getExitStatus(self, id): |
632 |
|
return self.getStatusAttribute_(id, 'exit_code') |
633 |
|
|
653 |
|
jobStat.getStatus(id, level) |
654 |
|
err, apiMsg = jobStat.get_error() |
655 |
|
if err: |
352 |
– |
#print 'Error caught', apiMsg |
353 |
– |
#common.log.message(apiMsg) |
656 |
|
common.logger.debug(5,'Error caught' + apiMsg) |
657 |
|
return None |
658 |
|
else: |
680 |
|
|
681 |
|
# Determine the output directory name |
682 |
|
dir = common.work_space.resDir() |
683 |
< |
dir += os.getlogin() |
683 |
> |
dir += os.environ['USER'] |
684 |
|
dir += '_' + os.path.basename(id) |
685 |
|
return dir |
686 |
|
|
690 |
|
cmd = 'edg-job-cancel --noint ' + id |
691 |
|
cmd_out = runCommand(cmd) |
692 |
|
return cmd_out |
693 |
+ |
|
694 |
+ |
def createFakeJdl(self,nj): # TMP Just waiting listmatch functionalitly |
695 |
+ |
# implementation into BOSS4 Daniele |
696 |
+ |
""" |
697 |
+ |
Create a fake jdl considering |
698 |
+ |
only requirements |
699 |
+ |
""" |
700 |
+ |
#job = common.job_list[nj] |
701 |
+ |
job = common.job_list[0] |
702 |
+ |
jbt = job.type() |
703 |
+ |
inp_storage_subdir = '' |
704 |
+ |
|
705 |
+ |
|
706 |
+ |
SPL = inp_storage_subdir |
707 |
+ |
if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/' |
708 |
+ |
|
709 |
+ |
jdl = open(common.work_space.shareDir()+"fake.jdl","w") |
710 |
+ |
|
711 |
+ |
script = job.scriptFilename() |
712 |
+ |
jdl.write('Executable = "' + os.path.basename(script) +'";\n') |
713 |
+ |
|
714 |
+ |
req='Requirements = ' |
715 |
+ |
noreq=req |
716 |
+ |
req = req + jbt.getRequirements() |
717 |
+ |
#### and USER REQUIREMENT |
718 |
+ |
if self.EDG_requirements: |
719 |
+ |
if (req != noreq): |
720 |
+ |
req = req + ' && ' |
721 |
+ |
req = req + self.EDG_requirements |
722 |
+ |
#### FEDE ##### |
723 |
+ |
if self.EDG_ce_white_list: |
724 |
+ |
ce_white_list = string.split(self.EDG_ce_white_list,',') |
725 |
+ |
#print "req = ", req |
726 |
+ |
for i in range(len(ce_white_list)): |
727 |
+ |
if i == 0: |
728 |
+ |
if (req != noreq): |
729 |
+ |
req = req + ' && ' |
730 |
+ |
req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
731 |
+ |
pass |
732 |
+ |
else: |
733 |
+ |
req = req + ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
734 |
+ |
req = req + ')' |
735 |
+ |
|
736 |
+ |
if self.EDG_ce_black_list: |
737 |
+ |
ce_black_list = string.split(self.EDG_ce_black_list,',') |
738 |
+ |
for ce in ce_black_list: |
739 |
+ |
if (req != noreq): |
740 |
+ |
req = req + ' && ' |
741 |
+ |
req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))' |
742 |
+ |
pass |
743 |
+ |
|
744 |
+ |
############### |
745 |
+ |
clockTime=480 |
746 |
+ |
if self.EDG_clock_time: |
747 |
+ |
clockTime= self.EDG_clock_time |
748 |
+ |
if (req != noreq): |
749 |
+ |
req = req + ' && ' |
750 |
+ |
req = req + '((other.GlueCEPolicyMaxWallClockTime == 0) || (other.GlueCEPolicyMaxWallClockTime>='+str(clockTime)+'))' |
751 |
+ |
|
752 |
+ |
cpuTime=1000 |
753 |
+ |
if self.EDG_cpu_time: |
754 |
+ |
cpuTime=self.EDG_cpu_time |
755 |
+ |
if (req != noreq): |
756 |
+ |
req = req + ' && ' |
757 |
+ |
req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))' |
758 |
+ |
|
759 |
+ |
if (req != noreq): |
760 |
+ |
req = req + ';\n' |
761 |
+ |
jdl.write(req) |
762 |
+ |
|
763 |
+ |
jdl.write('VirtualOrganisation = "' + self.VO + '";\n') |
764 |
+ |
|
765 |
+ |
if ( self.EDG_retry_count ): |
766 |
+ |
jdl.write('RetryCount = '+self.EDG_retry_count+';\n') |
767 |
+ |
pass |
768 |
|
|
769 |
< |
def createSchScript(self, nj): |
769 |
> |
jdl.write('MyProxyServer = "' + self.proxyServer + '";\n') |
770 |
> |
|
771 |
> |
jdl.close() |
772 |
> |
return |
773 |
> |
|
774 |
> |
|
775 |
> |
def createXMLSchScript(self, nj, argsList, jobList): |
776 |
> |
# def createXMLSchScript(self, nj): |
777 |
|
""" |
778 |
< |
Create a JDL-file for EDG. |
778 |
> |
Create a XML-file for BOSS4. |
779 |
|
""" |
780 |
+ |
# job = common.job_list[nj] |
781 |
|
|
782 |
< |
job = common.job_list[nj] |
782 |
> |
""" |
783 |
> |
INDY |
784 |
> |
[begin] da rivedere: |
785 |
> |
in particolare passerei il jobType ed eliminerei le dipendenze da job |
786 |
> |
""" |
787 |
> |
index = nj - 1 |
788 |
> |
job = common.job_list[index] |
789 |
|
jbt = job.type() |
399 |
– |
inp_sandbox = jbt.inputSandbox(nj) |
400 |
– |
out_sandbox = jbt.outputSandbox(nj) |
401 |
– |
inp_storage_subdir = '' |
790 |
|
|
791 |
< |
title = '# This JDL was generated by '+\ |
792 |
< |
common.prog_name+' (version '+common.prog_version_str+')\n' |
791 |
> |
inp_sandbox = jbt.inputSandbox(index) |
792 |
> |
out_sandbox = jbt.outputSandbox(index) |
793 |
> |
""" |
794 |
> |
[end] da rivedere |
795 |
> |
""" |
796 |
> |
|
797 |
> |
|
798 |
> |
title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' |
799 |
|
jt_string = '' |
800 |
+ |
|
801 |
+ |
xml_fname = str(self.jobtypeName)+'.xml' |
802 |
+ |
xml = open(common.work_space.shareDir()+'/'+xml_fname, 'a') |
803 |
|
|
804 |
+ |
#TaskName |
805 |
+ |
dir = string.split(common.work_space.topDir(), '/') |
806 |
+ |
taskName = dir[len(dir)-2] |
807 |
+ |
|
808 |
+ |
to_writeReq = '' |
809 |
+ |
to_write = '' |
810 |
+ |
req=' ' |
811 |
+ |
req = req + jbt.getRequirements() |
812 |
+ |
if self.EDG_requirements: |
813 |
+ |
if (req == ' '): |
814 |
+ |
req = req + self.EDG_requirements |
815 |
+ |
else: |
816 |
+ |
req = req + ' && ' + self.EDG_requirements |
817 |
+ |
if self.EDG_ce_white_list: |
818 |
+ |
ce_white_list = string.split(self.EDG_ce_white_list,',') |
819 |
+ |
for i in range(len(ce_white_list)): |
820 |
+ |
if i == 0: |
821 |
+ |
if (req == ' '): |
822 |
+ |
req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
823 |
+ |
else: |
824 |
+ |
req = req + ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
825 |
+ |
pass |
826 |
+ |
else: |
827 |
+ |
req = req + ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
828 |
+ |
req = req + ')' |
829 |
+ |
|
830 |
+ |
if self.EDG_ce_black_list: |
831 |
+ |
ce_black_list = string.split(self.EDG_ce_black_list,',') |
832 |
+ |
for ce in ce_black_list: |
833 |
+ |
if (req == ' '): |
834 |
+ |
req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))' |
835 |
+ |
else: |
836 |
+ |
req = req + ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))' |
837 |
+ |
pass |
838 |
+ |
if self.EDG_clock_time: |
839 |
+ |
if (req == ' '): |
840 |
+ |
req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
841 |
+ |
else: |
842 |
+ |
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
843 |
+ |
|
844 |
+ |
if self.EDG_cpu_time: |
845 |
+ |
if (req == ' '): |
846 |
+ |
req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
847 |
+ |
else: |
848 |
+ |
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
849 |
+ |
if (req != ' '): |
850 |
+ |
req = req + '\n' |
851 |
+ |
to_writeReq = req |
852 |
+ |
|
853 |
|
|
854 |
+ |
if ( self.EDG_retry_count ): |
855 |
+ |
to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n' |
856 |
+ |
pass |
857 |
+ |
|
858 |
+ |
#to_write = to_write + 'MyProxyServer = ""' + self.proxyServer + '""\n' |
859 |
+ |
to_write = to_write + 'MyProxyServer = "' + self.proxyServer + '"\n' |
860 |
+ |
to_write = to_write + 'VirtualOrganisation = "' + self.VO + '"\n' |
861 |
+ |
|
862 |
+ |
|
863 |
+ |
#TaskName |
864 |
+ |
dir = string.split(common.work_space.topDir(), '/') |
865 |
+ |
taskName = dir[len(dir)-2] |
866 |
+ |
|
867 |
+ |
|
868 |
+ |
xml.write(str(title)) |
869 |
+ |
xml.write('<task name="' +str(taskName)+'">\n') |
870 |
+ |
xml.write(jt_string) |
871 |
+ |
#Here it must pass the extra Tags.. (into Task & out of chain) |
872 |
+ |
if (to_writeReq != ''): |
873 |
+ |
xml.write('<extraTags>\n') |
874 |
+ |
xml.write('<Requirements>\n') |
875 |
+ |
xml.write('<![CDATA[\n') |
876 |
+ |
xml.write(to_writeReq) |
877 |
+ |
xml.write(']]>\n') |
878 |
+ |
xml.write('</Requirements>\n') |
879 |
+ |
xml.write('</extraTags>\n') |
880 |
+ |
pass |
881 |
|
|
882 |
< |
SPL = inp_storage_subdir |
883 |
< |
if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/' |
882 |
> |
if (to_write != ''): |
883 |
> |
xml.write('<extraTags\n') |
884 |
> |
xml.write(to_write) |
885 |
> |
xml.write('/>\n') |
886 |
> |
pass |
887 |
|
|
888 |
< |
jdl_fname = job.jdlFilename() |
889 |
< |
jdl = open(jdl_fname, 'w') |
890 |
< |
jdl.write(title) |
888 |
> |
xml.write('<iterator>\n') |
889 |
> |
print str(nj) |
890 |
> |
xml.write('\t<iteratorRule name="ITR1" rule="1:'+ str(nj) + '" />\n') |
891 |
> |
print argsList |
892 |
> |
xml.write('\t<iteratorRule name="ITR2" rule="'+ argsList + '" />\n') |
893 |
> |
print jobList |
894 |
> |
xml.write('\t<iteratorRule name="ITR3" rule="'+ jobList + '" />\n') |
895 |
> |
|
896 |
> |
xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n') |
897 |
> |
xml.write(jt_string) |
898 |
|
|
899 |
< |
script = job.scriptFilename() |
417 |
< |
jdl.write('Executable = "' + os.path.basename(script) +'";\n') |
418 |
< |
jdl.write(jt_string) |
899 |
> |
#executable |
900 |
|
|
901 |
+ |
""" |
902 |
+ |
INDY |
903 |
+ |
script dipende dal jobType: dovrebbe essere semplice tirarlo fuori in altro modo |
904 |
+ |
""" |
905 |
+ |
script = job.scriptFilename() |
906 |
+ |
xml.write('<program exec="' + os.path.basename(script) +'"\n') |
907 |
+ |
xml.write(jt_string) |
908 |
+ |
|
909 |
+ |
|
910 |
|
### only one .sh JDL has arguments: |
911 |
< |
firstEvent = common.jobDB.firstEvent(nj) |
912 |
< |
maxEvents = common.jobDB.maxEvents(nj) |
913 |
< |
jdl.write('Arguments = "' + str(nj+1)+' '+str(firstEvent)+' '+str(maxEvents)+'";\n') |
914 |
< |
|
915 |
< |
inp_box = 'InputSandbox = { ' |
916 |
< |
inp_box = inp_box + '"' + script + '",' |
911 |
> |
### Fabio |
912 |
> |
# xml.write('args = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'"\n') |
913 |
> |
xml.write('args = "_ITR2_"\n') |
914 |
> |
xml.write('program_types="crabjob"\n') |
915 |
> |
inp_box = 'infiles="' |
916 |
> |
inp_box = inp_box + '' + script + ',' |
917 |
|
|
918 |
|
if inp_sandbox != None: |
919 |
|
for fl in inp_sandbox: |
920 |
< |
inp_box = inp_box + ' "' + fl + '",' |
920 |
> |
inp_box = inp_box + '' + fl + ',' |
921 |
|
pass |
922 |
|
pass |
923 |
|
|
924 |
< |
#if common.use_jam: |
925 |
< |
# inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",' |
926 |
< |
|
927 |
< |
for addFile in jbt.additional_inbox_files: |
928 |
< |
addFile = os.path.abspath(addFile) |
929 |
< |
inp_box = inp_box+' "'+addFile+'",' |
930 |
< |
pass |
924 |
> |
# Marco (VERY TEMPORARY ML STUFF) |
925 |
> |
inp_box = inp_box + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + ',' +\ |
926 |
> |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + ','+\ |
927 |
> |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + ','+\ |
928 |
> |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + ','+\ |
929 |
> |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') |
930 |
> |
# End Marco |
931 |
> |
|
932 |
> |
if (not jbt.additional_inbox_files == []): |
933 |
> |
inp_box = inp_box + ', ' |
934 |
> |
for addFile in jbt.additional_inbox_files: |
935 |
> |
addFile = os.path.abspath(addFile) |
936 |
> |
inp_box = inp_box+''+addFile+',' |
937 |
> |
pass |
938 |
|
|
939 |
|
if inp_box[-1] == ',' : inp_box = inp_box[:-1] |
940 |
< |
inp_box = inp_box + ' };\n' |
941 |
< |
jdl.write(inp_box) |
445 |
< |
|
446 |
< |
jdl.write('StdOutput = "' + job.stdout() + '";\n') |
447 |
< |
jdl.write('StdError = "' + job.stderr() + '";\n') |
940 |
> |
inp_box = inp_box + ' "\n' |
941 |
> |
xml.write(inp_box) |
942 |
|
|
943 |
+ |
base = jbt.name() |
944 |
+ |
stdout = base + '__ITR3_.stdout' |
945 |
+ |
stderr = base + '__ITR3_.stderr' |
946 |
|
|
947 |
< |
if job.stdout() == job.stderr(): |
948 |
< |
out_box = 'OutputSandbox = { "' + \ |
949 |
< |
job.stdout() + '", ".BrokerInfo",' |
950 |
< |
else: |
951 |
< |
out_box = 'OutputSandbox = { "' + \ |
952 |
< |
job.stdout() + '", "' + \ |
953 |
< |
job.stderr() + '", ".BrokerInfo",' |
947 |
> |
xml.write('stderr="' + stdout + '"\n') |
948 |
> |
xml.write('stdout="' + stderr + '"\n') |
949 |
> |
|
950 |
> |
|
951 |
> |
out_box = 'outfiles="' + \ |
952 |
> |
stdout + ',' + \ |
953 |
> |
stderr + ',.BrokerInfo,' |
954 |
|
|
955 |
< |
if self.return_data : |
955 |
> |
""" |
956 |
> |
if int(self.return_data) == 1: |
957 |
|
if out_sandbox != None: |
958 |
|
for fl in out_sandbox: |
959 |
< |
out_box = out_box + ' "' + fl + '",' |
959 |
> |
out_box = out_box + '' + fl + ',' |
960 |
|
pass |
961 |
|
pass |
962 |
|
pass |
963 |
< |
|
963 |
> |
""" |
964 |
> |
|
965 |
> |
""" |
966 |
> |
INDY |
967 |
> |
qualcosa del genere andrebbe fatta per gli infiles |
968 |
> |
""" |
969 |
> |
if int(self.return_data) == 1: |
970 |
> |
for fl in jbt.output_file: |
971 |
> |
out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ',' |
972 |
> |
pass |
973 |
> |
pass |
974 |
> |
|
975 |
|
if out_box[-1] == ',' : out_box = out_box[:-1] |
976 |
< |
out_box = out_box + ' };' |
977 |
< |
jdl.write(out_box+'\n') |
976 |
> |
out_box = out_box + '"' |
977 |
> |
xml.write(out_box+'\n') |
978 |
> |
|
979 |
> |
xml.write('group="'+taskName+'"\n') |
980 |
> |
# xml.write('BossAttr="[crabjob.INTERNAL_ID=' + str(nj+1) +']"\n') |
981 |
> |
#xml.write('BossAttr="[crabjob.INTERNAL_ID=_ITR1_]"\n') |
982 |
> |
xml.write('BossAttr="crabjob.INTERNAL_ID=_ITR1_"\n') |
983 |
|
|
984 |
< |
### if at least a CE exists ... |
985 |
< |
if common.analisys_common_info['sites']: |
986 |
< |
if common.analisys_common_info['sw_version']: |
987 |
< |
req='Requirements = ' |
474 |
< |
req=req + 'Member("VO-cms-' + \ |
475 |
< |
common.analisys_common_info['sw_version'] + \ |
476 |
< |
'", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
477 |
< |
if len(common.analisys_common_info['sites'])>0: |
478 |
< |
req = req + ' && (' |
479 |
< |
for i in range(len(common.analisys_common_info['sites'])): |
480 |
< |
req = req + 'other.GlueCEInfoHostName == "' \ |
481 |
< |
+ common.analisys_common_info['sites'][i] + '"' |
482 |
< |
if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ): |
483 |
< |
req = req + ' || ' |
484 |
< |
req = req + ')' |
984 |
> |
|
985 |
> |
|
986 |
> |
xml.write('/>\n') |
987 |
> |
xml.write('</chain>\n') |
988 |
|
|
989 |
< |
#### and USER REQUIREMENT |
990 |
< |
if self.EDG_requirements: |
991 |
< |
req = req + ' && ' + self.EDG_requirements |
489 |
< |
if self.EDG_clock_time: |
490 |
< |
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
491 |
< |
if self.EDG_cpu_time: |
492 |
< |
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
493 |
< |
req = req + ';\n' |
494 |
< |
jdl.write(req) |
495 |
< |
|
496 |
< |
jdl.write('VirtualOrganisation = "' + self.VO + '";\n') |
989 |
> |
# if int(nj) == int(common.jobDB.nJobs()-1): xml.write('</task>\n') |
990 |
> |
xml.write('</iterator>\n') |
991 |
> |
xml.write('</task>\n') |
992 |
|
|
498 |
– |
if ( self.EDG_retry_count ): |
499 |
– |
jdl.write('RetryCount = '+self.EDG_retry_count+';\n') |
500 |
– |
pass |
993 |
|
|
994 |
< |
jdl.close() |
994 |
> |
xml.close() |
995 |
> |
|
996 |
|
return |
997 |
|
|
998 |
+ |
|
999 |
+ |
|
1000 |
|
def checkProxy(self): |
1001 |
|
""" |
1002 |
|
Function to check the Globus proxy. |
1003 |
|
""" |
1004 |
|
if (self.proxyValid): return |
1005 |
|
timeleft = -999 |
1006 |
< |
minTimeLeft=10 # in hours |
1007 |
< |
cmd = 'grid-proxy-info -e -v '+str(minTimeLeft)+':00' |
1008 |
< |
try: cmd_out = runCommand(cmd,0) |
1009 |
< |
except: print cmd_out |
1010 |
< |
if (cmd_out == None or cmd_out=='1'): |
1011 |
< |
common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 100h\n") |
1012 |
< |
cmd = 'grid-proxy-init -valid 100:00' |
1006 |
> |
minTimeLeft=10*3600 # in seconds |
1007 |
> |
|
1008 |
> |
minTimeLeftServer = 100 # in hours |
1009 |
> |
|
1010 |
> |
#cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00' |
1011 |
> |
#cmd = 'voms-proxy-info -timeleft' |
1012 |
> |
mustRenew = 0 |
1013 |
> |
timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null') |
1014 |
> |
timeLeftServer = -999 |
1015 |
> |
if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal): |
1016 |
> |
mustRenew = 1 |
1017 |
> |
else: |
1018 |
> |
timeLeftServer = runCommand('voms-proxy-info -actimeleft 2>/dev/null | head -1') |
1019 |
> |
if not timeLeftServer or not isInt(timeLeftServer): |
1020 |
> |
mustRenew = 1 |
1021 |
> |
elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft: |
1022 |
> |
mustRenew = 1 |
1023 |
> |
pass |
1024 |
> |
pass |
1025 |
> |
|
1026 |
> |
if mustRenew: |
1027 |
> |
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") |
1028 |
> |
cmd = 'voms-proxy-init -voms cms -valid 96:00' |
1029 |
|
try: |
1030 |
+ |
# SL as above: damn it! |
1031 |
|
out = os.system(cmd) |
1032 |
|
if (out>0): raise CrabException("Unable to create a valid proxy!\n") |
1033 |
|
except: |
1034 |
|
msg = "Unable to create a valid proxy!\n" |
1035 |
|
raise CrabException(msg) |
1036 |
< |
cmd = 'grid-proxy-info -timeleft' |
1037 |
< |
cmd_out = runCommand(cmd,0) |
1038 |
< |
#print cmd_out, time.time() |
1039 |
< |
#time.time(cms_out) |
1036 |
> |
# cmd = 'grid-proxy-info -timeleft' |
1037 |
> |
# cmd_out = runCommand(cmd,0,20) |
1038 |
> |
pass |
1039 |
> |
|
1040 |
> |
## now I do have a voms proxy valid, and I check the myproxy server |
1041 |
> |
renewProxy = 0 |
1042 |
> |
cmd = 'myproxy-info -d -s '+self.proxyServer |
1043 |
> |
cmd_out = runCommand(cmd,0,20) |
1044 |
> |
if not cmd_out: |
1045 |
> |
common.logger.message('No credential delegated to myproxy server '+self.proxyServer+' will do now') |
1046 |
> |
renewProxy = 1 |
1047 |
> |
else: |
1048 |
> |
# if myproxy exist but not long enough, renew |
1049 |
> |
reTime = re.compile( r'timeleft: (\d+)' ) |
1050 |
> |
#print "<"+str(reTime.search( cmd_out ).group(1))+">" |
1051 |
> |
if reTime.match( cmd_out ): |
1052 |
> |
time = reTime.search( line ).group(1) |
1053 |
> |
if time < minTimeLeftServer: |
1054 |
> |
renewProxy = 1 |
1055 |
> |
common.logger.message('No credential delegation will expire in '+time+' hours: renew it') |
1056 |
> |
pass |
1057 |
|
pass |
1058 |
+ |
|
1059 |
+ |
# if not, create one. |
1060 |
+ |
if renewProxy: |
1061 |
+ |
cmd = 'myproxy-init -d -n -s '+self.proxyServer |
1062 |
+ |
out = os.system(cmd) |
1063 |
+ |
if (out>0): |
1064 |
+ |
raise CrabException("Unable to delegate the proxy to myproxyserver "+self.proxyServer+" !\n") |
1065 |
+ |
pass |
1066 |
+ |
|
1067 |
+ |
# cache proxy validity |
1068 |
|
self.proxyValid=1 |
1069 |
|
return |
1070 |
< |
|
1070 |
> |
|
1071 |
|
def configOpt_(self): |
1072 |
|
edg_ui_cfg_opt = ' ' |
1073 |
|
if self.edg_config: |
1074 |
< |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
1074 |
> |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
1075 |
|
if self.edg_config_vo: |
1076 |
< |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
1076 |
> |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
1077 |
|
return edg_ui_cfg_opt |