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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines