1 |
< |
from Scheduler import Scheduler |
1 |
> |
from SchedulerGrid import SchedulerGrid |
2 |
|
from crab_logger import Logger |
3 |
|
from crab_exceptions import * |
4 |
|
from crab_util import * |
5 |
< |
from EdgConfig import * |
5 |
> |
from GliteConfig import * |
6 |
> |
import EdgLoggingInfo |
7 |
|
import common |
8 |
|
|
9 |
|
import os, sys, time |
10 |
|
|
11 |
< |
class SchedulerGlite(Scheduler): |
12 |
< |
def __init__(self): |
13 |
< |
Scheduler.__init__(self,"GLITE") |
14 |
< |
self.states = [ "Acl", "cancelReason", "cancelling","ce_node","children", \ |
15 |
< |
"children_hist","children_num","children_states","condorId","condor_jdl", \ |
16 |
< |
"cpuTime","destination", "done_code","exit_code","expectFrom", \ |
17 |
< |
"expectUpdate","globusId","jdl","jobId","jobtype", \ |
18 |
< |
"lastUpdateTime","localId","location", "matched_jdl","network_server", \ |
19 |
< |
"owner","parent_job", "reason","resubmitted","rsl","seed",\ |
20 |
< |
"stateEnterTime","stateEnterTimes","subjob_failed", \ |
21 |
< |
"user tags" , "status" , "status_code","hierarchy"] |
22 |
< |
return |
23 |
< |
|
24 |
< |
def configure(self, cfg_params): |
25 |
< |
|
26 |
< |
try: |
27 |
< |
RB = cfg_params["EDG.rb"] |
28 |
< |
edgConfig = EdgConfig(RB) |
29 |
< |
self.edg_config = edgConfig.config() |
30 |
< |
self.edg_config_vo = edgConfig.configVO() |
31 |
< |
except KeyError: |
32 |
< |
self.edg_config = '' |
33 |
< |
self.edg_config_vo = '' |
34 |
< |
|
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: self.LCG_version = cfg_params["EDG.lcg_version"] |
41 |
< |
except KeyError: self.LCG_version = '2' |
42 |
< |
|
43 |
< |
try: self.EDG_requirements = cfg_params['EDG.requirements'] |
44 |
< |
except KeyError: self.EDG_requirements = '' |
45 |
< |
|
46 |
< |
try: self.EDG_retry_count = cfg_params['EDG.retry_count'] |
47 |
< |
except KeyError: self.EDG_retry_count = '' |
48 |
< |
|
49 |
< |
try: |
50 |
< |
self.EDG_ce_black_list = cfg_params['EDG.ce_black_list'] |
51 |
< |
except KeyError: |
52 |
< |
self.EDG_ce_black_list = '' |
53 |
< |
|
54 |
< |
try: |
55 |
< |
self.EDG_ce_white_list = cfg_params['EDG.ce_white_list'] |
56 |
< |
except KeyError: self.EDG_ce_white_list = '' |
57 |
< |
|
58 |
< |
try: self.VO = cfg_params['EDG.virtual_organization'] |
59 |
< |
except KeyError: self.VO = 'cms' |
60 |
< |
|
61 |
< |
try: self.return_data = cfg_params['USER.return_data'] |
62 |
< |
except KeyError: self.return_data = 1 |
63 |
< |
|
64 |
< |
try: |
65 |
< |
self.copy_input_data = common.analisys_common_info['copy_input_data'] |
66 |
< |
except KeyError: self.copy_input_data = 0 |
67 |
< |
|
68 |
< |
try: |
69 |
< |
self.copy_data = cfg_params["USER.copy_data"] |
70 |
< |
if int(self.copy_data) == 1: |
71 |
< |
try: |
72 |
< |
self.SE = cfg_params['USER.storage_element'] |
73 |
< |
self.SE_PATH = cfg_params['USER.storage_path'] |
74 |
< |
except KeyError: |
75 |
< |
msg = "Error. The [USER] section does not have 'storage_element'" |
76 |
< |
msg = msg + " and/or 'storage_path' entries, necessary to copy the output" |
77 |
< |
common.logger.message(msg) |
78 |
< |
raise CrabException(msg) |
79 |
< |
except KeyError: self.copy_data = 0 |
80 |
< |
|
81 |
< |
if ( int(self.return_data) == 0 and int(self.copy_data) == 0 ): |
82 |
< |
msg = 'Warning: return_data = 0 and copy_data = 0 ==> your exe output will be lost\n' |
83 |
< |
msg = msg + 'Please modify return_data and copy_data value in your crab.cfg file\n' |
84 |
< |
raise CrabException(msg) |
85 |
< |
|
86 |
< |
try: |
87 |
< |
self.lfc_host = cfg_params['EDG.lfc_host'] |
88 |
< |
except KeyError: |
89 |
< |
msg = "Error. The [EDG] section does not have 'lfc_host' value" |
90 |
< |
msg = msg + " it's necessary to know the LFC host name" |
91 |
< |
common.logger.message(msg) |
92 |
< |
raise CrabException(msg) |
93 |
< |
try: |
94 |
< |
self.lcg_catalog_type = cfg_params['EDG.lcg_catalog_type'] |
95 |
< |
except KeyError: |
96 |
< |
msg = "Error. The [EDG] section does not have 'lcg_catalog_type' value" |
97 |
< |
msg = msg + " it's necessary to know the catalog type" |
98 |
< |
common.logger.message(msg) |
99 |
< |
raise CrabException(msg) |
100 |
< |
try: |
101 |
< |
self.lfc_home = cfg_params['EDG.lfc_home'] |
102 |
< |
except KeyError: |
103 |
< |
msg = "Error. The [EDG] section does not have 'lfc_home' value" |
104 |
< |
msg = msg + " it's necessary to know the home catalog dir" |
105 |
< |
common.logger.message(msg) |
106 |
< |
raise CrabException(msg) |
11 |
> |
class SchedulerGlite(SchedulerGrid): |
12 |
> |
def __init__(self, name="GLITE"): |
13 |
> |
SchedulerGrid.__init__(self,name) |
14 |
> |
|
15 |
> |
self.OSBsize = 55000 |
16 |
> |
|
17 |
> |
def configure(self,cfg_params): |
18 |
> |
SchedulerGrid.configure(self, cfg_params) |
19 |
> |
self.checkProxy() |
20 |
> |
self.environment_unique_identifier = 'GLITE_WMS_JOBID' |
21 |
> |
|
22 |
> |
def realSchedParams(self,cfg_params): |
23 |
> |
""" |
24 |
> |
Return dictionary with specific parameters, to use |
25 |
> |
with real scheduler |
26 |
> |
""" |
27 |
> |
self.rb_param_file='' |
28 |
> |
if (cfg_params.has_key('EDG.rb')): |
29 |
> |
self.rb_param_file=common.scheduler.rb_configure(cfg_params.get("EDG.rb")) |
30 |
> |
self.wms_service=cfg_params.get("EDG.wms_service",'') |
31 |
> |
params = { 'service' : self.wms_service, \ |
32 |
> |
'config' : self.rb_param_file |
33 |
> |
} |
34 |
> |
return params |
35 |
|
|
108 |
– |
try: |
109 |
– |
self.register_data = cfg_params["USER.register_data"] |
110 |
– |
if int(self.register_data) == 1: |
111 |
– |
try: |
112 |
– |
self.LFN = cfg_params['USER.lfn_dir'] |
113 |
– |
except KeyError: |
114 |
– |
msg = "Error. The [USER] section does not have 'lfn_dir' value" |
115 |
– |
msg = msg + " it's necessary for LCF registration" |
116 |
– |
common.logger.message(msg) |
117 |
– |
raise CrabException(msg) |
118 |
– |
except KeyError: self.register_data = 0 |
119 |
– |
|
120 |
– |
if ( int(self.copy_data) == 0 and int(self.register_data) == 1 ): |
121 |
– |
msg = 'Warning: register_data = 1 must be used with copy_data = 1\n' |
122 |
– |
msg = msg + 'Please modify copy_data value in your crab.cfg file\n' |
123 |
– |
common.logger.message(msg) |
124 |
– |
raise CrabException(msg) |
125 |
– |
|
126 |
– |
try: self.EDG_requirements = cfg_params['EDG.requirements'] |
127 |
– |
except KeyError: self.EDG_requirements = '' |
128 |
– |
|
129 |
– |
try: self.EDG_retry_count = cfg_params['EDG.retry_count'] |
130 |
– |
except KeyError: self.EDG_retry_count = '' |
131 |
– |
|
132 |
– |
try: self.EDG_clock_time = cfg_params['EDG.max_wall_clock_time'] |
133 |
– |
except KeyError: self.EDG_clock_time= '' |
134 |
– |
|
135 |
– |
try: self.EDG_cpu_time = cfg_params['EDG.max_cpu_time'] |
136 |
– |
except KeyError: self.EDG_cpu_time = '' |
137 |
– |
|
138 |
– |
# Add EDG_WL_LOCATION to the python path |
139 |
– |
try: |
140 |
– |
path = os.environ['EDG_WL_LOCATION'] |
141 |
– |
except: |
142 |
– |
msg = "Error: the EDG_WL_LOCATION variable is not set." |
143 |
– |
raise CrabException(msg) |
144 |
– |
|
145 |
– |
libPath=os.path.join(path, "lib") |
146 |
– |
sys.path.append(libPath) |
147 |
– |
libPath=os.path.join(path, "lib", "python") |
148 |
– |
sys.path.append(libPath) |
36 |
|
|
37 |
< |
self.proxyValid=0 |
38 |
< |
return |
39 |
< |
|
37 |
> |
def rb_configure(self, RB): |
38 |
> |
if not RB: return None |
39 |
> |
glite_config = None |
40 |
> |
rb_param_file = None |
41 |
|
|
42 |
< |
def sched_parameter(self): |
43 |
< |
""" |
156 |
< |
Returns file with scheduler-specific parameters |
157 |
< |
""" |
158 |
< |
if (self.edg_config and self.edg_config_vo != ''): |
159 |
< |
self.param='sched_param.clad' |
160 |
< |
param_file = open(common.work_space.shareDir()+'/'+self.param, 'w') |
161 |
< |
param_file.write('RBconfig = "'+self.edg_config+'";\n') |
162 |
< |
param_file.write('RBconfigVO = "'+self.edg_config_vo+'";') |
163 |
< |
param_file.close() |
164 |
< |
return 1 |
165 |
< |
else: |
166 |
< |
return 0 |
167 |
< |
|
168 |
< |
def wsSetupEnvironment(self): |
169 |
< |
""" |
170 |
< |
Returns part of a job script which does scheduler-specific work. |
171 |
< |
""" |
172 |
< |
txt = '' |
173 |
< |
txt += 'echo "middleware discovery " \n' |
174 |
< |
txt += 'if [ $VO_CMS_SW_DIR ]; then\n' |
175 |
< |
txt += ' middleware=LCG \n' |
176 |
< |
txt += ' echo "middleware =$middleware" \n' |
177 |
< |
txt += 'elif [ $GRID3_APP_DIR ]; then\n' |
178 |
< |
txt += ' middleware=OSG \n' |
179 |
< |
txt += ' echo "middleware =$middleware" \n' |
180 |
< |
txt += 'elif [ $OSG_APP ]; then \n' |
181 |
< |
txt += ' middleware=OSG \n' |
182 |
< |
txt += ' echo "middleware =$middleware" \n' |
183 |
< |
txt += 'else \n' |
184 |
< |
txt += ' echo "SET_CMS_ENV 1 ==> middleware not identified" \n' |
185 |
< |
txt += ' echo "JOB_EXIT_STATUS = 1"\n' |
186 |
< |
txt += ' exit 1\n' |
187 |
< |
txt += 'fi\n' |
188 |
< |
|
189 |
< |
txt += '\n\n' |
190 |
< |
|
191 |
< |
### OLI: removed to move DashBoard reporting header to front of wrapper script |
192 |
< |
# txt += 'if [ $middleware == LCG ]; then \n' |
193 |
< |
# txt += ' echo "SyncGridJobId=`echo $EDG_WL_JOBID`" | tee -a $RUNTIME_AREA/$repo\n' |
194 |
< |
# txt += 'fi\n' |
195 |
< |
|
196 |
< |
if int(self.copy_data) == 1: |
197 |
< |
if self.SE: |
198 |
< |
txt += 'export SE='+self.SE+'\n' |
199 |
< |
txt += 'echo "SE = $SE"\n' |
200 |
< |
if self.SE_PATH: |
201 |
< |
if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/' |
202 |
< |
txt += 'export SE_PATH='+self.SE_PATH+'\n' |
203 |
< |
txt += 'echo "SE_PATH = $SE_PATH"\n' |
204 |
< |
|
205 |
< |
txt += 'export VO='+self.VO+'\n' |
206 |
< |
### FEDE: add some line for LFC catalog setting |
207 |
< |
txt += 'if [ $middleware == LCG ]; then \n' |
208 |
< |
txt += ' if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n' |
209 |
< |
txt += ' export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n' |
210 |
< |
txt += ' fi\n' |
211 |
< |
txt += ' if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n' |
212 |
< |
txt += ' export LFC_HOST='+self.lfc_host+'\n' |
213 |
< |
txt += ' fi\n' |
214 |
< |
txt += ' if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n' |
215 |
< |
txt += ' export LFC_HOME='+self.lfc_home+'\n' |
216 |
< |
txt += ' fi\n' |
217 |
< |
txt += 'elif [ $middleware == OSG ]; then\n' |
218 |
< |
txt += ' echo "LFC catalog setting to be implemented for OSG"\n' |
219 |
< |
txt += 'fi\n' |
220 |
< |
##### |
221 |
< |
if int(self.register_data) == 1: |
222 |
< |
txt += 'if [ $middleware == LCG ]; then \n' |
223 |
< |
txt += ' export LFN='+self.LFN+'\n' |
224 |
< |
txt += ' lfc-ls $LFN\n' |
225 |
< |
txt += ' result=$?\n' |
226 |
< |
txt += ' echo $result\n' |
227 |
< |
### creation of LFN dir in LFC catalog, under /grid/cms dir |
228 |
< |
txt += ' if [ $result != 0 ]; then\n' |
229 |
< |
txt += ' lfc-mkdir $LFN\n' |
230 |
< |
txt += ' result=$?\n' |
231 |
< |
txt += ' echo $result\n' |
232 |
< |
txt += ' fi\n' |
233 |
< |
txt += 'elif [ $middleware == OSG ]; then\n' |
234 |
< |
txt += ' echo " Files registration to be implemented for OSG"\n' |
235 |
< |
txt += 'fi\n' |
236 |
< |
txt += '\n' |
237 |
< |
|
238 |
< |
if self.VO: |
239 |
< |
txt += 'export VO='+self.VO+'\n' |
240 |
< |
if self.LFN: |
241 |
< |
txt += 'if [ $middleware == LCG ]; then \n' |
242 |
< |
txt += ' export LFN='+self.LFN+'\n' |
243 |
< |
txt += 'fi\n' |
244 |
< |
txt += '\n' |
245 |
< |
|
246 |
< |
txt += 'if [ $middleware == LCG ]; then\n' |
247 |
< |
txt += ' CloseCEs=`glite-brokerinfo getCE`\n' |
248 |
< |
txt += ' echo "CloseCEs = $CloseCEs"\n' |
249 |
< |
txt += ' CE=`echo $CloseCEs | sed -e "s/:.*//"`\n' |
250 |
< |
txt += ' echo "CE = $CE"\n' |
251 |
< |
txt += 'elif [ $middleware == OSG ]; then \n' |
252 |
< |
txt += ' if [ $OSG_JOB_CONTACT ]; then \n' |
253 |
< |
txt += ' CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n' |
254 |
< |
txt += ' else \n' |
255 |
< |
txt += ' echo "SET_ENV 1 ==> ERROR in setting CE name - OSG mode -" \n' |
256 |
< |
txt += ' exit 1 \n' |
257 |
< |
txt += ' fi \n' |
258 |
< |
txt += 'fi \n' |
42 |
> |
gliteConfig = GliteConfig(RB) |
43 |
> |
glite_config = gliteConfig.config() |
44 |
|
|
45 |
< |
return txt |
45 |
> |
if (glite_config ): |
46 |
> |
rb_param_file = glite_config |
47 |
> |
return rb_param_file |
48 |
|
|
49 |
< |
def wsCopyInput(self): |
49 |
> |
def ce_list(self): |
50 |
|
""" |
51 |
< |
Copy input data from SE to WN |
51 |
> |
Returns string with requirement CE related |
52 |
|
""" |
53 |
< |
txt = '' |
54 |
< |
try: |
55 |
< |
self.copy_input_data = common.analisys_common_info['copy_input_data'] |
56 |
< |
#print "self.copy_input_data = ", self.copy_input_data |
57 |
< |
except KeyError: self.copy_input_data = 0 |
58 |
< |
if int(self.copy_input_data) == 1: |
59 |
< |
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
60 |
< |
txt += 'if [ $middleware == OSG ]; then\n' |
61 |
< |
txt += ' #\n' |
62 |
< |
txt += ' # Copy Input Data from SE to this WN deactivated in OSG mode\n' |
63 |
< |
txt += ' #\n' |
64 |
< |
txt += ' echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n' |
65 |
< |
txt += 'elif [ $middleware == LCG ]; then \n' |
66 |
< |
txt += ' #\n' |
67 |
< |
txt += ' # Copy Input Data from SE to this WN\n' |
68 |
< |
txt += ' #\n' |
69 |
< |
### changed by georgia (put a loop copying more than one input files per jobs) |
70 |
< |
txt += ' for input_file in $cur_file_list \n' |
71 |
< |
txt += ' do \n' |
285 |
< |
txt += ' lcg-cp --vo $VO lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n' |
286 |
< |
txt += ' copy_input_exit_status=$?\n' |
287 |
< |
txt += ' echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n' |
288 |
< |
txt += ' if [ $copy_input_exit_status -ne 0 ]; then \n' |
289 |
< |
txt += ' echo "Problems with copying to WN" \n' |
290 |
< |
txt += ' else \n' |
291 |
< |
txt += ' echo "input copied into WN" \n' |
292 |
< |
txt += ' fi \n' |
293 |
< |
txt += ' done \n' |
294 |
< |
### copy a set of PU ntuples (same for each jobs -- but accessed randomly) |
295 |
< |
txt += ' for file in $cur_pu_list \n' |
296 |
< |
txt += ' do \n' |
297 |
< |
txt += ' lcg-cp --vo $VO lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n' |
298 |
< |
txt += ' copy_input_exit_status=$?\n' |
299 |
< |
txt += ' echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n' |
300 |
< |
txt += ' if [ $copy_input_pu_exit_status -ne 0 ]; then \n' |
301 |
< |
txt += ' echo "Problems with copying pu to WN" \n' |
302 |
< |
txt += ' else \n' |
303 |
< |
txt += ' echo "input pu files copied into WN" \n' |
304 |
< |
txt += ' fi \n' |
305 |
< |
txt += ' done \n' |
306 |
< |
txt += ' \n' |
307 |
< |
txt += ' ### Check SCRATCH space available on WN : \n' |
308 |
< |
txt += ' df -h \n' |
309 |
< |
txt += 'fi \n' |
310 |
< |
|
311 |
< |
return txt |
53 |
> |
req = '' |
54 |
> |
if self.EDG_ce_white_list: |
55 |
> |
ce_white_list = self.EDG_ce_white_list |
56 |
> |
tmpCe=[] |
57 |
> |
concString = '&&' |
58 |
> |
for ce in ce_white_list: |
59 |
> |
tmpCe.append('RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId)') |
60 |
> |
if len(tmpCe) == 1: |
61 |
> |
req += " && (" + concString.join(tmpCe) + ") " |
62 |
> |
elif len(tmpCe) > 1: |
63 |
> |
firstCE = 0 |
64 |
> |
for reqTemp in tmpCe: |
65 |
> |
if firstCE == 0: |
66 |
> |
req += " && ( (" + reqTemp + ") " |
67 |
> |
firstCE = 1 |
68 |
> |
elif firstCE > 0: |
69 |
> |
req += " || (" + reqTemp + ") " |
70 |
> |
if firstCE > 0: |
71 |
> |
req += ") " |
72 |
|
|
73 |
< |
def wsCopyOutput(self): |
74 |
< |
""" |
75 |
< |
Write a CopyResults part of a job script, e.g. |
76 |
< |
to copy produced output into a storage element. |
77 |
< |
""" |
78 |
< |
txt = '' |
79 |
< |
if int(self.copy_data) == 1: |
320 |
< |
txt += '#\n' |
321 |
< |
txt += '# Copy output to SE = $SE\n' |
322 |
< |
txt += '#\n' |
323 |
< |
txt += 'if [ $exe_result -eq 0 ]; then\n' |
324 |
< |
txt += ' for out_file in $file_list ; do\n' |
325 |
< |
txt += ' echo "Trying to copy output file to $SE "\n' |
326 |
< |
## OLI_Daniele globus-* for OSG, lcg-* for LCG |
327 |
< |
txt += ' if [ $middleware == OSG ]; then\n' |
328 |
< |
txt += ' echo "globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
329 |
< |
txt += ' copy_exit_status=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
330 |
< |
#txt += ' exitstring=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
331 |
< |
txt += ' elif [ $middleware == LCG ]; then \n' |
332 |
< |
txt += ' echo "lcg-cp --vo cms -t 1200 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n' |
333 |
< |
txt += ' copy_exit_status=`lcg-cp --vo cms -t 1200 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
334 |
< |
#txt += ' exitstring=`lcg-cp --vo cms -t 30 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n' |
335 |
< |
txt += ' fi \n' |
336 |
< |
#txt += ' copy_exit_status=$?\n' |
337 |
< |
txt += ' echo "COPY_EXIT_STATUS = $copy_exit_status"\n' |
338 |
< |
txt += ' echo "STAGE_OUT = $copy_exit_status"\n' |
339 |
< |
txt += ' if [ $copy_exit_status -ne 0 ]; then\n' |
340 |
< |
txt += ' echo "Problems with SE = $SE"\n' |
341 |
< |
txt += ' echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n' |
342 |
< |
txt += ' echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n' |
343 |
< |
txt += ' else\n' |
344 |
< |
txt += ' echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n' |
345 |
< |
txt += ' echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n' |
346 |
< |
txt += ' echo "output copied into $SE/$SE_PATH directory"\n' |
347 |
< |
txt += ' echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n' |
348 |
< |
txt += ' fi\n' |
349 |
< |
txt += ' done\n' |
350 |
< |
txt += 'fi\n' |
351 |
< |
return txt |
73 |
> |
if self.EDG_ce_black_list: |
74 |
> |
ce_black_list = self.EDG_ce_black_list |
75 |
> |
tmpCe=[] |
76 |
> |
concString = '&&' |
77 |
> |
for ce in ce_black_list: |
78 |
> |
tmpCe.append('(!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))') |
79 |
> |
if len(tmpCe): req += " && (" + concString.join(tmpCe) + ") " |
80 |
|
|
81 |
< |
def wsRegisterOutput(self): |
82 |
< |
""" |
355 |
< |
Returns part of a job script which does scheduler-specific work. |
356 |
< |
""" |
81 |
> |
# requirement added to skip gliteCE |
82 |
> |
req += '&& (!RegExp("blah", other.GlueCEUniqueId))' |
83 |
|
|
84 |
< |
txt = '' |
359 |
< |
if int(self.register_data) == 1: |
360 |
< |
## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG) |
361 |
< |
txt += 'if [ $middleware == OSG ]; then\n' |
362 |
< |
txt += ' #\n' |
363 |
< |
txt += ' # Register output to LFC deactivated in OSG mode\n' |
364 |
< |
txt += ' #\n' |
365 |
< |
txt += ' echo "Register output to LFC deactivated in OSG mode"\n' |
366 |
< |
txt += 'elif [ $middleware == LCG ]; then \n' |
367 |
< |
txt += '#\n' |
368 |
< |
txt += '# Register output to LFC\n' |
369 |
< |
txt += '#\n' |
370 |
< |
txt += ' if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n' |
371 |
< |
txt += ' for out_file in $file_list ; do\n' |
372 |
< |
txt += ' echo "Trying to register the output file into LFC"\n' |
373 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n' |
374 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n' |
375 |
< |
txt += ' register_exit_status=$?\n' |
376 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
377 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
378 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
379 |
< |
txt += ' echo "Problems with the registration to LFC" \n' |
380 |
< |
txt += ' echo "Try with srm protocol" \n' |
381 |
< |
txt += ' echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n' |
382 |
< |
txt += ' lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n' |
383 |
< |
txt += ' register_exit_status=$?\n' |
384 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
385 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
386 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
387 |
< |
txt += ' echo "Problems with the registration into LFC" \n' |
388 |
< |
txt += ' fi \n' |
389 |
< |
txt += ' else \n' |
390 |
< |
txt += ' echo "output registered to LFC"\n' |
391 |
< |
txt += ' fi \n' |
392 |
< |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
393 |
< |
txt += ' done\n' |
394 |
< |
txt += ' elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n' |
395 |
< |
txt += ' echo "Trying to copy output file to CloseSE"\n' |
396 |
< |
txt += ' CLOSE_SE=`glite-brokerinfo getCloseSEs | head -1`\n' |
397 |
< |
txt += ' for out_file in $file_list ; do\n' |
398 |
< |
txt += ' echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n' |
399 |
< |
txt += ' lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file 2>&1 \n' |
400 |
< |
txt += ' register_exit_status=$?\n' |
401 |
< |
txt += ' echo "REGISTER_EXIT_STATUS = $register_exit_status"\n' |
402 |
< |
txt += ' echo "STAGE_OUT = $register_exit_status"\n' |
403 |
< |
txt += ' if [ $register_exit_status -ne 0 ]; then \n' |
404 |
< |
txt += ' echo "Problems with CloseSE" \n' |
405 |
< |
txt += ' else \n' |
406 |
< |
txt += ' echo "The program was successfully executed"\n' |
407 |
< |
txt += ' echo "SE = $CLOSE_SE"\n' |
408 |
< |
txt += ' echo "LFN for the file is LFN=${LFN}/$out_file"\n' |
409 |
< |
txt += ' fi \n' |
410 |
< |
txt += ' echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n' |
411 |
< |
txt += ' done\n' |
412 |
< |
txt += ' else\n' |
413 |
< |
txt += ' echo "Problem with the executable"\n' |
414 |
< |
txt += ' fi \n' |
415 |
< |
txt += 'fi \n' |
416 |
< |
return txt |
84 |
> |
return req,self.EDG_ce_white_list,self.EDG_ce_black_list |
85 |
|
|
86 |
< |
def loggingInfo(self, id): |
86 |
> |
def se_list(self, id, dest): |
87 |
|
""" |
88 |
< |
retrieve the logging info from logging and bookkeeping and return it |
88 |
> |
Returns string with requirement SE related |
89 |
|
""" |
90 |
< |
self.checkProxy() |
91 |
< |
cmd = 'glite-job-logging-info -v 2 ' + id |
92 |
< |
#cmd_out = os.popen(cmd) |
93 |
< |
cmd_out = runCommand(cmd) |
94 |
< |
return cmd_out |
90 |
> |
hostList=self.findSites_(id,dest) |
91 |
> |
req='' |
92 |
> |
reqtmp=[] |
93 |
> |
concString = '||' |
94 |
> |
|
95 |
> |
for arg in hostList: |
96 |
> |
reqtmp.append(' Member("'+arg+'" , other.GlueCESEBindGroupSEUniqueID) ') |
97 |
> |
|
98 |
> |
if len(reqtmp): req += " && (" + concString.join(reqtmp) + ") " |
99 |
|
|
100 |
< |
def listMatch(self, nj): |
100 |
> |
return req |
101 |
> |
|
102 |
> |
def jdlParam(self): |
103 |
|
""" |
104 |
< |
Check the compatibility of available resources |
104 |
> |
Returns |
105 |
|
""" |
106 |
< |
self.checkProxy() |
107 |
< |
jdl = common.job_list[nj].jdlFilename() |
108 |
< |
cmd = 'glite-job-list-match ' + self.configOpt_() + jdl |
109 |
< |
cmd_out = runCommand(cmd,0,10) |
110 |
< |
if not cmd_out: |
111 |
< |
raise CrabException("ERROR: "+cmd+" failed!") |
112 |
< |
|
439 |
< |
return self.parseListMatch_(cmd_out, jdl) |
440 |
< |
|
441 |
< |
def parseListMatch_(self, out, jdl): |
442 |
< |
""" |
443 |
< |
Parse the f* output of edg-list-match and produce something sensible |
444 |
< |
""" |
445 |
< |
reComment = re.compile( r'^\**$' ) |
446 |
< |
reEmptyLine = re.compile( r'^$' ) |
447 |
< |
reVO = re.compile( r'Selected Virtual Organisation name.*' ) |
448 |
< |
reLine = re.compile( r'.*') |
449 |
< |
reCE = re.compile( r'(.*:.*)') |
450 |
< |
reCEId = re.compile( r'CEId.*') |
451 |
< |
reNO = re.compile( r'No Computing Element matching' ) |
452 |
< |
reRB = re.compile( r'Connecting to host' ) |
453 |
< |
next = 0 |
454 |
< |
CEs=[] |
455 |
< |
Match=0 |
456 |
< |
|
457 |
< |
#print out |
458 |
< |
lines = reLine.findall(out) |
459 |
< |
|
460 |
< |
i=0 |
461 |
< |
CEs=[] |
462 |
< |
for line in lines: |
463 |
< |
string.strip(line) |
464 |
< |
#print line |
465 |
< |
if reNO.match( line ): |
466 |
< |
common.logger.debug(5,line) |
467 |
< |
return 0 |
468 |
< |
pass |
469 |
< |
if reVO.match( line ): |
470 |
< |
VO =reVO.match( line ).group() |
471 |
< |
common.logger.debug(5,"VO "+VO) |
472 |
< |
pass |
473 |
< |
|
474 |
< |
if reRB.match( line ): |
475 |
< |
RB = reRB.match(line).group() |
476 |
< |
common.logger.debug(5,"RB "+RB) |
477 |
< |
pass |
478 |
< |
|
479 |
< |
if reCEId.search( line ): |
480 |
< |
for lineCE in lines[i:-1]: |
481 |
< |
if reCE.match( lineCE ): |
482 |
< |
CE = string.strip(reCE.search(lineCE).group(1)) |
483 |
< |
CEs.append(CE.split(':')[0]) |
484 |
< |
pass |
485 |
< |
pass |
486 |
< |
pass |
487 |
< |
i=i+1 |
488 |
< |
pass |
489 |
< |
|
490 |
< |
common.logger.debug(5,"All CE :"+str(CEs)) |
491 |
< |
|
492 |
< |
sites = [] |
493 |
< |
[sites.append(it) for it in CEs if not sites.count(it)] |
494 |
< |
|
495 |
< |
common.logger.debug(5,"All Sites :"+str(sites)) |
496 |
< |
return len(sites) |
497 |
< |
|
498 |
< |
def noMatchFound_(self, jdl): |
499 |
< |
reReq = re.compile( r'Requirements' ) |
500 |
< |
reString = re.compile( r'"\S*"' ) |
501 |
< |
f = file(jdl,'r') |
502 |
< |
for line in f.readlines(): |
503 |
< |
line= line.strip() |
504 |
< |
if reReq.match(line): |
505 |
< |
for req in reString.findall(line): |
506 |
< |
if re.search("VO",req): |
507 |
< |
common.logger.message( "SW required: "+req) |
508 |
< |
continue |
509 |
< |
if re.search('"\d+',req): |
510 |
< |
common.logger.message("Other req : "+req) |
511 |
< |
continue |
512 |
< |
common.logger.message( "CE required: "+req) |
513 |
< |
break |
514 |
< |
pass |
515 |
< |
raise CrabException("No compatible resources found!") |
106 |
> |
req='' |
107 |
> |
if self.EDG_addJdlParam: |
108 |
> |
if self.EDG_addJdlParam[-1] == '': self.EDG_addJdlParam= self.EDG_addJdlParam[:-1] |
109 |
> |
for p in self.EDG_addJdlParam: |
110 |
> |
# param_file.write(string.strip(p)+';\n') |
111 |
> |
req+=string.strip(p)+';\n' ## BL--DS |
112 |
> |
return req |
113 |
|
|
114 |
< |
def submit(self, nj): |
114 |
> |
def specific_req(self): |
115 |
|
""" |
116 |
< |
Submit one EDG job. |
116 |
> |
Returns string with specific requirements |
117 |
|
""" |
118 |
+ |
req='' |
119 |
+ |
if self.EDG_clock_time: |
120 |
+ |
if (not req == ' '): req = req + ' && ' |
121 |
+ |
req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
122 |
|
|
123 |
< |
self.checkProxy() |
124 |
< |
jid = None |
125 |
< |
jdl = common.job_list[nj].jdlFilename() |
123 |
> |
if self.EDG_cpu_time: |
124 |
> |
if (not req == ' '): req = req + ' && ' |
125 |
> |
req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
126 |
|
|
127 |
< |
cmd = 'glite-job-submit ' + self.configOpt_() + jdl |
527 |
< |
cmd_out = runCommand(cmd) |
528 |
< |
if cmd_out != None: |
529 |
< |
reSid = re.compile( r'https.+' ) |
530 |
< |
jid = reSid.search(cmd_out).group() |
531 |
< |
pass |
532 |
< |
return jid |
127 |
> |
return req |
128 |
|
|
129 |
< |
def resubmit(self, nj_list): |
129 |
> |
def sched_fix_parameter(self): |
130 |
|
""" |
131 |
< |
Prepare jobs to be submit |
131 |
> |
Returns string with requirements and scheduler-specific parameters |
132 |
|
""" |
133 |
< |
return |
133 |
> |
index = int(common._db.nJobs()) |
134 |
> |
job = common.job_list[index-1] |
135 |
> |
jbt = job.type() |
136 |
> |
req = '' |
137 |
> |
req = req + jbt.getRequirements() |
138 |
|
|
139 |
< |
def getExitStatus(self, id): |
140 |
< |
return self.getStatusAttribute_(id, 'exit_code') |
139 |
> |
if self.EDG_requirements: |
140 |
> |
if (not req == ' '): req = req + ' && ' |
141 |
> |
req = req + self.EDG_requirements |
142 |
|
|
143 |
< |
def queryStatus(self, id): |
144 |
< |
return self.getStatusAttribute_(id, 'status') |
143 |
> |
Task_Req={'jobType':req}## DS--BL |
144 |
> |
common._db.updateTask_(Task_Req) |
145 |
|
|
146 |
< |
def queryDest(self, id): |
147 |
< |
return self.getStatusAttribute_(id, 'destination') |
146 |
> |
def sched_parameter(self,i,task): |
147 |
> |
""" |
148 |
> |
Returns string with requirements and scheduler-specific parameters |
149 |
> |
""" |
150 |
> |
dest= task.jobs[i-1]['dlsDestination'] ## DS--BL |
151 |
|
|
152 |
+ |
req='' |
153 |
+ |
req +=task['jobType'] |
154 |
|
|
155 |
< |
def getStatusAttribute_(self, id, attr): |
156 |
< |
""" Query a status of the job with id """ |
155 |
> |
sched_param='' |
156 |
> |
sched_param+='Requirements = ' + req +self.specific_req() + self.se_list(i,dest) +\ |
157 |
> |
self.ce_list()[0] +';\n' ## BL--DS |
158 |
> |
if self.EDG_addJdlParam: sched_param+=self.jdlParam() ## BL--DS |
159 |
> |
sched_param+='MyProxyServer = "' + self.proxyServer + '";\n' |
160 |
> |
sched_param+='VirtualOrganisation = "' + self.VO + '";\n' |
161 |
> |
sched_param+='RetryCount = '+str(self.EDG_retry_count)+';\n' |
162 |
> |
sched_param+='ShallowRetryCount = '+str(self.EDG_shallow_retry_count)+';\n' |
163 |
|
|
164 |
< |
self.checkProxy() |
554 |
< |
hstates = {} |
555 |
< |
Status = importName('edg_wl_userinterface_common_LbWrapper', 'Status') |
556 |
< |
# Bypass edg-job-status interfacing directly to C++ API |
557 |
< |
# Job attribute vector to retrieve status without edg-job-status |
558 |
< |
level = 0 |
559 |
< |
# Instance of the Status class provided by LB API |
560 |
< |
jobStat = Status() |
561 |
< |
st = 0 |
562 |
< |
jobStat.getStatus(id, level) |
563 |
< |
err, apiMsg = jobStat.get_error() |
564 |
< |
if err: |
565 |
< |
common.logger.debug(5,'Error caught' + apiMsg) |
566 |
< |
return None |
567 |
< |
else: |
568 |
< |
for i in range(len(self.states)): |
569 |
< |
# Fill an hash table with all information retrieved from LB API |
570 |
< |
hstates[ self.states[i] ] = jobStat.loadStatus(st)[i] |
571 |
< |
result = jobStat.loadStatus(st)[ self.states.index(attr) ] |
572 |
< |
return result |
573 |
< |
|
574 |
< |
def queryDetailedStatus(self, id): |
575 |
< |
""" Query a detailed status of the job with id """ |
576 |
< |
cmd = 'glite-job-status '+id |
577 |
< |
cmd_out = runCommand(cmd) |
578 |
< |
return cmd_out |
164 |
> |
return sched_param |
165 |
|
|
166 |
< |
def getOutput(self, id): |
166 |
> |
def decodeLogInfo(self, file): |
167 |
|
""" |
168 |
< |
Get output for a finished job with id. |
583 |
< |
Returns the name of directory with results. |
168 |
> |
Parse logging info file and return main info |
169 |
|
""" |
170 |
+ |
loggingInfo = EdgLoggingInfo.EdgLoggingInfo() |
171 |
+ |
reason = loggingInfo.decodeReason(file) |
172 |
+ |
return reason |
173 |
|
|
174 |
< |
self.checkProxy() |
175 |
< |
cmd = 'glite-job-get-output --dir ' + common.work_space.resDir() + ' ' + id |
176 |
< |
cmd_out = runCommand(cmd) |
174 |
> |
def findSites_(self, n, sites): |
175 |
> |
itr4 =[] |
176 |
> |
if len(sites)>0 and sites[0]=="": |
177 |
> |
return itr4 |
178 |
> |
if sites != [""]: |
179 |
> |
##Addedd Daniele |
180 |
> |
replicas = self.blackWhiteListParser.checkBlackList(sites,n) |
181 |
> |
if len(replicas)!=0: |
182 |
> |
replicas = self.blackWhiteListParser.checkWhiteList(replicas,n) |
183 |
|
|
184 |
< |
# Determine the output directory name |
185 |
< |
dir = common.work_space.resDir() |
186 |
< |
dir += os.environ['USER'] |
593 |
< |
dir += '_' + os.path.basename(id) |
594 |
< |
return dir |
184 |
> |
itr4 = replicas |
185 |
> |
##### |
186 |
> |
return itr4 |
187 |
|
|
188 |
< |
def cancel(self, id): |
189 |
< |
""" Cancel the EDG job with id """ |
598 |
< |
self.checkProxy() |
599 |
< |
cmd = 'glite-job-cancel --noint ' + id |
600 |
< |
cmd_out = runCommand(cmd) |
601 |
< |
return cmd_out |
602 |
< |
|
603 |
< |
|
604 |
< |
def createXMLSchScript(self, nj): |
188 |
> |
|
189 |
> |
def wsExitFunc(self): |
190 |
|
""" |
606 |
– |
Create a XML-file for BOSS4. |
191 |
|
""" |
192 |
< |
job = common.job_list[nj] |
609 |
< |
jbt = job.type() |
610 |
< |
inp_sandbox = jbt.inputSandbox(nj) |
611 |
< |
out_sandbox = jbt.outputSandbox(nj) |
612 |
< |
|
613 |
< |
title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' |
614 |
< |
jt_string = '' |
615 |
< |
|
616 |
< |
xml_fname = 'orca.xml' |
617 |
< |
xml = open(common.work_space.shareDir()+'/'+xml_fname, 'a') |
618 |
< |
|
619 |
< |
#TaskName |
620 |
< |
dir = string.split(common.work_space.topDir(), '/') |
621 |
< |
taskName = dir[len(dir)-2] |
622 |
< |
|
623 |
< |
to_writeReq = '' |
624 |
< |
to_write = '' |
625 |
< |
req=' ' |
626 |
< |
req = req + jbt.getRequirements() |
627 |
< |
if self.EDG_requirements: |
628 |
< |
if (req == ' '): |
629 |
< |
req = req + self.EDG_requirements |
630 |
< |
else: |
631 |
< |
req = req + ' && ' + self.EDG_requirements |
632 |
< |
if self.EDG_ce_white_list: |
633 |
< |
ce_white_list = string.split(self.EDG_ce_white_list,',') |
634 |
< |
for i in range(len(ce_white_list)): |
635 |
< |
if i == 0: |
636 |
< |
if (req == ' '): |
637 |
< |
req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
638 |
< |
else: |
639 |
< |
req = req + ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
640 |
< |
pass |
641 |
< |
else: |
642 |
< |
req = req + ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))' |
643 |
< |
req = req + ')' |
644 |
< |
|
645 |
< |
if self.EDG_ce_black_list: |
646 |
< |
ce_black_list = string.split(self.EDG_ce_black_list,',') |
647 |
< |
for ce in ce_black_list: |
648 |
< |
if (req == ' '): |
649 |
< |
req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))' |
650 |
< |
else: |
651 |
< |
req = req + ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))' |
652 |
< |
pass |
653 |
< |
if self.EDG_clock_time: |
654 |
< |
if (req == ' '): |
655 |
< |
req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
656 |
< |
else: |
657 |
< |
req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time |
192 |
> |
txt = '\n' |
193 |
|
|
194 |
< |
if self.EDG_cpu_time: |
195 |
< |
if (req == ' '): |
196 |
< |
req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
197 |
< |
else: |
198 |
< |
req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time |
199 |
< |
if (req != ' '): |
200 |
< |
req = req + '\n' |
201 |
< |
to_writeReq = req |
202 |
< |
|
203 |
< |
|
204 |
< |
if ( self.EDG_retry_count ): |
205 |
< |
to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n' |
206 |
< |
pass |
207 |
< |
|
208 |
< |
to_write = to_write + 'MyProxyServer = ""' + self.proxyServer + '""\n' |
209 |
< |
to_write = to_write + 'VirtualOrganisation = ""' + self.VO + '""\n' |
210 |
< |
|
211 |
< |
|
212 |
< |
#TaskName |
213 |
< |
dir = string.split(common.work_space.topDir(), '/') |
214 |
< |
taskName = dir[len(dir)-2] |
215 |
< |
|
216 |
< |
if nj == 0: |
217 |
< |
xml.write(str(title)) |
218 |
< |
xml.write('<task name="' +str(taskName)+'">\n') |
219 |
< |
xml.write(jt_string) |
220 |
< |
#Here it must pass the extra Tags.. (into Task & out of chain) |
221 |
< |
if (to_writeReq != ''): |
222 |
< |
xml.write('<extraTags>\n') |
223 |
< |
xml.write('<Requirements>\n') |
224 |
< |
xml.write('<![CDATA[\n') |
225 |
< |
xml.write(to_writeReq) |
226 |
< |
xml.write(']]>\n') |
227 |
< |
xml.write('</Requirements>\n') |
228 |
< |
xml.write('</extraTags>\n') |
229 |
< |
pass |
230 |
< |
|
231 |
< |
if (to_write != ''): |
232 |
< |
xml.write('<extraTags\n') |
233 |
< |
xml.write(to_write) |
699 |
< |
xml.write('/>\n') |
700 |
< |
pass |
701 |
< |
pass |
702 |
< |
|
703 |
< |
xml.write('<chain scheduler="glite">\n') |
704 |
< |
xml.write(jt_string) |
705 |
< |
|
706 |
< |
#executable |
707 |
< |
script = job.scriptFilename() |
708 |
< |
xml.write('<program exec="' + os.path.basename(script) +'"\n') |
709 |
< |
xml.write(jt_string) |
710 |
< |
|
711 |
< |
|
712 |
< |
### only one .sh JDL has arguments: |
713 |
< |
### Fabio |
714 |
< |
xml.write('args = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "GLITE") +'"\n') |
715 |
< |
xml.write('program_types="crabjob"\n') |
716 |
< |
inp_box = 'infiles="' |
717 |
< |
inp_box = inp_box + '' + script + ',' |
718 |
< |
|
719 |
< |
if inp_sandbox != None: |
720 |
< |
for fl in inp_sandbox: |
721 |
< |
inp_box = inp_box + '' + fl + ',' |
722 |
< |
pass |
723 |
< |
pass |
724 |
< |
|
725 |
< |
# Marco (VERY TEMPORARY ML STUFF) |
726 |
< |
inp_box = inp_box + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + ',' +\ |
727 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + ','+\ |
728 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + ','+\ |
729 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + ','+\ |
730 |
< |
os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') |
731 |
< |
# End Marco |
732 |
< |
|
733 |
< |
if (not jbt.additional_inbox_files == []): |
734 |
< |
inp_box = inp_box + ', ' |
735 |
< |
for addFile in jbt.additional_inbox_files: |
736 |
< |
addFile = os.path.abspath(addFile) |
737 |
< |
inp_box = inp_box+''+addFile+',' |
738 |
< |
pass |
739 |
< |
|
740 |
< |
if inp_box[-1] == ',' : inp_box = inp_box[:-1] |
741 |
< |
inp_box = inp_box + ' "\n' |
742 |
< |
xml.write(inp_box) |
743 |
< |
|
744 |
< |
xml.write('stderr="' + job.stdout() + '"\n') |
745 |
< |
xml.write('stdout="' + job.stderr() + '"\n') |
746 |
< |
|
747 |
< |
|
748 |
< |
if job.stdout() == job.stderr(): |
749 |
< |
out_box = 'outfiles="' + \ |
750 |
< |
job.stdout() + ',.BrokerInfo,' |
751 |
< |
else: |
752 |
< |
out_box = 'outfiles="' + \ |
753 |
< |
job.stdout() + ',' + \ |
754 |
< |
job.stderr() + ',.BrokerInfo,' |
755 |
< |
|
756 |
< |
if int(self.return_data) == 1: |
757 |
< |
if out_sandbox != None: |
758 |
< |
for fl in out_sandbox: |
759 |
< |
out_box = out_box + '' + fl + ',' |
760 |
< |
pass |
761 |
< |
pass |
762 |
< |
pass |
763 |
< |
|
764 |
< |
if out_box[-1] == ',' : out_box = out_box[:-1] |
765 |
< |
out_box = out_box + '"' |
766 |
< |
xml.write(out_box+'\n') |
767 |
< |
|
768 |
< |
xml.write('group="'+taskName+'"\n') |
769 |
< |
xml.write('BossAttr="[crabjob.INTERNAL_ID=' + str(nj+1) +']"\n') |
770 |
< |
|
771 |
< |
|
772 |
< |
|
773 |
< |
xml.write('/>\n') |
774 |
< |
xml.write('</chain>\n') |
775 |
< |
|
776 |
< |
if int(nj) == int(common.jobDB.nJobs()-1): xml.write('</task>\n') |
777 |
< |
|
778 |
< |
|
779 |
< |
xml.close() |
780 |
< |
|
781 |
< |
return |
782 |
< |
|
783 |
< |
|
784 |
< |
|
785 |
< |
def checkProxy(self): |
786 |
< |
""" |
787 |
< |
Function to check the Globus proxy. |
788 |
< |
""" |
789 |
< |
if (self.proxyValid): return |
790 |
< |
timeleft = -999 |
791 |
< |
minTimeLeft=10*3600 # in seconds |
792 |
< |
|
793 |
< |
minTimeLeftServer = 100 # in hours |
794 |
< |
|
795 |
< |
#cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00' |
796 |
< |
#cmd = 'voms-proxy-info -timeleft' |
797 |
< |
mustRenew = 0 |
798 |
< |
timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null') |
799 |
< |
timeLeftServer = -999 |
800 |
< |
if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal): |
801 |
< |
mustRenew = 1 |
802 |
< |
else: |
803 |
< |
timeLeftServer = runCommand('voms-proxy-info -actimeleft 2>/dev/null | head -1') |
804 |
< |
if not timeLeftServer or not isInt(timeLeftServer): |
805 |
< |
mustRenew = 1 |
806 |
< |
elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft: |
807 |
< |
mustRenew = 1 |
808 |
< |
pass |
809 |
< |
pass |
810 |
< |
|
811 |
< |
if mustRenew: |
812 |
< |
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") |
813 |
< |
cmd = 'voms-proxy-init -voms cms -valid 96:00' |
814 |
< |
try: |
815 |
< |
# SL as above: damn it! |
816 |
< |
out = os.system(cmd) |
817 |
< |
if (out>0): raise CrabException("Unable to create a valid proxy!\n") |
818 |
< |
except: |
819 |
< |
msg = "Unable to create a valid proxy!\n" |
820 |
< |
raise CrabException(msg) |
821 |
< |
# cmd = 'grid-proxy-info -timeleft' |
822 |
< |
# cmd_out = runCommand(cmd,0,20) |
823 |
< |
pass |
824 |
< |
|
825 |
< |
## now I do have a voms proxy valid, and I check the myproxy server |
826 |
< |
renewProxy = 0 |
827 |
< |
cmd = 'myproxy-info -d -s '+self.proxyServer |
828 |
< |
cmd_out = runCommand(cmd,0,20) |
829 |
< |
if not cmd_out: |
830 |
< |
common.logger.message('No credential delegated to myproxy server '+self.proxyServer+' will do now') |
831 |
< |
renewProxy = 1 |
832 |
< |
else: |
833 |
< |
# if myproxy exist but not long enough, renew |
834 |
< |
reTime = re.compile( r'timeleft: (\d+)' ) |
835 |
< |
#print "<"+str(reTime.search( cmd_out ).group(1))+">" |
836 |
< |
if reTime.match( cmd_out ): |
837 |
< |
time = reTime.search( line ).group(1) |
838 |
< |
if time < minTimeLeftServer: |
839 |
< |
renewProxy = 1 |
840 |
< |
common.logger.message('No credential delegation will expire in '+time+' hours: renew it') |
841 |
< |
pass |
842 |
< |
pass |
843 |
< |
|
844 |
< |
# if not, create one. |
845 |
< |
if renewProxy: |
846 |
< |
cmd = 'myproxy-init -d -n -s '+self.proxyServer |
847 |
< |
out = os.system(cmd) |
848 |
< |
if (out>0): |
849 |
< |
raise CrabException("Unable to delegate the proxy to myproxyserver "+self.proxyServer+" !\n") |
850 |
< |
pass |
851 |
< |
|
852 |
< |
# cache proxy validity |
853 |
< |
self.proxyValid=1 |
854 |
< |
return |
855 |
< |
|
856 |
< |
def configOpt_(self): |
857 |
< |
edg_ui_cfg_opt = ' ' |
858 |
< |
if self.edg_config: |
859 |
< |
edg_ui_cfg_opt = ' -c ' + self.edg_config + ' ' |
860 |
< |
if self.edg_config_vo: |
861 |
< |
edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' ' |
862 |
< |
return edg_ui_cfg_opt |
194 |
> |
txt += '#\n' |
195 |
> |
txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n' |
196 |
> |
txt += '#\n\n' |
197 |
> |
|
198 |
> |
txt += 'func_exit() { \n' |
199 |
> |
txt += self.wsExitFunc_common() |
200 |
> |
### specific Glite check for OSB |
201 |
> |
txt += ' tar zcvf ${out_files}.tgz ${final_list}\n' |
202 |
> |
txt += ' tmp_size=`ls -gGrta ${out_files}.tgz | awk \'{ print $3 }\'`\n' |
203 |
> |
txt += ' rm ${out_files}.tgz\n' |
204 |
> |
txt += ' size=`expr $tmp_size`\n' |
205 |
> |
txt += ' echo "Total Output dimension: $size"\n' |
206 |
> |
txt += ' limit='+str(self.OSBsize) +' \n' |
207 |
> |
txt += ' echo "WARNING: output files size limit is set to: $limit"\n' |
208 |
> |
txt += ' if [ "$limit" -lt "$sum" ]; then\n' |
209 |
> |
txt += ' exceed=1\n' |
210 |
> |
txt += ' job_exit_code=70000\n' |
211 |
> |
txt += ' echo "Output Sanbox too big. Produced output is lost "\n' |
212 |
> |
txt += ' else\n' |
213 |
> |
txt += ' exceed=0\n' |
214 |
> |
txt += ' echo "Total Output dimension $sum is fine."\n' |
215 |
> |
txt += ' fi\n' |
216 |
> |
|
217 |
> |
txt += ' echo "JOB_EXIT_STATUS = $job_exit_code"\n' |
218 |
> |
txt += ' echo "JobExitCode=$job_exit_code" >> $RUNTIME_AREA/$repo\n' |
219 |
> |
txt += ' dumpStatus $RUNTIME_AREA/$repo\n' |
220 |
> |
txt += ' if [ $exceed -ne 1 ]; then\n' |
221 |
> |
txt += ' tar zcvf ${out_files}.tgz ${final_list}\n' |
222 |
> |
txt += ' else\n' |
223 |
> |
txt += ' tar zcvf ${out_files}.tgz CMSSW_${NJob}.stdout CMSSW_${NJob}.stderr\n' |
224 |
> |
txt += ' fi\n' |
225 |
> |
txt += ' exit $job_exit_code\n' |
226 |
> |
|
227 |
> |
txt += '}\n' |
228 |
> |
return txt |
229 |
> |
|
230 |
> |
def userName(self): |
231 |
> |
""" return the user name """ |
232 |
> |
tmp=runCommand("voms-proxy-info -identity") |
233 |
> |
return tmp.strip() |