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.62 by slacapra, Tue Jun 20 15:37:51 2006 UTC vs.
Revision 1.90 by slacapra, Fri Oct 6 15:50:17 2006 UTC

# Line 37 | Line 37 | class SchedulerEdg(Scheduler):
37              self.proxyServer = 'myproxy.cern.ch'
38          common.logger.debug(5,'Setting myproxy server to '+self.proxyServer)
39  
40 +        try:
41 +            self.role = cfg_params["EDG.role"]
42 +        except KeyError:
43 +            self.role = None
44 +            
45          try: self.LCG_version = cfg_params["EDG.lcg_version"]
46          except KeyError: self.LCG_version = '2'
47  
# Line 63 | Line 68 | class SchedulerEdg(Scheduler):
68          try: self.return_data = cfg_params['USER.return_data']
69          except KeyError: self.return_data = 1
70  
66        try:
67             self.copy_input_data = common.analisys_common_info['copy_input_data']
68             #print "self.copy_input_data = ", self.copy_input_data
69        except KeyError: self.copy_input_data = 0
70
71          try:
72              self.copy_data = cfg_params["USER.copy_data"]
73              if int(self.copy_data) == 1:
# Line 158 | Line 158 | class SchedulerEdg(Scheduler):
158          except:
159              self._taskId = ''
160  
161 +        try: self.jobtypeName = cfg_params['CRAB.jobtype']
162 +        except KeyError: self.jobtypeName = ''
163 +
164 +        try: self.schedulerName = cfg_params['CRAB.scheduler']
165 +        except KeyError: self.scheduler = ''
166 +
167          return
168      
169  
170      def sched_parameter(self):
171          """
172 <        Returns file with scheduler-specific parameters
172 >        Returns file with requirements and scheduler-specific parameters
173          """
174 <      
175 <        if (self.edg_config and self.edg_config_vo != ''):
176 <            self.param='sched_param.clad'
174 >        index = int(common.jobDB.nJobs()) - 1
175 >        job = common.job_list[index]
176 >        jbt = job.type()
177 >        
178 >        lastDest=''
179 >        first = []
180 >        last  = []
181 >        for n in range(common.jobDB.nJobs()):
182 >            currDest=common.jobDB.destination(n)
183 >            if (currDest!=lastDest):
184 >                lastDest = currDest
185 >                first.append(n)
186 >                if n != 0:last.append(n-1)
187 >        if len(first)>len(last) :last.append(common.jobDB.nJobs())
188 >  
189 >        req = ''
190 >        req = req + jbt.getRequirements()
191 >    
192 >        if self.EDG_requirements:
193 >            if (req == ' '):
194 >                req = req + self.EDG_requirements
195 >            else:
196 >                req = req +  ' && ' + self.EDG_requirements
197 >        if self.EDG_ce_white_list:
198 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
199 >            for i in range(len(ce_white_list)):
200 >                if i == 0:
201 >                    if (req == ' '):
202 >                        req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
203 >                    else:
204 >                        req = req +  ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
205 >                    pass
206 >                else:
207 >                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
208 >            req = req + ')'
209 >        
210 >        if self.EDG_ce_black_list:
211 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
212 >            for ce in ce_black_list:
213 >                if (req == ' '):
214 >                    req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
215 >                else:
216 >                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
217 >                pass
218 >        if self.EDG_clock_time:
219 >            if (req == ' '):
220 >                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
221 >            else:
222 >                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
223 >
224 >        if self.EDG_cpu_time:
225 >            if (req == ' '):
226 >                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
227 >            else:
228 >                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
229 >                
230 >        for i in range(len(first)): # Add loop DS
231 >            self.param='sched_param_'+str(i)+'.clad'
232              param_file = open(common.work_space.shareDir()+'/'+self.param, 'w')
233 <            param_file.write('RBconfig = "'+self.edg_config+'";\n')  
234 <            param_file.write('RBconfigVO = "'+self.edg_config_vo+'";')
233 >
234 >            itr4=self.findSites_(first[i])
235 >            if (itr4 != []):
236 >                req1=''  
237 >                for arg in itr4:
238 >                    req1 = req + ' && anyMatch(other.storage.CloseSEs, ('+str(arg)+'))'
239 >            param_file.write('Requirements = '+req1 +';\n')  
240 >  
241 >            if (self.edg_config and self.edg_config_vo != ''):
242 >                param_file.write('RBconfig = "'+self.edg_config+'";\n')  
243 >                param_file.write('RBconfigVO = "'+self.edg_config_vo+'";')
244 >
245              param_file.close()  
246 <            return 1
176 <        else:
177 <            return 0
246 >
247  
248      def wsSetupEnvironment(self):
249          """
250          Returns part of a job script which does scheduler-specific work.
251          """
252          txt = ''
253 +        txt += '# strip arguments\n'
254 +        txt += 'echo "strip arguments"\n'
255 +        txt += 'args=("$@")\n'
256 +        txt += 'nargs=$#\n'
257 +        txt += 'shift $nargs\n'
258          txt += "# job number (first parameter for job wrapper)\n"
259 <        txt += "NJob=$1\n"
259 >        #txt += "NJob=$1\n"
260 >        txt += "NJob=${args[0]}\n"
261  
262          txt += '# job identification to DashBoard \n'
263 <        txt += 'echo "MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`" | tee -a $RUNTIME_AREA/$repo \n'
264 <        txt += 'echo "SyncGridJobId=`echo $EDG_WL_JOBID`" | tee -a $RUNTIME_AREA/$repo \n'
265 <        txt += 'echo "MonitorID=`echo ' + self._taskId + '`" | tee -a $RUNTIME_AREA/$repo\n'
263 >        txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n'
264 >        txt += 'SyncGridJobId=`echo $EDG_WL_JOBID`\n'
265 >        txt += 'MonitorID=`echo ' + self._taskId + '`\n'
266 >        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
267 >        txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
268 >        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
269  
270          txt += 'echo "middleware discovery " \n'
271 <        txt += 'if [ $VO_CMS_SW_DIR ]; then \n'
194 <        txt += '    middleware=LCG \n'
195 <        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
196 <        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
197 <        txt += '    echo "middleware =$middleware" \n'
198 <        txt += 'elif [ $GRID3_APP_DIR ]; then\n'
271 >        txt += 'if [ $GRID3_APP_DIR ]; then\n'
272          txt += '    middleware=OSG \n'
273          txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
274          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
# Line 205 | Line 278 | class SchedulerEdg(Scheduler):
278          txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
279          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
280          txt += '    echo "middleware =$middleware" \n'
281 +        txt += 'elif [ $VO_CMS_SW_DIR ]; then \n'
282 +        txt += '    middleware=LCG \n'
283 +        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
284 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
285 +        txt += '    echo "middleware =$middleware" \n'
286          txt += 'else \n'
287          txt += '    echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
288          txt += '    echo "JOB_EXIT_STATUS = 10030" \n'
289          txt += '    echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n'
290          txt += '    dumpStatus $RUNTIME_AREA/$repo \n'
291 +        txt += '    rm -f $RUNTIME_AREA/$repo \n'
292 +        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
293 +        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
294          txt += '    exit 1 \n'
295          txt += 'fi \n'
296  
297          txt += '# report first time to DashBoard \n'
298          txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
299 <
299 >        txt += 'rm -f $RUNTIME_AREA/$repo \n'
300 >        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
301 >        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
302 >        
303          txt += '\n\n'
304  
305          if int(self.copy_data) == 1:
# Line 228 | Line 312 | class SchedulerEdg(Scheduler):
312                txt += 'echo "SE_PATH = $SE_PATH"\n'
313  
314          txt += 'export VO='+self.VO+'\n'
315 <        ### FEDE: add some line for LFC catalog setting
315 >        ### add some line for LFC catalog setting
316          txt += 'if [ $middleware == LCG ]; then \n'
317          txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
318          txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
# Line 281 | Line 365 | class SchedulerEdg(Scheduler):
365          txt += '        echo "JOB_EXIT_STATUS = 10099" \n'
366          txt += '        echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n'
367          txt += '        dumpStatus $RUNTIME_AREA/$repo \n'
368 +        txt += '        rm -f $RUNTIME_AREA/$repo \n'
369 +        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
370 +        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
371          txt += '        exit 1 \n'
372          txt += '    fi \n'
373          txt += 'fi \n'
# Line 292 | Line 379 | class SchedulerEdg(Scheduler):
379          Copy input data from SE to WN    
380          """
381          txt = ''
382 <        try:
296 <            self.copy_input_data = common.analisys_common_info['copy_input_data']
297 <            #print "self.copy_input_data = ", self.copy_input_data
298 <        except KeyError: self.copy_input_data = 0
299 <        if int(self.copy_input_data) == 1:
382 >
383          ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
384 <           txt += 'if [ $middleware == OSG ]; then\n'
385 <           txt += '   #\n'
386 <           txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
387 <           txt += '   #\n'
388 <           txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
389 <           txt += 'elif [ $middleware == LCG ]; then \n'
390 <           txt += '   #\n'
391 <           txt += '   #   Copy Input Data from SE to this WN\n'
392 <           txt += '   #\n'
393 < ### changed by georgia (put a loop copying more than one input files per jobs)          
394 <           txt += '   for input_file in $cur_file_list \n'
395 <           txt += '   do \n'
396 <           txt += '    lcg-cp --vo $VO lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
397 <           txt += '    copy_input_exit_status=$?\n'
398 <           txt += '    echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
399 <           txt += '    if [ $copy_input_exit_status -ne 0 ]; then \n'
400 <           txt += '       echo "Problems with copying to WN" \n'
401 <           txt += '    else \n'
402 <           txt += '       echo "input copied into WN" \n'
403 <           txt += '    fi \n'
404 <           txt += '   done \n'
405 < ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
406 <           txt += '   for file in $cur_pu_list \n'
407 <           txt += '   do \n'
408 <           txt += '    lcg-cp --vo $VO lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
409 <           txt += '    copy_input_exit_status=$?\n'
410 <           txt += '    echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
411 <           txt += '    if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
412 <           txt += '       echo "Problems with copying pu to WN" \n'
413 <           txt += '    else \n'
414 <           txt += '       echo "input pu files copied into WN" \n'
415 <           txt += '    fi \n'
416 <           txt += '   done \n'
417 <           txt += '   \n'
418 <           txt += '   ### Check SCRATCH space available on WN : \n'
419 <           txt += '   df -h \n'
420 <           txt += 'fi \n'
384 >        txt += 'if [ $middleware == OSG ]; then\n'
385 >        txt += '   #\n'
386 >        txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
387 >        txt += '   #\n'
388 >        txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
389 >        txt += 'elif [ $middleware == LCG ]; then \n'
390 >        txt += '   #\n'
391 >        txt += '   #   Copy Input Data from SE to this WN\n'
392 >        txt += '   #\n'
393 >        ### changed by georgia (put a loop copying more than one input files per jobs)          
394 >        txt += '   for input_file in $cur_file_list \n'
395 >        txt += '   do \n'
396 >        txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
397 >        txt += '      copy_input_exit_status=$?\n'
398 >        txt += '      echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
399 >        txt += '      if [ $copy_input_exit_status -ne 0 ]; then \n'
400 >        txt += '         echo "Problems with copying to WN" \n'
401 >        txt += '      else \n'
402 >        txt += '         echo "input copied into WN" \n'
403 >        txt += '      fi \n'
404 >        txt += '   done \n'
405 >        ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
406 >        txt += '   for file in $cur_pu_list \n'
407 >        txt += '   do \n'
408 >        txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
409 >        txt += '      copy_input_pu_exit_status=$?\n'
410 >        txt += '      echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
411 >        txt += '      if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
412 >        txt += '         echo "Problems with copying pu to WN" \n'
413 >        txt += '      else \n'
414 >        txt += '         echo "input pu files copied into WN" \n'
415 >        txt += '      fi \n'
416 >        txt += '   done \n'
417 >        txt += '   \n'
418 >        txt += '   ### Check SCRATCH space available on WN : \n'
419 >        txt += '   df -h \n'
420 >        txt += 'fi \n'
421            
422          return txt
423  
# Line 348 | Line 431 | class SchedulerEdg(Scheduler):
431             txt += '#\n'
432             txt += '#   Copy output to SE = $SE\n'
433             txt += '#\n'
434 <           txt += 'if [ $exe_result -eq 0 ]; then\n'
434 >           txt += '    if [ $middleware == OSG ]; then\n'
435 >           txt += '        echo "X509_USER_PROXY = $X509_USER_PROXY"\n'
436 >           txt += '        echo "source $OSG_APP/glite/setup_glite_ui.sh"\n'
437 >           txt += '        source $OSG_APP/glite/setup_glite_ui.sh\n'
438 >           txt += '        export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n'
439 >           txt += '        echo "export X509_CERT_DIR=$X509_CERT_DIR"\n'
440 >           txt += '    fi \n'
441             txt += '    for out_file in $file_list ; do\n'
442 <           txt += '        echo "Trying to copy output file to $SE "\n'
443 <           ## OLI_Daniele globus-* for OSG, lcg-* for LCG
444 <           txt += '        if [ $middleware == OSG ]; then\n'
445 <           txt += '           echo "globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
446 <           txt += '           copy_exit_status=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
447 <           #txt += '           exitstring=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
448 <           txt += '        elif [ $middleware == LCG ]; then \n'
449 <           txt += '           echo "lcg-cp --vo cms -t 1200 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
450 <           txt += '           copy_exit_status=`lcg-cp --vo cms -t 1200 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
362 <           #txt += '           exitstring=`lcg-cp --vo cms -t 30 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
363 <           txt += '        fi \n'
364 <           #txt += '        copy_exit_status=$?\n'
365 <           txt += '        echo "COPY_EXIT_STATUS = $copy_exit_status"\n'
442 >           txt += '        echo "Trying to copy output file to $SE using lcg-cp"\n'
443 >           if common.logger.debugLevel() >= 5:
444 >               txt += '        echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
445 >               txt += '        exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
446 >           else:
447 >               txt += '        echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
448 >               txt += '        exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
449 >           txt += '        copy_exit_status=$?\n'
450 >           txt += '        echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
451             txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
452             txt += '        if [ $copy_exit_status -ne 0 ]; then\n'
453 <           txt += '            echo "Problems with SE = $SE"\n'
453 >           txt += '            echo "Possible problem with SE = $SE"\n'
454             txt += '            echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
455             txt += '            echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
456 +           txt += '            echo "lcg-cp failed.  For verbose lcg-cp output, use command line option -debug 5."\n'
457 +           txt += '            echo "lcg-cp failed, attempting srmcp"\n'
458 +           txt += '            echo "mkdir -p $HOME/.srmconfig"\n'
459 +           txt += '            mkdir -p $HOME/.srmconfig\n'
460 +           txt += '            if [ $middleware == LCG ]; then\n'
461 +           txt += '               echo "srmcp -retry_num 5 -retry_timeout 480000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
462 +           txt += '               exitstring=`srmcp -retry_num 5 -retry_timeout 480000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
463 +           txt += '            elif [ $middleware == OSG ]; then\n'
464 +           txt += '               echo "srmcp -retry_num 5 -retry_timeout 240000 -x509_user_trusted_certificates $OSG_APP/glite/etc/grid-security/certificates file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
465 +           txt += '               exitstring=`srmcp -retry_num 5 -retry_timeout 240000 -x509_user_trusted_certificates $OSG_APP/glite/etc/grid-security/certificates file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
466 +           txt += '            fi \n'
467 +           txt += '            copy_exit_status=$?\n'
468 +           txt += '            echo "COPY_EXIT_STATUS for srm = $copy_exit_status"\n'
469 +           txt += '            echo "STAGE_OUT = $copy_exit_status"\n'
470 +           txt += '            if [ $copy_exit_status -ne 0 ]; then\n'
471 +           txt += '               echo "Problems with SE = $SE"\n'
472 +           txt += '               echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
473 +           txt += '               echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
474 +           txt += '               echo "lcg-cp and srm failed"\n'
475 +           txt += '               echo "If storage_path in your config file contains a ? you may need a \? instead."\n'
476 +           txt += '            else\n'
477 +           txt += '               echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
478 +           txt += '               echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
479 +           txt += '               echo "output copied into $SE/$SE_PATH directory"\n'
480 +           txt += '               echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
481 +           txt += '               echo "srmcp succeeded"\n'
482 +           txt += '            fi\n'
483             txt += '        else\n'
484             txt += '            echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
485             txt += '            echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
486             txt += '            echo "output copied into $SE/$SE_PATH directory"\n'
487             txt += '            echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
488 +           txt += '            echo "lcg-cp succeeded"\n'
489             txt += '         fi\n'
490             txt += '     done\n'
378           txt += 'fi\n'
491          return txt
492  
493      def wsRegisterOutput(self):
# Line 395 | Line 507 | class SchedulerEdg(Scheduler):
507             txt += '#\n'
508             txt += '#  Register output to LFC\n'
509             txt += '#\n'
510 <           txt += '   if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
510 >           txt += '   if [ $copy_exit_status -eq 0 ]; then\n'
511             txt += '      for out_file in $file_list ; do\n'
512             txt += '         echo "Trying to register the output file into LFC"\n'
513 <           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n'
514 <           txt += '         lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n'
513 >           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n'
514 >           txt += '         lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n'
515             txt += '         register_exit_status=$?\n'
516             txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
517             txt += '         echo "STAGE_OUT = $register_exit_status"\n'
518             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
519             txt += '            echo "Problems with the registration to LFC" \n'
520             txt += '            echo "Try with srm protocol" \n'
521 <           txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n'
522 <           txt += '            lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n'
521 >           txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n'
522 >           txt += '            lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n'
523             txt += '            register_exit_status=$?\n'
524             txt += '            echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
525             txt += '            echo "STAGE_OUT = $register_exit_status"\n'
# Line 419 | Line 531 | class SchedulerEdg(Scheduler):
531             txt += '         fi \n'
532             txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
533             txt += '      done\n'
534 <           txt += '   elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
534 >           txt += '   else \n'
535             txt += '      echo "Trying to copy output file to CloseSE"\n'
536             txt += '      CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
537             txt += '      for out_file in $file_list ; do\n'
538 <           txt += '         echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n'
539 <           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'
538 >           txt += '         echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://$RUNTIME_AREA/$out_file 2>&1" \n'
539 >           txt += '         lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://$RUNTIME_AREA/$out_file 2>&1 \n'
540             txt += '         register_exit_status=$?\n'
541             txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
542             txt += '         echo "STAGE_OUT = $register_exit_status"\n'
543             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
544 <           txt += '            echo "Problems with CloseSE" \n'
544 >           txt += '            echo "Problems with CloseSE or Catalog" \n'
545             txt += '         else \n'
546             txt += '            echo "The program was successfully executed"\n'
547             txt += '            echo "SE = $CLOSE_SE"\n'
# Line 437 | Line 549 | class SchedulerEdg(Scheduler):
549             txt += '         fi \n'
550             txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
551             txt += '      done\n'
440           txt += '   else\n'
441           txt += '      echo "Problem with the executable"\n'
552             txt += '   fi \n'
553 +           txt += '   exit_status=$register_exit_status\n'
554             txt += 'fi \n'
555          return txt
556  
# Line 453 | Line 564 | class SchedulerEdg(Scheduler):
564          cmd_out = runCommand(cmd)
565          return cmd_out
566  
456    def listMatch(self, nj):
457        """
458        Check the compatibility of available resources
459        """
460        self.checkProxy()
461        jdl = common.job_list[nj].jdlFilename()
462        cmd = 'edg-job-list-match ' + self.configOpt_() + jdl
463        cmd_out = runCommand(cmd,0,10)
464        if not cmd_out:
465            raise CrabException("ERROR: "+cmd+" failed!")
466
467        return self.parseListMatch_(cmd_out, jdl)
468
469    def parseListMatch_(self, out, jdl):
470        """
471        Parse the f* output of edg-list-match and produce something sensible
472        """
473        reComment = re.compile( r'^\**$' )
474        reEmptyLine = re.compile( r'^$' )
475        reVO = re.compile( r'Selected Virtual Organisation name.*' )
476        reLine = re.compile( r'.*')
477        reCE = re.compile( r'(.*:.*)')
478        reCEId = re.compile( r'CEId.*')
479        reNO = re.compile( r'No Computing Element matching' )
480        reRB = re.compile( r'Connecting to host' )
481        next = 0
482        CEs=[]
483        Match=0
484
485        #print out
486        lines = reLine.findall(out)
487
488        i=0
489        CEs=[]
490        for line in lines:
491            string.strip(line)
492            #print line
493            if reNO.match( line ):
494                common.logger.debug(5,line)
495                return 0
496                pass
497            if reVO.match( line ):
498                VO =reVO.match( line ).group()
499                common.logger.debug(5,"VO "+VO)
500                pass
501
502            if reRB.match( line ):
503                RB = reRB.match(line).group()
504                common.logger.debug(5,"RB "+RB)
505                pass
506
507            if reCEId.search( line ):
508                for lineCE in lines[i:-1]:
509                    if reCE.match( lineCE ):
510                        CE = string.strip(reCE.search(lineCE).group(1))
511                        CEs.append(CE.split(':')[0])
512                        pass
513                    pass
514                pass
515            i=i+1
516            pass
517
518        common.logger.debug(5,"All CE :"+str(CEs))
519
520        sites = []
521        [sites.append(it) for it in CEs if not sites.count(it)]
522
523        common.logger.debug(5,"All Sites :"+str(sites))
524        common.logger.message("Matched Sites :"+str(sites))
525        return len(sites)
526
527    def noMatchFound_(self, jdl):
528        reReq = re.compile( r'Requirements' )
529        reString = re.compile( r'"\S*"' )
530        f = file(jdl,'r')
531        for line in f.readlines():
532            line= line.strip()
533            if reReq.match(line):
534                for req in reString.findall(line):
535                    if re.search("VO",req):
536                        common.logger.message( "SW required: "+req)
537                        continue
538                    if re.search('"\d+',req):
539                        common.logger.message("Other req  : "+req)
540                        continue
541                    common.logger.message( "CE required: "+req)
542                break
543            pass
544        raise CrabException("No compatible resources found!")
545
546    def submit(self, nj):
547        """
548        Submit one EDG job.
549        """
550
551        self.checkProxy()
552        jid = None
553        jdl = common.job_list[nj].jdlFilename()
554
555        cmd = 'edg-job-submit ' + self.configOpt_() + jdl
556        cmd_out = runCommand(cmd)
557        if cmd_out != None:
558            reSid = re.compile( r'https.+' )
559            jid = reSid.search(cmd_out).group()
560            pass
561        return jid
562
563    def resubmit(self, nj_list):
564        """
565        Prepare jobs to be submit
566        """
567        return
568
567      def getExitStatus(self, id):
568          return self.getStatusAttribute_(id, 'exit_code')
569  
# Line 597 | Line 595 | class SchedulerEdg(Scheduler):
595              for i in range(len(self.states)):
596                  # Fill an hash table with all information retrieved from LB API
597                  hstates[ self.states[i] ] = jobStat.loadStatus(st)[i]
598 <            result = jobStat.loadStatus(st)[ self.states.index(attr) ]
598 >            result = jobStat.loadStatus(st)[self.states.index(attr)]
599              return result
600  
601      def queryDetailedStatus(self, id):
# Line 606 | Line 604 | class SchedulerEdg(Scheduler):
604          cmd_out = runCommand(cmd)
605          return cmd_out
606  
607 <    def getOutput(self, id):
607 >    ##### FEDE ######        
608 >    def findSites_(self, n):
609 >        itr4 =[]
610 >        sites = common.jobDB.destination(n)
611 >        if len(sites)>0 and sites[0]=="Any":
612 >            return itr4
613 >        itr = ''
614 >        if sites != [""]:#CarlosDaniele
615 >            for site in sites:
616 >                #itr = itr + 'target.GlueSEUniqueID==&quot;'+site+'&quot; || '
617 >                itr = itr + 'target.GlueSEUniqueID=="'+site+'" || '
618 >            itr = itr[0:-4]
619 >            itr4.append( itr )
620 >        return itr4
621 >
622 >    def createXMLSchScript(self, nj, argsList):
623 >   # def createXMLSchScript(self, nj):
624 >      
625 >        """
626 >        Create a XML-file for BOSS4.
627 >        """
628 >  #      job = common.job_list[nj]
629          """
630 <        Get output for a finished job with id.
631 <        Returns the name of directory with results.
630 >        INDY
631 >        [begin] FIX-ME:
632 >        I would pass jobType instead of job
633 >        """
634 >        index = nj - 1
635 >        job = common.job_list[index]
636 >        jbt = job.type()
637 >        
638 >        inp_sandbox = jbt.inputSandbox(index)
639 >        out_sandbox = jbt.outputSandbox(index)
640 >        """
641 >        [end] FIX-ME
642          """
643  
644 <        self.checkProxy()
645 <        cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() + ' ' + id
646 <        cmd_out = runCommand(cmd)
644 >        
645 >        title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n'
646 >        jt_string = ''
647 >        
648 >        xml_fname = str(self.jobtypeName)+'.xml'
649 >        xml = open(common.work_space.shareDir()+'/'+xml_fname, 'a')
650  
651 <        # Determine the output directory name
652 <        dir = common.work_space.resDir()
653 <        dir += os.environ['USER']
654 <        dir += '_' + os.path.basename(id)
655 <        return dir
651 >        #TaskName  
652 >        dir = string.split(common.work_space.topDir(), '/')
653 >        taskName = dir[len(dir)-2]
654 >  
655 >        to_writeReq = ''
656 >        to_write = ''
657  
658 <    def cancel(self, id):
659 <        """ Cancel the EDG job with id """
627 <        self.checkProxy()
628 <        cmd = 'edg-job-cancel --noint ' + id
629 <        cmd_out = runCommand(cmd)
630 <        return cmd_out
658 >        req=' '
659 >        req = req + jbt.getRequirements()
660  
632    def createSchScript(self, nj):
633        """
634        Create a JDL-file for EDG.
635        """
661  
662 <        job = common.job_list[nj]
663 <        jbt = job.type()
664 <        inp_sandbox = jbt.inputSandbox(nj)
665 <        out_sandbox = jbt.outputSandbox(nj)
666 <        inp_storage_subdir = ''
662 >        #sites = common.jobDB.destination(nj)
663 >        #if len(sites)>0 and sites[0]!="Any":
664 >        #    req = req + ' && anyMatch(other.storage.CloseSEs, (_ITR4_))'
665 >        #req = req    
666 >    
667 >        if self.EDG_requirements:
668 >            if (req == ' '):
669 >                req = req + self.EDG_requirements
670 >            else:
671 >                req = req +  ' && ' + self.EDG_requirements
672 >        if self.EDG_ce_white_list:
673 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
674 >            for i in range(len(ce_white_list)):
675 >                if i == 0:
676 >                    if (req == ' '):
677 >                        req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
678 >                    else:
679 >                        req = req +  ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
680 >                    pass
681 >                else:
682 >                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
683 >            req = req + ')'
684          
685 <        title = '# This JDL was generated by '+\
686 <                common.prog_name+' (version '+common.prog_version_str+')\n'
687 <        jt_string = ''
685 >        if self.EDG_ce_black_list:
686 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
687 >            for ce in ce_black_list:
688 >                if (req == ' '):
689 >                    req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
690 >                else:
691 >                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
692 >                pass
693 >        if self.EDG_clock_time:
694 >            if (req == ' '):
695 >                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
696 >            else:
697 >                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
698 >
699 >        if self.EDG_cpu_time:
700 >            if (req == ' '):
701 >                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
702 >            else:
703 >                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
704 >                                                                                          
705 >        if ( self.EDG_retry_count ):              
706 >            to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n'
707 >            pass
708  
709 +        to_write = to_write + 'MyProxyServer = "&quot;' + self.proxyServer + '&quot;"\n'
710 +        to_write = to_write + 'VirtualOrganisation = "&quot;' + self.VO + '&quot;"\n'
711  
712 +                #TaskName  
713 +        dir = string.split(common.work_space.topDir(), '/')
714 +        taskName = dir[len(dir)-2]
715 +
716 +        xml.write(str(title))
717 +        xml.write('<task name="' +str(taskName)+'">\n')
718 +        xml.write(jt_string)
719          
720 <        SPL = inp_storage_subdir
721 <        if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/'
720 >        if (to_write != ''):
721 >            xml.write('<extraTags\n')
722 >            xml.write(to_write)
723 >            xml.write('/>\n')
724 >            pass
725  
726 <        jdl_fname = job.jdlFilename()
727 <        jdl = open(jdl_fname, 'w')
728 <        jdl.write(title)
726 >        xml.write('<iterator>\n')
727 >        xml.write('\t<iteratorRule name="ITR1">\n')
728 >        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ' </ruleElement>\n')
729 >        xml.write('\t</iteratorRule>\n')
730 >        xml.write('\t<iteratorRule name="ITR2">\n')
731 >        for arg in argsList:
732 >            xml.write('\t\t<ruleElement> <![CDATA[\n'+ arg + '\n\t\t]]> </ruleElement>\n')
733 >            pass
734 >        xml.write('\t</iteratorRule>\n')
735 >        #print jobList
736 >        xml.write('\t<iteratorRule name="ITR3">\n')
737 >        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ':1:6 </ruleElement>\n')
738 >        xml.write('\t</iteratorRule>\n')
739 >
740 >        '''
741 >        indy: here itr4
742 >        '''
743 >        
744  
745 <        script = job.scriptFilename()
746 <        jdl.write('Executable = "' + os.path.basename(script) +'";\n')
658 <        jdl.write(jt_string)
745 >        xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n')
746 >        xml.write(jt_string)
747  
748 <        ### only one .sh  JDL has arguments:
748 >        #executable
749  
750 +        """
751 +        INDY
752 +        script depends on jobType: it should be probably get in a different way
753 +        """        
754 +        script = job.scriptFilename()
755 +        xml.write('<program>\n')
756 +        xml.write('<exec> ' + os.path.basename(script) +' </exec>\n')
757 +        xml.write(jt_string)
758 +    
759 +          
760 +        ### only one .sh  JDL has arguments:
761          ### Fabio
762 <        jdl.write('Arguments = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'";\n')
763 <        inp_box = 'InputSandbox = { '
764 <        inp_box = inp_box + '"' + script + '",'
762 > #        xml.write('args = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'"\n')
763 >        xml.write('<args> <![CDATA[\n _ITR2_ \n]]> </args>\n')
764 >        xml.write('<program_types> crabjob </program_types>\n')
765 >        inp_box = script + ','
766  
767          if inp_sandbox != None:
768              for fl in inp_sandbox:
769 <                inp_box = inp_box + ' "' + fl + '",'
769 >                inp_box = inp_box + '' + fl + ','
770                  pass
771              pass
772  
773 <        #if common.use_jam:
774 <        #   inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",'
775 <
776 <        # Marco (VERY TEMPORARY ML STUFF)
777 <        inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\
678 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + '", "'+\
679 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\
680 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\
681 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"'
682 <        # End Marco
773 >        inp_box = inp_box + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + ',' +\
774 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + ','+\
775 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + ','+\
776 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + ','+\
777 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py')
778  
779          if (not jbt.additional_inbox_files == []):
780 <            inp_box = inp_box + ', '
780 >            inp_box = inp_box + ','
781              for addFile in jbt.additional_inbox_files:
782                  addFile = os.path.abspath(addFile)
783 <                inp_box = inp_box+' "'+addFile+'",'
783 >                inp_box = inp_box+''+addFile+','
784                  pass
785  
786          if inp_box[-1] == ',' : inp_box = inp_box[:-1]
787 <        inp_box = inp_box + ' };\n'
788 <        jdl.write(inp_box)
694 <
695 <        jdl.write('StdOutput     = "' + job.stdout() + '";\n')
696 <        jdl.write('StdError      = "' + job.stderr() + '";\n')
787 >        inp_box = '<infiles> <![CDATA[\n' + inp_box + '\n]]> </infiles>\n'
788 >        xml.write(inp_box)
789          
790 +        base = jbt.name()
791 +        stdout = base + '__ITR3_.stdout'
792 +        stderr = base + '__ITR3_.stderr'
793 +        
794 +        xml.write('<stderr> ' + stderr + '</stderr>\n')
795 +        xml.write('<stdout> ' + stdout + '</stdout>\n')
796          
699        if job.stdout() == job.stderr():
700          out_box = 'OutputSandbox = { "' + \
701                    job.stdout() + '", ".BrokerInfo",'
702        else:
703          out_box = 'OutputSandbox = { "' + \
704                    job.stdout() + '", "' + \
705                    job.stderr() + '", ".BrokerInfo",'
797  
798 +        out_box = stdout + ',' + \
799 +                  stderr + ',.BrokerInfo,'
800 +
801 +        """
802          if int(self.return_data) == 1:
803              if out_sandbox != None:
804                  for fl in out_sandbox:
805 <                    out_box = out_box + ' "' + fl + '",'
805 >                    out_box = out_box + '' + fl + ','
806                      pass
807                  pass
808              pass
809 <                                                                                                                                                            
715 <        if out_box[-1] == ',' : out_box = out_box[:-1]
716 <        out_box = out_box + ' };'
717 <        jdl.write(out_box+'\n')
718 <
809 >        """
810  
811 <        req='Requirements = '
812 <        noreq=req
813 <        req = req + jbt.getRequirements()
814 <        #### and USER REQUIREMENT
815 <        if self.EDG_requirements:
816 <            if (req != noreq):
817 <                req = req +  ' && '
727 <            req = req + self.EDG_requirements
728 <        #### FEDE #####
729 <        if self.EDG_ce_white_list:
730 <            ce_white_list = string.split(self.EDG_ce_white_list,',')
731 <            #print "req = ", req
732 <            for i in range(len(ce_white_list)):
733 <                if i == 0:
734 <                    if (req != noreq):
735 <                        req = req +  ' && '
736 <                    req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
737 <                    pass
738 <                else:
739 <                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
740 <            req = req + ')'
741 <        
742 <        if self.EDG_ce_black_list:
743 <            ce_black_list = string.split(self.EDG_ce_black_list,',')
744 <            for ce in ce_black_list:
745 <                if (req != noreq):
746 <                    req = req +  ' && '
747 <                req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
811 >        """
812 >        INDY
813 >        something similar should be also done for infiles (if it makes sense!)
814 >        """
815 >        if int(self.return_data) == 1:
816 >            for fl in jbt.output_file:
817 >                out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ','
818                  pass
819 +            pass
820  
821 <        ###############
822 <        clockTime=480
823 <        if self.EDG_clock_time:
824 <            clockTime= self.EDG_clock_time
825 <        if (req != noreq):
755 <            req = req + ' && '
756 <        req = req + '((other.GlueCEPolicyMaxWallClockTime == 0) || (other.GlueCEPolicyMaxWallClockTime>='+str(clockTime)+'))'
821 >        if out_box[-1] == ',' : out_box = out_box[:-1]
822 >        out_box = '<outfiles> <![CDATA[\n' + out_box + '\n]]></outfiles>\n'
823 >        xml.write(out_box)
824 >
825 >        xml.write('<BossAttr> crabjob.INTERNAL_ID=_ITR1_ </BossAttr>\n')
826  
827 <        cpuTime=1000
828 <        if self.EDG_cpu_time:
760 <            cpuTime=self.EDG_cpu_time
761 <        if (req != noreq):
762 <            req = req + ' && '
763 <        req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))'
764 <
765 <        if (req != noreq):
766 <            req = req + ';\n'
767 <            jdl.write(req)
768 <                                                                                                                                                            
769 <        jdl.write('VirtualOrganisation = "' + self.VO + '";\n')
827 >        xml.write('</program>\n')
828 >        xml.write('</chain>\n')
829  
830 <        if ( self.EDG_retry_count ):              
831 <            jdl.write('RetryCount = '+self.EDG_retry_count+';\n')
773 <            pass
830 >        xml.write('</iterator>\n')
831 >        xml.write('</task>\n')
832  
833 <        jdl.write('MyProxyServer = "' + self.proxyServer + '";\n')
833 >        xml.close()
834 >      
835  
777        jdl.close()
836          return
837  
838      def checkProxy(self):
# Line 787 | Line 845 | class SchedulerEdg(Scheduler):
845  
846          minTimeLeftServer = 100 # in hours
847  
790        #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
791        #cmd = 'voms-proxy-info -timeleft'
848          mustRenew = 0
849 <        timeLeftLocal = runCommand('voms-proxy-info -timeleft')
849 >        timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null')
850          timeLeftServer = -999
851          if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal):
852              mustRenew = 1
853          else:
854 <            timeLeftServer = runCommand('voms-proxy-info -actimeleft | head -1')
854 >            timeLeftServer = runCommand('voms-proxy-info -actimeleft 2>/dev/null | head -1')
855              if not timeLeftServer or not isInt(timeLeftServer):
856                  mustRenew = 1
857              elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft:
# Line 805 | Line 861 | class SchedulerEdg(Scheduler):
861  
862          if mustRenew:
863              common.logger.message( "No valid proxy found or remaining time of validity of already existing proxy shorter than 10 hours!\n Creating a user proxy with default length of 96h\n")
864 <            cmd = 'voms-proxy-init -voms cms -valid 96:00'
864 >            cmd = 'voms-proxy-init -voms '+self.VO+' -valid 96:00'
865 >            if self.role:
866 >                cmd = 'voms-proxy-init -voms '+self.VO+':/'+self.VO+'/role='+self.role+' -valid 96:00'
867              try:
868                  # SL as above: damn it!
869                  out = os.system(cmd)
# Line 813 | Line 871 | class SchedulerEdg(Scheduler):
871              except:
872                  msg = "Unable to create a valid proxy!\n"
873                  raise CrabException(msg)
816            # cmd = 'grid-proxy-info -timeleft'
817            # cmd_out = runCommand(cmd,0,20)
874              pass
875  
876          ## now I do have a voms proxy valid, and I check the myproxy server

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines