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.75 by mkirn, Fri Jul 28 18:04:01 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          """
# Line 199 | Line 268 | class SchedulerEdg(Scheduler):
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'
203 <        txt += '    middleware=LCG \n'
204 <        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
205 <        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
206 <        txt += '    echo "middleware =$middleware" \n'
207 <        txt += 'elif [ $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 214 | 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'
# Line 243 | 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 310 | Line 379 | class SchedulerEdg(Scheduler):
379          Copy input data from SE to WN    
380          """
381          txt = ''
382 <        try:
314 <            self.copy_input_data = common.analisys_common_info['copy_input_data']
315 <            #print "self.copy_input_data = ", self.copy_input_data
316 <        except KeyError: self.copy_input_data = 0
317 <        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 <           #### FEDE
397 <           #txt += '      echo "which lcg-cp" \n'
398 <           #txt += '      which lcg-cp \n'
399 <           #########
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 <           #### FEDE
413 <           #txt += '      echo "which lcg-cp" \n'
414 <           #txt += '      which lcg-cp \n'
415 <           #########
416 <           txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
417 <           txt += '      copy_input_pu_exit_status=$?\n'
418 <           txt += '      echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
419 <           txt += '      if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
420 <           txt += '         echo "Problems with copying pu to WN" \n'
356 <           txt += '      else \n'
357 <           txt += '         echo "input pu files copied into WN" \n'
358 <           txt += '      fi \n'
359 <           txt += '   done \n'
360 <           txt += '   \n'
361 <           txt += '   ### Check SCRATCH space available on WN : \n'
362 <           txt += '   df -h \n'
363 <           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 374 | Line 431 | class SchedulerEdg(Scheduler):
431             txt += '#\n'
432             txt += '#   Copy output to SE = $SE\n'
433             txt += '#\n'
377           #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'
# Line 384 | Line 440 | class SchedulerEdg(Scheduler):
440             txt += '    fi \n'
441             txt += '    for out_file in $file_list ; do\n'
442             txt += '        echo "Trying to copy output file to $SE using lcg-cp"\n'
443 <           txt += '        echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
444 <           txt += '        exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\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'
# Line 393 | Line 453 | class SchedulerEdg(Scheduler):
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'
# Line 427 | Line 488 | class SchedulerEdg(Scheduler):
488             txt += '            echo "lcg-cp succeeded"\n'
489             txt += '         fi\n'
490             txt += '     done\n'
430           #txt += 'fi\n'
491          return txt
492  
493      def wsRegisterOutput(self):
# Line 447 | Line 507 | class SchedulerEdg(Scheduler):
507             txt += '#\n'
508             txt += '#  Register output to LFC\n'
509             txt += '#\n'
450           #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'
454           #### FEDE
455           #txt += '         echo "which lcg-rf" \n'
456           #txt += '         which lcg-rf \n'
457           #########
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'
# Line 463 | Line 518 | class SchedulerEdg(Scheduler):
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'
466           #### FEDE
467           #txt += '            echo "which lcg-rf" \n'
468           #txt += '            which lcg-rf \n'
469           #########
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'
# Line 480 | 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'
483           #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'
488           #### FEDE
489           #txt += '         echo "which lcg-cr" \n'
490           #txt += '         which lcg-cr \n'
491           #########
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'
# Line 503 | 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'
506           #txt += '   else\n'
507           #txt += '      echo "Problem with the executable"\n'
552             txt += '   fi \n'
553             txt += '   exit_status=$register_exit_status\n'
554             txt += 'fi \n'
# Line 520 | Line 564 | class SchedulerEdg(Scheduler):
564          cmd_out = runCommand(cmd)
565          return cmd_out
566  
523    def listMatch(self, nj):
524        """
525        Check the compatibility of available resources
526        """
527        self.checkProxy()
528        jdl = common.job_list[nj].jdlFilename()
529        cmd = 'edg-job-list-match ' + self.configOpt_() + jdl
530        cmd_out = runCommand(cmd,0,45)
531        if not cmd_out:
532            raise CrabException("ERROR: "+cmd+" failed!")
533
534        return self.parseListMatch_(cmd_out, jdl)
535
536    def parseListMatch_(self, out, jdl):
537        """
538        Parse the f* output of edg-list-match and produce something sensible
539        """
540        reComment = re.compile( r'^\**$' )
541        reEmptyLine = re.compile( r'^$' )
542        reVO = re.compile( r'Selected Virtual Organisation name.*' )
543        reLine = re.compile( r'.*')
544        reCE = re.compile( r'(.*:.*)')
545        reCEId = re.compile( r'CEId.*')
546        reNO = re.compile( r'No Computing Element matching' )
547        reRB = re.compile( r'Connecting to host' )
548        next = 0
549        CEs=[]
550        Match=0
551
552        #print out
553        lines = reLine.findall(out)
554
555        i=0
556        CEs=[]
557        for line in lines:
558            string.strip(line)
559            #print line
560            if reNO.match( line ):
561                common.logger.debug(5,line)
562                return 0
563                pass
564            if reVO.match( line ):
565                VO =reVO.match( line ).group()
566                common.logger.debug(5,"VO "+VO)
567                pass
568
569            if reRB.match( line ):
570                RB = reRB.match(line).group()
571                common.logger.debug(5,"RB "+RB)
572                pass
573
574            if reCEId.search( line ):
575                for lineCE in lines[i:-1]:
576                    if reCE.match( lineCE ):
577                        CE = string.strip(reCE.search(lineCE).group(1))
578                        CEs.append(CE.split(':')[0])
579                        pass
580                    pass
581                pass
582            i=i+1
583            pass
584
585        common.logger.debug(5,"All CE :"+str(CEs))
586
587        sites = []
588        [sites.append(it) for it in CEs if not sites.count(it)]
589
590        common.logger.debug(5,"All Sites :"+str(sites))
591        common.logger.message("Matched Sites :"+str(sites))
592        return len(sites)
593
594    def noMatchFound_(self, jdl):
595        reReq = re.compile( r'Requirements' )
596        reString = re.compile( r'"\S*"' )
597        f = file(jdl,'r')
598        for line in f.readlines():
599            line= line.strip()
600            if reReq.match(line):
601                for req in reString.findall(line):
602                    if re.search("VO",req):
603                        common.logger.message( "SW required: "+req)
604                        continue
605                    if re.search('"\d+',req):
606                        common.logger.message("Other req  : "+req)
607                        continue
608                    common.logger.message( "CE required: "+req)
609                break
610            pass
611        raise CrabException("No compatible resources found!")
612
613    def submit(self, nj):
614        """
615        Submit one EDG job.
616        """
617
618        self.checkProxy()
619        jid = None
620        jdl = common.job_list[nj].jdlFilename()
621
622        cmd = 'edg-job-submit ' + self.configOpt_() + jdl
623        cmd_out = runCommand(cmd)
624        if cmd_out != None:
625            reSid = re.compile( r'https.+' )
626            jid = reSid.search(cmd_out).group()
627            pass
628        return jid
629
630    def resubmit(self, nj_list):
631        """
632        Prepare jobs to be submit
633        """
634        return
635
567      def getExitStatus(self, id):
568          return self.getStatusAttribute_(id, 'exit_code')
569  
# Line 664 | 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 673 | 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 <        Get output for a finished job with id.
629 <        Returns the name of directory with results.
628 >  #      job = common.job_list[nj]
629 >        """
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 """
694 <        self.checkProxy()
695 <        cmd = 'edg-job-cancel --noint ' + id
696 <        cmd_out = runCommand(cmd)
697 <        return cmd_out
658 >        req=' '
659 >        req = req + jbt.getRequirements()
660  
699    def createSchScript(self, nj):
700        """
701        Create a JDL-file for EDG.
702        """
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')
725 <        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') + '", "' +\
745 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + '", "'+\
746 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\
747 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\
748 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"'
749 <        # 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)
761 <
762 <        jdl.write('StdOutput     = "' + job.stdout() + '";\n')
763 <        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 <        if job.stdout() == job.stderr():
795 <          out_box = 'OutputSandbox = { "' + \
796 <                    job.stdout() + '", ".BrokerInfo",'
797 <        else:
798 <          out_box = 'OutputSandbox = { "' + \
799 <                    job.stdout() + '", "' + \
772 <                    job.stderr() + '", ".BrokerInfo",'
794 >        xml.write('<stderr> ' + stderr + '</stderr>\n')
795 >        xml.write('<stdout> ' + stdout + '</stdout>\n')
796 >        
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 <                                                                                                                                                            
782 <        if out_box[-1] == ',' : out_box = out_box[:-1]
783 <        out_box = out_box + ' };'
784 <        jdl.write(out_box+'\n')
785 <
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 +  ' && '
794 <            req = req + self.EDG_requirements
795 <        #### FEDE #####
796 <        if self.EDG_ce_white_list:
797 <            ce_white_list = string.split(self.EDG_ce_white_list,',')
798 <            #print "req = ", req
799 <            for i in range(len(ce_white_list)):
800 <                if i == 0:
801 <                    if (req != noreq):
802 <                        req = req +  ' && '
803 <                    req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
804 <                    pass
805 <                else:
806 <                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
807 <            req = req + ')'
808 <        
809 <        if self.EDG_ce_black_list:
810 <            ce_black_list = string.split(self.EDG_ce_black_list,',')
811 <            for ce in ce_black_list:
812 <                if (req != noreq):
813 <                    req = req +  ' && '
814 <                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):
822 <            req = req + ' && '
823 <        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:
827 <            cpuTime=self.EDG_cpu_time
828 <        if (req != noreq):
829 <            req = req + ' && '
830 <        req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))'
831 <
832 <        if (req != noreq):
833 <            req = req + ';\n'
834 <            jdl.write(req)
835 <                                                                                                                                                            
836 <        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')
840 <            pass
830 >        xml.write('</iterator>\n')
831 >        xml.write('</task>\n')
832  
833 <        jdl.write('MyProxyServer = "' + self.proxyServer + '";\n')
833 >        xml.close()
834 >      
835  
844        jdl.close()
836          return
837  
838      def checkProxy(self):
# Line 854 | Line 845 | class SchedulerEdg(Scheduler):
845  
846          minTimeLeftServer = 100 # in hours
847  
857        #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
858        #cmd = 'voms-proxy-info -timeleft'
848          mustRenew = 0
849          timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null')
850          timeLeftServer = -999
# Line 872 | 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 880 | Line 871 | class SchedulerEdg(Scheduler):
871              except:
872                  msg = "Unable to create a valid proxy!\n"
873                  raise CrabException(msg)
883            # cmd = 'grid-proxy-info -timeleft'
884            # 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