4 |
|
from crab_util import * |
5 |
|
import common |
6 |
|
|
7 |
< |
import os, sys, tempfile |
7 |
> |
import os, sys, time |
8 |
|
|
9 |
|
class SchedulerEdg(Scheduler): |
10 |
|
def __init__(self): |
21 |
|
|
22 |
|
def configure(self, cfg_params): |
23 |
|
|
24 |
< |
try: self.edg_ui_cfg = cfg_params["EDG.rb_config"] |
25 |
< |
except KeyError: self.edg_ui_cfg = '' |
26 |
< |
|
27 |
< |
try: |
28 |
< |
self.edg_config = cfg_params["EDG.config"] |
29 |
< |
if not os.path.isfile(self.edg_config): |
30 |
< |
raise CrabException("File EDG.config "+self.edg_config+" does not exist") |
24 |
> |
try: self.edg_config = cfg_params["EDG.config"] |
25 |
|
except KeyError: self.edg_config = '' |
26 |
|
|
27 |
< |
try: |
34 |
< |
self.edg_config_vo = cfg_params["EDG.config_vo"] |
35 |
< |
if not os.path.isfile(self.edg_config_vo): |
36 |
< |
raise CrabException("File EDG.config_vo "+self.edg_config_vo+" does not exist") |
27 |
> |
try: self.edg_config_vo = cfg_params["EDG.config_vo"] |
28 |
|
except KeyError: self.edg_config_vo = '' |
29 |
|
|
30 |
|
try: self.LCG_version = cfg_params["EDG.lcg_version"] |
36 |
|
try: self.EDG_retry_count = cfg_params['EDG.retry_count'] |
37 |
|
except KeyError: self.EDG_retry_count = '' |
38 |
|
|
39 |
< |
try: |
40 |
< |
self.VO = cfg_params['EDG.virtual_organization'] |
41 |
< |
except KeyError: |
42 |
< |
self.VO = 'cms' |
39 |
> |
try: self.VO = cfg_params['EDG.virtual_organization'] |
40 |
> |
except KeyError: self.VO = 'cms' |
41 |
> |
|
42 |
> |
try: self.return_data = cfg_params['USER.return_data'] |
43 |
> |
except KeyError: self.return_data = '' |
44 |
> |
|
45 |
> |
try: |
46 |
> |
self.copy_data = cfg_params["USER.copy_data"] |
47 |
> |
try: |
48 |
> |
self.SE = cfg_params['USER.storage_element'] |
49 |
> |
self.SE_PATH = cfg_params['USER.storage_path'] |
50 |
> |
except KeyError: |
51 |
> |
msg = "Error. The [USER] section does not have 'storage_element'" |
52 |
> |
msg = msg + " and/or 'storage_path' entries, necessary to copy the output" |
53 |
> |
common.logger.message(msg) |
54 |
> |
raise CrabException(msg) |
55 |
> |
except KeyError: self.copy_data = '' |
56 |
> |
|
57 |
> |
try: |
58 |
> |
self.register_data = cfg_params["USER.register_data"] |
59 |
> |
try: |
60 |
> |
self.LFN = cfg_params['USER.lfn_dir'] |
61 |
> |
except KeyError: |
62 |
> |
msg = "Error. The [USER] section does not have 'lfn_dir' value" |
63 |
> |
msg = msg + " it's necessary for RLS registration" |
64 |
> |
common.logger.message(msg) |
65 |
> |
raise CrabException(msg) |
66 |
> |
except KeyError: self.register_data= '' |
67 |
> |
|
68 |
> |
try: self.EDG_requirements = cfg_params['EDG.requirements'] |
69 |
> |
except KeyError: self.EDG_requirements = '' |
70 |
> |
|
71 |
> |
try: self.EDG_retry_count = cfg_params['EDG.retry_count'] |
72 |
> |
except KeyError: self.EDG_retry_count = '' |
73 |
> |
|
74 |
> |
try: self.EDG_clock_time = cfg_params['EDG.max_wall_clock_time'] |
75 |
> |
except KeyError: self.EDG_clock_time= '' |
76 |
> |
|
77 |
> |
try: self.EDG_cpu_time = cfg_params['EDG.max_cpu_time'] |
78 |
> |
except KeyError: self.EDG_cpu_time = '' |
79 |
|
|
80 |
|
# Add EDG_WL_LOCATION to the python path |
81 |
|
|
90 |
|
libPath=os.path.join(path, "lib", "python") |
91 |
|
sys.path.append(libPath) |
92 |
|
|
93 |
< |
self.checkProxy_() |
93 |
> |
self.proxyValid=0 |
94 |
|
return |
95 |
|
|
96 |
+ |
|
97 |
+ |
def sched_parameter(self): |
98 |
+ |
""" |
99 |
+ |
Returns file with scheduler-specific parameters |
100 |
+ |
""" |
101 |
+ |
|
102 |
+ |
if (self.edg_config and self.edg_config_vo != ''): |
103 |
+ |
self.param='sched_param.clad' |
104 |
+ |
param_file = open(common.work_space.shareDir()+'/'+self.param, 'w') |
105 |
+ |
param_file.write('RBconfig = "'+self.edg_config+'";\n') |
106 |
+ |
param_file.write('RBconfigVO = "'+self.edg_config_vo+'";') |
107 |
+ |
param_file.close() |
108 |
+ |
return 1 |
109 |
+ |
else: |
110 |
+ |
return 0 |
111 |
+ |
|
112 |
|
def wsSetupEnvironment(self): |
113 |
|
""" |
114 |
|
Returns part of a job script which does scheduler-specific work. |
115 |
|
""" |
116 |
< |
txt = '\n' |
116 |
> |
|
117 |
> |
txt = '' |
118 |
> |
if self.copy_data: |
119 |
> |
if self.SE: |
120 |
> |
txt += 'export SE='+self.SE+'\n' |
121 |
> |
txt += 'echo "SE = $SE"\n' |
122 |
> |
if self.SE_PATH: |
123 |
> |
if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/' |
124 |
> |
txt += 'export SE_PATH='+self.SE_PATH+'\n' |
125 |
> |
txt += 'echo "SE_PATH = $SE_PATH"\n' |
126 |
> |
|
127 |
> |
if self.register_data: |
128 |
> |
if self.VO: |
129 |
> |
txt += 'export VO='+self.VO+'\n' |
130 |
> |
if self.LFN: |
131 |
> |
txt += 'export LFN='+self.LFN+'\n' |
132 |
> |
txt += '\n' |
133 |
|
txt += 'CloseCEs=`edg-brokerinfo getCE`\n' |
134 |
|
txt += 'echo "CloseCEs = $CloseCEs"\n' |
135 |
|
txt += 'CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
136 |
|
txt += 'echo "CE = $CE"\n' |
137 |
|
return txt |
138 |
|
|
139 |
+ |
def wsCopyOutput(self): |
140 |
+ |
""" |
141 |
+ |
Write a CopyResults part of a job script, e.g. |
142 |
+ |
to copy produced output into a storage element. |
143 |
+ |
""" |
144 |
+ |
txt = '' |
145 |
+ |
if self.copy_data: |
146 |
+ |
copy = 'globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file' |
147 |
+ |
txt += '#\n' |
148 |
+ |
txt += '# Copy output to SE = $SE\n' |
149 |
+ |
txt += '#\n' |
150 |
+ |
#### per orca l'exit_status non e' affidabile..... |
151 |
+ |
#txt += 'if [ $executable_exit_status -eq 0 ]; then\n' |
152 |
+ |
txt += 'if [ $exe_result -eq 0 ]; then\n' |
153 |
+ |
txt += ' for out_file in $file_list ; do\n' |
154 |
+ |
txt += ' echo "Trying to copy output file to $SE "\n' |
155 |
+ |
txt += ' echo "'+copy+'"\n' |
156 |
+ |
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' |
164 |
+ |
txt += ' fi \n' |
165 |
+ |
txt += ' done\n' |
166 |
+ |
txt += 'fi \n' |
167 |
+ |
return txt |
168 |
+ |
|
169 |
+ |
def wsRegisterOutput(self): |
170 |
+ |
""" |
171 |
+ |
Returns part of a job script which does scheduler-specific work. |
172 |
+ |
""" |
173 |
+ |
|
174 |
+ |
txt = '' |
175 |
+ |
if self.register_data: |
176 |
+ |
txt += '#\n' |
177 |
+ |
txt += '# Register output to RLS\n' |
178 |
+ |
txt += '#\n' |
179 |
+ |
### analogo |
180 |
+ |
#txt += 'if [[ $executable_exit_status -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
181 |
+ |
txt += 'if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
182 |
+ |
txt += ' for out_file in $file_list ; do\n' |
183 |
+ |
txt += ' echo "Trying to register the output file into RLS"\n' |
184 |
+ |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n' |
185 |
+ |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
186 |
+ |
txt += ' register_exit_status=$?\n' |
187 |
+ |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
188 |
+ |
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' |
194 |
+ |
txt += ' register_exit_status=$?\n' |
195 |
+ |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
196 |
+ |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
197 |
+ |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
198 |
+ |
txt += ' echo "Problems with the registration into RLS" \n' |
199 |
+ |
txt += ' fi \n' |
200 |
+ |
txt += ' else \n' |
201 |
+ |
txt += ' echo "output registered to RLS"\n' |
202 |
+ |
txt += ' fi \n' |
203 |
+ |
txt += ' done\n' |
204 |
+ |
txt += 'elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n' |
205 |
+ |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
206 |
+ |
txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
207 |
+ |
txt += ' for out_file in $file_list ; do\n' |
208 |
+ |
txt += ' echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n' |
209 |
+ |
txt += ' lcg-cr -v -l lfn:${LFN}/$out_file -d $SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file 2>&1 \n' |
210 |
+ |
txt += ' register_exit_status=$?\n' |
211 |
+ |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
212 |
+ |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
213 |
+ |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
214 |
+ |
txt += ' echo "Problems with CloseSE" \n' |
215 |
+ |
txt += ' else \n' |
216 |
+ |
txt += ' echo "The program was successfully executed"\n' |
217 |
+ |
txt += ' echo "SE = $CLOSE_SE"\n' |
218 |
+ |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
219 |
+ |
txt += ' fi \n' |
220 |
+ |
txt += ' done\n' |
221 |
+ |
txt += 'else\n' |
222 |
+ |
txt += ' echo "Problem with the executable"\n' |
223 |
+ |
txt += 'fi \n' |
224 |
+ |
return txt |
225 |
+ |
##################### |
226 |
+ |
|
227 |
|
def loggingInfo(self, nj): |
228 |
|
""" |
229 |
|
retrieve the logging info from logging and bookkeeping and return it |
230 |
|
""" |
231 |
+ |
self.checkProxy() |
232 |
|
id = common.jobDB.jobId(nj) |
233 |
< |
edg_ui_cfg_opt = '' |
86 |
< |
if self.edg_config: |
87 |
< |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
88 |
< |
cmd = 'edg-job-get-logging-info -v 2 ' + edg_ui_cfg_opt + id |
89 |
< |
print cmd |
233 |
> |
cmd = 'edg-job-get-logging-info -v 2 ' + self.configOpt_() + id |
234 |
|
myCmd = os.popen(cmd) |
235 |
|
cmd_out = myCmd.readlines() |
236 |
|
myCmd.close() |
240 |
|
""" |
241 |
|
Check the compatibility of available resources |
242 |
|
""" |
243 |
+ |
self.checkProxy() |
244 |
|
jdl = common.job_list[nj].jdlFilename() |
245 |
< |
#print ' jdl ',nj, jdl |
101 |
< |
edg_ui_cfg_opt = '' |
102 |
< |
if self.edg_config: |
103 |
< |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
104 |
< |
if self.edg_config_vo: |
105 |
< |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
106 |
< |
cmd = 'edg-job-list-match ' + edg_ui_cfg_opt + jdl |
245 |
> |
cmd = 'edg-job-list-match ' + self.configOpt_() + jdl |
246 |
|
myCmd = os.popen(cmd) |
247 |
|
cmd_out = myCmd.readlines() |
248 |
|
myCmd.close() |
260 |
|
Match=0 |
261 |
|
for line in out: |
262 |
|
line = line.strip() |
124 |
– |
#print line |
263 |
|
if reComment.match( line ): |
264 |
|
next = 0 |
265 |
|
continue |
313 |
|
Submit one EDG job. |
314 |
|
""" |
315 |
|
|
316 |
+ |
self.checkProxy() |
317 |
|
jid = None |
318 |
|
jdl = common.job_list[nj].jdlFilename() |
319 |
< |
id_tmp = tempfile.mktemp() |
320 |
< |
edg_ui_cfg_opt = ' ' |
182 |
< |
if self.edg_config: |
183 |
< |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
184 |
< |
if self.edg_config_vo: |
185 |
< |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
186 |
< |
cmd = 'edg-job-submit -o ' + id_tmp + edg_ui_cfg_opt + jdl |
319 |
> |
|
320 |
> |
cmd = 'edg-job-submit ' + self.configOpt_() + jdl |
321 |
|
cmd_out = runCommand(cmd) |
322 |
|
if cmd_out != None: |
323 |
< |
idfile = open(id_tmp) |
324 |
< |
jid_line = idfile.readline() |
191 |
< |
while jid_line[0] == '#': |
192 |
< |
jid_line = idfile.readline() |
193 |
< |
pass |
194 |
< |
jid = string.strip(jid_line) |
195 |
< |
os.unlink(id_tmp) |
323 |
> |
reSid = re.compile( r'https.+' ) |
324 |
> |
jid = reSid.search(cmd).group() |
325 |
|
pass |
326 |
|
return jid |
327 |
|
|
328 |
|
def getExitStatus(self, id): |
329 |
|
return self.getStatusAttribute_(id, 'exit_code') |
330 |
+ |
|
331 |
|
def queryStatus(self, id): |
332 |
|
return self.getStatusAttribute_(id, 'status') |
333 |
|
|
334 |
+ |
def queryDest(self, id): |
335 |
+ |
return self.getStatusAttribute_(id, 'destination') |
336 |
+ |
|
337 |
+ |
|
338 |
|
def getStatusAttribute_(self, id, attr): |
339 |
|
""" Query a status of the job with id """ |
340 |
|
|
341 |
+ |
self.checkProxy() |
342 |
|
hstates = {} |
343 |
|
Status = importName('edg_wl_userinterface_common_LbWrapper', 'Status') |
344 |
|
# Bypass edg-job-status interfacing directly to C++ API |
355 |
|
return None |
356 |
|
else: |
357 |
|
for i in range(len(self.states)): |
223 |
– |
#print "states = ", states |
358 |
|
# Fill an hash table with all information retrieved from LB API |
359 |
|
hstates[ self.states[i] ] = jobStat.loadStatus(st)[i] |
360 |
|
result = jobStat.loadStatus(st)[ self.states.index(attr) ] |
372 |
|
Returns the name of directory with results. |
373 |
|
""" |
374 |
|
|
375 |
+ |
self.checkProxy() |
376 |
|
cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() + ' ' + id |
377 |
|
cmd_out = runCommand(cmd) |
378 |
|
|
384 |
|
|
385 |
|
def cancel(self, id): |
386 |
|
""" Cancel the EDG job with id """ |
387 |
+ |
self.checkProxy() |
388 |
|
cmd = 'edg-job-cancel --noint ' + id |
389 |
|
cmd_out = runCommand(cmd) |
390 |
|
return cmd_out |
391 |
|
|
392 |
< |
def checkProxy_(self): |
257 |
< |
""" |
258 |
< |
Function to check the Globus proxy. |
259 |
< |
""" |
260 |
< |
cmd = 'grid-proxy-info -timeleft' |
261 |
< |
cmd_out = runCommand(cmd) |
262 |
< |
ok = 1 |
263 |
< |
timeleft = -999 |
264 |
< |
try: timeleft = int(cmd_out) |
265 |
< |
except ValueError: ok=0 |
266 |
< |
except TypeError: ok=0 |
267 |
< |
if timeleft < 1: ok=0 |
268 |
< |
|
269 |
< |
if ok==0: |
270 |
< |
msg = 'No valid proxy found !\n' |
271 |
< |
msg += "Please do 'grid-proxy-init'." |
272 |
< |
raise CrabException(msg) |
273 |
< |
return |
274 |
< |
|
275 |
< |
def createJDL(self, nj): |
392 |
> |
def createSchScript(self, nj): |
393 |
|
""" |
394 |
|
Create a JDL-file for EDG. |
395 |
|
""" |
396 |
|
|
397 |
|
job = common.job_list[nj] |
398 |
|
jbt = job.type() |
282 |
– |
# jbt.loadJobInfo() |
399 |
|
inp_sandbox = jbt.inputSandbox(nj) |
400 |
|
out_sandbox = jbt.outputSandbox(nj) |
401 |
< |
inp_storage_subdir = ''#jbt.inputStorageSubdir() |
401 |
> |
inp_storage_subdir = '' |
402 |
|
|
403 |
|
title = '# This JDL was generated by '+\ |
404 |
|
common.prog_name+' (version '+common.prog_version_str+')\n' |
405 |
|
jt_string = '' |
406 |
+ |
|
407 |
+ |
|
408 |
|
|
409 |
|
SPL = inp_storage_subdir |
410 |
|
if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/' |
417 |
|
jdl.write('Executable = "' + os.path.basename(script) +'";\n') |
418 |
|
jdl.write(jt_string) |
419 |
|
|
420 |
+ |
### only one .sh JDL has arguments: |
421 |
|
firstEvent = common.jobDB.firstEvent(nj) |
422 |
|
maxEvents = common.jobDB.maxEvents(nj) |
423 |
|
jdl.write('Arguments = "' + str(nj+1)+' '+str(firstEvent)+' '+str(maxEvents)+'";\n') |
445 |
|
|
446 |
|
jdl.write('StdOutput = "' + job.stdout() + '";\n') |
447 |
|
jdl.write('StdError = "' + job.stderr() + '";\n') |
448 |
< |
|
449 |
< |
#if common.flag_return_data : |
450 |
< |
# for fl in job.outputDataFiles(): |
451 |
< |
# out_box = out_box + ' "' + fl + '",' |
452 |
< |
# pass |
453 |
< |
# pass |
454 |
< |
|
455 |
< |
out_box = 'OutputSandbox = { ' |
456 |
< |
if out_sandbox != None: |
457 |
< |
for fl in out_sandbox: |
458 |
< |
out_box = out_box + ' "' + fl + '",' |
448 |
> |
|
449 |
> |
|
450 |
> |
if job.stdout() == job.stderr(): |
451 |
> |
out_box = 'OutputSandbox = { "' + \ |
452 |
> |
job.stdout() + '", ".BrokerInfo",' |
453 |
> |
else: |
454 |
> |
out_box = 'OutputSandbox = { "' + \ |
455 |
> |
job.stdout() + '", "' + \ |
456 |
> |
job.stderr() + '", ".BrokerInfo",' |
457 |
> |
|
458 |
> |
if self.return_data : |
459 |
> |
if out_sandbox != None: |
460 |
> |
for fl in out_sandbox: |
461 |
> |
out_box = out_box + ' "' + fl + '",' |
462 |
> |
pass |
463 |
|
pass |
464 |
|
pass |
465 |
< |
|
465 |
> |
|
466 |
|
if out_box[-1] == ',' : out_box = out_box[:-1] |
467 |
|
out_box = out_box + ' };' |
468 |
|
jdl.write(out_box+'\n') |
469 |
|
|
470 |
< |
# If CloseCE is used ... |
348 |
< |
#if common.flag_usecloseCE and job.inputDataFiles(): |
349 |
< |
# indata = 'InputData = { ' |
350 |
< |
# for fl in job.inputDataFiles(): |
351 |
< |
# indata = indata + ' "lfn:' + SPL + fl + '",' |
352 |
< |
# if indata[-1] == ',' : indata = indata[:-1] |
353 |
< |
# indata = indata + ' };' |
354 |
< |
# jdl.write(indata+'\n') |
355 |
< |
# jdl.write('DataAccessProtocol = { "gsiftp" };\n') |
356 |
< |
|
470 |
> |
### if at least a CE exists ... |
471 |
|
if common.analisys_common_info['sites']: |
472 |
< |
if common.analisys_common_info['sw_version']: |
473 |
< |
|
474 |
< |
req='Requirements = ' |
475 |
< |
### First ORCA version |
476 |
< |
req=req + 'Member("VO-cms-' + \ |
477 |
< |
common.analisys_common_info['sw_version'] + \ |
478 |
< |
'", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
479 |
< |
## then sites |
480 |
< |
if len(common.analisys_common_info['sites'])>0: |
481 |
< |
req = req + ' && (' |
482 |
< |
for i in range(len(common.analisys_common_info['sites'])): |
483 |
< |
req = req + 'other.GlueCEInfoHostName == "' \ |
484 |
< |
+ common.analisys_common_info['sites'][i] + '"' |
485 |
< |
if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ): |
486 |
< |
req = req + ' || ' |
487 |
< |
req = req + ')' |
488 |
< |
## then user requirement |
489 |
< |
if self.EDG_requirements: |
490 |
< |
req = req + ' && ' + self.EDG_requirements |
491 |
< |
req = req + ';\n' |
492 |
< |
jdl.write(req) |
493 |
< |
|
472 |
> |
if common.analisys_common_info['sw_version']: |
473 |
> |
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 + ')' |
485 |
> |
|
486 |
> |
#### 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') |
497 |
|
|
498 |
|
if ( self.EDG_retry_count ): |
501 |
|
|
502 |
|
jdl.close() |
503 |
|
return |
504 |
+ |
|
505 |
+ |
def checkProxy(self): |
506 |
+ |
""" |
507 |
+ |
Function to check the Globus proxy. |
508 |
+ |
""" |
509 |
+ |
if (self.proxyValid): return |
510 |
+ |
timeleft = -999 |
511 |
+ |
minTimeLeft=10 # in hours |
512 |
+ |
cmd = 'grid-proxy-info -e -v '+str(minTimeLeft)+':00' |
513 |
+ |
try: cmd_out = runCommand(cmd,0) |
514 |
+ |
except: print cmd_out |
515 |
+ |
if (cmd_out == None or cmd_out=='1'): |
516 |
+ |
common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 100h\n") |
517 |
+ |
cmd = 'grid-proxy-init -valid 100:00' |
518 |
+ |
try: |
519 |
+ |
out = os.system(cmd) |
520 |
+ |
if (out>0): raise CrabException("Unable to create a valid proxy!\n") |
521 |
+ |
except: |
522 |
+ |
msg = "Unable to create a valid proxy!\n" |
523 |
+ |
raise CrabException(msg) |
524 |
+ |
cmd = 'grid-proxy-info -timeleft' |
525 |
+ |
cmd_out = runCommand(cmd,0) |
526 |
+ |
print cmd_out, time.time() |
527 |
+ |
#time.time(cms_out) |
528 |
+ |
pass |
529 |
+ |
self.proxyValid=1 |
530 |
+ |
return |
531 |
+ |
|
532 |
+ |
def configOpt_(self): |
533 |
+ |
edg_ui_cfg_opt = ' ' |
534 |
+ |
if self.edg_config: |
535 |
+ |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
536 |
+ |
if self.edg_config_vo: |
537 |
+ |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
538 |
+ |
return edg_ui_cfg_opt |