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 |
|
return |
158 |
|
|
159 |
|
|
161 |
|
""" |
162 |
|
Returns file with scheduler-specific parameters |
163 |
|
""" |
101 |
– |
|
164 |
|
if (self.edg_config and self.edg_config_vo != ''): |
165 |
|
self.param='sched_param.clad' |
166 |
|
param_file = open(common.work_space.shareDir()+'/'+self.param, 'w') |
175 |
|
""" |
176 |
|
Returns part of a job script which does scheduler-specific work. |
177 |
|
""" |
116 |
– |
|
178 |
|
txt = '' |
179 |
< |
if self.copy_data: |
179 |
> |
txt += "# job number (first parameter for job wrapper)\n" |
180 |
> |
txt += "NJob=$1\n" |
181 |
> |
|
182 |
> |
txt += '# job identification to DashBoard \n' |
183 |
> |
txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n' |
184 |
> |
txt += 'SyncGridJobId=`echo $EDG_WL_JOBID`\n' |
185 |
> |
txt += 'MonitorID=`echo ' + self._taskId + '`\n' |
186 |
> |
txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
187 |
> |
txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n' |
188 |
> |
txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
189 |
> |
|
190 |
> |
txt += 'echo "middleware discovery " \n' |
191 |
> |
txt += 'if [ $VO_CMS_SW_DIR ]; then \n' |
192 |
> |
txt += ' middleware=LCG \n' |
193 |
> |
txt += ' echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n' |
194 |
> |
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
195 |
> |
txt += ' echo "middleware =$middleware" \n' |
196 |
> |
txt += 'elif [ $GRID3_APP_DIR ]; then\n' |
197 |
> |
txt += ' middleware=OSG \n' |
198 |
> |
txt += ' echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n' |
199 |
> |
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
200 |
> |
txt += ' echo "middleware =$middleware" \n' |
201 |
> |
txt += 'elif [ $OSG_APP ]; then \n' |
202 |
> |
txt += ' middleware=OSG \n' |
203 |
> |
txt += ' echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n' |
204 |
> |
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
205 |
> |
txt += ' echo "middleware =$middleware" \n' |
206 |
> |
txt += 'else \n' |
207 |
> |
txt += ' echo "SET_CMS_ENV 10030 ==> middleware not identified" \n' |
208 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10030" \n' |
209 |
> |
txt += ' echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n' |
210 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo \n' |
211 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
212 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
213 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
214 |
> |
txt += ' exit 1 \n' |
215 |
> |
txt += 'fi \n' |
216 |
> |
|
217 |
> |
txt += '# report first time to DashBoard \n' |
218 |
> |
txt += 'dumpStatus $RUNTIME_AREA/$repo \n' |
219 |
> |
txt += 'rm -f $RUNTIME_AREA/$repo \n' |
220 |
> |
txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
221 |
> |
txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
222 |
> |
|
223 |
> |
txt += '\n\n' |
224 |
> |
|
225 |
> |
if int(self.copy_data) == 1: |
226 |
|
if self.SE: |
227 |
|
txt += 'export SE='+self.SE+'\n' |
228 |
|
txt += 'echo "SE = $SE"\n' |
230 |
|
if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/' |
231 |
|
txt += 'export SE_PATH='+self.SE_PATH+'\n' |
232 |
|
txt += 'echo "SE_PATH = $SE_PATH"\n' |
233 |
< |
|
234 |
< |
if self.register_data: |
233 |
> |
|
234 |
> |
txt += 'export VO='+self.VO+'\n' |
235 |
> |
### FEDE: add some line for LFC catalog setting |
236 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
237 |
> |
txt += ' if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n' |
238 |
> |
txt += ' export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n' |
239 |
> |
txt += ' fi\n' |
240 |
> |
txt += ' if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n' |
241 |
> |
txt += ' export LFC_HOST='+self.lfc_host+'\n' |
242 |
> |
txt += ' fi\n' |
243 |
> |
txt += ' if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n' |
244 |
> |
txt += ' export LFC_HOME='+self.lfc_home+'\n' |
245 |
> |
txt += ' fi\n' |
246 |
> |
txt += 'elif [ $middleware == OSG ]; then\n' |
247 |
> |
txt += ' echo "LFC catalog setting to be implemented for OSG"\n' |
248 |
> |
txt += 'fi\n' |
249 |
> |
##### |
250 |
> |
if int(self.register_data) == 1: |
251 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
252 |
> |
txt += ' export LFN='+self.LFN+'\n' |
253 |
> |
txt += ' lfc-ls $LFN\n' |
254 |
> |
txt += ' result=$?\n' |
255 |
> |
txt += ' echo $result\n' |
256 |
> |
### creation of LFN dir in LFC catalog, under /grid/cms dir |
257 |
> |
txt += ' if [ $result != 0 ]; then\n' |
258 |
> |
txt += ' lfc-mkdir $LFN\n' |
259 |
> |
txt += ' result=$?\n' |
260 |
> |
txt += ' echo $result\n' |
261 |
> |
txt += ' fi\n' |
262 |
> |
txt += 'elif [ $middleware == OSG ]; then\n' |
263 |
> |
txt += ' echo " Files registration to be implemented for OSG"\n' |
264 |
> |
txt += 'fi\n' |
265 |
> |
txt += '\n' |
266 |
> |
|
267 |
|
if self.VO: |
268 |
|
txt += 'export VO='+self.VO+'\n' |
269 |
|
if self.LFN: |
270 |
< |
txt += 'export LFN='+self.LFN+'\n' |
270 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
271 |
> |
txt += ' export LFN='+self.LFN+'\n' |
272 |
> |
txt += 'fi\n' |
273 |
|
txt += '\n' |
274 |
< |
txt += 'CloseCEs=`edg-brokerinfo getCE`\n' |
275 |
< |
txt += 'echo "CloseCEs = $CloseCEs"\n' |
276 |
< |
txt += 'CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
277 |
< |
txt += 'echo "CE = $CE"\n' |
274 |
> |
|
275 |
> |
txt += 'if [ $middleware == LCG ]; then\n' |
276 |
> |
txt += ' CloseCEs=`edg-brokerinfo getCE`\n' |
277 |
> |
txt += ' echo "CloseCEs = $CloseCEs"\n' |
278 |
> |
txt += ' CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
279 |
> |
txt += ' echo "CE = $CE"\n' |
280 |
> |
txt += 'elif [ $middleware == OSG ]; then \n' |
281 |
> |
txt += ' if [ $OSG_JOB_CONTACT ]; then \n' |
282 |
> |
txt += ' CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n' |
283 |
> |
txt += ' else \n' |
284 |
> |
txt += ' echo "SET_CMS_ENV 10099 ==> OSG mode: ERROR in setting CE name from OSG_JOB_CONTACT" \n' |
285 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10099" \n' |
286 |
> |
txt += ' echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n' |
287 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo \n' |
288 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
289 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
290 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
291 |
> |
txt += ' exit 1 \n' |
292 |
> |
txt += ' fi \n' |
293 |
> |
txt += 'fi \n' |
294 |
> |
|
295 |
> |
return txt |
296 |
> |
|
297 |
> |
def wsCopyInput(self): |
298 |
> |
""" |
299 |
> |
Copy input data from SE to WN |
300 |
> |
""" |
301 |
> |
txt = '' |
302 |
> |
try: |
303 |
> |
self.copy_input_data = common.analisys_common_info['copy_input_data'] |
304 |
> |
#print "self.copy_input_data = ", self.copy_input_data |
305 |
> |
except KeyError: self.copy_input_data = 0 |
306 |
> |
if int(self.copy_input_data) == 1: |
307 |
> |
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
308 |
> |
txt += 'if [ $middleware == OSG ]; then\n' |
309 |
> |
txt += ' #\n' |
310 |
> |
txt += ' # Copy Input Data from SE to this WN deactivated in OSG mode\n' |
311 |
> |
txt += ' #\n' |
312 |
> |
txt += ' echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n' |
313 |
> |
txt += 'elif [ $middleware == LCG ]; then \n' |
314 |
> |
txt += ' #\n' |
315 |
> |
txt += ' # Copy Input Data from SE to this WN\n' |
316 |
> |
txt += ' #\n' |
317 |
> |
### changed by georgia (put a loop copying more than one input files per jobs) |
318 |
> |
txt += ' for input_file in $cur_file_list \n' |
319 |
> |
txt += ' do \n' |
320 |
> |
#### FEDE |
321 |
> |
#txt += ' echo "which lcg-cp" \n' |
322 |
> |
#txt += ' which lcg-cp \n' |
323 |
> |
######### |
324 |
> |
txt += ' lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n' |
325 |
> |
txt += ' copy_input_exit_status=$?\n' |
326 |
> |
txt += ' echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n' |
327 |
> |
txt += ' if [ $copy_input_exit_status -ne 0 ]; then \n' |
328 |
> |
txt += ' echo "Problems with copying to WN" \n' |
329 |
> |
txt += ' else \n' |
330 |
> |
txt += ' echo "input copied into WN" \n' |
331 |
> |
txt += ' fi \n' |
332 |
> |
txt += ' done \n' |
333 |
> |
### copy a set of PU ntuples (same for each jobs -- but accessed randomly) |
334 |
> |
txt += ' for file in $cur_pu_list \n' |
335 |
> |
txt += ' do \n' |
336 |
> |
#### FEDE |
337 |
> |
#txt += ' echo "which lcg-cp" \n' |
338 |
> |
#txt += ' which lcg-cp \n' |
339 |
> |
######### |
340 |
> |
txt += ' lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n' |
341 |
> |
txt += ' copy_input_pu_exit_status=$?\n' |
342 |
> |
txt += ' echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n' |
343 |
> |
txt += ' if [ $copy_input_pu_exit_status -ne 0 ]; then \n' |
344 |
> |
txt += ' echo "Problems with copying pu to WN" \n' |
345 |
> |
txt += ' else \n' |
346 |
> |
txt += ' echo "input pu files copied into WN" \n' |
347 |
> |
txt += ' fi \n' |
348 |
> |
txt += ' done \n' |
349 |
> |
txt += ' \n' |
350 |
> |
txt += ' ### Check SCRATCH space available on WN : \n' |
351 |
> |
txt += ' df -h \n' |
352 |
> |
txt += 'fi \n' |
353 |
> |
|
354 |
|
return txt |
355 |
|
|
356 |
|
def wsCopyOutput(self): |
359 |
|
to copy produced output into a storage element. |
360 |
|
""" |
361 |
|
txt = '' |
362 |
< |
if self.copy_data: |
146 |
< |
copy = 'globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file' |
362 |
> |
if int(self.copy_data) == 1: |
363 |
|
txt += '#\n' |
364 |
|
txt += '# Copy output to SE = $SE\n' |
365 |
|
txt += '#\n' |
366 |
< |
#### per orca l'exit_status non e' affidabile..... |
367 |
< |
#txt += 'if [ $executable_exit_status -eq 0 ]; then\n' |
368 |
< |
txt += 'if [ $exe_result -eq 0 ]; then\n' |
369 |
< |
txt += ' for out_file in $file_list ; do\n' |
370 |
< |
txt += ' echo "Trying to copy output file to $SE "\n' |
371 |
< |
txt += ' echo "'+copy+'"\n' |
372 |
< |
txt += ' '+copy+' 2>&1\n' |
157 |
< |
txt += ' copy_exit_status=$?\n' |
158 |
< |
txt += ' echo "COPY_EXIT_STATUS = $copy_exit_status"\n' |
159 |
< |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
160 |
< |
txt += ' if [ $copy_exit_status -ne 0 ]; then \n' |
161 |
< |
txt += ' echo "Problems with SE= $SE" \n' |
162 |
< |
txt += ' else \n' |
163 |
< |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
366 |
> |
#txt += 'if [ $exe_result -eq 0 ]; then\n' |
367 |
> |
txt += ' if [ $middleware == OSG ]; then\n' |
368 |
> |
txt += ' echo "X509_USER_PROXY = $X509_USER_PROXY"\n' |
369 |
> |
txt += ' echo "source $OSG_APP/glite/setup_glite_ui.sh"\n' |
370 |
> |
txt += ' source $OSG_APP/glite/setup_glite_ui.sh\n' |
371 |
> |
txt += ' export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n' |
372 |
> |
txt += ' echo "export X509_CERT_DIR=$X509_CERT_DIR"\n' |
373 |
|
txt += ' fi \n' |
374 |
< |
txt += ' done\n' |
375 |
< |
txt += 'fi \n' |
374 |
> |
txt += ' for out_file in $file_list ; do\n' |
375 |
> |
txt += ' echo "Trying to copy output file to $SE using lcg-cp"\n' |
376 |
> |
txt += ' echo "lcg-cp --vo $VO -t 1200 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
377 |
> |
txt += ' exitstring=`lcg-cp --vo $VO -t 1200 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
378 |
> |
txt += ' copy_exit_status=$?\n' |
379 |
> |
txt += ' echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n' |
380 |
> |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
381 |
> |
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
382 |
> |
txt += ' echo "Possible problem with SE = $SE"\n' |
383 |
> |
txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n' |
384 |
> |
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
385 |
> |
txt += ' echo "lcg-cp failed, attempting srmcp"\n' |
386 |
> |
txt += ' echo "mkdir -p $HOME/.srmconfig"\n' |
387 |
> |
txt += ' mkdir -p $HOME/.srmconfig\n' |
388 |
> |
txt += ' if [ $middleware == LCG ]; then\n' |
389 |
> |
txt += ' echo "srmcp -retry_num 5 -retry_timeout 240000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n' |
390 |
> |
txt += ' exitstring=`srmcp -retry_num 5 -retry_timeout 240000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n' |
391 |
> |
txt += ' elif [ $middleware == OSG ]; then\n' |
392 |
> |
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' |
393 |
> |
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' |
394 |
> |
txt += ' fi \n' |
395 |
> |
txt += ' copy_exit_status=$?\n' |
396 |
> |
txt += ' echo "COPY_EXIT_STATUS for srm = $copy_exit_status"\n' |
397 |
> |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
398 |
> |
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
399 |
> |
txt += ' echo "Problems with SE = $SE"\n' |
400 |
> |
txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n' |
401 |
> |
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
402 |
> |
txt += ' echo "lcg-cp and srm failed"\n' |
403 |
> |
txt += ' echo "If storage_path in your config file contains a ? you may need a \? instead."\n' |
404 |
> |
txt += ' else\n' |
405 |
> |
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
406 |
> |
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
407 |
> |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
408 |
> |
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
409 |
> |
txt += ' echo "srmcp succeeded"\n' |
410 |
> |
txt += ' fi\n' |
411 |
> |
txt += ' else\n' |
412 |
> |
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
413 |
> |
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
414 |
> |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
415 |
> |
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
416 |
> |
txt += ' echo "lcg-cp succeeded"\n' |
417 |
> |
txt += ' fi\n' |
418 |
> |
txt += ' done\n' |
419 |
> |
#txt += 'fi\n' |
420 |
|
return txt |
421 |
|
|
422 |
|
def wsRegisterOutput(self): |
425 |
|
""" |
426 |
|
|
427 |
|
txt = '' |
428 |
< |
if self.register_data: |
428 |
> |
if int(self.register_data) == 1: |
429 |
> |
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
430 |
> |
txt += 'if [ $middleware == OSG ]; then\n' |
431 |
> |
txt += ' #\n' |
432 |
> |
txt += ' # Register output to LFC deactivated in OSG mode\n' |
433 |
> |
txt += ' #\n' |
434 |
> |
txt += ' echo "Register output to LFC deactivated in OSG mode"\n' |
435 |
> |
txt += 'elif [ $middleware == LCG ]; then \n' |
436 |
|
txt += '#\n' |
437 |
< |
txt += '# Register output to RLS\n' |
437 |
> |
txt += '# Register output to LFC\n' |
438 |
|
txt += '#\n' |
439 |
< |
### analogo |
440 |
< |
#txt += 'if [[ $executable_exit_status -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
441 |
< |
txt += 'if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
442 |
< |
txt += ' for out_file in $file_list ; do\n' |
443 |
< |
txt += ' echo "Trying to register the output file into RLS"\n' |
444 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n' |
445 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
446 |
< |
txt += ' register_exit_status=$?\n' |
447 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
448 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
189 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
190 |
< |
txt += ' echo "Problems with the registration to RLS" \n' |
191 |
< |
txt += ' echo "Try with srm protocol" \n' |
192 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n' |
193 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n' |
439 |
> |
#txt += ' if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
440 |
> |
txt += ' if [ $copy_exit_status -eq 0 ]; then\n' |
441 |
> |
txt += ' for out_file in $file_list ; do\n' |
442 |
> |
txt += ' echo "Trying to register the output file into LFC"\n' |
443 |
> |
#### FEDE |
444 |
> |
#txt += ' echo "which lcg-rf" \n' |
445 |
> |
#txt += ' which lcg-rf \n' |
446 |
> |
######### |
447 |
> |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n' |
448 |
> |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
449 |
|
txt += ' register_exit_status=$?\n' |
450 |
|
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
451 |
|
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
452 |
|
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
453 |
< |
txt += ' echo "Problems with the registration into RLS" \n' |
453 |
> |
txt += ' echo "Problems with the registration to LFC" \n' |
454 |
> |
txt += ' echo "Try with srm protocol" \n' |
455 |
> |
#### FEDE |
456 |
> |
#txt += ' echo "which lcg-rf" \n' |
457 |
> |
#txt += ' which lcg-rf \n' |
458 |
> |
######### |
459 |
> |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n' |
460 |
> |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n' |
461 |
> |
txt += ' register_exit_status=$?\n' |
462 |
> |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
463 |
> |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
464 |
> |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
465 |
> |
txt += ' echo "Problems with the registration into LFC" \n' |
466 |
> |
txt += ' fi \n' |
467 |
> |
txt += ' else \n' |
468 |
> |
txt += ' echo "output registered to LFC"\n' |
469 |
|
txt += ' fi \n' |
470 |
< |
txt += ' else \n' |
471 |
< |
txt += ' echo "output registered to RLS"\n' |
472 |
< |
txt += ' fi \n' |
473 |
< |
txt += ' done\n' |
474 |
< |
txt += 'elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n' |
475 |
< |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
476 |
< |
txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
477 |
< |
txt += ' for out_file in $file_list ; do\n' |
478 |
< |
txt += ' echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n' |
479 |
< |
txt += ' lcg-cr -v -l lfn:${LFN}/$out_file -d $SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file 2>&1 \n' |
480 |
< |
txt += ' register_exit_status=$?\n' |
481 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
482 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
483 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
484 |
< |
txt += ' echo "Problems with CloseSE" \n' |
485 |
< |
txt += ' else \n' |
486 |
< |
txt += ' echo "The program was successfully executed"\n' |
487 |
< |
txt += ' echo "SE = $CLOSE_SE"\n' |
488 |
< |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
489 |
< |
txt += ' fi \n' |
490 |
< |
txt += ' done\n' |
491 |
< |
txt += 'else\n' |
492 |
< |
txt += ' echo "Problem with the executable"\n' |
470 |
> |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
471 |
> |
txt += ' done\n' |
472 |
> |
#txt += ' elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n' |
473 |
> |
txt += ' else \n' |
474 |
> |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
475 |
> |
txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
476 |
> |
txt += ' for out_file in $file_list ; do\n' |
477 |
> |
#### FEDE |
478 |
> |
#txt += ' echo "which lcg-cr" \n' |
479 |
> |
#txt += ' which lcg-cr \n' |
480 |
> |
######### |
481 |
> |
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' |
482 |
> |
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' |
483 |
> |
txt += ' register_exit_status=$?\n' |
484 |
> |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
485 |
> |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
486 |
> |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
487 |
> |
txt += ' echo "Problems with CloseSE or Catalog" \n' |
488 |
> |
txt += ' else \n' |
489 |
> |
txt += ' echo "The program was successfully executed"\n' |
490 |
> |
txt += ' echo "SE = $CLOSE_SE"\n' |
491 |
> |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
492 |
> |
txt += ' fi \n' |
493 |
> |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
494 |
> |
txt += ' done\n' |
495 |
> |
#txt += ' else\n' |
496 |
> |
#txt += ' echo "Problem with the executable"\n' |
497 |
> |
txt += ' fi \n' |
498 |
> |
txt += ' exit_status=$register_exit_status\n' |
499 |
|
txt += 'fi \n' |
500 |
|
return txt |
225 |
– |
##################### |
501 |
|
|
502 |
< |
def loggingInfo(self, nj): |
502 |
> |
def loggingInfo(self, id): |
503 |
|
""" |
504 |
|
retrieve the logging info from logging and bookkeeping and return it |
505 |
|
""" |
506 |
|
self.checkProxy() |
507 |
< |
id = common.jobDB.jobId(nj) |
508 |
< |
cmd = 'edg-job-get-logging-info -v 2 ' + self.configOpt_() + id |
509 |
< |
myCmd = os.popen(cmd) |
235 |
< |
cmd_out = myCmd.readlines() |
236 |
< |
myCmd.close() |
507 |
> |
cmd = 'edg-job-get-logging-info -v 2 ' + id |
508 |
> |
#cmd_out = os.popen(cmd) |
509 |
> |
cmd_out = runCommand(cmd) |
510 |
|
return cmd_out |
511 |
|
|
512 |
|
def listMatch(self, nj): |
516 |
|
self.checkProxy() |
517 |
|
jdl = common.job_list[nj].jdlFilename() |
518 |
|
cmd = 'edg-job-list-match ' + self.configOpt_() + jdl |
519 |
< |
myCmd = os.popen(cmd) |
520 |
< |
cmd_out = myCmd.readlines() |
521 |
< |
myCmd.close() |
519 |
> |
cmd_out = runCommand(cmd,0,10) |
520 |
> |
if not cmd_out: |
521 |
> |
raise CrabException("ERROR: "+cmd+" failed!") |
522 |
> |
|
523 |
|
return self.parseListMatch_(cmd_out, jdl) |
524 |
|
|
525 |
|
def parseListMatch_(self, out, jdl): |
526 |
+ |
""" |
527 |
+ |
Parse the f* output of edg-list-match and produce something sensible |
528 |
+ |
""" |
529 |
|
reComment = re.compile( r'^\**$' ) |
530 |
|
reEmptyLine = re.compile( r'^$' ) |
531 |
|
reVO = re.compile( r'Selected Virtual Organisation name.*' ) |
532 |
< |
reCE = re.compile( r'CEId' ) |
532 |
> |
reLine = re.compile( r'.*') |
533 |
> |
reCE = re.compile( r'(.*:.*)') |
534 |
> |
reCEId = re.compile( r'CEId.*') |
535 |
|
reNO = re.compile( r'No Computing Element matching' ) |
536 |
|
reRB = re.compile( r'Connecting to host' ) |
537 |
|
next = 0 |
538 |
|
CEs=[] |
539 |
|
Match=0 |
540 |
< |
for line in out: |
541 |
< |
line = line.strip() |
542 |
< |
if reComment.match( line ): |
543 |
< |
next = 0 |
544 |
< |
continue |
545 |
< |
if reEmptyLine.match(line): |
546 |
< |
continue |
540 |
> |
|
541 |
> |
#print out |
542 |
> |
lines = reLine.findall(out) |
543 |
> |
|
544 |
> |
i=0 |
545 |
> |
CEs=[] |
546 |
> |
for line in lines: |
547 |
> |
string.strip(line) |
548 |
> |
#print line |
549 |
> |
if reNO.match( line ): |
550 |
> |
common.logger.debug(5,line) |
551 |
> |
return 0 |
552 |
> |
pass |
553 |
|
if reVO.match( line ): |
554 |
< |
VO =line.split()[-1] |
555 |
< |
common.logger.debug(5, 'VO :'+VO) |
554 |
> |
VO =reVO.match( line ).group() |
555 |
> |
common.logger.debug(5,"VO "+VO) |
556 |
|
pass |
557 |
+ |
|
558 |
|
if reRB.match( line ): |
559 |
< |
RB =line.split()[3] |
560 |
< |
common.logger.debug(5, 'Using RB :'+RB) |
559 |
> |
RB = reRB.match(line).group() |
560 |
> |
common.logger.debug(5,"RB "+RB) |
561 |
|
pass |
562 |
< |
if reCE.search( line ): |
563 |
< |
next = 1 |
564 |
< |
continue |
565 |
< |
if next: |
566 |
< |
CE=line.split(':')[0] |
567 |
< |
CEs.append(CE) |
568 |
< |
common.logger.debug(5, 'Matched CE :'+CE) |
569 |
< |
Match=Match+1 |
284 |
< |
pass |
285 |
< |
if reNO.match( line ): |
286 |
< |
common.logger.debug(5,line) |
287 |
< |
self.noMatchFound_(jdl) |
288 |
< |
Match=0 |
562 |
> |
|
563 |
> |
if reCEId.search( line ): |
564 |
> |
for lineCE in lines[i:-1]: |
565 |
> |
if reCE.match( lineCE ): |
566 |
> |
CE = string.strip(reCE.search(lineCE).group(1)) |
567 |
> |
CEs.append(CE.split(':')[0]) |
568 |
> |
pass |
569 |
> |
pass |
570 |
|
pass |
571 |
< |
return Match |
571 |
> |
i=i+1 |
572 |
> |
pass |
573 |
> |
|
574 |
> |
common.logger.debug(5,"All CE :"+str(CEs)) |
575 |
> |
|
576 |
> |
sites = [] |
577 |
> |
[sites.append(it) for it in CEs if not sites.count(it)] |
578 |
> |
|
579 |
> |
common.logger.debug(5,"All Sites :"+str(sites)) |
580 |
> |
common.logger.message("Matched Sites :"+str(sites)) |
581 |
> |
return len(sites) |
582 |
|
|
583 |
|
def noMatchFound_(self, jdl): |
584 |
|
reReq = re.compile( r'Requirements' ) |
612 |
|
cmd_out = runCommand(cmd) |
613 |
|
if cmd_out != None: |
614 |
|
reSid = re.compile( r'https.+' ) |
615 |
< |
jid = reSid.search(cmd).group() |
615 |
> |
jid = reSid.search(cmd_out).group() |
616 |
|
pass |
617 |
|
return jid |
618 |
|
|
619 |
+ |
def resubmit(self, nj_list): |
620 |
+ |
""" |
621 |
+ |
Prepare jobs to be submit |
622 |
+ |
""" |
623 |
+ |
return |
624 |
+ |
|
625 |
|
def getExitStatus(self, id): |
626 |
|
return self.getStatusAttribute_(id, 'exit_code') |
627 |
|
|
647 |
|
jobStat.getStatus(id, level) |
648 |
|
err, apiMsg = jobStat.get_error() |
649 |
|
if err: |
650 |
< |
print 'Error caught', apiMsg |
354 |
< |
common.log.message(apiMsg) |
650 |
> |
common.logger.debug(5,'Error caught' + apiMsg) |
651 |
|
return None |
652 |
|
else: |
653 |
|
for i in range(len(self.states)): |
674 |
|
|
675 |
|
# Determine the output directory name |
676 |
|
dir = common.work_space.resDir() |
677 |
< |
dir += os.getlogin() |
677 |
> |
dir += os.environ['USER'] |
678 |
|
dir += '_' + os.path.basename(id) |
679 |
|
return dir |
680 |
|
|
685 |
|
cmd_out = runCommand(cmd) |
686 |
|
return cmd_out |
687 |
|
|
688 |
< |
def createSchScript(self, nj): |
688 |
> |
|
689 |
> |
def createXMLSchScript(self, nj): |
690 |
|
""" |
691 |
< |
Create a JDL-file for EDG. |
691 |
> |
Create a XML-file for BOSS4. |
692 |
|
""" |
396 |
– |
|
693 |
|
job = common.job_list[nj] |
694 |
|
jbt = job.type() |
695 |
|
inp_sandbox = jbt.inputSandbox(nj) |
696 |
|
out_sandbox = jbt.outputSandbox(nj) |
401 |
– |
inp_storage_subdir = '' |
697 |
|
|
698 |
< |
title = '# This JDL was generated by '+\ |
404 |
< |
common.prog_name+' (version '+common.prog_version_str+')\n' |
698 |
> |
title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' |
699 |
|
jt_string = '' |
700 |
+ |
|
701 |
+ |
xml_fname = 'orca.xml' |
702 |
+ |
xml = open(common.work_space.shareDir()+'/'+xml_fname, 'a') |
703 |
|
|
704 |
< |
|
704 |
> |
#TaskName |
705 |
> |
dir = string.split(common.work_space.topDir(), '/') |
706 |
> |
taskName = dir[len(dir)-2] |
707 |
> |
|
708 |
> |
to_writeReq = '' |
709 |
> |
to_write = '' |
710 |
> |
req=' ' |
711 |
> |
req = req + jbt.getRequirements() |
712 |
> |
if self.EDG_requirements: |
713 |
> |
if (req == ' '): |
714 |
> |
req = req + self.EDG_requirements |
715 |
> |
else: |
716 |
> |
req = req + ' && ' + self.EDG_requirements |
717 |
> |
if self.EDG_ce_white_list: |
718 |
> |
ce_white_list = string.split(self.EDG_ce_white_list,',') |
719 |
> |
for i in range(len(ce_white_list)): |
720 |
> |
if i == 0: |
721 |
> |
if (req == ' '): |
722 |
> |
req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
723 |
> |
else: |
724 |
> |
req = req + ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
725 |
> |
pass |
726 |
> |
else: |
727 |
> |
req = req + ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
728 |
> |
req = req + ')' |
729 |
|
|
730 |
< |
SPL = inp_storage_subdir |
731 |
< |
if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/' |
730 |
> |
if self.EDG_ce_black_list: |
731 |
> |
ce_black_list = string.split(self.EDG_ce_black_list,',') |
732 |
> |
for ce in ce_black_list: |
733 |
> |
if (req == ' '): |
734 |
> |
req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))' |
735 |
> |
else: |
736 |
> |
req = req + ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))' |
737 |
> |
pass |
738 |
> |
if self.EDG_clock_time: |
739 |
> |
if (req == ' '): |
740 |
> |
req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
741 |
> |
else: |
742 |
> |
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
743 |
|
|
744 |
< |
jdl_fname = job.jdlFilename() |
745 |
< |
jdl = open(jdl_fname, 'w') |
746 |
< |
jdl.write(title) |
744 |
> |
if self.EDG_cpu_time: |
745 |
> |
if (req == ' '): |
746 |
> |
req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
747 |
> |
else: |
748 |
> |
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
749 |
> |
if (req != ' '): |
750 |
> |
req = req + '\n' |
751 |
> |
to_writeReq = req |
752 |
> |
|
753 |
|
|
754 |
< |
script = job.scriptFilename() |
755 |
< |
jdl.write('Executable = "' + os.path.basename(script) +'";\n') |
756 |
< |
jdl.write(jt_string) |
754 |
> |
if ( self.EDG_retry_count ): |
755 |
> |
to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n' |
756 |
> |
pass |
757 |
|
|
758 |
< |
### only one .sh JDL has arguments: |
759 |
< |
firstEvent = common.jobDB.firstEvent(nj) |
422 |
< |
maxEvents = common.jobDB.maxEvents(nj) |
423 |
< |
jdl.write('Arguments = "' + str(nj+1)+' '+str(firstEvent)+' '+str(maxEvents)+'";\n') |
758 |
> |
to_write = to_write + 'MyProxyServer = ""' + self.proxyServer + '""\n' |
759 |
> |
to_write = to_write + 'VirtualOrganisation = ""' + self.VO + '""\n' |
760 |
|
|
425 |
– |
inp_box = 'InputSandbox = { ' |
426 |
– |
inp_box = inp_box + '"' + script + '",' |
761 |
|
|
762 |
< |
if inp_sandbox != None: |
763 |
< |
for fl in inp_sandbox: |
764 |
< |
inp_box = inp_box + ' "' + fl + '",' |
762 |
> |
#TaskName |
763 |
> |
dir = string.split(common.work_space.topDir(), '/') |
764 |
> |
taskName = dir[len(dir)-2] |
765 |
> |
|
766 |
> |
if nj == 0: |
767 |
> |
xml.write(str(title)) |
768 |
> |
xml.write('<task name="' +str(taskName)+'">\n') |
769 |
> |
xml.write(jt_string) |
770 |
> |
#Here it must pass the extra Tags.. (into Task & out of chain) |
771 |
> |
if (to_writeReq != ''): |
772 |
> |
xml.write('<extraTags>\n') |
773 |
> |
xml.write('<Requirements>\n') |
774 |
> |
xml.write('<![CDATA[\n') |
775 |
> |
xml.write(to_writeReq) |
776 |
> |
xml.write(']]>\n') |
777 |
> |
xml.write('</Requirements>\n') |
778 |
> |
xml.write('</extraTags>\n') |
779 |
> |
pass |
780 |
> |
|
781 |
> |
if (to_write != ''): |
782 |
> |
xml.write('<extraTags\n') |
783 |
> |
xml.write(to_write) |
784 |
> |
xml.write('/>\n') |
785 |
|
pass |
786 |
|
pass |
787 |
+ |
|
788 |
+ |
xml.write('<chain scheduler="edg">\n') |
789 |
+ |
xml.write(jt_string) |
790 |
|
|
791 |
< |
#if common.use_jam: |
792 |
< |
# inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",' |
791 |
> |
#executable |
792 |
> |
script = job.scriptFilename() |
793 |
> |
xml.write('<program exec="' + os.path.basename(script) +'"\n') |
794 |
> |
xml.write(jt_string) |
795 |
> |
|
796 |
> |
|
797 |
> |
### only one .sh JDL has arguments: |
798 |
> |
### Fabio |
799 |
> |
xml.write('args = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'"\n') |
800 |
> |
xml.write('program_types="crabjob"\n') |
801 |
> |
inp_box = 'infiles="' |
802 |
> |
inp_box = inp_box + '' + script + ',' |
803 |
|
|
804 |
< |
for addFile in jbt.additional_inbox_files: |
805 |
< |
addFile = os.path.abspath(addFile) |
806 |
< |
inp_box = inp_box+' "'+addFile+'",' |
804 |
> |
if inp_sandbox != None: |
805 |
> |
for fl in inp_sandbox: |
806 |
> |
inp_box = inp_box + '' + fl + ',' |
807 |
> |
pass |
808 |
|
pass |
809 |
|
|
810 |
+ |
# Marco (VERY TEMPORARY ML STUFF) |
811 |
+ |
inp_box = inp_box + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + ',' +\ |
812 |
+ |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + ','+\ |
813 |
+ |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + ','+\ |
814 |
+ |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + ','+\ |
815 |
+ |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') |
816 |
+ |
# End Marco |
817 |
+ |
|
818 |
+ |
if (not jbt.additional_inbox_files == []): |
819 |
+ |
inp_box = inp_box + ', ' |
820 |
+ |
for addFile in jbt.additional_inbox_files: |
821 |
+ |
addFile = os.path.abspath(addFile) |
822 |
+ |
inp_box = inp_box+''+addFile+',' |
823 |
+ |
pass |
824 |
+ |
|
825 |
|
if inp_box[-1] == ',' : inp_box = inp_box[:-1] |
826 |
< |
inp_box = inp_box + ' };\n' |
827 |
< |
jdl.write(inp_box) |
826 |
> |
inp_box = inp_box + ' "\n' |
827 |
> |
xml.write(inp_box) |
828 |
|
|
829 |
< |
jdl.write('StdOutput = "' + job.stdout() + '";\n') |
830 |
< |
jdl.write('StdError = "' + job.stderr() + '";\n') |
829 |
> |
xml.write('stderr="' + job.stdout() + '"\n') |
830 |
> |
xml.write('stdout="' + job.stderr() + '"\n') |
831 |
|
|
832 |
|
|
833 |
|
if job.stdout() == job.stderr(): |
834 |
< |
out_box = 'OutputSandbox = { "' + \ |
835 |
< |
job.stdout() + '", ".BrokerInfo",' |
834 |
> |
out_box = 'outfiles="' + \ |
835 |
> |
job.stdout() + ',.BrokerInfo,' |
836 |
|
else: |
837 |
< |
out_box = 'OutputSandbox = { "' + \ |
838 |
< |
job.stdout() + '", "' + \ |
839 |
< |
job.stderr() + '", ".BrokerInfo",' |
837 |
> |
out_box = 'outfiles="' + \ |
838 |
> |
job.stdout() + ',' + \ |
839 |
> |
job.stderr() + ',.BrokerInfo,' |
840 |
|
|
841 |
< |
if self.return_data : |
841 |
> |
if int(self.return_data) == 1: |
842 |
|
if out_sandbox != None: |
843 |
|
for fl in out_sandbox: |
844 |
< |
out_box = out_box + ' "' + fl + '",' |
844 |
> |
out_box = out_box + '' + fl + ',' |
845 |
|
pass |
846 |
|
pass |
847 |
|
pass |
848 |
|
|
849 |
|
if out_box[-1] == ',' : out_box = out_box[:-1] |
850 |
< |
out_box = out_box + ' };' |
851 |
< |
jdl.write(out_box+'\n') |
850 |
> |
out_box = out_box + '"' |
851 |
> |
xml.write(out_box+'\n') |
852 |
> |
|
853 |
> |
xml.write('group="'+taskName+'"\n') |
854 |
> |
xml.write('BossAttr="[crabjob.INTERNAL_ID=' + str(nj+1) +']"\n') |
855 |
|
|
856 |
< |
### if at least a CE exists ... |
857 |
< |
if common.analisys_common_info['sites']: |
858 |
< |
if common.analisys_common_info['sw_version']: |
859 |
< |
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 + ')' |
856 |
> |
|
857 |
> |
|
858 |
> |
xml.write('/>\n') |
859 |
> |
xml.write('</chain>\n') |
860 |
|
|
861 |
< |
#### and USER REQUIREMENT |
487 |
< |
if self.EDG_requirements: |
488 |
< |
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') |
861 |
> |
if int(nj) == int(common.jobDB.nJobs()-1): xml.write('</task>\n') |
862 |
|
|
498 |
– |
if ( self.EDG_retry_count ): |
499 |
– |
jdl.write('RetryCount = '+self.EDG_retry_count+';\n') |
500 |
– |
pass |
863 |
|
|
864 |
< |
jdl.close() |
864 |
> |
xml.close() |
865 |
> |
|
866 |
|
return |
867 |
|
|
868 |
+ |
|
869 |
+ |
|
870 |
|
def checkProxy(self): |
871 |
|
""" |
872 |
|
Function to check the Globus proxy. |
873 |
|
""" |
874 |
|
if (self.proxyValid): return |
875 |
|
timeleft = -999 |
876 |
< |
minTimeLeft=10 # in hours |
877 |
< |
cmd = 'grid-proxy-info -e -v '+str(minTimeLeft)+':00' |
878 |
< |
try: cmd_out = runCommand(cmd,0) |
879 |
< |
except: print cmd_out |
880 |
< |
if (cmd_out == None or cmd_out=='1'): |
881 |
< |
common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 100h\n") |
882 |
< |
cmd = 'grid-proxy-init -valid 100:00' |
876 |
> |
minTimeLeft=10*3600 # in seconds |
877 |
> |
|
878 |
> |
minTimeLeftServer = 100 # in hours |
879 |
> |
|
880 |
> |
#cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00' |
881 |
> |
#cmd = 'voms-proxy-info -timeleft' |
882 |
> |
mustRenew = 0 |
883 |
> |
timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null') |
884 |
> |
timeLeftServer = -999 |
885 |
> |
if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal): |
886 |
> |
mustRenew = 1 |
887 |
> |
else: |
888 |
> |
timeLeftServer = runCommand('voms-proxy-info -actimeleft 2>/dev/null | head -1') |
889 |
> |
if not timeLeftServer or not isInt(timeLeftServer): |
890 |
> |
mustRenew = 1 |
891 |
> |
elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft: |
892 |
> |
mustRenew = 1 |
893 |
> |
pass |
894 |
> |
pass |
895 |
> |
|
896 |
> |
if mustRenew: |
897 |
> |
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") |
898 |
> |
cmd = 'voms-proxy-init -voms cms -valid 96:00' |
899 |
|
try: |
900 |
+ |
# SL as above: damn it! |
901 |
|
out = os.system(cmd) |
902 |
|
if (out>0): raise CrabException("Unable to create a valid proxy!\n") |
903 |
|
except: |
904 |
|
msg = "Unable to create a valid proxy!\n" |
905 |
|
raise CrabException(msg) |
906 |
< |
cmd = 'grid-proxy-info -timeleft' |
907 |
< |
cmd_out = runCommand(cmd,0) |
908 |
< |
print cmd_out, time.time() |
909 |
< |
#time.time(cms_out) |
906 |
> |
# cmd = 'grid-proxy-info -timeleft' |
907 |
> |
# cmd_out = runCommand(cmd,0,20) |
908 |
> |
pass |
909 |
> |
|
910 |
> |
## now I do have a voms proxy valid, and I check the myproxy server |
911 |
> |
renewProxy = 0 |
912 |
> |
cmd = 'myproxy-info -d -s '+self.proxyServer |
913 |
> |
cmd_out = runCommand(cmd,0,20) |
914 |
> |
if not cmd_out: |
915 |
> |
common.logger.message('No credential delegated to myproxy server '+self.proxyServer+' will do now') |
916 |
> |
renewProxy = 1 |
917 |
> |
else: |
918 |
> |
# if myproxy exist but not long enough, renew |
919 |
> |
reTime = re.compile( r'timeleft: (\d+)' ) |
920 |
> |
#print "<"+str(reTime.search( cmd_out ).group(1))+">" |
921 |
> |
if reTime.match( cmd_out ): |
922 |
> |
time = reTime.search( line ).group(1) |
923 |
> |
if time < minTimeLeftServer: |
924 |
> |
renewProxy = 1 |
925 |
> |
common.logger.message('No credential delegation will expire in '+time+' hours: renew it') |
926 |
> |
pass |
927 |
> |
pass |
928 |
> |
|
929 |
> |
# if not, create one. |
930 |
> |
if renewProxy: |
931 |
> |
cmd = 'myproxy-init -d -n -s '+self.proxyServer |
932 |
> |
out = os.system(cmd) |
933 |
> |
if (out>0): |
934 |
> |
raise CrabException("Unable to delegate the proxy to myproxyserver "+self.proxyServer+" !\n") |
935 |
|
pass |
936 |
+ |
|
937 |
+ |
# cache proxy validity |
938 |
|
self.proxyValid=1 |
939 |
|
return |
940 |
< |
|
940 |
> |
|
941 |
|
def configOpt_(self): |
942 |
|
edg_ui_cfg_opt = ' ' |
943 |
|
if self.edg_config: |
944 |
< |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
944 |
> |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
945 |
|
if self.edg_config_vo: |
946 |
< |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
946 |
> |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
947 |
|
return edg_ui_cfg_opt |