ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/SchedulerEdg.py
Revision: 1.118
Committed: Wed Jun 13 11:09:26 2007 UTC (17 years, 10 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_1_5_3_pre1
Changes since 1.117: +6 -1 lines
Log Message:
add check if both copy_data and return_data are set to 1: raise exception

File Contents

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