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