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.73.2.2 by fanzago, Wed Jul 19 10:53:40 2006 UTC vs.
Revision 1.85 by gutsche, Wed Sep 27 16:17:07 2006 UTC

# Line 21 | Line 21 | class SchedulerEdg(Scheduler):
21          return
22  
23      def configure(self, cfg_params):
24 <        # test branch 2
24 >
25          try:
26              RB = cfg_params["EDG.rb"]
27              edgConfig = EdgConfig(RB)
# 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 158 | Line 163 | class SchedulerEdg(Scheduler):
163          except:
164              self._taskId = ''
165  
166 +        try: self.jobtypeName = cfg_params['CRAB.jobtype']
167 +        except KeyError: self.jobtypeName = ''
168 +
169 +        try: self.schedulerName = cfg_params['CRAB.scheduler']
170 +        except KeyError: self.scheduler = ''
171 +
172          return
173      
174  
# Line 181 | Line 192 | class SchedulerEdg(Scheduler):
192          Returns part of a job script which does scheduler-specific work.
193          """
194          txt = ''
195 +        txt += '# strip arguments\n'
196 +        txt += 'echo "strip arguments"\n'
197 +        txt += 'args=("$@")\n'
198 +        txt += 'nargs=$#\n'
199 +        txt += 'shift $nargs\n'
200          txt += "# job number (first parameter for job wrapper)\n"
201 <        txt += "NJob=$1\n"
201 >        #txt += "NJob=$1\n"
202 >        txt += "NJob=${args[0]}\n"
203  
204          txt += '# job identification to DashBoard \n'
205          txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n'
# Line 193 | Line 210 | class SchedulerEdg(Scheduler):
210          txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
211  
212          txt += 'echo "middleware discovery " \n'
213 <        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'
213 >        txt += 'if [ $GRID3_APP_DIR ]; then\n'
214          txt += '    middleware=OSG \n'
215          txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
216          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
# Line 208 | Line 220 | class SchedulerEdg(Scheduler):
220          txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
221          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
222          txt += '    echo "middleware =$middleware" \n'
223 +        txt += 'elif [ $VO_CMS_SW_DIR ]; then \n'
224 +        txt += '    middleware=LCG \n'
225 +        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
226 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
227 +        txt += '    echo "middleware =$middleware" \n'
228          txt += 'else \n'
229          txt += '    echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
230          txt += '    echo "JOB_EXIT_STATUS = 10030" \n'
# Line 306 | Line 323 | class SchedulerEdg(Scheduler):
323          txt = ''
324          try:
325              self.copy_input_data = common.analisys_common_info['copy_input_data']
309            #print "self.copy_input_data = ", self.copy_input_data
326          except KeyError: self.copy_input_data = 0
327          if int(self.copy_input_data) == 1:
328          ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
# Line 319 | Line 335 | class SchedulerEdg(Scheduler):
335             txt += '   #\n'
336             txt += '   #   Copy Input Data from SE to this WN\n'
337             txt += '   #\n'
338 < ### changed by georgia (put a loop copying more than one input files per jobs)          
338 >           ### changed by georgia (put a loop copying more than one input files per jobs)          
339             txt += '   for input_file in $cur_file_list \n'
340             txt += '   do \n'
325           #### FEDE
326           #txt += '      echo "which lcg-cp" \n'
327           #txt += '      which lcg-cp \n'
328           #########
341             txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
342             txt += '      copy_input_exit_status=$?\n'
343             txt += '      echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
# Line 335 | Line 347 | class SchedulerEdg(Scheduler):
347             txt += '         echo "input copied into WN" \n'
348             txt += '      fi \n'
349             txt += '   done \n'
350 < ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
350 >           ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
351             txt += '   for file in $cur_pu_list \n'
352             txt += '   do \n'
341           #### FEDE
342           #txt += '      echo "which lcg-cp" \n'
343           #txt += '      which lcg-cp \n'
344           #########
353             txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
354             txt += '      copy_input_pu_exit_status=$?\n'
355             txt += '      echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
# Line 368 | Line 376 | class SchedulerEdg(Scheduler):
376             txt += '#\n'
377             txt += '#   Copy output to SE = $SE\n'
378             txt += '#\n'
371           #txt += 'if [ $exe_result -eq 0 ]; then\n'
379             txt += '    if [ $middleware == OSG ]; then\n'
380             txt += '        echo "X509_USER_PROXY = $X509_USER_PROXY"\n'
381             txt += '        echo "source $OSG_APP/glite/setup_glite_ui.sh"\n'
# Line 378 | Line 385 | class SchedulerEdg(Scheduler):
385             txt += '    fi \n'
386             txt += '    for out_file in $file_list ; do\n'
387             txt += '        echo "Trying to copy output file to $SE using lcg-cp"\n'
388 <           txt += '        echo "lcg-cp --vo $VO -t 1200 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
389 <           txt += '        exitstring=`lcg-cp --vo $VO -t 1200 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
388 >           if common.logger.debugLevel() >= 5:
389 >               txt += '        echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
390 >               txt += '        exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
391 >           else:
392 >               txt += '        echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
393 >               txt += '        exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
394             txt += '        copy_exit_status=$?\n'
395             txt += '        echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
396             txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
# Line 387 | Line 398 | class SchedulerEdg(Scheduler):
398             txt += '            echo "Possible problem with SE = $SE"\n'
399             txt += '            echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
400             txt += '            echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
401 +           txt += '            echo "lcg-cp failed.  For verbose lcg-cp output, use command line option -debug 5."\n'
402             txt += '            echo "lcg-cp failed, attempting srmcp"\n'
403             txt += '            echo "mkdir -p $HOME/.srmconfig"\n'
404             txt += '            mkdir -p $HOME/.srmconfig\n'
405             txt += '            if [ $middleware == LCG ]; then\n'
406 <           txt += '               echo "srmcp -retry_num 5 -retry_timeout 240000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
407 <           txt += '               exitstring=`srmcp -retry_num 5 -retry_timeout 240000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
406 >           txt += '               echo "srmcp -retry_num 5 -retry_timeout 480000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
407 >           txt += '               exitstring=`srmcp -retry_num 5 -retry_timeout 480000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
408             txt += '            elif [ $middleware == OSG ]; then\n'
409 <           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'
410 <           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'
409 >           txt += '               echo "srmcp -retry_num 5 -retry_timeout 240000 -x509_user_trusted_certificates $X509_CERT_DIR file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
410 >           txt += '               exitstring=`srmcp -retry_num 5 -retry_timeout 240000 -x509_user_trusted_certificates $X509_CERT_DIR file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
411             txt += '            fi \n'
412             txt += '            copy_exit_status=$?\n'
413             txt += '            echo "COPY_EXIT_STATUS for srm = $copy_exit_status"\n'
# Line 421 | Line 433 | class SchedulerEdg(Scheduler):
433             txt += '            echo "lcg-cp succeeded"\n'
434             txt += '         fi\n'
435             txt += '     done\n'
424           #txt += 'fi\n'
436          return txt
437  
438      def wsRegisterOutput(self):
# Line 441 | Line 452 | class SchedulerEdg(Scheduler):
452             txt += '#\n'
453             txt += '#  Register output to LFC\n'
454             txt += '#\n'
444           #txt += '   if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
455             txt += '   if [ $copy_exit_status -eq 0 ]; then\n'
456             txt += '      for out_file in $file_list ; do\n'
457             txt += '         echo "Trying to register the output file into LFC"\n'
448           #### FEDE
449           #txt += '         echo "which lcg-rf" \n'
450           #txt += '         which lcg-rf \n'
451           #########
458             txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n'
459             txt += '         lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n'
460             txt += '         register_exit_status=$?\n'
# Line 457 | Line 463 | class SchedulerEdg(Scheduler):
463             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
464             txt += '            echo "Problems with the registration to LFC" \n'
465             txt += '            echo "Try with srm protocol" \n'
460           #### FEDE
461           #txt += '            echo "which lcg-rf" \n'
462           #txt += '            which lcg-rf \n'
463           #########
466             txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n'
467             txt += '            lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n'
468             txt += '            register_exit_status=$?\n'
# Line 474 | Line 476 | class SchedulerEdg(Scheduler):
476             txt += '         fi \n'
477             txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
478             txt += '      done\n'
477           #txt += '   elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
479             txt += '   else \n'
480             txt += '      echo "Trying to copy output file to CloseSE"\n'
481             txt += '      CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
482             txt += '      for out_file in $file_list ; do\n'
482           #### FEDE
483           #txt += '         echo "which lcg-cr" \n'
484           #txt += '         which lcg-cr \n'
485           #########
483             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'
484             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'
485             txt += '         register_exit_status=$?\n'
# Line 497 | Line 494 | class SchedulerEdg(Scheduler):
494             txt += '         fi \n'
495             txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
496             txt += '      done\n'
500           #txt += '   else\n'
501           #txt += '      echo "Problem with the executable"\n'
497             txt += '   fi \n'
498             txt += '   exit_status=$register_exit_status\n'
499             txt += 'fi \n'
# Line 514 | Line 509 | class SchedulerEdg(Scheduler):
509          cmd_out = runCommand(cmd)
510          return cmd_out
511  
517    def listMatch(self, nj):
518        """
519        Check the compatibility of available resources
520        """
521        self.checkProxy()
522        jdl = common.job_list[nj].jdlFilename()
523        cmd = 'edg-job-list-match ' + self.configOpt_() + jdl
524        cmd_out = runCommand(cmd,0,10)
525        if not cmd_out:
526            raise CrabException("ERROR: "+cmd+" failed!")
527
528        return self.parseListMatch_(cmd_out, jdl)
529
530    def parseListMatch_(self, out, jdl):
531        """
532        Parse the f* output of edg-list-match and produce something sensible
533        """
534        reComment = re.compile( r'^\**$' )
535        reEmptyLine = re.compile( r'^$' )
536        reVO = re.compile( r'Selected Virtual Organisation name.*' )
537        reLine = re.compile( r'.*')
538        reCE = re.compile( r'(.*:.*)')
539        reCEId = re.compile( r'CEId.*')
540        reNO = re.compile( r'No Computing Element matching' )
541        reRB = re.compile( r'Connecting to host' )
542        next = 0
543        CEs=[]
544        Match=0
545
546        #print out
547        lines = reLine.findall(out)
548
549        i=0
550        CEs=[]
551        for line in lines:
552            string.strip(line)
553            #print line
554            if reNO.match( line ):
555                common.logger.debug(5,line)
556                return 0
557                pass
558            if reVO.match( line ):
559                VO =reVO.match( line ).group()
560                common.logger.debug(5,"VO "+VO)
561                pass
562
563            if reRB.match( line ):
564                RB = reRB.match(line).group()
565                common.logger.debug(5,"RB "+RB)
566                pass
567
568            if reCEId.search( line ):
569                for lineCE in lines[i:-1]:
570                    if reCE.match( lineCE ):
571                        CE = string.strip(reCE.search(lineCE).group(1))
572                        CEs.append(CE.split(':')[0])
573                        pass
574                    pass
575                pass
576            i=i+1
577            pass
578
579        common.logger.debug(5,"All CE :"+str(CEs))
580
581        sites = []
582        [sites.append(it) for it in CEs if not sites.count(it)]
583
584        common.logger.debug(5,"All Sites :"+str(sites))
585        common.logger.message("Matched Sites :"+str(sites))
586        return len(sites)
587
588    def noMatchFound_(self, jdl):
589        reReq = re.compile( r'Requirements' )
590        reString = re.compile( r'"\S*"' )
591        f = file(jdl,'r')
592        for line in f.readlines():
593            line= line.strip()
594            if reReq.match(line):
595                for req in reString.findall(line):
596                    if re.search("VO",req):
597                        common.logger.message( "SW required: "+req)
598                        continue
599                    if re.search('"\d+',req):
600                        common.logger.message("Other req  : "+req)
601                        continue
602                    common.logger.message( "CE required: "+req)
603                break
604            pass
605        raise CrabException("No compatible resources found!")
606
607    def submit(self, nj):
608        """
609        Submit one EDG job.
610        """
611
612        self.checkProxy()
613        jid = None
614        jdl = common.job_list[nj].jdlFilename()
615
616        cmd = 'edg-job-submit ' + self.configOpt_() + jdl
617        cmd_out = runCommand(cmd)
618        if cmd_out != None:
619            reSid = re.compile( r'https.+' )
620            jid = reSid.search(cmd_out).group()
621            pass
622        return jid
623
624    def resubmit(self, nj_list):
625        """
626        Prepare jobs to be submit
627        """
628        return
629
512      def getExitStatus(self, id):
513          return self.getStatusAttribute_(id, 'exit_code')
514  
# Line 658 | Line 540 | class SchedulerEdg(Scheduler):
540              for i in range(len(self.states)):
541                  # Fill an hash table with all information retrieved from LB API
542                  hstates[ self.states[i] ] = jobStat.loadStatus(st)[i]
543 <            result = jobStat.loadStatus(st)[ self.states.index(attr) ]
543 >            result = jobStat.loadStatus(st)[self.states.index(attr)]
544              return result
545  
546      def queryDetailedStatus(self, id):
# Line 667 | Line 549 | class SchedulerEdg(Scheduler):
549          cmd_out = runCommand(cmd)
550          return cmd_out
551  
552 <    def getOutput(self, id):
552 >    ##### FEDE ######        
553 >    def findSites_(self, n_tot_job):
554 >        itr4 = []
555 >       # print "n_tot_job = ", n_tot_job
556 >        for n in range(n_tot_job):
557 >            sites = common.jobDB.destination(n)
558 >            if len(sites)>0 and sites[0]=="Any": continue
559 >
560 >            #job = common.job_list[n]
561 >            #jbt = job.type()
562 >           # print "common.jobDB.destination(n) = ", common.jobDB.destination(n)
563 >           # print "sites = ", sites
564 >            itr = ''
565 >            if sites != [""]:#CarlosDaniele
566 >                for site in sites:
567 >                    #itr = itr + 'target.GlueSEUniqueID==&quot;'+site+'&quot; || '
568 >                    itr = itr + 'target.GlueSEUniqueID=="'+site+'" || '
569 >                    pass
570 >                # remove last ||
571 >                itr = itr[0:-4]
572 >                itr4.append( itr )
573 >        # remove last ,
574 >       # print "itr4 = ", itr4
575 >        return itr4
576 >
577 >    def createXMLSchScript(self, nj, argsList):
578 >   # def createXMLSchScript(self, nj):
579 >        """
580 >        Create a XML-file for BOSS4.
581 >        """
582 >  #      job = common.job_list[nj]
583 >        """
584 >        INDY
585 >        [begin] da rivedere:
586 >        in particolare passerei il jobType ed eliminerei le dipendenze da job
587 >        """
588 >        index = nj - 1
589 >        job = common.job_list[index]
590 >        jbt = job.type()
591 >        
592 >        inp_sandbox = jbt.inputSandbox(index)
593 >        out_sandbox = jbt.outputSandbox(index)
594          """
595 <        Get output for a finished job with id.
673 <        Returns the name of directory with results.
595 >        [end] da rivedere
596          """
597  
598 <        self.checkProxy()
599 <        cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() + ' ' + id
600 <        cmd_out = runCommand(cmd)
598 >        
599 >        title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n'
600 >        jt_string = ''
601 >        
602 >        xml_fname = str(self.jobtypeName)+'.xml'
603 >        xml = open(common.work_space.shareDir()+'/'+xml_fname, 'a')
604  
605 <        # Determine the output directory name
606 <        dir = common.work_space.resDir()
607 <        dir += os.environ['USER']
608 <        dir += '_' + os.path.basename(id)
609 <        return dir
605 >        #TaskName  
606 >        dir = string.split(common.work_space.topDir(), '/')
607 >        taskName = dir[len(dir)-2]
608 >  
609 >        to_writeReq = ''
610 >        to_write = ''
611  
612 <    def cancel(self, id):
613 <        """ Cancel the EDG job with id """
688 <        self.checkProxy()
689 <        cmd = 'edg-job-cancel --noint ' + id
690 <        cmd_out = runCommand(cmd)
691 <        return cmd_out
612 >        req=' '
613 >        req = req + jbt.getRequirements()
614  
693    def createSchScript(self, nj):
694        """
695        Create a JDL-file for EDG.
696        """
615  
616 <        job = common.job_list[nj]
617 <        jbt = job.type()
618 <        inp_sandbox = jbt.inputSandbox(nj)
619 <        out_sandbox = jbt.outputSandbox(nj)
620 <        inp_storage_subdir = ''
616 >        #sites = common.jobDB.destination(nj)
617 >        #if len(sites)>0 and sites[0]!="Any":
618 >        #    req = req + ' && anyMatch(other.storage.CloseSEs, (_ITR4_))'
619 >        #req = req    
620 >    
621 >        if self.EDG_requirements:
622 >            if (req == ' '):
623 >                req = req + self.EDG_requirements
624 >            else:
625 >                req = req +  ' && ' + self.EDG_requirements
626 >        if self.EDG_ce_white_list:
627 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
628 >            for i in range(len(ce_white_list)):
629 >                if i == 0:
630 >                    if (req == ' '):
631 >                        req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
632 >                    else:
633 >                        req = req +  ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
634 >                    pass
635 >                else:
636 >                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
637 >            req = req + ')'
638          
639 <        title = '# This JDL was generated by '+\
640 <                common.prog_name+' (version '+common.prog_version_str+')\n'
641 <        jt_string = ''
639 >        if self.EDG_ce_black_list:
640 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
641 >            for ce in ce_black_list:
642 >                if (req == ' '):
643 >                    req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
644 >                else:
645 >                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
646 >                pass
647 >        if self.EDG_clock_time:
648 >            if (req == ' '):
649 >                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
650 >            else:
651 >                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
652 >
653 >        if self.EDG_cpu_time:
654 >            if (req == ' '):
655 >                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
656 >            else:
657 >                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
658 >                                                                                          
659 >        if ( self.EDG_retry_count ):              
660 >            to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n'
661 >            pass
662  
663 +        to_write = to_write + 'MyProxyServer = "&quot;' + self.proxyServer + '&quot;"\n'
664 +        to_write = to_write + 'VirtualOrganisation = "&quot;' + self.VO + '&quot;"\n'
665  
666 +
667 +        #TaskName  
668 +        dir = string.split(common.work_space.topDir(), '/')
669 +        taskName = dir[len(dir)-2]
670 +
671 +        xml.write(str(title))
672 +        xml.write('<task name="' +str(taskName)+'">\n')
673 +        xml.write(jt_string)
674 +
675 +        xml.write('<iterator>\n')
676 +        xml.write('\t<iteratorRule name="ITR1">\n')
677 +        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ' </ruleElement>\n')
678 +        xml.write('\t</iteratorRule>\n')
679 +        xml.write('\t<iteratorRule name="ITR2">\n')
680 +        for arg in argsList:
681 +            xml.write('\t\t<ruleElement> <![CDATA[\n'+ arg + '\n\t\t]]> </ruleElement>\n')
682 +            pass
683 +        xml.write('\t</iteratorRule>\n')
684 +        #print jobList
685 +        xml.write('\t<iteratorRule name="ITR3">\n')
686 +        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ':1:6 </ruleElement>\n')
687 +        xml.write('\t</iteratorRule>\n')
688 +
689 +        '''
690 +        indy: qui sotto ci sta itr4
691 +        '''
692          
693 <        SPL = inp_storage_subdir
694 <        if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/'
693 >        itr4=self.findSites_(nj)
694 >        #print "--->>> itr4 = ", itr4
695 >        if (itr4 != []):
696 >            xml.write('\t<iteratorRule name="ITR4">\n')
697 >        #print argsList
698 >            for arg in itr4:
699 >                xml.write('\t\t<ruleElement> <![CDATA[\n'+ arg + '\n\t\t]]> </ruleElement>\n')
700 >                pass
701 >            xml.write('\t</iteratorRule>\n')
702 >            req = req + ' && anyMatch(other.storage.CloseSEs, (_ITR4_))'
703 >            pass
704 >        #    print "--->>> req= ", req        
705 >        
706 >        if (to_write != ''):
707 >            xml.write('<extraTags\n')
708 >            xml.write(to_write)
709 >            xml.write('/>\n')
710 >            pass
711  
712 <        jdl_fname = job.jdlFilename()
713 <        jdl = open(jdl_fname, 'w')
715 <        jdl.write(title)
712 >        xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n')
713 >        xml.write(jt_string)
714  
715 <        script = job.scriptFilename()
716 <        jdl.write('Executable = "' + os.path.basename(script) +'";\n')
717 <        jdl.write(jt_string)
715 >        if (req != ' '):
716 >            req = req + '\n'
717 >            xml.write('<extraTags>\n')
718 >            xml.write('<Requirements>\n')
719 >            xml.write('<![CDATA[\n')
720 >            xml.write(req)
721 >            xml.write(']]>\n')
722 >            xml.write('</Requirements>\n')
723 >            xml.write('</extraTags>\n')
724 >            pass
725  
726 <        ### only one .sh  JDL has arguments:
726 >        #executable
727  
728 +        """
729 +        INDY
730 +        script dipende dal jobType: dovrebbe essere semplice tirarlo fuori in altro modo
731 +        """        
732 +        script = job.scriptFilename()
733 +        xml.write('<program>\n')
734 +        xml.write('<exec> ' + os.path.basename(script) +' </exec>\n')
735 +        xml.write(jt_string)
736 +    
737 +          
738 +        ### only one .sh  JDL has arguments:
739          ### Fabio
740 <        jdl.write('Arguments = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'";\n')
741 <        inp_box = 'InputSandbox = { '
742 <        inp_box = inp_box + '"' + script + '",'
740 > #        xml.write('args = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'"\n')
741 >        xml.write('<args> <![CDATA[\n _ITR2_ \n]]> </args>\n')
742 >        xml.write('<program_types> crabjob </program_types>\n')
743 >        inp_box = script + ','
744  
745          if inp_sandbox != None:
746              for fl in inp_sandbox:
747 <                inp_box = inp_box + ' "' + fl + '",'
747 >                inp_box = inp_box + '' + fl + ','
748                  pass
749              pass
750  
751 <        #if common.use_jam:
752 <        #   inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",'
753 <
754 <        # Marco (VERY TEMPORARY ML STUFF)
755 <        inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\
739 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + '", "'+\
740 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\
741 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\
742 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"'
743 <        # End Marco
751 >        inp_box = inp_box + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + ',' +\
752 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + ','+\
753 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + ','+\
754 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + ','+\
755 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py')
756  
757          if (not jbt.additional_inbox_files == []):
758 <            inp_box = inp_box + ', '
758 >            inp_box = inp_box + ','
759              for addFile in jbt.additional_inbox_files:
760                  addFile = os.path.abspath(addFile)
761 <                inp_box = inp_box+' "'+addFile+'",'
761 >                inp_box = inp_box+''+addFile+','
762                  pass
763  
764          if inp_box[-1] == ',' : inp_box = inp_box[:-1]
765 <        inp_box = inp_box + ' };\n'
766 <        jdl.write(inp_box)
755 <
756 <        jdl.write('StdOutput     = "' + job.stdout() + '";\n')
757 <        jdl.write('StdError      = "' + job.stderr() + '";\n')
765 >        inp_box = '<infiles> <![CDATA[\n' + inp_box + '\n]]> </infiles>\n'
766 >        xml.write(inp_box)
767          
768 +        base = jbt.name()
769 +        stdout = base + '__ITR3_.stdout'
770 +        stderr = base + '__ITR3_.stderr'
771          
772 <        if job.stdout() == job.stderr():
773 <          out_box = 'OutputSandbox = { "' + \
774 <                    job.stdout() + '", ".BrokerInfo",'
775 <        else:
776 <          out_box = 'OutputSandbox = { "' + \
777 <                    job.stdout() + '", "' + \
766 <                    job.stderr() + '", ".BrokerInfo",'
772 >        xml.write('<stderr> ' + stderr + '</stderr>\n')
773 >        xml.write('<stdout> ' + stdout + '</stdout>\n')
774 >        
775 >
776 >        out_box = stdout + ',' + \
777 >                  stderr + ',.BrokerInfo,'
778  
779 +        """
780          if int(self.return_data) == 1:
781              if out_sandbox != None:
782                  for fl in out_sandbox:
783 <                    out_box = out_box + ' "' + fl + '",'
783 >                    out_box = out_box + '' + fl + ','
784                      pass
785                  pass
786              pass
787 <                                                                                                                                                            
776 <        if out_box[-1] == ',' : out_box = out_box[:-1]
777 <        out_box = out_box + ' };'
778 <        jdl.write(out_box+'\n')
779 <
787 >        """
788  
789 <        req='Requirements = '
790 <        noreq=req
791 <        req = req + jbt.getRequirements()
792 <        #### and USER REQUIREMENT
793 <        if self.EDG_requirements:
794 <            if (req != noreq):
795 <                req = req +  ' && '
788 <            req = req + self.EDG_requirements
789 <        #### FEDE #####
790 <        if self.EDG_ce_white_list:
791 <            ce_white_list = string.split(self.EDG_ce_white_list,',')
792 <            #print "req = ", req
793 <            for i in range(len(ce_white_list)):
794 <                if i == 0:
795 <                    if (req != noreq):
796 <                        req = req +  ' && '
797 <                    req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
798 <                    pass
799 <                else:
800 <                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
801 <            req = req + ')'
802 <        
803 <        if self.EDG_ce_black_list:
804 <            ce_black_list = string.split(self.EDG_ce_black_list,',')
805 <            for ce in ce_black_list:
806 <                if (req != noreq):
807 <                    req = req +  ' && '
808 <                req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
789 >        """
790 >        INDY
791 >        qualcosa del genere andrebbe fatta per gli infiles
792 >        """        
793 >        if int(self.return_data) == 1:
794 >            for fl in jbt.output_file:
795 >                out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ','
796                  pass
797 +            pass
798  
799 <        ###############
800 <        clockTime=480
801 <        if self.EDG_clock_time:
802 <            clockTime= self.EDG_clock_time
803 <        if (req != noreq):
816 <            req = req + ' && '
817 <        req = req + '((other.GlueCEPolicyMaxWallClockTime == 0) || (other.GlueCEPolicyMaxWallClockTime>='+str(clockTime)+'))'
818 <
819 <        cpuTime=1000
820 <        if self.EDG_cpu_time:
821 <            cpuTime=self.EDG_cpu_time
822 <        if (req != noreq):
823 <            req = req + ' && '
824 <        req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))'
825 <
826 <        if (req != noreq):
827 <            req = req + ';\n'
828 <            jdl.write(req)
829 <                                                                                                                                                            
830 <        jdl.write('VirtualOrganisation = "' + self.VO + '";\n')
799 >        if out_box[-1] == ',' : out_box = out_box[:-1]
800 >        out_box = '<outfiles> <![CDATA[\n' + out_box + '\n]]></outfiles>\n'
801 >        xml.write(out_box)
802 >
803 >        xml.write('<BossAttr> crabjob.INTERNAL_ID=_ITR1_ </BossAttr>\n')
804  
805 <        if ( self.EDG_retry_count ):              
806 <            jdl.write('RetryCount = '+self.EDG_retry_count+';\n')
834 <            pass
805 >        xml.write('</program>\n')
806 >        xml.write('</chain>\n')
807  
808 <        jdl.write('MyProxyServer = "' + self.proxyServer + '";\n')
808 >        xml.write('</iterator>\n')
809 >        xml.write('</task>\n')
810  
811 <        jdl.close()
811 >        xml.close()
812          return
813  
814      def checkProxy(self):
# Line 848 | Line 821 | class SchedulerEdg(Scheduler):
821  
822          minTimeLeftServer = 100 # in hours
823  
851        #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
852        #cmd = 'voms-proxy-info -timeleft'
824          mustRenew = 0
825          timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null')
826          timeLeftServer = -999
# Line 866 | Line 837 | class SchedulerEdg(Scheduler):
837  
838          if mustRenew:
839              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")
840 <            cmd = 'voms-proxy-init -voms cms -valid 96:00'
840 >            cmd = 'voms-proxy-init -voms '+self.VO+' -valid 96:00'
841 >            if self.role:
842 >                cmd = 'voms-proxy-init -voms '+self.VO+':/'+self.VO+'/role='+self.role+' -valid 96:00'
843              try:
844                  # SL as above: damn it!
845                  out = os.system(cmd)
# Line 874 | Line 847 | class SchedulerEdg(Scheduler):
847              except:
848                  msg = "Unable to create a valid proxy!\n"
849                  raise CrabException(msg)
877            # cmd = 'grid-proxy-info -timeleft'
878            # cmd_out = runCommand(cmd,0,20)
850              pass
851  
852          ## now I do have a voms proxy valid, and I check the myproxy server

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines