ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/SchedulerEdg.py
(Generate patch)

Comparing COMP/CRAB/python/SchedulerEdg.py (file contents):
Revision 1.45 by spiga, Tue Mar 28 07:38:37 2006 UTC vs.
Revision 1.73.2.5.2.2 by fanzago, Mon Aug 21 15:08:24 2006 UTC

# Line 2 | Line 2 | from Scheduler import Scheduler
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, time
# Line 21 | Line 22 | class SchedulerEdg(Scheduler):
22  
23      def configure(self, cfg_params):
24  
25 <        try: self.edg_config = cfg_params["EDG.config"]
26 <        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: self.LCG_version = cfg_params["EDG.lcg_version"]
41          except KeyError: self.LCG_version = '2'
# Line 36 | Line 46 | class SchedulerEdg(Scheduler):
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']
44             #print "self.copy_input_data = ", self.copy_input_data
66          except KeyError: self.copy_input_data = 0
67  
47        try: self.return_data = cfg_params['USER.return_data']
48        except KeyError: self.return_data = 1
49
68          try:
69              self.copy_data = cfg_params["USER.copy_data"]
70              if int(self.copy_data) == 1:
# Line 118 | Line 136 | class SchedulerEdg(Scheduler):
136          except KeyError: self.EDG_cpu_time = ''
137  
138          # Add EDG_WL_LOCATION to the python path
121
139          try:
140              path = os.environ['EDG_WL_LOCATION']
141          except:
# Line 131 | Line 148 | class SchedulerEdg(Scheduler):
148          sys.path.append(libPath)
149  
150          self.proxyValid=0
151 +
152 +        try:
153 +            self._taskId = cfg_params['taskId']
154 +        except:
155 +            self._taskId = ''
156 +
157 +        try: self.jobtypeName = cfg_params['CRAB.jobtype']
158 +        except KeyError: self.jobtypeName = ''
159 +
160 +        try: self.schedulerName = cfg_params['CRAB.scheduler']
161 +        except KeyError: self.scheduler = ''
162 +
163          return
164      
165  
# Line 138 | Line 167 | class SchedulerEdg(Scheduler):
167          """
168          Returns file with scheduler-specific parameters
169          """
141      
170          if (self.edg_config and self.edg_config_vo != ''):
171              self.param='sched_param.clad'
172              param_file = open(common.work_space.shareDir()+'/'+self.param, 'w')
# Line 153 | Line 181 | class SchedulerEdg(Scheduler):
181          """
182          Returns part of a job script which does scheduler-specific work.
183          """
156
184          txt = ''
185 +        txt += "# job number (first parameter for job wrapper)\n"
186 +        txt += "NJob=$1\n"
187 +
188 +        txt += '# job identification to DashBoard \n'
189 +        txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n'
190 +        txt += 'SyncGridJobId=`echo $EDG_WL_JOBID`\n'
191 +        txt += 'MonitorID=`echo ' + self._taskId + '`\n'
192 +        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
193 +        txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
194 +        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
195 +
196 +        txt += 'echo "middleware discovery " \n'
197 +        txt += 'if [ $VO_CMS_SW_DIR ]; then \n'
198 +        txt += '    middleware=LCG \n'
199 +        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
200 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
201 +        txt += '    echo "middleware =$middleware" \n'
202 +        txt += 'elif [ $GRID3_APP_DIR ]; then\n'
203 +        txt += '    middleware=OSG \n'
204 +        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
205 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
206 +        txt += '    echo "middleware =$middleware" \n'
207 +        txt += 'elif [ $OSG_APP ]; then \n'
208 +        txt += '    middleware=OSG \n'
209 +        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
210 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
211 +        txt += '    echo "middleware =$middleware" \n'
212 +        txt += 'else \n'
213 +        txt += '    echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
214 +        txt += '    echo "JOB_EXIT_STATUS = 10030" \n'
215 +        txt += '    echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n'
216 +        txt += '    dumpStatus $RUNTIME_AREA/$repo \n'
217 +        txt += '    rm -f $RUNTIME_AREA/$repo \n'
218 +        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
219 +        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
220 +        txt += '    exit 1 \n'
221 +        txt += 'fi \n'
222 +
223 +        txt += '# report first time to DashBoard \n'
224 +        txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
225 +        txt += 'rm -f $RUNTIME_AREA/$repo \n'
226 +        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
227 +        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
228 +        
229 +        txt += '\n\n'
230 +
231          if int(self.copy_data) == 1:
232             if self.SE:
233                txt += 'export SE='+self.SE+'\n'
# Line 163 | Line 236 | class SchedulerEdg(Scheduler):
236                if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
237                txt += 'export SE_PATH='+self.SE_PATH+'\n'
238                txt += 'echo "SE_PATH = $SE_PATH"\n'
239 <                                                                                                                                                            
239 >
240          txt += 'export VO='+self.VO+'\n'
241          ### FEDE: add some line for LFC catalog setting
242 <        txt += 'if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
243 <        txt += '   export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
244 <        txt += 'fi\n'
245 <        txt += 'if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
246 <        txt += 'export LFC_HOST='+self.lfc_host+'\n'
247 <        txt += 'fi\n'
248 <        txt += 'if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
249 <        txt += 'export LFC_HOME='+self.lfc_home+'\n'
242 >        txt += 'if [ $middleware == LCG ]; then \n'
243 >        txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
244 >        txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
245 >        txt += '    fi\n'
246 >        txt += '    if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
247 >        txt += '        export LFC_HOST='+self.lfc_host+'\n'
248 >        txt += '    fi\n'
249 >        txt += '    if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
250 >        txt += '        export LFC_HOME='+self.lfc_home+'\n'
251 >        txt += '    fi\n'
252 >        txt += 'elif [ $middleware == OSG ]; then\n'
253 >        txt += '    echo "LFC catalog setting to be implemented for OSG"\n'
254          txt += 'fi\n'
255          #####
256          if int(self.register_data) == 1:
257 <           txt += 'export LFN='+self.LFN+'\n'
258 <           txt += 'lfc-ls $LFN\n'
259 <           txt += 'result=$?\n'
260 <           txt += 'echo $result\n'
257 >           txt += 'if [ $middleware == LCG ]; then \n'
258 >           txt += '    export LFN='+self.LFN+'\n'
259 >           txt += '    lfc-ls $LFN\n'
260 >           txt += '    result=$?\n'
261 >           txt += '    echo $result\n'
262             ### creation of LFN dir in LFC catalog, under /grid/cms dir  
263 <           txt += 'if [ $result != 0 ]; then\n'
264 <           txt += '   lfc-mkdir $LFN\n'
265 <           txt += '   result=$?\n'
266 <           txt += '   echo $result\n'
263 >           txt += '    if [ $result != 0 ]; then\n'
264 >           txt += '       lfc-mkdir $LFN\n'
265 >           txt += '       result=$?\n'
266 >           txt += '       echo $result\n'
267 >           txt += '    fi\n'
268 >           txt += 'elif [ $middleware == OSG ]; then\n'
269 >           txt += '    echo " Files registration to be implemented for OSG"\n'
270             txt += 'fi\n'
271             txt += '\n'
272 <        txt += 'CloseCEs=`edg-brokerinfo getCE`\n'
273 <        txt += 'echo "CloseCEs = $CloseCEs"\n'
274 <        txt += 'CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
275 <        txt += 'echo "CE = $CE"\n'
272 >
273 >           if self.VO:
274 >              txt += 'export VO='+self.VO+'\n'
275 >           if self.LFN:
276 >              txt += 'if [ $middleware == LCG ]; then \n'
277 >              txt += '    export LFN='+self.LFN+'\n'
278 >              txt += 'fi\n'
279 >              txt += '\n'
280 >
281 >        txt += 'if [ $middleware == LCG ]; then\n'
282 >        txt += '    CloseCEs=`edg-brokerinfo getCE`\n'
283 >        txt += '    echo "CloseCEs = $CloseCEs"\n'
284 >        txt += '    CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
285 >        txt += '    echo "CE = $CE"\n'
286 >        txt += 'elif [ $middleware == OSG ]; then \n'
287 >        txt += '    if [ $OSG_JOB_CONTACT ]; then \n'
288 >        txt += '        CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n'
289 >        txt += '    else \n'
290 >        txt += '        echo "SET_CMS_ENV 10099 ==> OSG mode: ERROR in setting CE name from OSG_JOB_CONTACT" \n'
291 >        txt += '        echo "JOB_EXIT_STATUS = 10099" \n'
292 >        txt += '        echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n'
293 >        txt += '        dumpStatus $RUNTIME_AREA/$repo \n'
294 >        txt += '        rm -f $RUNTIME_AREA/$repo \n'
295 >        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
296 >        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
297 >        txt += '        exit 1 \n'
298 >        txt += '    fi \n'
299 >        txt += 'fi \n'
300 >
301          return txt
302  
303      def wsCopyInput(self):
# Line 204 | Line 310 | class SchedulerEdg(Scheduler):
310              #print "self.copy_input_data = ", self.copy_input_data
311          except KeyError: self.copy_input_data = 0
312          if int(self.copy_input_data) == 1:
313 <           txt += '#\n'
314 <           txt += '#   Copy Input Data from SE to this WN\n'
315 <           txt += '#\n'
313 >        ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
314 >           txt += 'if [ $middleware == OSG ]; then\n'
315 >           txt += '   #\n'
316 >           txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
317 >           txt += '   #\n'
318 >           txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
319 >           txt += 'elif [ $middleware == LCG ]; then \n'
320 >           txt += '   #\n'
321 >           txt += '   #   Copy Input Data from SE to this WN\n'
322 >           txt += '   #\n'
323   ### changed by georgia (put a loop copying more than one input files per jobs)          
324 <           txt +='for input_file in $cur_file_list \n'
325 <           txt +='do \n'
326 <           txt +=' lcg-cp --vo $VO lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
327 <           txt +=' copy_input_exit_status=$?\n'
328 <           txt +=' echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
329 <           txt +=' if [ $copy_input_exit_status -ne 0 ]; then \n'
330 <           txt +='    echo "Problems with copying to WN" \n'
331 <           txt +=' else \n'
332 <           txt +='    echo "input copied into WN" \n'
333 <           txt +=' fi \n'
334 <           txt +='done \n'
324 >           txt += '   for input_file in $cur_file_list \n'
325 >           txt += '   do \n'
326 >           #### FEDE
327 >           #txt += '      echo "which lcg-cp" \n'
328 >           #txt += '      which lcg-cp \n'
329 >           #########
330 >           txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
331 >           txt += '      copy_input_exit_status=$?\n'
332 >           txt += '      echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
333 >           txt += '      if [ $copy_input_exit_status -ne 0 ]; then \n'
334 >           txt += '         echo "Problems with copying to WN" \n'
335 >           txt += '      else \n'
336 >           txt += '         echo "input copied into WN" \n'
337 >           txt += '      fi \n'
338 >           txt += '   done \n'
339   ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
340 <           txt +='for file in $cur_pu_list \n'
341 <           txt +='do \n'
342 <           txt +=' lcg-cp --vo $VO lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
343 <           txt +=' copy_input_exit_status=$?\n'
344 <           txt +=' echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
345 <           txt +=' if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
346 <           txt +='    echo "Problems with copying pu to WN" \n'
347 <           txt +=' else \n'
348 <           txt +='    echo "input pu files copied into WN" \n'
349 <           txt +=' fi \n'
350 <           txt +='done \n'
351 <           txt +='\n'
352 <           txt +='### Check SCRATCH space available on WN : \n'
353 <           txt +='df -h \n'
340 >           txt += '   for file in $cur_pu_list \n'
341 >           txt += '   do \n'
342 >           #### FEDE
343 >           #txt += '      echo "which lcg-cp" \n'
344 >           #txt += '      which lcg-cp \n'
345 >           #########
346 >           txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
347 >           txt += '      copy_input_pu_exit_status=$?\n'
348 >           txt += '      echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
349 >           txt += '      if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
350 >           txt += '         echo "Problems with copying pu to WN" \n'
351 >           txt += '      else \n'
352 >           txt += '         echo "input pu files copied into WN" \n'
353 >           txt += '      fi \n'
354 >           txt += '   done \n'
355 >           txt += '   \n'
356 >           txt += '   ### Check SCRATCH space available on WN : \n'
357 >           txt += '   df -h \n'
358 >           txt += 'fi \n'
359 >          
360          return txt
361  
362      def wsCopyOutput(self):
# Line 246 | Line 369 | class SchedulerEdg(Scheduler):
369             txt += '#\n'
370             txt += '#   Copy output to SE = $SE\n'
371             txt += '#\n'
372 <           txt += 'if [ $exe_result -eq 0 ]; then\n'
372 >           #txt += 'if [ $exe_result -eq 0 ]; then\n'
373 >           txt += '    if [ $middleware == OSG ]; then\n'
374 >           txt += '        echo "X509_USER_PROXY = $X509_USER_PROXY"\n'
375 >           txt += '        echo "source $OSG_APP/glite/setup_glite_ui.sh"\n'
376 >           txt += '        source $OSG_APP/glite/setup_glite_ui.sh\n'
377 >           txt += '        export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n'
378 >           txt += '        echo "export X509_CERT_DIR=$X509_CERT_DIR"\n'
379 >           txt += '    fi \n'
380             txt += '    for out_file in $file_list ; do\n'
381 <           txt += '        echo "Trying to copy output file to $SE "\n'
382 <           txt += '        echo "lcg-cp --vo cms -t 1200 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
383 < #           txt += '        echo "globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
254 <           txt += '        exitstring=`lcg-cp --vo cms -t 1200 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
255 < #           txt += '        exitstring=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
381 >           txt += '        echo "Trying to copy output file to $SE using lcg-cp"\n'
382 >           txt += '        echo "lcg-cp --vo $VO -t 1200 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
383 >           txt += '        exitstring=`lcg-cp --vo $VO -t 1200 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
384             txt += '        copy_exit_status=$?\n'
385 <           txt += '        echo "COPY_EXIT_STATUS = $copy_exit_status"\n'
385 >           txt += '        echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
386             txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
387             txt += '        if [ $copy_exit_status -ne 0 ]; then\n'
388 <           txt += '            echo "Problems with SE = $SE"\n'
388 >           txt += '            echo "Possible problem with SE = $SE"\n'
389             txt += '            echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
390             txt += '            echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
391 +           txt += '            echo "lcg-cp failed, attempting srmcp"\n'
392 +           txt += '            echo "mkdir -p $HOME/.srmconfig"\n'
393 +           txt += '            mkdir -p $HOME/.srmconfig\n'
394 +           txt += '            if [ $middleware == LCG ]; then\n'
395 +           txt += '               echo "srmcp -retry_num 5 -retry_timeout 240000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
396 +           txt += '               exitstring=`srmcp -retry_num 5 -retry_timeout 240000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
397 +           txt += '            elif [ $middleware == OSG ]; then\n'
398 +           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'
399 +           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'
400 +           txt += '            fi \n'
401 +           txt += '            copy_exit_status=$?\n'
402 +           txt += '            echo "COPY_EXIT_STATUS for srm = $copy_exit_status"\n'
403 +           txt += '            echo "STAGE_OUT = $copy_exit_status"\n'
404 +           txt += '            if [ $copy_exit_status -ne 0 ]; then\n'
405 +           txt += '               echo "Problems with SE = $SE"\n'
406 +           txt += '               echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
407 +           txt += '               echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
408 +           txt += '               echo "lcg-cp and srm failed"\n'
409 +           txt += '               echo "If storage_path in your config file contains a ? you may need a \? instead."\n'
410 +           txt += '            else\n'
411 +           txt += '               echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
412 +           txt += '               echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
413 +           txt += '               echo "output copied into $SE/$SE_PATH directory"\n'
414 +           txt += '               echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
415 +           txt += '               echo "srmcp succeeded"\n'
416 +           txt += '            fi\n'
417             txt += '        else\n'
418             txt += '            echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
419             txt += '            echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
420             txt += '            echo "output copied into $SE/$SE_PATH directory"\n'
421             txt += '            echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
422 +           txt += '            echo "lcg-cp succeeded"\n'
423             txt += '         fi\n'
424             txt += '     done\n'
425 <           txt += 'fi\n'
425 >           #txt += 'fi\n'
426          return txt
427  
428      def wsRegisterOutput(self):
# Line 277 | Line 432 | class SchedulerEdg(Scheduler):
432  
433          txt = ''
434          if int(self.register_data) == 1:
435 +        ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
436 +           txt += 'if [ $middleware == OSG ]; then\n'
437 +           txt += '   #\n'
438 +           txt += '   #   Register output to LFC deactivated in OSG mode\n'
439 +           txt += '   #\n'
440 +           txt += '   echo "Register output to LFC deactivated in OSG mode"\n'
441 +           txt += 'elif [ $middleware == LCG ]; then \n'
442             txt += '#\n'
443             txt += '#  Register output to LFC\n'
444             txt += '#\n'
445 <           txt += 'if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
446 <           txt += '   for out_file in $file_list ; do\n'
447 <           txt += '      echo "Trying to register the output file into LFC"\n'
448 <           txt += '      echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n'
449 <           txt += '      lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n'
450 <           txt += '      register_exit_status=$?\n'
451 <           txt += '      echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
452 <           txt += '      echo "STAGE_OUT = $register_exit_status"\n'
453 <           txt += '      if [ $register_exit_status -ne 0 ]; then \n'
454 <           txt += '         echo "Problems with the registration to LFC" \n'
293 <           txt += '         echo "Try with srm protocol" \n'
294 <           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n'
295 <           txt += '         lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n'
445 >           #txt += '   if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
446 >           txt += '   if [ $copy_exit_status -eq 0 ]; then\n'
447 >           txt += '      for out_file in $file_list ; do\n'
448 >           txt += '         echo "Trying to register the output file into LFC"\n'
449 >           #### FEDE
450 >           #txt += '         echo "which lcg-rf" \n'
451 >           #txt += '         which lcg-rf \n'
452 >           #########
453 >           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n'
454 >           txt += '         lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n'
455             txt += '         register_exit_status=$?\n'
456             txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
457             txt += '         echo "STAGE_OUT = $register_exit_status"\n'
458             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
459 <           txt += '            echo "Problems with the registration into LFC" \n'
459 >           txt += '            echo "Problems with the registration to LFC" \n'
460 >           txt += '            echo "Try with srm protocol" \n'
461 >           #### FEDE
462 >           #txt += '            echo "which lcg-rf" \n'
463 >           #txt += '            which lcg-rf \n'
464 >           #########
465 >           txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n'
466 >           txt += '            lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n'
467 >           txt += '            register_exit_status=$?\n'
468 >           txt += '            echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
469 >           txt += '            echo "STAGE_OUT = $register_exit_status"\n'
470 >           txt += '            if [ $register_exit_status -ne 0 ]; then \n'
471 >           txt += '               echo "Problems with the registration into LFC" \n'
472 >           txt += '            fi \n'
473 >           txt += '         else \n'
474 >           txt += '            echo "output registered to LFC"\n'
475             txt += '         fi \n'
476 <           txt += '      else \n'
477 <           txt += '         echo "output registered to LFC"\n'
478 <           txt += '      fi \n'
479 <           txt += '      echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
480 <           txt += '   done\n'
481 <           txt += 'elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
482 <           txt += '   echo "Trying to copy output file to CloseSE"\n'
483 <           txt += '   CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
484 <           txt += '   for out_file in $file_list ; do\n'
485 <           txt += '      echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n'
486 <           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'
487 <           txt += '      register_exit_status=$?\n'
488 <           txt += '      echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
489 <           txt += '      echo "STAGE_OUT = $register_exit_status"\n'
490 <           txt += '      if [ $register_exit_status -ne 0 ]; then \n'
491 <           txt += '         echo "Problems with CloseSE" \n'
492 <           txt += '      else \n'
493 <           txt += '         echo "The program was successfully executed"\n'
494 <           txt += '         echo "SE = $CLOSE_SE"\n'
495 <           txt += '         echo "LFN for the file is LFN=${LFN}/$out_file"\n'
496 <           txt += '      fi \n'
497 <           txt += '      echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
498 <           txt += '   done\n'
499 <           txt += 'else\n'
500 <           txt += '   echo "Problem with the executable"\n'
476 >           txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
477 >           txt += '      done\n'
478 >           #txt += '   elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \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 >           #### FEDE
484 >           #txt += '         echo "which lcg-cr" \n'
485 >           #txt += '         which lcg-cr \n'
486 >           #########
487 >           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'
488 >           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'
489 >           txt += '         register_exit_status=$?\n'
490 >           txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
491 >           txt += '         echo "STAGE_OUT = $register_exit_status"\n'
492 >           txt += '         if [ $register_exit_status -ne 0 ]; then \n'
493 >           txt += '            echo "Problems with CloseSE or Catalog" \n'
494 >           txt += '         else \n'
495 >           txt += '            echo "The program was successfully executed"\n'
496 >           txt += '            echo "SE = $CLOSE_SE"\n'
497 >           txt += '            echo "LFN for the file is LFN=${LFN}/$out_file"\n'
498 >           txt += '         fi \n'
499 >           txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
500 >           txt += '      done\n'
501 >           #txt += '   else\n'
502 >           #txt += '      echo "Problem with the executable"\n'
503 >           txt += '   fi \n'
504 >           txt += '   exit_status=$register_exit_status\n'
505             txt += 'fi \n'
506          return txt
507  
# Line 342 | Line 520 | class SchedulerEdg(Scheduler):
520          Check the compatibility of available resources
521          """
522          self.checkProxy()
523 <        jdl = common.job_list[nj].jdlFilename()
524 <        cmd = 'edg-job-list-match ' + self.configOpt_() + jdl
523 >        jdl = common.work_space.shareDir()+"fake.jdl"
524 >        cmd = 'edg-job-list-match ' + self.configOpt_() + str(jdl)
525          cmd_out = runCommand(cmd,0,10)
526          if not cmd_out:
527              raise CrabException("ERROR: "+cmd+" failed!")
# Line 405 | Line 583 | class SchedulerEdg(Scheduler):
583          [sites.append(it) for it in CEs if not sites.count(it)]
584  
585          common.logger.debug(5,"All Sites :"+str(sites))
586 +        common.logger.message("Matched Sites :"+str(sites))
587          return len(sites)
588  
589      def noMatchFound_(self, jdl):
# Line 501 | Line 680 | class SchedulerEdg(Scheduler):
680  
681          # Determine the output directory name
682          dir = common.work_space.resDir()
683 <        dir += os.getlogin()
683 >        dir += os.environ['USER']
684          dir += '_' + os.path.basename(id)
685          return dir
686  
# Line 511 | Line 690 | class SchedulerEdg(Scheduler):
690          cmd = 'edg-job-cancel --noint ' + id
691          cmd_out = runCommand(cmd)
692          return cmd_out
693 <
694 <    def createSchScript(self, nj):
695 <        """
696 <        Create a JDL-file for EDG.
693 >
694 >    def createFakeJdl(self,nj):  # TMP Just waiting listmatch functionalitly  
695 >                                  # implementation into BOSS4   Daniele
696 >        """                          
697 >        Create a fake jdl considering
698 >        only requirements  
699          """
519
700          job = common.job_list[nj]
701          jbt = job.type()
522        inp_sandbox = jbt.inputSandbox(nj)
523        out_sandbox = jbt.outputSandbox(nj)
702          inp_storage_subdir = ''
703          
526        title = '# This JDL was generated by '+\
527                common.prog_name+' (version '+common.prog_version_str+')\n'
528        jt_string = ''
529
530
704          
705          SPL = inp_storage_subdir
706          if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/'
707  
708 <        jdl_fname = job.jdlFilename()
536 <        jdl = open(jdl_fname, 'w')
537 <        jdl.write(title)
708 >        jdl = open(common.work_space.shareDir()+"fake.jdl","w")
709  
710          script = job.scriptFilename()
711          jdl.write('Executable = "' + os.path.basename(script) +'";\n')
541        jdl.write(jt_string)
712  
713 <        ### only one .sh  JDL has arguments:
714 <        firstEvent = common.jobDB.firstEvent(nj)
715 <        maxEvents = common.jobDB.maxEvents(nj)
716 <        jdl.write('Arguments = "' + str(nj+1)+' '+str(firstEvent)+' '+str(maxEvents)+'";\n')
713 >        req='Requirements = '
714 >        noreq=req
715 >        req = req + jbt.getRequirements()
716 >        #### and USER REQUIREMENT
717 >        if self.EDG_requirements:
718 >            if (req != noreq):
719 >                req = req +  ' && '
720 >            req = req + self.EDG_requirements
721 >        #### FEDE #####
722 >        if self.EDG_ce_white_list:
723 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
724 >            #print "req = ", req
725 >            for i in range(len(ce_white_list)):
726 >                if i == 0:
727 >                    if (req != noreq):
728 >                        req = req +  ' && '
729 >                    req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
730 >                    pass
731 >                else:
732 >                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
733 >            req = req + ')'
734 >        
735 >        if self.EDG_ce_black_list:
736 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
737 >            for ce in ce_black_list:
738 >                if (req != noreq):
739 >                    req = req +  ' && '
740 >                req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
741 >                pass
742 >
743 >        ###############
744 >        clockTime=480
745 >        if self.EDG_clock_time:
746 >            clockTime= self.EDG_clock_time
747 >        if (req != noreq):
748 >            req = req + ' && '
749 >        req = req + '((other.GlueCEPolicyMaxWallClockTime == 0) || (other.GlueCEPolicyMaxWallClockTime>='+str(clockTime)+'))'
750 >
751 >        cpuTime=1000
752 >        if self.EDG_cpu_time:
753 >            cpuTime=self.EDG_cpu_time
754 >        if (req != noreq):
755 >            req = req + ' && '
756 >        req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))'
757 >
758 >        if (req != noreq):
759 >            req = req + ';\n'
760 >            jdl.write(req)
761 >                                                                                                                                                            
762 >        jdl.write('VirtualOrganisation = "' + self.VO + '";\n')
763 >
764 >        if ( self.EDG_retry_count ):              
765 >            jdl.write('RetryCount = '+self.EDG_retry_count+';\n')
766 >            pass
767 >
768 >        jdl.write('MyProxyServer = "' + self.proxyServer + '";\n')
769 >
770 >        jdl.close()
771 >        return
772 >        
773 >
774 >    def createXMLSchScript(self, nj):
775 >        """
776 >        Create a XML-file for BOSS4.
777 >        """
778 >        job = common.job_list[nj]
779 >        jbt = job.type()
780 >
781 >        inp_sandbox = jbt.inputSandbox(nj)
782 >        out_sandbox = jbt.outputSandbox(nj)
783 >  
784 >        title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n'
785 >        jt_string = ''
786 >        
787 >        xml_fname = str(self.jobtypeName)+'.xml'
788 >        xml = open(common.work_space.shareDir()+'/'+xml_fname, 'a')
789 >
790 >        #TaskName  
791 >        dir = string.split(common.work_space.topDir(), '/')
792 >        taskName = dir[len(dir)-2]
793 >  
794 >        to_writeReq = ''
795 >        to_write = ''
796 >        req=' '
797 >        req = req + jbt.getRequirements()
798 >        if self.EDG_requirements:
799 >            if (req == ' '):
800 >                req = req + self.EDG_requirements
801 >            else:
802 >                req = req +  ' && ' + self.EDG_requirements
803 >        if self.EDG_ce_white_list:
804 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
805 >            for i in range(len(ce_white_list)):
806 >                if i == 0:
807 >                    if (req == ' '):
808 >                        req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
809 >                    else:
810 >                        req = req +  ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
811 >                    pass
812 >                else:
813 >                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
814 >            req = req + ')'
815 >        
816 >        if self.EDG_ce_black_list:
817 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
818 >            for ce in ce_black_list:
819 >                if (req == ' '):
820 >                    req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
821 >                else:
822 >                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
823 >                pass
824 >        if self.EDG_clock_time:
825 >            if (req == ' '):
826 >                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
827 >            else:
828 >                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
829 >
830 >        if self.EDG_cpu_time:
831 >            if (req == ' '):
832 >                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
833 >            else:
834 >                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
835 >        if (req != ' '):
836 >            req = req + '\n'
837 >            to_writeReq = req
838 >                                                                                                                                                            
839  
840 <        inp_box = 'InputSandbox = { '
841 <        inp_box = inp_box + '"' + script + '",'
840 >        if ( self.EDG_retry_count ):              
841 >            to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n'
842 >            pass
843 >
844 >        to_write = to_write + 'MyProxyServer = "&quot;' + self.proxyServer + '&quot;"\n'
845 >        to_write = to_write + 'VirtualOrganisation = "&quot;' + self.VO + '&quot;"\n'
846 >
847 >
848 >        #TaskName  
849 >        dir = string.split(common.work_space.topDir(), '/')
850 >        taskName = dir[len(dir)-2]
851 >
852 >        if nj == 0:
853 >            xml.write(str(title))
854 >            xml.write('<task name="' +str(taskName)+'">\n')
855 >            xml.write(jt_string)
856 >            #Here it must pass the extra Tags.. (into Task & out of chain)  
857 >            if (to_writeReq != ''):
858 >                xml.write('<extraTags>\n')
859 >                xml.write('<Requirements>\n')
860 >                xml.write('<![CDATA[\n')
861 >                xml.write(to_writeReq)
862 >                xml.write(']]>\n')
863 >                xml.write('</Requirements>\n')
864 >                xml.write('</extraTags>\n')
865 >                pass
866 >
867 >            if (to_write != ''):
868 >                xml.write('<extraTags\n')
869 >                xml.write(to_write)
870 >                xml.write('/>\n')
871 >                pass
872 >            pass
873 >  
874 >        xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n')
875 >        xml.write(jt_string)
876 >
877 >        #executable
878 >        script = job.scriptFilename()
879 >        xml.write('<program exec="' + os.path.basename(script) +'"\n')
880 >        xml.write(jt_string)
881 >    
882 >          
883 >        ### only one .sh  JDL has arguments:
884 >        ### Fabio
885 >        xml.write('args = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'"\n')
886 >        xml.write('program_types="crabjob"\n')
887 >        inp_box = 'infiles="'
888 >        inp_box = inp_box + '' + script + ','
889  
890          if inp_sandbox != None:
891              for fl in inp_sandbox:
892 <                inp_box = inp_box + ' "' + fl + '",'
892 >                inp_box = inp_box + '' + fl + ','
893                  pass
894              pass
895  
557        #if common.use_jam:
558        #   inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",'
559
896          # Marco (VERY TEMPORARY ML STUFF)
897 <        inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\
898 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\
899 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\
900 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"'
897 >        inp_box = inp_box + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + ',' +\
898 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + ','+\
899 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + ','+\
900 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + ','+\
901 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py')
902          # End Marco
903  
904          if (not jbt.additional_inbox_files == []):
905              inp_box = inp_box + ', '
906              for addFile in jbt.additional_inbox_files:
907                  addFile = os.path.abspath(addFile)
908 <                inp_box = inp_box+' "'+addFile+'",'
908 >                inp_box = inp_box+''+addFile+','
909                  pass
910  
911          if inp_box[-1] == ',' : inp_box = inp_box[:-1]
912 <        inp_box = inp_box + ' };\n'
913 <        jdl.write(inp_box)
912 >        inp_box = inp_box + ' "\n'
913 >        xml.write(inp_box)
914  
915 <        jdl.write('StdOutput     = "' + job.stdout() + '";\n')
916 <        jdl.write('StdError      = "' + job.stderr() + '";\n')
915 >        xml.write('stderr="' + job.stderr() + '"\n')
916 >        xml.write('stdout="' + job.stdout() + '"\n')
917          
918          
919          if job.stdout() == job.stderr():
920 <          out_box = 'OutputSandbox = { "' + \
921 <                    job.stdout() + '", ".BrokerInfo",'
920 >          out_box = 'outfiles="' + \
921 >                    job.stdout() + ',.BrokerInfo,'
922          else:
923 <          out_box = 'OutputSandbox = { "' + \
924 <                    job.stdout() + '", "' + \
925 <                    job.stderr() + '", ".BrokerInfo",'
923 >          out_box = 'outfiles="' + \
924 >                    job.stdout() + ',' + \
925 >                    job.stderr() + ',.BrokerInfo,'
926  
927          if int(self.return_data) == 1:
928              if out_sandbox != None:
929                  for fl in out_sandbox:
930 <                    out_box = out_box + ' "' + fl + '",'
930 >                    out_box = out_box + '' + fl + ','
931                      pass
932                  pass
933              pass
934                                                                                                                                                              
935          if out_box[-1] == ',' : out_box = out_box[:-1]
936 <        out_box = out_box + ' };'
937 <        jdl.write(out_box+'\n')
936 >        out_box = out_box + '"'
937 >        xml.write(out_box+'\n')
938 >
939 >        xml.write('group="'+taskName+'"\n')
940 >        xml.write('BossAttr="[crabjob.INTERNAL_ID=' + str(nj+1) +']"\n')
941  
942 +        
943 +      
944 +        xml.write('/>\n')
945 +        xml.write('</chain>\n')
946  
947 <        req='Requirements = '
604 <        req = req + jbt.getRequirements()
605 < #        ### if at least a CE exists ...
606 < #        if common.analisys_common_info['sites']:
607 < #           if common.analisys_common_info['sw_version']:
608 < #                req='Requirements = '
609 < #                req=req + 'Member("VO-cms-' + \
610 < #                     common.analisys_common_info['sw_version'] + \
611 < #                     '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
612 < #            if len(common.analisys_common_info['sites'])>0:
613 < #                req = req + ' && ('
614 < #                for i in range(len(common.analisys_common_info['sites'])):
615 < #                    req = req + 'other.GlueCEInfoHostName == "' \
616 < #                         + common.analisys_common_info['sites'][i] + '"'
617 < #                    if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ):
618 < #                        req = req + ' || '
619 < #            req = req + ')'
620 <        #### and USER REQUIREMENT
621 <        if self.EDG_requirements:
622 <            if (req == 'Requirement = '):
623 <                req = req + self.EDG_requirements
624 <            else:
625 <                req = req +  ' && ' + self.EDG_requirements
626 <        if self.EDG_clock_time:
627 <            if (req == 'Requirement = '):
628 <                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
629 <            else:
630 <                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
631 <                
632 <        if self.EDG_cpu_time:
633 <            if (req == 'Requirement = '):
634 <                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
635 <            else:
636 <                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
637 <        if (req != 'Requirement = '):
638 <            req = req + ';\n'
639 <            jdl.write(req)
640 <                                                                                                                                                            
641 <        jdl.write('VirtualOrganisation = "' + self.VO + '";\n')
947 >        if int(nj) == int(common.jobDB.nJobs()-1): xml.write('</task>\n')
948  
643        if ( self.EDG_retry_count ):              
644            jdl.write('RetryCount = '+self.EDG_retry_count+';\n')
645            pass
949  
950 <        jdl.close()
950 >        xml.close()
951 >
952          return
953  
954 +
955 +
956      def checkProxy(self):
957          """
958          Function to check the Globus proxy.
959          """
960          if (self.proxyValid): return
961          timeleft = -999
962 <        minTimeLeft=10 # in hours
963 <        cmd = 'grid-proxy-info -e -v '+str(minTimeLeft)+':00'
964 <        # SL Here I have to use os.system since the stupid command exit with >0 if no valid proxy is found
965 <        cmd_out = os.system(cmd)
966 <        if (cmd_out>0):
967 <            common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 100h\n")
968 <            cmd = 'grid-proxy-init -valid 100:00'
962 >        minTimeLeft=10*3600 # in seconds
963 >
964 >        minTimeLeftServer = 100 # in hours
965 >
966 >        #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
967 >        #cmd = 'voms-proxy-info -timeleft'
968 >        mustRenew = 0
969 >        timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null')
970 >        timeLeftServer = -999
971 >        if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal):
972 >            mustRenew = 1
973 >        else:
974 >            timeLeftServer = runCommand('voms-proxy-info -actimeleft 2>/dev/null | head -1')
975 >            if not timeLeftServer or not isInt(timeLeftServer):
976 >                mustRenew = 1
977 >            elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft:
978 >                mustRenew = 1
979 >            pass
980 >        pass
981 >
982 >        if mustRenew:
983 >            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")
984 >            cmd = 'voms-proxy-init -voms cms -valid 96:00'
985              try:
986                  # SL as above: damn it!
987                  out = os.system(cmd)
# Line 670 | Line 992 | class SchedulerEdg(Scheduler):
992              # cmd = 'grid-proxy-info -timeleft'
993              # cmd_out = runCommand(cmd,0,20)
994              pass
995 +
996 +        ## now I do have a voms proxy valid, and I check the myproxy server
997 +        renewProxy = 0
998 +        cmd = 'myproxy-info -d -s '+self.proxyServer
999 +        cmd_out = runCommand(cmd,0,20)
1000 +        if not cmd_out:
1001 +            common.logger.message('No credential delegated to myproxy server '+self.proxyServer+' will do now')
1002 +            renewProxy = 1
1003 +        else:
1004 +            # if myproxy exist but not long enough, renew
1005 +            reTime = re.compile( r'timeleft: (\d+)' )
1006 +            #print "<"+str(reTime.search( cmd_out ).group(1))+">"
1007 +            if reTime.match( cmd_out ):
1008 +                time = reTime.search( line ).group(1)
1009 +                if time < minTimeLeftServer:
1010 +                    renewProxy = 1
1011 +                    common.logger.message('No credential delegation will expire in '+time+' hours: renew it')
1012 +                pass
1013 +            pass
1014 +        
1015 +        # if not, create one.
1016 +        if renewProxy:
1017 +            cmd = 'myproxy-init -d -n -s '+self.proxyServer
1018 +            out = os.system(cmd)
1019 +            if (out>0):
1020 +                raise CrabException("Unable to delegate the proxy to myproxyserver "+self.proxyServer+" !\n")
1021 +            pass
1022 +
1023 +        # cache proxy validity
1024          self.proxyValid=1
1025          return
1026 <    
1026 >
1027      def configOpt_(self):
1028          edg_ui_cfg_opt = ' '
1029          if self.edg_config:
1030 <          edg_ui_cfg_opt = ' -c ' + self.edg_config + ' '
1030 >            edg_ui_cfg_opt = ' -c ' + self.edg_config + ' '
1031          if self.edg_config_vo:
1032 <          edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' '
1032 >            edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' '
1033          return edg_ui_cfg_opt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines