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