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