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