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, tempfile |
8 |
> |
import os, sys, time |
9 |
|
|
10 |
|
class SchedulerEdg(Scheduler): |
11 |
|
def __init__(self): |
12 |
|
Scheduler.__init__(self,"EDG") |
13 |
+ |
self.states = [ "Acl", "cancelReason", "cancelling","ce_node","children", \ |
14 |
+ |
"children_hist","children_num","children_states","condorId","condor_jdl", \ |
15 |
+ |
"cpuTime","destination", "done_code","exit_code","expectFrom", \ |
16 |
+ |
"expectUpdate","globusId","jdl","jobId","jobtype", \ |
17 |
+ |
"lastUpdateTime","localId","location", "matched_jdl","network_server", \ |
18 |
+ |
"owner","parent_job", "reason","resubmitted","rsl","seed",\ |
19 |
+ |
"stateEnterTime","stateEnterTimes","subjob_failed", \ |
20 |
+ |
"user tags" , "status" , "status_code","hierarchy"] |
21 |
|
return |
22 |
|
|
23 |
|
def configure(self, cfg_params): |
24 |
+ |
##Addedd Daniele |
25 |
+ |
###################################### |
26 |
|
|
27 |
< |
try: self.edg_ui_cfg = cfg_params["EDG.rb_config"] |
28 |
< |
except KeyError: self.edg_ui_cfg = '' |
27 |
> |
SEBlackList = [] |
28 |
> |
try: |
29 |
> |
tmpBad = string.split(cfg_params['EDG.se_black_list'],',') |
30 |
> |
for tmp in tmpBad: |
31 |
> |
tmp=string.strip(tmp) |
32 |
> |
SEBlackList.append(tmp) |
33 |
> |
except KeyError: |
34 |
> |
pass |
35 |
> |
common.logger.debug(5,'SEBlackList: '+str(SEBlackList)) |
36 |
> |
self.reSEBlackList=[] |
37 |
> |
for bad in SEBlackList: |
38 |
> |
self.reSEBlackList.append(re.compile( string.lower(bad) )) |
39 |
|
|
40 |
< |
try: self.edg_config = cfg_params["EDG.config"] |
41 |
< |
except KeyError: self.edg_config = '' |
40 |
> |
SEWhiteList = [] |
41 |
> |
try: |
42 |
> |
tmpGood = string.split(cfg_params['EDG.se_white_list'],',') |
43 |
> |
for tmp in tmpGood: |
44 |
> |
tmp=string.strip(tmp) |
45 |
> |
SEWhiteList.append(tmp) |
46 |
> |
except KeyError: |
47 |
> |
pass |
48 |
> |
common.logger.debug(5,'SEWhiteList: '+str(SEWhiteList)) |
49 |
> |
self.reSEWhiteList=[] |
50 |
> |
for good in SEWhiteList: |
51 |
> |
self.reSEWhiteList.append(re.compile( string.lower(good) )) |
52 |
|
|
22 |
– |
try: self.edg_config_vo = cfg_params["EDG.config_vo"] |
23 |
– |
except KeyError: self.edg_config_vo = '' |
53 |
|
|
54 |
+ |
###################################### |
55 |
+ |
try: |
56 |
+ |
RB=cfg_params["EDG.rb"] |
57 |
+ |
self.rb_param_file=self.rb_configure(RB) |
58 |
+ |
except KeyError: |
59 |
+ |
self.rb_param_file='' |
60 |
+ |
pass |
61 |
+ |
try: |
62 |
+ |
self.proxyServer = cfg_params["EDG.proxy_server"] |
63 |
+ |
except KeyError: |
64 |
+ |
self.proxyServer = 'myproxy.cern.ch' |
65 |
+ |
common.logger.debug(5,'Setting myproxy server to '+self.proxyServer) |
66 |
+ |
|
67 |
+ |
try: |
68 |
+ |
self.group = cfg_params["EDG.group"] |
69 |
+ |
except KeyError: |
70 |
+ |
self.group = None |
71 |
+ |
|
72 |
+ |
try: |
73 |
+ |
self.role = cfg_params["EDG.role"] |
74 |
+ |
except KeyError: |
75 |
+ |
self.role = None |
76 |
+ |
|
77 |
|
try: self.LCG_version = cfg_params["EDG.lcg_version"] |
78 |
|
except KeyError: self.LCG_version = '2' |
79 |
|
|
80 |
+ |
try: |
81 |
+ |
self.EDG_ce_black_list = cfg_params['EDG.ce_black_list'] |
82 |
+ |
except KeyError: |
83 |
+ |
self.EDG_ce_black_list = '' |
84 |
+ |
|
85 |
+ |
try: |
86 |
+ |
self.EDG_ce_white_list = cfg_params['EDG.ce_white_list'] |
87 |
+ |
except KeyError: self.EDG_ce_white_list = '' |
88 |
+ |
|
89 |
+ |
try: self.VO = cfg_params['EDG.virtual_organization'] |
90 |
+ |
except KeyError: self.VO = 'cms' |
91 |
+ |
|
92 |
+ |
try: self.copy_input_data = cfg_params["USER.copy_input_data"] |
93 |
+ |
except KeyError: self.copy_input_data = 0 |
94 |
+ |
|
95 |
+ |
try: self.return_data = cfg_params['USER.return_data'] |
96 |
+ |
except KeyError: self.return_data = 0 |
97 |
+ |
|
98 |
+ |
try: |
99 |
+ |
self.copy_data = cfg_params["USER.copy_data"] |
100 |
+ |
if int(self.copy_data) == 1: |
101 |
+ |
try: |
102 |
+ |
self.SE = cfg_params['USER.storage_element'] |
103 |
+ |
self.SE_PATH = cfg_params['USER.storage_path'] |
104 |
+ |
except KeyError: |
105 |
+ |
msg = "Error. The [USER] section does not have 'storage_element'" |
106 |
+ |
msg = msg + " and/or 'storage_path' entries, necessary to copy the output" |
107 |
+ |
common.logger.message(msg) |
108 |
+ |
raise CrabException(msg) |
109 |
+ |
except KeyError: self.copy_data = 0 |
110 |
+ |
|
111 |
+ |
if ( int(self.return_data) == 0 and int(self.copy_data) == 0 ): |
112 |
+ |
msg = 'Warning: return_data = 0 and copy_data = 0 ==> your exe output will be lost\n' |
113 |
+ |
msg = msg + 'Please modify return_data and copy_data value in your crab.cfg file\n' |
114 |
+ |
raise CrabException(msg) |
115 |
+ |
|
116 |
+ |
########### FEDE FOR DBS2 ############################## |
117 |
+ |
try: |
118 |
+ |
self.publish_data = cfg_params["USER.publish_data"] |
119 |
+ |
if int(self.publish_data) == 1: |
120 |
+ |
try: |
121 |
+ |
self.publish_data_name = cfg_params['USER.publish_data_name'] |
122 |
+ |
except KeyError: |
123 |
+ |
msg = "Error. The [USER] section does not have 'publish_data_name'" |
124 |
+ |
raise CrabException(msg) |
125 |
+ |
try: |
126 |
+ |
tmp = runCommand("voms-proxy-info -identity") |
127 |
+ |
tmp = string.split(tmp,'/') |
128 |
+ |
reCN=re.compile(r'CN=') |
129 |
+ |
for t in tmp: |
130 |
+ |
if reCN.match(t): |
131 |
+ |
self.UserGridName=string.strip((t.replace('CN=','')).replace(' ','')) |
132 |
+ |
|
133 |
+ |
#self.UserGridName = string.strip(runCommand("voms-proxy-info -identity | awk -F\'CN\' \'{print $2$3$4}\' | tr -d \'=/ \'")) |
134 |
+ |
except: |
135 |
+ |
msg = "Error. Problem with voms-proxy-info -identity command" |
136 |
+ |
raise CrabException(msg) |
137 |
+ |
except KeyError: self.publish_data = 0 |
138 |
+ |
|
139 |
+ |
if ( int(self.copy_data) == 0 and int(self.publish_data) == 1 ): |
140 |
+ |
msg = 'Warning: publish_data = 1 must be used with copy_data = 1\n' |
141 |
+ |
msg = msg + 'Please modify copy_data value in your crab.cfg file\n' |
142 |
+ |
common.logger.message(msg) |
143 |
+ |
raise CrabException(msg) |
144 |
+ |
################################################# |
145 |
+ |
|
146 |
+ |
try: |
147 |
+ |
self.lfc_host = cfg_params['EDG.lfc_host'] |
148 |
+ |
except KeyError: |
149 |
+ |
msg = "Error. The [EDG] section does not have 'lfc_host' value" |
150 |
+ |
msg = msg + " it's necessary to know the LFC host name" |
151 |
+ |
common.logger.message(msg) |
152 |
+ |
raise CrabException(msg) |
153 |
+ |
try: |
154 |
+ |
self.lcg_catalog_type = cfg_params['EDG.lcg_catalog_type'] |
155 |
+ |
except KeyError: |
156 |
+ |
msg = "Error. The [EDG] section does not have 'lcg_catalog_type' value" |
157 |
+ |
msg = msg + " it's necessary to know the catalog type" |
158 |
+ |
common.logger.message(msg) |
159 |
+ |
raise CrabException(msg) |
160 |
+ |
try: |
161 |
+ |
self.lfc_home = cfg_params['EDG.lfc_home'] |
162 |
+ |
except KeyError: |
163 |
+ |
msg = "Error. The [EDG] section does not have 'lfc_home' value" |
164 |
+ |
msg = msg + " it's necessary to know the home catalog dir" |
165 |
+ |
common.logger.message(msg) |
166 |
+ |
raise CrabException(msg) |
167 |
+ |
|
168 |
+ |
try: |
169 |
+ |
self.register_data = cfg_params["USER.register_data"] |
170 |
+ |
if int(self.register_data) == 1: |
171 |
+ |
try: |
172 |
+ |
self.LFN = cfg_params['USER.lfn_dir'] |
173 |
+ |
except KeyError: |
174 |
+ |
msg = "Error. The [USER] section does not have 'lfn_dir' value" |
175 |
+ |
msg = msg + " it's necessary for LCF registration" |
176 |
+ |
common.logger.message(msg) |
177 |
+ |
raise CrabException(msg) |
178 |
+ |
except KeyError: self.register_data = 0 |
179 |
+ |
|
180 |
+ |
if ( int(self.copy_data) == 0 and int(self.register_data) == 1 ): |
181 |
+ |
msg = 'Warning: register_data = 1 must be used with copy_data = 1\n' |
182 |
+ |
msg = msg + 'Please modify copy_data value in your crab.cfg file\n' |
183 |
+ |
common.logger.message(msg) |
184 |
+ |
raise CrabException(msg) |
185 |
+ |
|
186 |
|
try: self.EDG_requirements = cfg_params['EDG.requirements'] |
187 |
|
except KeyError: self.EDG_requirements = '' |
188 |
|
|
189 |
+ |
try: self.EDG_addJdlParam = string.split(cfg_params['EDG.additional_jdl_parameters'],',') |
190 |
+ |
except KeyError: self.EDG_addJdlParam = [] |
191 |
+ |
|
192 |
|
try: self.EDG_retry_count = cfg_params['EDG.retry_count'] |
193 |
|
except KeyError: self.EDG_retry_count = '' |
194 |
|
|
195 |
< |
try: |
196 |
< |
self.VO = cfg_params['EDG.virtual_organization'] |
36 |
< |
except KeyError: |
37 |
< |
msg = 'EDG.virtual_organization is mandatory.' |
38 |
< |
raise CrabException(msg) |
195 |
> |
try: self.EDG_shallow_retry_count= cfg_params['EDG.shallow_retry_count'] |
196 |
> |
except KeyError: self.EDG_shallow_retry_count = '' |
197 |
|
|
198 |
< |
|
199 |
< |
#self.scripts_dir = common.bin_dir + '/scripts' |
200 |
< |
#self.cmd_prefix = 'edg' |
201 |
< |
#if common.LCG_version == '0' : self.cmd_prefix = 'dg' |
198 |
> |
try: self.EDG_clock_time = cfg_params['EDG.max_wall_clock_time'] |
199 |
> |
except KeyError: self.EDG_clock_time= '' |
200 |
> |
|
201 |
> |
try: self.EDG_cpu_time = cfg_params['EDG.max_cpu_time'] |
202 |
> |
except KeyError: self.EDG_cpu_time = '' |
203 |
|
|
204 |
|
# Add EDG_WL_LOCATION to the python path |
205 |
|
|
214 |
|
libPath=os.path.join(path, "lib", "python") |
215 |
|
sys.path.append(libPath) |
216 |
|
|
217 |
< |
self.checkProxy_() |
217 |
> |
self.proxyValid=0 |
218 |
> |
|
219 |
> |
try: |
220 |
> |
self._taskId = cfg_params['taskId'] |
221 |
> |
except: |
222 |
> |
self._taskId = '' |
223 |
> |
|
224 |
> |
try: self.jobtypeName = cfg_params['CRAB.jobtype'] |
225 |
> |
except KeyError: self.jobtypeName = '' |
226 |
> |
|
227 |
> |
try: self.schedulerName = cfg_params['CRAB.scheduler'] |
228 |
> |
except KeyError: self.scheduler = '' |
229 |
> |
|
230 |
> |
try: self.dontCheckProxy=int(cfg_params["EDG.dont_check_proxy"]) |
231 |
> |
except KeyError: self.dontCheckProxy = 0 |
232 |
> |
|
233 |
|
return |
234 |
|
|
235 |
+ |
|
236 |
+ |
def rb_configure(self, RB): |
237 |
+ |
self.edg_config = '' |
238 |
+ |
self.edg_config_vo = '' |
239 |
+ |
self.rb_param_file = '' |
240 |
+ |
|
241 |
+ |
edgConfig = EdgConfig(RB) |
242 |
+ |
self.edg_config = edgConfig.config() |
243 |
+ |
self.edg_config_vo = edgConfig.configVO() |
244 |
+ |
|
245 |
+ |
if (self.edg_config and self.edg_config_vo != ''): |
246 |
+ |
self.rb_param_file = 'RBconfig = "'+self.edg_config+'";\nRBconfigVO = "'+self.edg_config_vo+'";\n' |
247 |
+ |
#print "rb_param_file = ", self.rb_param_file |
248 |
+ |
return self.rb_param_file |
249 |
+ |
|
250 |
+ |
|
251 |
+ |
def sched_parameter(self): |
252 |
+ |
""" |
253 |
+ |
Returns file with requirements and scheduler-specific parameters |
254 |
+ |
""" |
255 |
+ |
index = int(common.jobDB.nJobs()) - 1 |
256 |
+ |
job = common.job_list[index] |
257 |
+ |
jbt = job.type() |
258 |
+ |
|
259 |
+ |
lastBlock=-1 |
260 |
+ |
first = [] |
261 |
+ |
for n in range(common.jobDB.nJobs()): |
262 |
+ |
currBlock=common.jobDB.block(n) |
263 |
+ |
if (currBlock!=lastBlock): |
264 |
+ |
lastBlock = currBlock |
265 |
+ |
first.append(n) |
266 |
+ |
|
267 |
+ |
req = '' |
268 |
+ |
req = req + jbt.getRequirements() |
269 |
+ |
|
270 |
+ |
if self.EDG_requirements: |
271 |
+ |
if (req == ' '): |
272 |
+ |
req = req + self.EDG_requirements |
273 |
+ |
else: |
274 |
+ |
req = req + ' && ' + self.EDG_requirements |
275 |
+ |
|
276 |
+ |
if self.EDG_ce_white_list: |
277 |
+ |
ce_white_list = string.split(self.EDG_ce_white_list,',') |
278 |
+ |
for i in range(len(ce_white_list)): |
279 |
+ |
if i == 0: |
280 |
+ |
if (req == ' '): |
281 |
+ |
req = req + '((RegExp("' + string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))' |
282 |
+ |
else: |
283 |
+ |
req = req + ' && ((RegExp("' + string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))' |
284 |
+ |
pass |
285 |
+ |
else: |
286 |
+ |
req = req + ' || (RegExp("' + string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))' |
287 |
+ |
req = req + ')' |
288 |
+ |
|
289 |
+ |
if self.EDG_ce_black_list: |
290 |
+ |
ce_black_list = string.split(self.EDG_ce_black_list,',') |
291 |
+ |
for ce in ce_black_list: |
292 |
+ |
if (req == ' '): |
293 |
+ |
req = req + '(!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))' |
294 |
+ |
else: |
295 |
+ |
req = req + ' && (!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))' |
296 |
+ |
pass |
297 |
+ |
if self.EDG_clock_time: |
298 |
+ |
if (req == ' '): |
299 |
+ |
req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
300 |
+ |
else: |
301 |
+ |
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
302 |
+ |
|
303 |
+ |
if self.EDG_cpu_time: |
304 |
+ |
if (req == ' '): |
305 |
+ |
req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
306 |
+ |
else: |
307 |
+ |
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
308 |
+ |
|
309 |
+ |
for i in range(len(first)): # Add loop DS |
310 |
+ |
groupReq = req |
311 |
+ |
self.param='sched_param_'+str(i)+'.clad' |
312 |
+ |
param_file = open(common.work_space.shareDir()+'/'+self.param, 'w') |
313 |
+ |
|
314 |
+ |
itr4=self.findSites_(first[i]) |
315 |
+ |
for arg in itr4: |
316 |
+ |
groupReq = groupReq + ' && anyMatch(other.storage.CloseSEs, ('+str(arg)+'))' |
317 |
+ |
param_file.write('Requirements = '+groupReq +';\n') |
318 |
+ |
|
319 |
+ |
if (self.rb_param_file != ''): |
320 |
+ |
param_file.write(self.rb_param_file) |
321 |
+ |
|
322 |
+ |
if len(self.EDG_addJdlParam): |
323 |
+ |
for p in self.EDG_addJdlParam: |
324 |
+ |
param_file.write(p) |
325 |
+ |
|
326 |
+ |
param_file.close() |
327 |
+ |
|
328 |
+ |
|
329 |
|
def wsSetupEnvironment(self): |
330 |
|
""" |
331 |
|
Returns part of a job script which does scheduler-specific work. |
332 |
|
""" |
333 |
< |
txt = '\n' |
334 |
< |
txt += 'CloseCEs=`edg-brokerinfo getCE`\n' |
335 |
< |
txt += 'echo "CloseCEs = $CloseCEs"\n' |
336 |
< |
txt += 'CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
337 |
< |
txt += 'echo "CE = $CE"\n' |
333 |
> |
txt = '' |
334 |
> |
txt += '# strip arguments\n' |
335 |
> |
txt += 'echo "strip arguments"\n' |
336 |
> |
txt += 'args=("$@")\n' |
337 |
> |
txt += 'nargs=$#\n' |
338 |
> |
txt += 'shift $nargs\n' |
339 |
> |
txt += "# job number (first parameter for job wrapper)\n" |
340 |
> |
#txt += "NJob=$1\n" |
341 |
> |
txt += "NJob=${args[0]}\n" |
342 |
> |
|
343 |
> |
txt += '# job identification to DashBoard \n' |
344 |
> |
txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n' |
345 |
> |
txt += 'SyncGridJobId=`echo $EDG_WL_JOBID`\n' |
346 |
> |
txt += 'MonitorID=`echo ' + self._taskId + '`\n' |
347 |
> |
txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
348 |
> |
txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n' |
349 |
> |
txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
350 |
> |
|
351 |
> |
txt += 'echo "middleware discovery " \n' |
352 |
> |
txt += 'if [ $GRID3_APP_DIR ]; then\n' |
353 |
> |
txt += ' middleware=OSG \n' |
354 |
> |
txt += ' echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n' |
355 |
> |
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
356 |
> |
txt += ' echo "middleware =$middleware" \n' |
357 |
> |
txt += 'elif [ $OSG_APP ]; then \n' |
358 |
> |
txt += ' middleware=OSG \n' |
359 |
> |
txt += ' echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n' |
360 |
> |
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
361 |
> |
txt += ' echo "middleware =$middleware" \n' |
362 |
> |
txt += 'elif [ $VO_CMS_SW_DIR ]; then \n' |
363 |
> |
txt += ' middleware=LCG \n' |
364 |
> |
# txt += ' echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n' |
365 |
> |
txt += ' echo "SyncCE=`glite-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n' |
366 |
> |
txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n' |
367 |
> |
txt += ' echo "middleware =$middleware" \n' |
368 |
> |
txt += 'else \n' |
369 |
> |
txt += ' echo "SET_CMS_ENV 10030 ==> middleware not identified" \n' |
370 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10030" \n' |
371 |
> |
txt += ' echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n' |
372 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo \n' |
373 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
374 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
375 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
376 |
> |
txt += ' exit 1 \n' |
377 |
> |
txt += 'fi \n' |
378 |
> |
|
379 |
> |
txt += '# report first time to DashBoard \n' |
380 |
> |
txt += 'dumpStatus $RUNTIME_AREA/$repo \n' |
381 |
> |
txt += 'rm -f $RUNTIME_AREA/$repo \n' |
382 |
> |
txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
383 |
> |
txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
384 |
> |
|
385 |
> |
txt += '\n\n' |
386 |
> |
|
387 |
> |
# if int(self.copy_data) == 1: |
388 |
> |
# if self.SE: |
389 |
> |
# txt += 'export SE='+self.SE+'\n' |
390 |
> |
# txt += 'echo "SE = $SE"\n' |
391 |
> |
# if self.SE_PATH: |
392 |
> |
# if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/' |
393 |
> |
# txt += 'export SE_PATH='+self.SE_PATH+'\n' |
394 |
> |
# txt += 'echo "SE_PATH = $SE_PATH"\n' |
395 |
> |
|
396 |
> |
txt += 'export VO='+self.VO+'\n' |
397 |
> |
### add some line for LFC catalog setting |
398 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
399 |
> |
txt += ' if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n' |
400 |
> |
txt += ' export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n' |
401 |
> |
txt += ' fi\n' |
402 |
> |
txt += ' if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n' |
403 |
> |
txt += ' export LFC_HOST='+self.lfc_host+'\n' |
404 |
> |
txt += ' fi\n' |
405 |
> |
txt += ' if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n' |
406 |
> |
txt += ' export LFC_HOME='+self.lfc_home+'\n' |
407 |
> |
txt += ' fi\n' |
408 |
> |
txt += 'elif [ $middleware == OSG ]; then\n' |
409 |
> |
txt += ' echo "LFC catalog setting to be implemented for OSG"\n' |
410 |
> |
txt += 'fi\n' |
411 |
> |
##### |
412 |
> |
if int(self.register_data) == 1: |
413 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
414 |
> |
txt += ' export LFN='+self.LFN+'\n' |
415 |
> |
txt += ' lfc-ls $LFN\n' |
416 |
> |
txt += ' result=$?\n' |
417 |
> |
txt += ' echo $result\n' |
418 |
> |
### creation of LFN dir in LFC catalog, under /grid/cms dir |
419 |
> |
txt += ' if [ $result != 0 ]; then\n' |
420 |
> |
txt += ' lfc-mkdir $LFN\n' |
421 |
> |
txt += ' result=$?\n' |
422 |
> |
txt += ' echo $result\n' |
423 |
> |
txt += ' fi\n' |
424 |
> |
txt += 'elif [ $middleware == OSG ]; then\n' |
425 |
> |
txt += ' echo " Files registration to be implemented for OSG"\n' |
426 |
> |
txt += 'fi\n' |
427 |
> |
txt += '\n' |
428 |
> |
|
429 |
> |
if self.VO: |
430 |
> |
txt += 'export VO='+self.VO+'\n' |
431 |
> |
if self.LFN: |
432 |
> |
txt += 'if [ $middleware == LCG ]; then \n' |
433 |
> |
txt += ' export LFN='+self.LFN+'\n' |
434 |
> |
txt += 'fi\n' |
435 |
> |
txt += '\n' |
436 |
> |
|
437 |
> |
txt += 'if [ $middleware == LCG ]; then\n' |
438 |
> |
# txt += ' CloseCEs=`edg-brokerinfo getCE`\n' |
439 |
> |
txt += ' CloseCEs=`glite-brokerinfo getCE`\n' |
440 |
> |
txt += ' echo "CloseCEs = $CloseCEs"\n' |
441 |
> |
txt += ' CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
442 |
> |
txt += ' echo "CE = $CE"\n' |
443 |
> |
txt += 'elif [ $middleware == OSG ]; then \n' |
444 |
> |
txt += ' if [ $OSG_JOB_CONTACT ]; then \n' |
445 |
> |
txt += ' CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n' |
446 |
> |
txt += ' else \n' |
447 |
> |
txt += ' echo "SET_CMS_ENV 10099 ==> OSG mode: ERROR in setting CE name from OSG_JOB_CONTACT" \n' |
448 |
> |
txt += ' echo "JOB_EXIT_STATUS = 10099" \n' |
449 |
> |
txt += ' echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n' |
450 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo \n' |
451 |
> |
txt += ' rm -f $RUNTIME_AREA/$repo \n' |
452 |
> |
txt += ' echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n' |
453 |
> |
txt += ' echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n' |
454 |
> |
txt += ' exit 1 \n' |
455 |
> |
txt += ' fi \n' |
456 |
> |
txt += 'fi \n' |
457 |
> |
|
458 |
|
return txt |
459 |
|
|
460 |
< |
def loggingInfo(self, nj): |
460 |
> |
def wsCopyInput(self): |
461 |
|
""" |
462 |
< |
retrieve the logging info from logging and bookkeeping and return it |
462 |
> |
Copy input data from SE to WN |
463 |
|
""" |
464 |
< |
id = common.jobDB.jobId(nj) |
465 |
< |
edg_ui_cfg_opt = '' |
78 |
< |
if self.edg_config: |
79 |
< |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
80 |
< |
cmd = 'edg-job-get-logging-info -v 2 ' + edg_ui_cfg_opt + id |
81 |
< |
print cmd |
82 |
< |
myCmd = os.popen(cmd) |
83 |
< |
cmd_out = myCmd.readlines() |
84 |
< |
myCmd.close() |
85 |
< |
return cmd_out |
464 |
> |
txt = '' |
465 |
> |
if not self.copy_input_data: return txt |
466 |
|
|
467 |
< |
def listMatch(self, nj): |
467 |
> |
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
468 |
> |
txt += 'if [ $middleware == OSG ]; then\n' |
469 |
> |
txt += ' #\n' |
470 |
> |
txt += ' # Copy Input Data from SE to this WN deactivated in OSG mode\n' |
471 |
> |
txt += ' #\n' |
472 |
> |
txt += ' echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n' |
473 |
> |
txt += 'elif [ $middleware == LCG ]; then \n' |
474 |
> |
txt += ' #\n' |
475 |
> |
txt += ' # Copy Input Data from SE to this WN\n' |
476 |
> |
txt += ' #\n' |
477 |
> |
### changed by georgia (put a loop copying more than one input files per jobs) |
478 |
> |
txt += ' for input_file in $cur_file_list \n' |
479 |
> |
txt += ' do \n' |
480 |
> |
txt += ' lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n' |
481 |
> |
txt += ' copy_input_exit_status=$?\n' |
482 |
> |
txt += ' echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n' |
483 |
> |
txt += ' if [ $copy_input_exit_status -ne 0 ]; then \n' |
484 |
> |
txt += ' echo "Problems with copying to WN" \n' |
485 |
> |
txt += ' else \n' |
486 |
> |
txt += ' echo "input copied into WN" \n' |
487 |
> |
txt += ' fi \n' |
488 |
> |
txt += ' done \n' |
489 |
> |
### copy a set of PU ntuples (same for each jobs -- but accessed randomly) |
490 |
> |
txt += ' for file in $cur_pu_list \n' |
491 |
> |
txt += ' do \n' |
492 |
> |
txt += ' lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n' |
493 |
> |
txt += ' copy_input_pu_exit_status=$?\n' |
494 |
> |
txt += ' echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n' |
495 |
> |
txt += ' if [ $copy_input_pu_exit_status -ne 0 ]; then \n' |
496 |
> |
txt += ' echo "Problems with copying pu to WN" \n' |
497 |
> |
txt += ' else \n' |
498 |
> |
txt += ' echo "input pu files copied into WN" \n' |
499 |
> |
txt += ' fi \n' |
500 |
> |
txt += ' done \n' |
501 |
> |
txt += ' \n' |
502 |
> |
txt += ' ### Check SCRATCH space available on WN : \n' |
503 |
> |
txt += ' df -h \n' |
504 |
> |
txt += 'fi \n' |
505 |
> |
|
506 |
> |
return txt |
507 |
> |
|
508 |
> |
def wsCopyOutput(self): |
509 |
|
""" |
510 |
< |
Check the compatibility of available resources |
510 |
> |
Write a CopyResults part of a job script, e.g. |
511 |
> |
to copy produced output into a storage element. |
512 |
|
""" |
513 |
< |
jdl = common.job_list[nj].jdlFilename() |
92 |
< |
edg_ui_cfg_opt = '' |
93 |
< |
if self.edg_config: |
94 |
< |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
95 |
< |
if self.edg_config_vo: |
96 |
< |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
97 |
< |
cmd = 'edg-job-list-match ' + edg_ui_cfg_opt + jdl |
98 |
< |
myCmd = os.popen(cmd) |
99 |
< |
cmd_out = myCmd.readlines() |
100 |
< |
myCmd.close() |
101 |
< |
return self.parseListMatch_(cmd_out, jdl) |
102 |
< |
|
103 |
< |
def parseListMatch_(self, out, jdl): |
104 |
< |
reComment = re.compile( r'^\**$' ) |
105 |
< |
reEmptyLine = re.compile( r'^$' ) |
106 |
< |
reVO = re.compile( r'Selected Virtual Organisation name.*' ) |
107 |
< |
reCE = re.compile( r'CEId' ) |
108 |
< |
reNO = re.compile( r'No Computing Element matching' ) |
109 |
< |
reRB = re.compile( r'Connecting to host' ) |
110 |
< |
next = 0 |
111 |
< |
CEs=[] |
112 |
< |
Match=0 |
113 |
< |
for line in out: |
114 |
< |
line = line.strip() |
115 |
< |
#print line |
116 |
< |
if reComment.match( line ): |
117 |
< |
next = 0 |
118 |
< |
continue |
119 |
< |
if reEmptyLine.match(line): |
120 |
< |
continue |
121 |
< |
if reVO.match( line ): |
122 |
< |
VO =line.split()[-1] |
123 |
< |
common.logger.debug(5, 'VO :'+VO) |
124 |
< |
pass |
125 |
< |
if reRB.match( line ): |
126 |
< |
RB =line.split()[3] |
127 |
< |
common.logger.debug(5, 'Using RB :'+RB) |
128 |
< |
pass |
129 |
< |
if reCE.search( line ): |
130 |
< |
next = 1 |
131 |
< |
continue |
132 |
< |
if next: |
133 |
< |
CE=line.split(':')[0] |
134 |
< |
CEs.append(CE) |
135 |
< |
common.logger.debug(5, 'Matched CE :'+CE) |
136 |
< |
Match=Match+1 |
137 |
< |
pass |
138 |
< |
if reNO.match( line ): |
139 |
< |
common.logger.debug(5,line) |
140 |
< |
self.noMatchFound_(jdl) |
141 |
< |
Match=0 |
142 |
< |
pass |
143 |
< |
return Match |
513 |
> |
txt = '' |
514 |
|
|
515 |
< |
def noMatchFound_(self, jdl): |
516 |
< |
reReq = re.compile( r'Requirements' ) |
517 |
< |
reString = re.compile( r'"\S*"' ) |
518 |
< |
f = file(jdl,'r') |
519 |
< |
for line in f.readlines(): |
520 |
< |
line= line.strip() |
521 |
< |
if reReq.match(line): |
522 |
< |
for req in reString.findall(line): |
523 |
< |
if re.search("VO",req): |
524 |
< |
common.logger.message( "SW required: "+req) |
525 |
< |
continue |
526 |
< |
if re.search('"\d+',req): |
527 |
< |
common.logger.message("Other req : "+req) |
528 |
< |
continue |
529 |
< |
common.logger.message( "CE required: "+req) |
530 |
< |
break |
531 |
< |
pass |
532 |
< |
raise CrabException("No compatible resources found!") |
533 |
< |
|
534 |
< |
def submit(self, nj): |
535 |
< |
""" |
536 |
< |
Submit one EDG job. |
537 |
< |
""" |
538 |
< |
|
539 |
< |
jid = None |
540 |
< |
jdl = common.job_list[nj].jdlFilename() |
541 |
< |
id_tmp = tempfile.mktemp() |
542 |
< |
edg_ui_cfg_opt = ' ' |
543 |
< |
if self.edg_config: |
544 |
< |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
545 |
< |
if self.edg_config_vo: |
546 |
< |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
547 |
< |
cmd = 'edg-job-submit -o ' + id_tmp + edg_ui_cfg_opt + jdl |
548 |
< |
cmd_out = runCommand(cmd) |
549 |
< |
if cmd_out != None: |
550 |
< |
idfile = open(id_tmp) |
551 |
< |
jid_line = idfile.readline() |
552 |
< |
while jid_line[0] == '#': |
553 |
< |
jid_line = idfile.readline() |
554 |
< |
pass |
555 |
< |
jid = string.strip(jid_line) |
556 |
< |
os.unlink(id_tmp) |
557 |
< |
pass |
558 |
< |
return jid |
515 |
> |
##### FEDE MOVED FROM SET_ENVIRONMENT ############## |
516 |
> |
|
517 |
> |
SE_PATH='' |
518 |
> |
if int(self.copy_data) == 1: |
519 |
> |
if self.SE: |
520 |
> |
txt += 'export SE='+self.SE+'\n' |
521 |
> |
txt += 'echo "SE = $SE"\n' |
522 |
> |
if self.SE_PATH: |
523 |
> |
if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/' |
524 |
> |
SE_PATH=self.SE_PATH |
525 |
> |
####### FEDE FOR DBS2 |
526 |
> |
if int(self.publish_data) == 1: |
527 |
> |
txt += '### publish_data = 1 so the SE path where to copy the output is: \n' |
528 |
> |
#txt += 'subject=`voms-proxy-info -subject | awk -F\'CN\' \'{print $2$3$4}\' | tr -d \'=/ \'` \n' |
529 |
> |
#txt += 'echo "subject = $subject" \n' |
530 |
> |
#path_add = '${subject}/'+ self.publish_data_name +'_${PSETHASH}/' |
531 |
> |
path_add = self.UserGridName + '/' + self.publish_data_name +'_${PSETHASH}/' |
532 |
> |
SE_PATH = SE_PATH + path_add |
533 |
> |
|
534 |
> |
txt += 'export SE_PATH='+SE_PATH+'\n' |
535 |
> |
txt += 'echo "SE_PATH = $SE_PATH"\n' |
536 |
> |
|
537 |
> |
########################################################## |
538 |
> |
|
539 |
> |
#if int(self.copy_data) == 1: |
540 |
> |
txt += '#\n' |
541 |
> |
txt += '# Copy output to SE = $SE\n' |
542 |
> |
txt += '#\n' |
543 |
> |
txt += ' if [ $middleware == OSG ]; then\n' |
544 |
> |
txt += ' echo "X509_USER_PROXY = $X509_USER_PROXY"\n' |
545 |
> |
txt += ' echo "source $OSG_APP/glite/setup_glite_ui.sh"\n' |
546 |
> |
txt += ' source $OSG_APP/glite/setup_glite_ui.sh\n' |
547 |
> |
txt += ' export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n' |
548 |
> |
txt += ' echo "export X509_CERT_DIR=$X509_CERT_DIR"\n' |
549 |
> |
txt += ' fi \n' |
550 |
> |
|
551 |
> |
txt += ' for out_file in $file_list ; do\n' |
552 |
> |
txt += ' echo "Trying to copy output file to $SE using srmcp"\n' |
553 |
> |
txt += ' echo "mkdir -p $HOME/.srmconfig"\n' |
554 |
> |
txt += ' mkdir -p $HOME/.srmconfig\n' |
555 |
> |
txt += ' if [ $middleware == LCG ]; then\n' |
556 |
> |
txt += ' echo "srmcp -retry_num 3 -retry_timeout 480000 file:///`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n' |
557 |
> |
txt += ' exitstring=`srmcp -retry_num 3 -retry_timeout 480000 file:///\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n' |
558 |
> |
txt += ' elif [ $middleware == OSG ]; then\n' |
559 |
> |
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' |
560 |
> |
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' |
561 |
> |
txt += ' fi \n' |
562 |
> |
txt += ' copy_exit_status=$?\n' |
563 |
> |
txt += ' echo "COPY_EXIT_STATUS for srmcp = $copy_exit_status"\n' |
564 |
> |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
565 |
> |
|
566 |
> |
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
567 |
> |
txt += ' echo "Possible problem with SE = $SE"\n' |
568 |
> |
txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n' |
569 |
> |
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
570 |
> |
txt += ' echo "srmcp failed, attempting lcg-cp."\n' |
571 |
> |
if common.logger.debugLevel() >= 5: |
572 |
> |
########### FEDE CHANGES TO WRITE IN SRM LNL.INFN.IT ################# |
573 |
> |
txt += ' echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
574 |
> |
txt += ' exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
575 |
> |
#txt += ' echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n' |
576 |
> |
#txt += ' exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n' |
577 |
> |
else: |
578 |
> |
txt += ' echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
579 |
> |
txt += ' exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
580 |
> |
#txt += ' echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n' |
581 |
> |
#txt += ' exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n' |
582 |
> |
txt += ' copy_exit_status=$?\n' |
583 |
> |
txt += ' echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n' |
584 |
> |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
585 |
> |
|
586 |
> |
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
587 |
> |
txt += ' echo "Problems with SE = $SE"\n' |
588 |
> |
txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n' |
589 |
> |
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
590 |
> |
txt += ' echo "srmcp and lcg-cp and failed!"\n' |
591 |
> |
txt += ' SE=""\n' |
592 |
> |
txt += ' echo "SE = $SE"\n' |
593 |
> |
txt += ' SE_PATH=""\n' |
594 |
> |
txt += ' echo "SE_PATH = $SE_PATH"\n' |
595 |
> |
txt += ' else\n' |
596 |
> |
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
597 |
> |
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
598 |
> |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
599 |
> |
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
600 |
> |
txt += ' echo "lcg-cp succeeded"\n' |
601 |
> |
txt += ' fi\n' |
602 |
> |
txt += ' else\n' |
603 |
> |
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
604 |
> |
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
605 |
> |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
606 |
> |
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
607 |
> |
txt += ' echo "srmcp succeeded"\n' |
608 |
> |
txt += ' fi\n' |
609 |
> |
txt += ' done\n' |
610 |
> |
txt += ' exit_status=$copy_exit_status\n' |
611 |
> |
return txt |
612 |
> |
|
613 |
> |
def wsRegisterOutput(self): |
614 |
> |
""" |
615 |
> |
Returns part of a job script which does scheduler-specific work. |
616 |
> |
""" |
617 |
|
|
618 |
< |
def queryStatus(self, id): |
619 |
< |
""" Query a status of the job with id """ |
620 |
< |
cmd0 = 'edg-job-status ' |
621 |
< |
cmd = cmd0 + id |
618 |
> |
txt = '' |
619 |
> |
if int(self.register_data) == 1: |
620 |
> |
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
621 |
> |
txt += 'if [ $middleware == OSG ]; then\n' |
622 |
> |
txt += ' #\n' |
623 |
> |
txt += ' # Register output to LFC deactivated in OSG mode\n' |
624 |
> |
txt += ' #\n' |
625 |
> |
txt += ' echo "Register output to LFC deactivated in OSG mode"\n' |
626 |
> |
txt += 'elif [ $middleware == LCG ]; then \n' |
627 |
> |
txt += '#\n' |
628 |
> |
txt += '# Register output to LFC\n' |
629 |
> |
txt += '#\n' |
630 |
> |
txt += ' if [ $copy_exit_status -eq 0 ]; then\n' |
631 |
> |
txt += ' for out_file in $file_list ; do\n' |
632 |
> |
txt += ' echo "Trying to register the output file into LFC"\n' |
633 |
> |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n' |
634 |
> |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
635 |
> |
txt += ' register_exit_status=$?\n' |
636 |
> |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
637 |
> |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
638 |
> |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
639 |
> |
txt += ' echo "Problems with the registration to LFC" \n' |
640 |
> |
txt += ' echo "Try with srm protocol" \n' |
641 |
> |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n' |
642 |
> |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n' |
643 |
> |
txt += ' register_exit_status=$?\n' |
644 |
> |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
645 |
> |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
646 |
> |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
647 |
> |
txt += ' echo "Problems with the registration into LFC" \n' |
648 |
> |
txt += ' fi \n' |
649 |
> |
txt += ' else \n' |
650 |
> |
txt += ' echo "output registered to LFC"\n' |
651 |
> |
txt += ' fi \n' |
652 |
> |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
653 |
> |
txt += ' done\n' |
654 |
> |
txt += ' else \n' |
655 |
> |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
656 |
> |
# txt += ' CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n' |
657 |
> |
txt += ' CLOSE_SE=`glite-brokerinfo getCloseSEs | head -1`\n' |
658 |
> |
txt += ' for out_file in $file_list ; do\n' |
659 |
> |
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' |
660 |
> |
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' |
661 |
> |
txt += ' register_exit_status=$?\n' |
662 |
> |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
663 |
> |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
664 |
> |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
665 |
> |
txt += ' echo "Problems with CloseSE or Catalog" \n' |
666 |
> |
txt += ' else \n' |
667 |
> |
txt += ' echo "The program was successfully executed"\n' |
668 |
> |
txt += ' echo "SE = $CLOSE_SE"\n' |
669 |
> |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
670 |
> |
txt += ' fi \n' |
671 |
> |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
672 |
> |
txt += ' done\n' |
673 |
> |
txt += ' fi \n' |
674 |
> |
txt += ' exit_status=$register_exit_status\n' |
675 |
> |
txt += 'fi \n' |
676 |
> |
return txt |
677 |
> |
|
678 |
> |
def loggingInfo(self, id): |
679 |
> |
""" |
680 |
> |
retrieve the logging info from logging and bookkeeping and return it |
681 |
> |
""" |
682 |
> |
self.checkProxy() |
683 |
> |
cmd = 'edg-job-get-logging-info -v 2 ' + id |
684 |
|
cmd_out = runCommand(cmd) |
685 |
< |
if cmd_out == None: |
196 |
< |
common.logger.message('Error. No output from `'+cmd+'`') |
197 |
< |
return None |
198 |
< |
# parse output |
199 |
< |
status_prefix = 'Current Status:' |
200 |
< |
status_index = string.find(cmd_out, status_prefix) |
201 |
< |
if status_index == -1: |
202 |
< |
common.logger.message('Error. Bad output of `'+cmd0+'`:\n'+cmd_out) |
203 |
< |
return None |
204 |
< |
status = cmd_out[(status_index+len(status_prefix)):] |
205 |
< |
nl = string.find(status,'\n') |
206 |
< |
status = string.strip(status[0:nl]) |
207 |
< |
return status |
685 |
> |
return cmd_out |
686 |
|
|
687 |
|
def queryDetailedStatus(self, id): |
688 |
|
""" Query a detailed status of the job with id """ |
690 |
|
cmd_out = runCommand(cmd) |
691 |
|
return cmd_out |
692 |
|
|
693 |
< |
def getOutput(self, id): |
693 |
> |
##Addedd Daniele |
694 |
> |
# ####################################################################### |
695 |
> |
def checkBlackList(self, Sites, fileblocks): |
696 |
|
""" |
697 |
< |
Get output for a finished job with id. |
218 |
< |
Returns the name of directory with results. |
697 |
> |
select sites that are not excluded by the user (via SE black list) |
698 |
|
""" |
699 |
+ |
goodSites = [] |
700 |
+ |
for aSite in Sites: |
701 |
+ |
common.logger.debug(10,'Site '+aSite) |
702 |
+ |
good=1 |
703 |
+ |
for re in self.reSEBlackList: |
704 |
+ |
if re.search(string.lower(aSite)): |
705 |
+ |
common.logger.debug(5,'SE in black list, skipping site '+aSite) |
706 |
+ |
good=0 |
707 |
+ |
pass |
708 |
+ |
if good: goodSites.append(aSite) |
709 |
+ |
if len(goodSites) == 0: |
710 |
+ |
msg = "No sites hosting the block %s after BlackList" % fileblocks |
711 |
+ |
common.logger.debug(5,msg) |
712 |
+ |
common.logger.debug(5,"Proceeding without this block.\n") |
713 |
+ |
else: |
714 |
+ |
common.logger.debug(5,"Selected sites for block "+str(fileblocks)+" via BlackList are "+str(goodSites)+"\n") |
715 |
+ |
return goodSites |
716 |
|
|
717 |
< |
cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() + ' ' + id |
718 |
< |
cmd_out = runCommand(cmd) |
719 |
< |
|
720 |
< |
# Determine the output directory name |
721 |
< |
dir = common.work_space.resDir() |
722 |
< |
dir += os.getlogin() |
723 |
< |
dir += '_' + os.path.basename(id) |
724 |
< |
return dir |
725 |
< |
|
726 |
< |
def cancel(self, id): |
727 |
< |
""" Cancel the EDG job with id """ |
728 |
< |
cmd = 'edg-job-cancel --noint ' + id |
729 |
< |
cmd_out = runCommand(cmd) |
730 |
< |
return cmd_out |
717 |
> |
# ####################################################################### |
718 |
> |
def checkWhiteList(self, Sites, fileblocks): |
719 |
> |
""" |
720 |
> |
select sites that are defined by the user (via SE white list) |
721 |
> |
""" |
722 |
> |
if len(self.reSEWhiteList)==0: return Sites |
723 |
> |
goodSites = [] |
724 |
> |
for aSite in Sites: |
725 |
> |
good=0 |
726 |
> |
for re in self.reSEWhiteList: |
727 |
> |
if re.search(string.lower(aSite)): |
728 |
> |
common.logger.debug(5,'SE in white list, adding site '+aSite) |
729 |
> |
good=1 |
730 |
> |
pass |
731 |
> |
if good: goodSites.append(aSite) |
732 |
> |
|
733 |
> |
if len(goodSites) == 0: |
734 |
> |
msg = "No sites hosting the block %s after WhiteList" % fileblocks |
735 |
> |
common.logger.debug(5,msg) |
736 |
> |
common.logger.debug(5,"Proceeding without this block.\n") |
737 |
> |
else: |
738 |
> |
common.logger.debug(5,"Selected sites for block "+str(fileblocks)+" via WhiteList are "+str(goodSites)+"\n") |
739 |
> |
|
740 |
> |
return goodSites |
741 |
> |
|
742 |
> |
# ####################################################################### |
743 |
> |
def findSites_(self, n): |
744 |
> |
itr4 =[] |
745 |
> |
|
746 |
> |
sites = common.jobDB.destination(n) |
747 |
> |
|
748 |
> |
if len(sites)>0 and sites[0]=="": |
749 |
> |
return itr4 |
750 |
> |
|
751 |
> |
itr = '' |
752 |
> |
if sites != [""]:#CarlosDaniele |
753 |
> |
##Addedd Daniele |
754 |
> |
replicas = self.checkBlackList(sites,n) |
755 |
> |
if len(replicas)!=0: |
756 |
> |
replicas = self.checkWhiteList(replicas,n) |
757 |
> |
|
758 |
> |
if len(replicas)==0: |
759 |
> |
msg = 'No sites remaining that host any part of the requested data! Exiting... ' |
760 |
> |
raise CrabException(msg) |
761 |
> |
##### |
762 |
> |
# for site in sites: |
763 |
> |
for site in replicas: |
764 |
> |
#itr = itr + 'target.GlueSEUniqueID=="'+site+'" || ' |
765 |
> |
itr = itr + 'target.GlueSEUniqueID=="'+site+'" || ' |
766 |
> |
itr = itr[0:-4] |
767 |
> |
itr4.append( itr ) |
768 |
> |
return itr4 |
769 |
|
|
770 |
< |
def checkProxy_(self): |
770 |
> |
def createXMLSchScript(self, nj, argsList): |
771 |
> |
|
772 |
|
""" |
773 |
< |
Function to check the Globus proxy. |
773 |
> |
Create a XML-file for BOSS4. |
774 |
|
""" |
775 |
< |
cmd = 'grid-proxy-info -timeleft' |
241 |
< |
cmd_out = runCommand(cmd) |
242 |
< |
ok = 1 |
243 |
< |
timeleft = -999 |
244 |
< |
try: timeleft = int(cmd_out) |
245 |
< |
except ValueError: ok=0 |
246 |
< |
except TypeError: ok=0 |
247 |
< |
if timeleft < 1: ok=0 |
248 |
< |
|
249 |
< |
if ok==0: |
250 |
< |
msg = 'No valid proxy found !\n' |
251 |
< |
msg += "Please do 'grid-proxy-init'." |
252 |
< |
raise CrabException(msg) |
253 |
< |
return |
254 |
< |
|
255 |
< |
def createJDL(self, nj): |
775 |
> |
# job = common.job_list[nj] |
776 |
|
""" |
777 |
< |
Create a JDL-file for EDG. |
777 |
> |
INDY |
778 |
> |
[begin] FIX-ME: |
779 |
> |
I would pass jobType instead of job |
780 |
|
""" |
781 |
< |
|
782 |
< |
job = common.job_list[nj] |
781 |
> |
index = nj - 1 |
782 |
> |
job = common.job_list[index] |
783 |
|
jbt = job.type() |
262 |
– |
# jbt.loadJobInfo() |
263 |
– |
inp_sandbox = jbt.inputSandbox(nj) |
264 |
– |
out_sandbox = jbt.outputSandbox(nj) |
265 |
– |
inp_storage_subdir = ''#jbt.inputStorageSubdir() |
784 |
|
|
785 |
< |
title = '# This JDL was generated by '+\ |
786 |
< |
common.prog_name+' (version '+common.prog_version_str+')\n' |
785 |
> |
inp_sandbox = jbt.inputSandbox(index) |
786 |
> |
#out_sandbox = jbt.outputSandbox(index) |
787 |
> |
""" |
788 |
> |
[end] FIX-ME |
789 |
> |
""" |
790 |
> |
|
791 |
> |
|
792 |
> |
title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' |
793 |
|
jt_string = '' |
794 |
|
|
795 |
< |
SPL = inp_storage_subdir |
796 |
< |
if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/' |
795 |
> |
xml_fname = str(self.jobtypeName)+'.xml' |
796 |
> |
xml = open(common.work_space.shareDir()+'/'+xml_fname, 'a') |
797 |
|
|
798 |
< |
jdl_fname = job.jdlFilename() |
799 |
< |
jdl = open(jdl_fname, 'w') |
800 |
< |
jdl.write(title) |
798 |
> |
#TaskName |
799 |
> |
dir = string.split(common.work_space.topDir(), '/') |
800 |
> |
taskName = dir[len(dir)-2] |
801 |
> |
|
802 |
> |
to_write = '' |
803 |
> |
|
804 |
> |
req=' ' |
805 |
> |
req = req + jbt.getRequirements() |
806 |
> |
|
807 |
> |
if self.EDG_requirements: |
808 |
> |
if (req == ' '): |
809 |
> |
req = req + self.EDG_requirements |
810 |
> |
else: |
811 |
> |
req = req + ' && ' + self.EDG_requirements |
812 |
> |
if self.EDG_ce_white_list: |
813 |
> |
ce_white_list = string.split(self.EDG_ce_white_list,',') |
814 |
> |
for i in range(len(ce_white_list)): |
815 |
> |
if i == 0: |
816 |
> |
if (req == ' '): |
817 |
> |
req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
818 |
> |
else: |
819 |
> |
req = req + ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
820 |
> |
pass |
821 |
> |
else: |
822 |
> |
req = req + ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
823 |
> |
req = req + ')' |
824 |
> |
|
825 |
> |
if self.EDG_ce_black_list: |
826 |
> |
ce_black_list = string.split(self.EDG_ce_black_list,',') |
827 |
> |
for ce in ce_black_list: |
828 |
> |
if (req == ' '): |
829 |
> |
req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))' |
830 |
> |
else: |
831 |
> |
req = req + ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))' |
832 |
> |
pass |
833 |
> |
if self.EDG_clock_time: |
834 |
> |
if (req == ' '): |
835 |
> |
req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
836 |
> |
else: |
837 |
> |
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
838 |
> |
|
839 |
> |
if self.EDG_cpu_time: |
840 |
> |
if (req == ' '): |
841 |
> |
req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
842 |
> |
else: |
843 |
> |
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
844 |
> |
|
845 |
> |
if ( self.EDG_retry_count ): |
846 |
> |
to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n' |
847 |
> |
pass |
848 |
|
|
849 |
< |
script = job.scriptFilename() |
850 |
< |
jdl.write('Executable = "' + os.path.basename(script) +'";\n') |
851 |
< |
jdl.write(jt_string) |
849 |
> |
if ( self.EDG_shallow_retry_count ): |
850 |
> |
to_write = to_write + 'ShallowRetryCount = "'+self.EDG_shallow_retry_count+'"\n' |
851 |
> |
pass |
852 |
> |
|
853 |
> |
to_write = to_write + 'MyProxyServer = ""' + self.proxyServer + '""\n' |
854 |
> |
to_write = to_write + 'VirtualOrganisation = ""' + self.VO + '""\n' |
855 |
> |
|
856 |
> |
#TaskName |
857 |
> |
dir = string.split(common.work_space.topDir(), '/') |
858 |
> |
taskName = dir[len(dir)-2] |
859 |
> |
|
860 |
> |
xml.write(str(title)) |
861 |
> |
#xml.write('<task name="' +str(taskName)+'" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache">\n') |
862 |
> |
|
863 |
> |
#xml.write('<task name="' +str(taskName)+ '" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache"' + '" task_info="' + os.path.expandvars('X509_USER_PROXY') + '">\n') |
864 |
> |
xml.write('<task name="' +str(taskName)+ '" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache"' + ' task_info="' + os.environ["X509_USER_PROXY"] + '">\n') |
865 |
> |
xml.write(jt_string) |
866 |
> |
|
867 |
> |
if (to_write != ''): |
868 |
> |
xml.write('<extraTags\n') |
869 |
> |
xml.write(to_write) |
870 |
> |
xml.write('/>\n') |
871 |
> |
pass |
872 |
> |
|
873 |
> |
xml.write('<iterator>\n') |
874 |
> |
xml.write('\t<iteratorRule name="ITR1">\n') |
875 |
> |
xml.write('\t\t<ruleElement> 1:'+ str(nj) + ' </ruleElement>\n') |
876 |
> |
xml.write('\t</iteratorRule>\n') |
877 |
> |
xml.write('\t<iteratorRule name="ITR2">\n') |
878 |
> |
for arg in argsList: |
879 |
> |
xml.write('\t\t<ruleElement> <![CDATA[\n'+ arg + '\n\t\t]]> </ruleElement>\n') |
880 |
> |
pass |
881 |
> |
xml.write('\t</iteratorRule>\n') |
882 |
> |
#print jobList |
883 |
> |
xml.write('\t<iteratorRule name="ITR3">\n') |
884 |
> |
xml.write('\t\t<ruleElement> 1:'+ str(nj) + ':1:6 </ruleElement>\n') |
885 |
> |
xml.write('\t</iteratorRule>\n') |
886 |
> |
|
887 |
> |
''' |
888 |
> |
indy: here itr4 |
889 |
> |
''' |
890 |
> |
|
891 |
> |
xml.write('<chain name="' +str(taskName)+'__ITR1_" scheduler="'+str(self.schedulerName)+'">\n') |
892 |
> |
# xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n') |
893 |
> |
xml.write(jt_string) |
894 |
|
|
895 |
< |
inp_box = 'InputSandbox = { ' |
896 |
< |
inp_box = inp_box + '"' + script + '",' |
895 |
> |
#executable |
896 |
> |
|
897 |
> |
""" |
898 |
> |
INDY |
899 |
> |
script depends on jobType: it should be probably get in a different way |
900 |
> |
""" |
901 |
> |
script = job.scriptFilename() |
902 |
> |
xml.write('<program>\n') |
903 |
> |
xml.write('<exec> ' + os.path.basename(script) +' </exec>\n') |
904 |
> |
xml.write(jt_string) |
905 |
> |
|
906 |
> |
xml.write('<args> <![CDATA[\n _ITR2_ \n]]> </args>\n') |
907 |
> |
xml.write('<program_types> crabjob </program_types>\n') |
908 |
> |
inp_box = common.work_space.pathForTgz() + 'job/' + jbt.scriptName + ',' |
909 |
|
|
910 |
|
if inp_sandbox != None: |
911 |
|
for fl in inp_sandbox: |
912 |
< |
inp_box = inp_box + ' "' + fl + '",' |
912 |
> |
inp_box = inp_box + '' + fl + ',' |
913 |
|
pass |
914 |
|
pass |
915 |
|
|
916 |
< |
#if common.use_jam: |
917 |
< |
# inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",' |
918 |
< |
|
919 |
< |
for addFile in jbt.additional_inbox_files: |
920 |
< |
addFile = os.path.abspath(addFile) |
921 |
< |
inp_box = inp_box+' "'+addFile+'",' |
297 |
< |
pass |
916 |
> |
# if (not jbt.additional_inbox_files == []): |
917 |
> |
# inp_box = inp_box + ',' |
918 |
> |
# for addFile in jbt.additional_inbox_files: |
919 |
> |
# #addFile = os.path.abspath(addFile) |
920 |
> |
# inp_box = inp_box+''+addFile+',' |
921 |
> |
# pass |
922 |
|
|
923 |
|
if inp_box[-1] == ',' : inp_box = inp_box[:-1] |
924 |
< |
inp_box = inp_box + ' };\n' |
925 |
< |
jdl.write(inp_box) |
924 |
> |
inp_box = '<infiles> <![CDATA[\n' + inp_box + '\n]]> </infiles>\n' |
925 |
> |
xml.write(inp_box) |
926 |
> |
|
927 |
> |
base = jbt.name() |
928 |
> |
stdout = base + '__ITR3_.stdout' |
929 |
> |
stderr = base + '__ITR3_.stderr' |
930 |
> |
|
931 |
> |
xml.write('<stderr> ' + stderr + '</stderr>\n') |
932 |
> |
xml.write('<stdout> ' + stdout + '</stdout>\n') |
933 |
> |
|
934 |
|
|
935 |
< |
jdl.write('StdOutput = "' + job.stdout() + '";\n') |
936 |
< |
jdl.write('StdError = "' + job.stderr() + '";\n') |
935 |
> |
out_box = stdout + ',' + \ |
936 |
> |
stderr + ',.BrokerInfo,' |
937 |
|
|
938 |
< |
#if common.flag_return_data : |
939 |
< |
# for fl in job.outputDataFiles(): |
940 |
< |
# out_box = out_box + ' "' + fl + '",' |
941 |
< |
# pass |
942 |
< |
# pass |
943 |
< |
|
944 |
< |
out_box = 'OutputSandbox = { ' |
945 |
< |
if out_sandbox != None: |
946 |
< |
for fl in out_sandbox: |
947 |
< |
out_box = out_box + ' "' + fl + '",' |
938 |
> |
""" |
939 |
> |
if int(self.return_data) == 1: |
940 |
> |
if out_sandbox != None: |
941 |
> |
for fl in out_sandbox: |
942 |
> |
out_box = out_box + '' + fl + ',' |
943 |
> |
pass |
944 |
> |
pass |
945 |
> |
pass |
946 |
> |
""" |
947 |
> |
|
948 |
> |
""" |
949 |
> |
INDY |
950 |
> |
something similar should be also done for infiles (if it makes sense!) |
951 |
> |
""" |
952 |
> |
# Stuff to be returned _always_ via sandbox |
953 |
> |
for fl in jbt.output_file_sandbox: |
954 |
> |
out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ',' |
955 |
> |
pass |
956 |
> |
pass |
957 |
> |
|
958 |
> |
# via sandbox iif required return_data |
959 |
> |
if int(self.return_data) == 1: |
960 |
> |
for fl in jbt.output_file: |
961 |
> |
out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ',' |
962 |
|
pass |
963 |
|
pass |
964 |
|
|
965 |
|
if out_box[-1] == ',' : out_box = out_box[:-1] |
966 |
< |
out_box = out_box + ' };' |
967 |
< |
jdl.write(out_box+'\n') |
966 |
> |
out_box = '<outfiles> <![CDATA[\n' + out_box + '\n]]></outfiles>\n' |
967 |
> |
xml.write(out_box) |
968 |
> |
|
969 |
> |
xml.write('<BossAttr> crabjob.INTERNAL_ID=_ITR1_ </BossAttr>\n') |
970 |
|
|
971 |
< |
# If CloseCE is used ... |
972 |
< |
#if common.flag_usecloseCE and job.inputDataFiles(): |
325 |
< |
# indata = 'InputData = { ' |
326 |
< |
# for fl in job.inputDataFiles(): |
327 |
< |
# indata = indata + ' "lfn:' + SPL + fl + '",' |
328 |
< |
# if indata[-1] == ',' : indata = indata[:-1] |
329 |
< |
# indata = indata + ' };' |
330 |
< |
# jdl.write(indata+'\n') |
331 |
< |
# jdl.write('DataAccessProtocol = { "gsiftp" };\n') |
332 |
< |
|
333 |
< |
if common.analisys_common_info['sites']: |
334 |
< |
if common.analisys_common_info['sw_version']: |
335 |
< |
|
336 |
< |
req='Requirements = ' |
337 |
< |
### First ORCA version |
338 |
< |
req=req + 'Member("VO-cms-' + \ |
339 |
< |
common.analisys_common_info['sw_version'] + \ |
340 |
< |
'", other.GlueHostApplicationSoftwareRunTimeEnvironment)' |
341 |
< |
## then sites |
342 |
< |
if len(common.analisys_common_info['sites'])>0: |
343 |
< |
req = req + ' && (' |
344 |
< |
for i in range(len(common.analisys_common_info['sites'])): |
345 |
< |
req = req + 'other.GlueCEInfoHostName == "' \ |
346 |
< |
+ common.analisys_common_info['sites'][i] + '"' |
347 |
< |
if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ): |
348 |
< |
req = req + ' || ' |
349 |
< |
req = req + ')' |
350 |
< |
## then user requirement |
351 |
< |
if self.EDG_requirements: |
352 |
< |
req = req + ' && ' + self.EDG_requirements |
353 |
< |
req = req + ';\n' |
354 |
< |
jdl.write(req) |
971 |
> |
xml.write('</program>\n') |
972 |
> |
xml.write('</chain>\n') |
973 |
|
|
974 |
< |
jdl.write('VirtualOrganisation = "' + self.VO + '";\n') |
974 |
> |
xml.write('</iterator>\n') |
975 |
> |
xml.write('</task>\n') |
976 |
|
|
977 |
< |
if ( self.EDG_retry_count ): |
978 |
< |
jdl.write('RetryCount = '+self.EDG_retry_count+';\n') |
977 |
> |
xml.close() |
978 |
> |
|
979 |
> |
|
980 |
> |
return |
981 |
> |
|
982 |
> |
def checkProxy(self): |
983 |
> |
""" |
984 |
> |
Function to check the Globus proxy. |
985 |
> |
""" |
986 |
> |
if (self.proxyValid): return |
987 |
> |
|
988 |
> |
### Just return if asked to do so |
989 |
> |
if (self.dontCheckProxy==1): |
990 |
> |
self.proxyValid=1 |
991 |
> |
return |
992 |
> |
|
993 |
> |
minTimeLeft=10*3600 # in seconds |
994 |
> |
|
995 |
> |
minTimeLeftServer = 100 # in hours |
996 |
> |
|
997 |
> |
mustRenew = 0 |
998 |
> |
timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null') |
999 |
> |
timeLeftServer = -999 |
1000 |
> |
if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal): |
1001 |
> |
mustRenew = 1 |
1002 |
> |
else: |
1003 |
> |
timeLeftServer = runCommand('voms-proxy-info -actimeleft 2>/dev/null | head -1') |
1004 |
> |
if not timeLeftServer or not isInt(timeLeftServer): |
1005 |
> |
mustRenew = 1 |
1006 |
> |
elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft: |
1007 |
> |
mustRenew = 1 |
1008 |
> |
pass |
1009 |
> |
pass |
1010 |
> |
|
1011 |
> |
if mustRenew: |
1012 |
> |
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") |
1013 |
> |
cmd = 'voms-proxy-init -voms '+self.VO |
1014 |
> |
if self.group: |
1015 |
> |
cmd += ':/'+self.VO+'/'+self.group |
1016 |
> |
if self.role: |
1017 |
> |
cmd += '/role='+self.role |
1018 |
> |
cmd += ' -valid 192:00' |
1019 |
> |
try: |
1020 |
> |
# SL as above: damn it! |
1021 |
> |
common.logger.debug(10,cmd) |
1022 |
> |
out = os.system(cmd) |
1023 |
> |
if (out>0): raise CrabException("Unable to create a valid proxy!\n") |
1024 |
> |
except: |
1025 |
> |
msg = "Unable to create a valid proxy!\n" |
1026 |
> |
raise CrabException(msg) |
1027 |
|
pass |
1028 |
|
|
1029 |
< |
jdl.close() |
1029 |
> |
## now I do have a voms proxy valid, and I check the myproxy server |
1030 |
> |
renewProxy = 0 |
1031 |
> |
cmd = 'myproxy-info -d -s '+self.proxyServer |
1032 |
> |
cmd_out = runCommand(cmd,0,20) |
1033 |
> |
if not cmd_out: |
1034 |
> |
common.logger.message('No credential delegated to myproxy server '+self.proxyServer+' will do now') |
1035 |
> |
renewProxy = 1 |
1036 |
> |
else: |
1037 |
> |
# if myproxy exist but not long enough, renew |
1038 |
> |
reTime = re.compile( r'timeleft: (\d+)' ) |
1039 |
> |
#print "<"+str(reTime.search( cmd_out ).group(1))+">" |
1040 |
> |
if reTime.match( cmd_out ): |
1041 |
> |
time = reTime.search( cmd_out ).group(1) |
1042 |
> |
if time < minTimeLeftServer: |
1043 |
> |
renewProxy = 1 |
1044 |
> |
common.logger.message('No credential delegation will expire in '+time+' hours: renew it') |
1045 |
> |
pass |
1046 |
> |
pass |
1047 |
> |
|
1048 |
> |
# if not, create one. |
1049 |
> |
if renewProxy: |
1050 |
> |
cmd = 'myproxy-init -d -n -s '+self.proxyServer |
1051 |
> |
out = os.system(cmd) |
1052 |
> |
if (out>0): |
1053 |
> |
raise CrabException("Unable to delegate the proxy to myproxyserver "+self.proxyServer+" !\n") |
1054 |
> |
pass |
1055 |
> |
|
1056 |
> |
# cache proxy validity |
1057 |
> |
self.proxyValid=1 |
1058 |
|
return |
1059 |
+ |
|
1060 |
+ |
def configOpt_(self): |
1061 |
+ |
edg_ui_cfg_opt = ' ' |
1062 |
+ |
if self.edg_config: |
1063 |
+ |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
1064 |
+ |
if self.edg_config_vo: |
1065 |
+ |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
1066 |
+ |
return edg_ui_cfg_opt |
1067 |
+ |
|
1068 |
+ |
def submitTout(self, list): |
1069 |
+ |
return 120 |
1070 |
+ |
|
1071 |
+ |
|