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

Comparing COMP/CRAB/python/SchedulerGlite.py (file contents):
Revision 1.1.2.3 by spiga, Tue Jul 25 14:58:14 2006 UTC vs.
Revision 1.1.2.3.2.2 by fanzago, Mon Sep 18 14:37:22 2006 UTC

# Line 135 | Line 135 | class SchedulerGlite(Scheduler):
135          try: self.EDG_cpu_time = cfg_params['EDG.max_cpu_time']
136          except KeyError: self.EDG_cpu_time = ''
137  
138
139        try: self.schedulerName = cfg_params['CRAB.scheduler']
140        except KeyError: self.schedulerName = ''
141
142        try: self.jobtypeName = cfg_params['CRAB.jobtype']
143        except KeyError: self.jobtypeName = ''
144
138          # Add EDG_WL_LOCATION to the python path
139          try:
140              path = os.environ['EDG_WL_LOCATION']
# Line 155 | Line 148 | class SchedulerGlite(Scheduler):
148          sys.path.append(libPath)
149  
150          self.proxyValid=0
151 +
152 +        try:
153 +            self._taskId = cfg_params['taskId']
154 +        except:
155 +            self._taskId = ''
156 +
157 +        try: self.jobtypeName = cfg_params['CRAB.jobtype']
158 +        except KeyError: self.jobtypeName = ''
159 +
160 +        try: self.schedulerName = cfg_params['CRAB.scheduler']
161 +        except KeyError: self.scheduler = ''
162 +
163          return
164      
165  
# Line 177 | Line 182 | class SchedulerGlite(Scheduler):
182          Returns part of a job script which does scheduler-specific work.
183          """
184          txt = ''
185 +        txt += '# strip arguments\n'
186 +        txt += 'echo "strip arguments"\n'
187 +        txt += 'args=("$@")\n'
188 +        txt += 'nargs=$#\n'
189 +        txt += 'shift $nargs\n'
190 +        txt += "# job number (first parameter for job wrapper)\n"
191 +        #txt += "NJob=$1\n"
192 +        txt += "NJob=${args[0]}\n"
193 +
194 +        txt += '# job identification to DashBoard \n'
195 +        txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n'
196 +        txt += 'SyncGridJobId=`echo $EDG_WL_JOBID`\n'
197 +        txt += 'MonitorID=`echo ' + self._taskId + '`\n'
198 +        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
199 +        txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
200 +        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
201 +
202          txt += 'echo "middleware discovery " \n'
203          txt += 'if [ $VO_CMS_SW_DIR ]; then\n'
204          txt += '    middleware=LCG \n'
205 +        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
206 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
207          txt += '    echo "middleware =$middleware" \n'
208          txt += 'elif [ $GRID3_APP_DIR ]; then\n'
209          txt += '    middleware=OSG \n'
210 +        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
211 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
212          txt += '    echo "middleware =$middleware" \n'
213          txt += 'elif [ $OSG_APP ]; 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'
217          txt += '    echo "middleware =$middleware" \n'
218          txt += 'else \n'
219 <        txt += '    echo "SET_CMS_ENV 1 ==> middleware not identified" \n'
220 <        txt += '    echo "JOB_EXIT_STATUS = 1"\n'
221 <        txt += '    exit 1\n'
222 <        txt += 'fi\n'
223 <
219 >        txt += '    echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
220 >        txt += '    echo "JOB_EXIT_STATUS = 10030" \n'
221 >        txt += '    echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n'
222 >        txt += '    dumpStatus $RUNTIME_AREA/$repo \n'
223 >        txt += '    rm -f $RUNTIME_AREA/$repo \n'
224 >        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
225 >        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
226 >        txt += '    exit 1 \n'
227 >        txt += 'fi \n'
228 >
229 >        txt += '# report first time to DashBoard \n'
230 >        txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
231 >        txt += 'rm -f $RUNTIME_AREA/$repo \n'
232 >        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
233 >        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
234 >        
235          txt += '\n\n'
236  
198        ### OLI: removed to move DashBoard reporting header to front of wrapper script
199        # txt += 'if [ $middleware == LCG ]; then \n'
200        # txt += '    echo "SyncGridJobId=`echo $EDG_WL_JOBID`" | tee -a $RUNTIME_AREA/$repo\n'
201        # txt += 'fi\n'
202
237          if int(self.copy_data) == 1:
238             if self.SE:
239                txt += 'export SE='+self.SE+'\n'
# Line 259 | Line 293 | class SchedulerGlite(Scheduler):
293          txt += '    if [ $OSG_JOB_CONTACT ]; then \n'
294          txt += '        CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n'
295          txt += '    else \n'
296 <        txt += '        echo "SET_ENV 1 ==> ERROR in setting CE name - OSG mode -" \n'
296 >        txt += '        echo "SET_CMS_ENV 10099 ==> OSG mode: ERROR in setting CE name from OSG_JOB_CONTACT" \n'
297 >        txt += '        echo "JOB_EXIT_STATUS = 10099" \n'
298 >        txt += '        echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n'
299 >        txt += '        dumpStatus $RUNTIME_AREA/$repo \n'
300 >        txt += '        rm -f $RUNTIME_AREA/$repo \n'
301 >        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
302 >        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
303          txt += '        exit 1 \n'
304          txt += '    fi \n'
305          txt += 'fi \n'
# Line 273 | Line 313 | class SchedulerGlite(Scheduler):
313          txt = ''
314          try:
315              self.copy_input_data = common.analisys_common_info['copy_input_data']
276            #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:
318          ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
# Line 286 | Line 325 | class SchedulerGlite(Scheduler):
325             txt += '   #\n'
326             txt += '   #   Copy Input Data from SE to this WN\n'
327             txt += '   #\n'
328 < ### changed by georgia (put a loop copying more than one input files per jobs)          
328 >           ### changed by georgia (put a loop copying more than one input files per jobs)          
329             txt += '   for input_file in $cur_file_list \n'
330             txt += '   do \n'
331 <           txt += '    lcg-cp --vo $VO lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
332 <           txt += '    copy_input_exit_status=$?\n'
333 <           txt += '    echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
334 <           txt += '    if [ $copy_input_exit_status -ne 0 ]; then \n'
335 <           txt += '       echo "Problems with copying to WN" \n'
336 <           txt += '    else \n'
337 <           txt += '       echo "input copied into WN" \n'
338 <           txt += '    fi \n'
331 >           txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
332 >           txt += '      copy_input_exit_status=$?\n'
333 >           txt += '      echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
334 >           txt += '      if [ $copy_input_exit_status -ne 0 ]; then \n'
335 >           txt += '         echo "Problems with copying to WN" \n'
336 >           txt += '      else \n'
337 >           txt += '         echo "input copied into WN" \n'
338 >           txt += '      fi \n'
339             txt += '   done \n'
340 < ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
340 >           ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
341             txt += '   for file in $cur_pu_list \n'
342             txt += '   do \n'
343 <           txt += '    lcg-cp --vo $VO lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
344 <           txt += '    copy_input_exit_status=$?\n'
345 <           txt += '    echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
346 <           txt += '    if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
347 <           txt += '       echo "Problems with copying pu to WN" \n'
348 <           txt += '    else \n'
349 <           txt += '       echo "input pu files copied into WN" \n'
350 <           txt += '    fi \n'
343 >           txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
344 >           txt += '      copy_input_pu_exit_status=$?\n'
345 >           txt += '      echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
346 >           txt += '      if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
347 >           txt += '         echo "Problems with copying pu to WN" \n'
348 >           txt += '      else \n'
349 >           txt += '         echo "input pu files copied into WN" \n'
350 >           txt += '      fi \n'
351             txt += '   done \n'
352             txt += '   \n'
353             txt += '   ### Check SCRATCH space available on WN : \n'
# Line 327 | Line 366 | class SchedulerGlite(Scheduler):
366             txt += '#\n'
367             txt += '#   Copy output to SE = $SE\n'
368             txt += '#\n'
369 <           txt += 'if [ $exe_result -eq 0 ]; then\n'
369 >           txt += '    if [ $middleware == OSG ]; then\n'
370 >           txt += '        echo "X509_USER_PROXY = $X509_USER_PROXY"\n'
371 >           txt += '        echo "source $OSG_APP/glite/setup_glite_ui.sh"\n'
372 >           txt += '        source $OSG_APP/glite/setup_glite_ui.sh\n'
373 >           txt += '        export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n'
374 >           txt += '        echo "export X509_CERT_DIR=$X509_CERT_DIR"\n'
375 >           txt += '    fi \n'
376             txt += '    for out_file in $file_list ; do\n'
377 <           txt += '        echo "Trying to copy output file to $SE "\n'
378 <           ## OLI_Daniele globus-* for OSG, lcg-* for LCG
379 <           txt += '        if [ $middleware == OSG ]; then\n'
380 <           txt += '           echo "globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
381 <           txt += '           copy_exit_status=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
337 <           #txt += '           exitstring=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
338 <           txt += '        elif [ $middleware == LCG ]; then \n'
339 <           txt += '           echo "lcg-cp --vo cms -t 1200 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
340 <           txt += '           copy_exit_status=`lcg-cp --vo cms -t 1200 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
341 <           #txt += '           exitstring=`lcg-cp --vo cms -t 30 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
342 <           txt += '        fi \n'
343 <           #txt += '        copy_exit_status=$?\n'
344 <           txt += '        echo "COPY_EXIT_STATUS = $copy_exit_status"\n'
377 >           txt += '        echo "Trying to copy output file to $SE using lcg-cp"\n'
378 >           txt += '        echo "lcg-cp --vo $VO -t 1200 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
379 >           txt += '        exitstring=`lcg-cp --vo $VO -t 1200 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
380 >           txt += '        copy_exit_status=$?\n'
381 >           txt += '        echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
382             txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
383             txt += '        if [ $copy_exit_status -ne 0 ]; then\n'
384 <           txt += '            echo "Problems with SE = $SE"\n'
384 >           txt += '            echo "Possible problem with SE = $SE"\n'
385             txt += '            echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
386             txt += '            echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
387 +           txt += '            echo "lcg-cp failed, attempting srmcp"\n'
388 +           txt += '            echo "mkdir -p $HOME/.srmconfig"\n'
389 +           txt += '            mkdir -p $HOME/.srmconfig\n'
390 +           txt += '            if [ $middleware == LCG ]; then\n'
391 +           txt += '               echo "srmcp -retry_num 5 -retry_timeout 240000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
392 +           txt += '               exitstring=`srmcp -retry_num 5 -retry_timeout 240000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
393 +           txt += '            elif [ $middleware == OSG ]; then\n'
394 +           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'
395 +           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'
396 +           txt += '            fi \n'
397 +           txt += '            copy_exit_status=$?\n'
398 +           txt += '            echo "COPY_EXIT_STATUS for srm = $copy_exit_status"\n'
399 +           txt += '            echo "STAGE_OUT = $copy_exit_status"\n'
400 +           txt += '            if [ $copy_exit_status -ne 0 ]; then\n'
401 +           txt += '               echo "Problems with SE = $SE"\n'
402 +           txt += '               echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
403 +           txt += '               echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
404 +           txt += '               echo "lcg-cp and srm failed"\n'
405 +           txt += '               echo "If storage_path in your config file contains a ? you may need a \? instead."\n'
406 +           txt += '            else\n'
407 +           txt += '               echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
408 +           txt += '               echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
409 +           txt += '               echo "output copied into $SE/$SE_PATH directory"\n'
410 +           txt += '               echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
411 +           txt += '               echo "srmcp succeeded"\n'
412 +           txt += '            fi\n'
413             txt += '        else\n'
414             txt += '            echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
415             txt += '            echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
416             txt += '            echo "output copied into $SE/$SE_PATH directory"\n'
417             txt += '            echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
418 +           txt += '            echo "lcg-cp succeeded"\n'
419             txt += '         fi\n'
420             txt += '     done\n'
357           txt += 'fi\n'
421          return txt
422  
423      def wsRegisterOutput(self):
# Line 374 | Line 437 | class SchedulerGlite(Scheduler):
437             txt += '#\n'
438             txt += '#  Register output to LFC\n'
439             txt += '#\n'
440 <           txt += '   if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
440 >           txt += '   if [ $copy_exit_status -eq 0 ]; then\n'
441             txt += '      for out_file in $file_list ; do\n'
442             txt += '         echo "Trying to register the output file into LFC"\n'
443 <           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n'
444 <           txt += '         lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n'
443 >           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n'
444 >           txt += '         lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n'
445             txt += '         register_exit_status=$?\n'
446             txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
447             txt += '         echo "STAGE_OUT = $register_exit_status"\n'
448             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
449             txt += '            echo "Problems with the registration to LFC" \n'
450             txt += '            echo "Try with srm protocol" \n'
451 <           txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n'
452 <           txt += '            lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n'
451 >           txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n'
452 >           txt += '            lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n'
453             txt += '            register_exit_status=$?\n'
454             txt += '            echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
455             txt += '            echo "STAGE_OUT = $register_exit_status"\n'
# Line 398 | Line 461 | class SchedulerGlite(Scheduler):
461             txt += '         fi \n'
462             txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
463             txt += '      done\n'
464 <           txt += '   elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
464 >           txt += '   else \n'
465             txt += '      echo "Trying to copy output file to CloseSE"\n'
466             txt += '      CLOSE_SE=`glite-brokerinfo getCloseSEs | head -1`\n'
467             txt += '      for out_file in $file_list ; do\n'
468 <           txt += '         echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n'
469 <           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'
468 >           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'
469 >           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'
470             txt += '         register_exit_status=$?\n'
471             txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
472             txt += '         echo "STAGE_OUT = $register_exit_status"\n'
473             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
474 <           txt += '            echo "Problems with CloseSE" \n'
474 >           txt += '            echo "Problems with CloseSE or Catalog" \n'
475             txt += '         else \n'
476             txt += '            echo "The program was successfully executed"\n'
477             txt += '            echo "SE = $CLOSE_SE"\n'
# Line 416 | Line 479 | class SchedulerGlite(Scheduler):
479             txt += '         fi \n'
480             txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
481             txt += '      done\n'
419           txt += '   else\n'
420           txt += '      echo "Problem with the executable"\n'
482             txt += '   fi \n'
483 +           txt += '   exit_status=$register_exit_status\n'
484             txt += 'fi \n'
485          return txt
486  
# Line 432 | Line 494 | class SchedulerGlite(Scheduler):
494          cmd_out = runCommand(cmd)
495          return cmd_out
496  
435    def listMatch(self, nj):
436        """
437        Check the compatibility of available resources
438        """
439        self.checkProxy()
440 #        jdl = common.job_list[nj].jdlFilename()
441        jdl = common.work_space.shareDir()+"fake.jdl"
442        cmd = 'glite-job-list-match ' + self.configOpt_() + jdl
443        cmd_out = runCommand(cmd,0,10)
444        if not cmd_out:
445            raise CrabException("ERROR: "+cmd+" failed!")
446
447        return self.parseListMatch_(cmd_out, jdl)
448
449    def parseListMatch_(self, out, jdl):
450        """
451        Parse the f* output of edg-list-match and produce something sensible
452        """
453        reComment = re.compile( r'^\**$' )
454        reEmptyLine = re.compile( r'^$' )
455        reVO = re.compile( r'Selected Virtual Organisation name.*' )
456        reLine = re.compile( r'.*')
457        reCE = re.compile( r'(.*:.*)')
458        reCEId = re.compile( r'CEId.*')
459        reNO = re.compile( r'No Computing Element matching' )
460        reRB = re.compile( r'Connecting to host' )
461        next = 0
462        CEs=[]
463        Match=0
464
465        #print out
466        lines = reLine.findall(out)
467
468        i=0
469        CEs=[]
470        for line in lines:
471            string.strip(line)
472            #print line
473            if reNO.match( line ):
474                common.logger.debug(5,line)
475                return 0
476                pass
477            if reVO.match( line ):
478                VO =reVO.match( line ).group()
479                common.logger.debug(5,"VO "+VO)
480                pass
481
482            if reRB.match( line ):
483                RB = reRB.match(line).group()
484                common.logger.debug(5,"RB "+RB)
485                pass
486
487            if reCEId.search( line ):
488                for lineCE in lines[i:-1]:
489                    if reCE.match( lineCE ):
490                        CE = string.strip(reCE.search(lineCE).group(1))
491                        CEs.append(CE.split(':')[0])
492                        pass
493                    pass
494                pass
495            i=i+1
496            pass
497
498        common.logger.debug(5,"All CE :"+str(CEs))
499
500        sites = []
501        [sites.append(it) for it in CEs if not sites.count(it)]
502
503        common.logger.debug(5,"All Sites :"+str(sites))
504        return len(sites)
505
506    def noMatchFound_(self, jdl):
507        reReq = re.compile( r'Requirements' )
508        reString = re.compile( r'"\S*"' )
509        f = file(jdl,'r')
510        for line in f.readlines():
511            line= line.strip()
512            if reReq.match(line):
513                for req in reString.findall(line):
514                    if re.search("VO",req):
515                        common.logger.message( "SW required: "+req)
516                        continue
517                    if re.search('"\d+',req):
518                        common.logger.message("Other req  : "+req)
519                        continue
520                    common.logger.message( "CE required: "+req)
521                break
522            pass
523        raise CrabException("No compatible resources found!")
524
525    def submit(self, nj):
526        """
527        Submit one EDG job.
528        """
529
530        self.checkProxy()
531        jid = None
532        jdl = common.job_list[nj].jdlFilename()
533
534        cmd = 'glite-job-submit ' + self.configOpt_() + jdl
535        cmd_out = runCommand(cmd)
536        if cmd_out != None:
537            reSid = re.compile( r'https.+' )
538            jid = reSid.search(cmd_out).group()
539            pass
540        return jid
541
542    def resubmit(self, nj_list):
543        """
544        Prepare jobs to be submit
545        """
546        return
547
497      def getExitStatus(self, id):
498          return self.getStatusAttribute_(id, 'exit_code')
499  
# Line 576 | Line 525 | class SchedulerGlite(Scheduler):
525              for i in range(len(self.states)):
526                  # Fill an hash table with all information retrieved from LB API
527                  hstates[ self.states[i] ] = jobStat.loadStatus(st)[i]
528 <            result = jobStat.loadStatus(st)[ self.states.index(attr) ]
528 >            result = jobStat.loadStatus(st)[self.states.index(attr)]
529              return result
530  
531      def queryDetailedStatus(self, id):
# Line 585 | Line 534 | class SchedulerGlite(Scheduler):
534          cmd_out = runCommand(cmd)
535          return cmd_out
536  
537 <    def getOutput(self, id):
537 >    ##### FEDE ######        
538 >    def findSites_(self, n_tot_job):
539 >        itr4 = []
540 >       # print "n_tot_job = ", n_tot_job
541 >        for n in range(n_tot_job):
542 >            sites = common.jobDB.destination(n)
543 >            #job = common.job_list[n]
544 >            #jbt = job.type()
545 >           # print "common.jobDB.destination(n) = ", common.jobDB.destination(n)
546 >           # print "sites = ", sites
547 >            itr = ''
548 >            for site in sites:
549 >                #itr = itr + 'target.GlueSEUniqueID==&quot;'+site+'&quot; || '
550 >                itr = itr + 'target.GlueSEUniqueID=="'+site+'" || '
551 >                pass
552 >            # remove last ||
553 >            itr = itr[0:-4]
554 >            itr4.append( itr )
555 >        # remove last ,
556 >       # print "itr4 = ", itr4
557 >        return itr4
558 >
559 >    def createXMLSchScript(self, nj, argsList):
560 >   # def createXMLSchScript(self, nj):
561          """
562 <        Get output for a finished job with id.
591 <        Returns the name of directory with results.
562 >        Create a XML-file for BOSS4.
563          """
564 <
565 <        self.checkProxy()
566 <        cmd = 'glite-job-get-output --dir ' + common.work_space.resDir() + ' ' + id
567 <        cmd_out = runCommand(cmd)
568 <
598 <        # Determine the output directory name
599 <        dir = common.work_space.resDir()
600 <        dir += os.environ['USER']
601 <        dir += '_' + os.path.basename(id)
602 <        return dir
603 <
604 <    def cancel(self, id):
605 <        """ Cancel the EDG job with id """
606 <        self.checkProxy()
607 <        cmd = 'glite-job-cancel --noint ' + id
608 <        cmd_out = runCommand(cmd)
609 <        return cmd_out
610 <
611 <
612 <    def createFakeJdl(self,nj):  # TMP Just waiting listmatch functionalitly  
613 <                                  # implementation into BOSS4   Daniele
614 <        """                          
615 <        Create a fake jdl considering
616 <        only requirements  
564 >  #      job = common.job_list[nj]
565 >        """
566 >        INDY
567 >        [begin] da rivedere:
568 >        in particolare passerei il jobType ed eliminerei le dipendenze da job
569          """
570 <        job = common.job_list[nj]
570 >        index = nj - 1
571 >        job = common.job_list[index]
572          jbt = job.type()
620        inp_storage_subdir = ''
573          
574 <        
575 <        SPL = inp_storage_subdir
624 <        if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/'
625 <
626 <        jdl = open(common.work_space.shareDir()+"fake.jdl","w")
627 <
628 <        script = job.scriptFilename()
629 <        jdl.write('Executable = "' + os.path.basename(script) +'";\n')
630 <
631 <        req='Requirements = '
632 <        noreq=req
633 <        req = req + jbt.getRequirements()
634 <        #### and USER REQUIREMENT
635 <        if self.EDG_requirements:
636 <            if (req != noreq):
637 <                req = req +  ' && '
638 <            req = req + self.EDG_requirements
639 <        #### FEDE #####
640 <        if self.EDG_ce_white_list:
641 <            ce_white_list = string.split(self.EDG_ce_white_list,',')
642 <            #print "req = ", req
643 <            for i in range(len(ce_white_list)):
644 <                if i == 0:
645 <                    if (req != noreq):
646 <                        req = req +  ' && '
647 <                    req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
648 <                    pass
649 <                else:
650 <                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
651 <            req = req + ')'
652 <        
653 <        if self.EDG_ce_black_list:
654 <            ce_black_list = string.split(self.EDG_ce_black_list,',')
655 <            for ce in ce_black_list:
656 <                if (req != noreq):
657 <                    req = req +  ' && '
658 <                req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
659 <                pass
660 <
661 <        ###############
662 <        clockTime=480
663 <        if self.EDG_clock_time:
664 <            clockTime= self.EDG_clock_time
665 <        if (req != noreq):
666 <            req = req + ' && '
667 <        req = req + '((other.GlueCEPolicyMaxWallClockTime == 0) || (other.GlueCEPolicyMaxWallClockTime>='+str(clockTime)+'))'
668 <
669 <        cpuTime=1000
670 <        if self.EDG_cpu_time:
671 <            cpuTime=self.EDG_cpu_time
672 <        if (req != noreq):
673 <            req = req + ' && '
674 <        req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))'
675 <
676 <        if (req != noreq):
677 <            req = req + ';\n'
678 <            jdl.write(req)
679 <                                                                                                                                                            
680 <        jdl.write('VirtualOrganisation = "' + self.VO + '";\n')
681 <
682 <        if ( self.EDG_retry_count ):              
683 <            jdl.write('RetryCount = '+self.EDG_retry_count+';\n')
684 <            pass
685 <
686 <        jdl.write('MyProxyServer = "' + self.proxyServer + '";\n')
687 <
688 <        jdl.close()
689 <        return
690 <    def createXMLSchScript(self, nj):
574 >        inp_sandbox = jbt.inputSandbox(index)
575 >        out_sandbox = jbt.outputSandbox(index)
576          """
577 <        Create a XML-file for BOSS4.
577 >        [end] da rivedere
578          """
579 <        job = common.job_list[nj]
695 <        jbt = job.type()
696 <        inp_sandbox = jbt.inputSandbox(nj)
697 <        out_sandbox = jbt.outputSandbox(nj)
579 >
580          
581          title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n'
582          jt_string = ''
# Line 708 | Line 590 | class SchedulerGlite(Scheduler):
590    
591          to_writeReq = ''
592          to_write = ''
593 +
594          req=' '
595 <        req = req + jbt.getRequirements()
595 >        req = req + jbt.getRequirements(nj)
596 >
597 >
598 >        #sites = common.jobDB.destination(nj)
599 >        #if len(sites)>0 and sites[0]!="Any":
600 >        #    req = req + ' && anyMatch(other.storage.CloseSEs, (_ITR4_))'
601 >        #req = req    
602 >    
603          if self.EDG_requirements:
604              if (req == ' '):
605                  req = req + self.EDG_requirements
# Line 747 | Line 637 | class SchedulerGlite(Scheduler):
637                  req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
638              else:
639                  req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
750        if (req != ' '):
751            req = req + '\n'
752            to_writeReq = req
640                                                                                                                                                              
754
641          if ( self.EDG_retry_count ):              
642              to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n'
643              pass
# Line 764 | Line 650 | class SchedulerGlite(Scheduler):
650          dir = string.split(common.work_space.topDir(), '/')
651          taskName = dir[len(dir)-2]
652  
653 <        if nj == 0:
654 <            xml.write(str(title))
655 <            xml.write('<task name="' +str(taskName)+'">\n')
770 <            xml.write(jt_string)
771 <            #Here it must pass the extra Tags.. (into Task & out of chain)  
772 <            if (to_writeReq != ''):
773 <                xml.write('<extraTags>\n')
774 <                xml.write('<Requirements>\n')
775 <                xml.write('<![CDATA[\n')
776 <                xml.write(to_writeReq)
777 <                xml.write(']]>\n')
778 <                xml.write('</Requirements>\n')
779 <                xml.write('</extraTags>\n')
780 <                pass
653 >        xml.write(str(title))
654 >        xml.write('<task name="' +str(taskName)+'">\n')
655 >        xml.write(jt_string)
656  
657 <            if (to_write != ''):
658 <                xml.write('<extraTags\n')
659 <                xml.write(to_write)
660 <                xml.write('/>\n')
657 >        xml.write('<iterator>\n')
658 >        xml.write('\t<iteratorRule name="ITR1">\n')
659 >        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ' </ruleElement>\n')
660 >        xml.write('\t</iteratorRule>\n')
661 >        xml.write('\t<iteratorRule name="ITR2">\n')
662 >        for arg in argsList:
663 >            xml.write('\t\t<ruleElement> <![CDATA[\n'+ arg + '\n\t\t]]> </ruleElement>\n')
664 >            pass
665 >        xml.write('\t</iteratorRule>\n')
666 >        #print jobList
667 >        xml.write('\t<iteratorRule name="ITR3">\n')
668 >        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ':1:6 </ruleElement>\n')
669 >        xml.write('\t</iteratorRule>\n')
670 >
671 >        '''
672 >        indy: qui sotto ci sta itr4
673 >        '''
674 >        
675 >        itr4=self.findSites_(nj)
676 >        #print "--->>> itr4 = ", itr4
677 >        if (itr4 != ''):
678 >            xml.write('\t<iteratorRule name="ITR4">\n')
679 >        #print argsList
680 >            for arg in itr4:
681 >                xml.write('\t\t<ruleElement> <![CDATA[\n'+ arg + '\n\t\t]]> </ruleElement>\n')
682                  pass
683 +            xml.write('\t</iteratorRule>\n')
684 +            req = req + ' && anyMatch(other.storage.CloseSEs, (_ITR4_))'
685              pass
686 <  
686 >        #    print "--->>> req= ", req        
687 >        
688 >        if (to_write != ''):
689 >            xml.write('<extraTags\n')
690 >            xml.write(to_write)
691 >            xml.write('/>\n')
692 >            pass
693 >
694          xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n')
695          xml.write(jt_string)
696  
697 +        if (req != ' '):
698 +            req = req + '\n'
699 +            xml.write('<extraTags>\n')
700 +            xml.write('<Requirements>\n')
701 +            xml.write('<![CDATA[\n')
702 +            xml.write(req)
703 +            xml.write(']]>\n')
704 +            xml.write('</Requirements>\n')
705 +            xml.write('</extraTags>\n')
706 +            pass
707 +
708          #executable
709 +
710 +        """
711 +        INDY
712 +        script dipende dal jobType: dovrebbe essere semplice tirarlo fuori in altro modo
713 +        """        
714          script = job.scriptFilename()
715 <        xml.write('<program exec="' + os.path.basename(script) +'"\n')
715 >        xml.write('<program>\n')
716 >        xml.write('<exec> ' + os.path.basename(script) +' </exec>\n')
717          xml.write(jt_string)
718      
719            
720          ### only one .sh  JDL has arguments:
721          ### Fabio
722 <        xml.write('args = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "GLITE") +'"\n')
723 <        xml.write('program_types="crabjob"\n')
724 <        inp_box = 'infiles="'
725 <        inp_box = inp_box + '' + script + ','
722 > #        xml.write('args = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'"\n')
723 >        xml.write('<args> <![CDATA[\n _ITR2_ \n]]> </args>\n')
724 >        xml.write('<program_types> crabjob </program_types>\n')
725 >        inp_box = script + ','
726  
727          if inp_sandbox != None:
728              for fl in inp_sandbox:
# Line 808 | Line 730 | class SchedulerGlite(Scheduler):
730                  pass
731              pass
732  
811        # Marco (VERY TEMPORARY ML STUFF)
733          inp_box = inp_box + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + ',' +\
734                    os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + ','+\
735                    os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + ','+\
736                    os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + ','+\
737                    os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py')
817        # End Marco
738  
739          if (not jbt.additional_inbox_files == []):
740              inp_box = inp_box + ', '
# Line 824 | Line 744 | class SchedulerGlite(Scheduler):
744                  pass
745  
746          if inp_box[-1] == ',' : inp_box = inp_box[:-1]
747 <        inp_box = inp_box + ' "\n'
747 >        inp_box = '<infiles> <![CDATA[\n' + inp_box + '\n]]> </infiles>\n'
748          xml.write(inp_box)
829
830        xml.write('stderr="' + job.stdout() + '"\n')
831        xml.write('stdout="' + job.stderr() + '"\n')
749          
750 +        base = jbt.name()
751 +        stdout = base + '__ITR3_.stdout'
752 +        stderr = base + '__ITR3_.stderr'
753 +        
754 +        xml.write('<stderr> ' + stderr + '</stderr>\n')
755 +        xml.write('<stdout> ' + stdout + '</stdout>\n')
756          
834        if job.stdout() == job.stderr():
835          out_box = 'outfiles="' + \
836                    job.stdout() + ',.BrokerInfo,'
837        else:
838          out_box = 'outfiles="' + \
839                    job.stdout() + ',' + \
840                    job.stderr() + ',.BrokerInfo,'
757  
758 +        out_box = stdout + ',' + \
759 +                  stderr + ',.BrokerInfo,'
760 +
761 +        """
762          if int(self.return_data) == 1:
763              if out_sandbox != None:
764                  for fl in out_sandbox:
# Line 846 | Line 766 | class SchedulerGlite(Scheduler):
766                      pass
767                  pass
768              pass
769 <                                                                                                                                                            
769 >        """
770 >
771 >        """
772 >        INDY
773 >        qualcosa del genere andrebbe fatta per gli infiles
774 >        """        
775 >        if int(self.return_data) == 1:
776 >            for fl in jbt.output_file:
777 >                out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ','
778 >                pass
779 >            pass
780 >
781          if out_box[-1] == ',' : out_box = out_box[:-1]
782 <        out_box = out_box + '"'
783 <        xml.write(out_box+'\n')
782 >        out_box = '<outfiles> <![CDATA[\n' + out_box + '\n]]></outfiles>\n'
783 >        xml.write(out_box)
784  
785 <        xml.write('group="'+taskName+'"\n')
855 <        xml.write('BossAttr="[crabjob.INTERNAL_ID=' + str(nj+1) +']"\n')
785 >        xml.write('<BossAttr> crabjob.INTERNAL_ID=_ITR1_ </BossAttr>\n')
786  
787 <        
858 <      
859 <        xml.write('/>\n')
787 >        xml.write('</program>\n')
788          xml.write('</chain>\n')
789  
790 <        if int(nj) == int(common.jobDB.nJobs()-1): xml.write('</task>\n')
791 <
790 >        xml.write('</iterator>\n')
791 >        xml.write('</task>\n')
792  
793          xml.close()
866
794          return
795  
869
870
796      def checkProxy(self):
797          """
798          Function to check the Globus proxy.
# Line 878 | Line 803 | class SchedulerGlite(Scheduler):
803  
804          minTimeLeftServer = 100 # in hours
805  
881        #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
882        #cmd = 'voms-proxy-info -timeleft'
806          mustRenew = 0
807          timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null')
808          timeLeftServer = -999
# Line 904 | Line 827 | class SchedulerGlite(Scheduler):
827              except:
828                  msg = "Unable to create a valid proxy!\n"
829                  raise CrabException(msg)
907            # cmd = 'grid-proxy-info -timeleft'
908            # cmd_out = runCommand(cmd,0,20)
830              pass
831  
832          ## now I do have a voms proxy valid, and I check the myproxy server
# Line 918 | Line 839 | class SchedulerGlite(Scheduler):
839          else:
840              # if myproxy exist but not long enough, renew
841              reTime = re.compile( r'timeleft: (\d+)' )
921            #print "<"+str(reTime.search( cmd_out ).group(1))+">"
842              if reTime.match( cmd_out ):
843                  time = reTime.search( line ).group(1)
844                  if time < minTimeLeftServer:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines