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.45 by spiga, Tue Mar 28 07:38:37 2006 UTC vs.
Revision 1.76 by mkirn, Fri Jul 28 18:51:44 2006 UTC

# Line 2 | Line 2 | from Scheduler import Scheduler
2   from crab_logger import Logger
3   from crab_exceptions import *
4   from crab_util import *
5 + from EdgConfig import *
6   import common
7  
8   import os, sys, time
# Line 21 | Line 22 | class SchedulerEdg(Scheduler):
22  
23      def configure(self, cfg_params):
24  
25 <        try: self.edg_config = cfg_params["EDG.config"]
26 <        except KeyError: self.edg_config = ''
25 >        try:
26 >            RB = cfg_params["EDG.rb"]
27 >            edgConfig = EdgConfig(RB)
28 >            self.edg_config = edgConfig.config()
29 >            self.edg_config_vo = edgConfig.configVO()
30 >        except KeyError:
31 >            self.edg_config = ''
32 >            self.edg_config_vo = ''
33  
34 <        try: self.edg_config_vo = cfg_params["EDG.config_vo"]
35 <        except KeyError: self.edg_config_vo = ''
34 >        try:
35 >            self.proxyServer = cfg_params["EDG.proxy_server"]
36 >        except KeyError:
37 >            self.proxyServer = 'myproxy.cern.ch'
38 >        common.logger.debug(5,'Setting myproxy server to '+self.proxyServer)
39  
40          try: self.LCG_version = cfg_params["EDG.lcg_version"]
41          except KeyError: self.LCG_version = '2'
# Line 36 | Line 46 | class SchedulerEdg(Scheduler):
46          try: self.EDG_retry_count = cfg_params['EDG.retry_count']
47          except KeyError: self.EDG_retry_count = ''
48  
49 +        try:
50 +            self.EDG_ce_black_list = cfg_params['EDG.ce_black_list']
51 +            #print "self.EDG_ce_black_list = ", self.EDG_ce_black_list
52 +        except KeyError:
53 +            self.EDG_ce_black_list  = ''
54 +
55 +        try:
56 +            self.EDG_ce_white_list = cfg_params['EDG.ce_white_list']
57 +            #print "self.EDG_ce_white_list = ", self.EDG_ce_white_list
58 +        except KeyError: self.EDG_ce_white_list = ''
59 +
60          try: self.VO = cfg_params['EDG.virtual_organization']
61          except KeyError: self.VO = 'cms'
62  
63 +        try: self.return_data = cfg_params['USER.return_data']
64 +        except KeyError: self.return_data = 1
65 +
66          try:
67               self.copy_input_data = common.analisys_common_info['copy_input_data']
68               #print "self.copy_input_data = ", self.copy_input_data
69          except KeyError: self.copy_input_data = 0
70  
47        try: self.return_data = cfg_params['USER.return_data']
48        except KeyError: self.return_data = 1
49
71          try:
72              self.copy_data = cfg_params["USER.copy_data"]
73              if int(self.copy_data) == 1:
# Line 131 | Line 152 | class SchedulerEdg(Scheduler):
152          sys.path.append(libPath)
153  
154          self.proxyValid=0
155 +
156 +        try:
157 +            self._taskId = cfg_params['taskId']
158 +        except:
159 +            self._taskId = ''
160 +
161          return
162      
163  
# Line 153 | Line 180 | class SchedulerEdg(Scheduler):
180          """
181          Returns part of a job script which does scheduler-specific work.
182          """
156
183          txt = ''
184 +        txt += '# strip arguments\n'
185 +        txt += 'echo "strip arguments"\n'
186 +        txt += 'args=("$@")\n'
187 +        txt += 'nargs=$#\n'
188 +        txt += 'shift $nargs\n'
189 +        txt += "# job number (first parameter for job wrapper)\n"
190 +        #txt += "NJob=$1\n"
191 +        txt += "NJob=${args[0]}\n"
192 +
193 +        txt += '# job identification to DashBoard \n'
194 +        txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n'
195 +        txt += 'SyncGridJobId=`echo $EDG_WL_JOBID`\n'
196 +        txt += 'MonitorID=`echo ' + self._taskId + '`\n'
197 +        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
198 +        txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
199 +        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
200 +
201 +        txt += 'echo "middleware discovery " \n'
202 +        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'
208 +        txt += '    middleware=OSG \n'
209 +        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
210 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
211 +        txt += '    echo "middleware =$middleware" \n'
212 +        txt += 'elif [ $OSG_APP ]; then \n'
213 +        txt += '    middleware=OSG \n'
214 +        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
215 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
216 +        txt += '    echo "middleware =$middleware" \n'
217 +        txt += 'else \n'
218 +        txt += '    echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
219 +        txt += '    echo "JOB_EXIT_STATUS = 10030" \n'
220 +        txt += '    echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n'
221 +        txt += '    dumpStatus $RUNTIME_AREA/$repo \n'
222 +        txt += '    rm -f $RUNTIME_AREA/$repo \n'
223 +        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
224 +        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
225 +        txt += '    exit 1 \n'
226 +        txt += 'fi \n'
227 +
228 +        txt += '# report first time to DashBoard \n'
229 +        txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
230 +        txt += 'rm -f $RUNTIME_AREA/$repo \n'
231 +        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
232 +        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
233 +        
234 +        txt += '\n\n'
235 +
236          if int(self.copy_data) == 1:
237             if self.SE:
238                txt += 'export SE='+self.SE+'\n'
# Line 163 | Line 241 | class SchedulerEdg(Scheduler):
241                if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
242                txt += 'export SE_PATH='+self.SE_PATH+'\n'
243                txt += 'echo "SE_PATH = $SE_PATH"\n'
244 <                                                                                                                                                            
244 >
245          txt += 'export VO='+self.VO+'\n'
246          ### FEDE: add some line for LFC catalog setting
247 <        txt += 'if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
248 <        txt += '   export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
249 <        txt += 'fi\n'
250 <        txt += 'if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
251 <        txt += 'export LFC_HOST='+self.lfc_host+'\n'
252 <        txt += 'fi\n'
253 <        txt += 'if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
254 <        txt += 'export LFC_HOME='+self.lfc_home+'\n'
247 >        txt += 'if [ $middleware == LCG ]; then \n'
248 >        txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
249 >        txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
250 >        txt += '    fi\n'
251 >        txt += '    if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
252 >        txt += '        export LFC_HOST='+self.lfc_host+'\n'
253 >        txt += '    fi\n'
254 >        txt += '    if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
255 >        txt += '        export LFC_HOME='+self.lfc_home+'\n'
256 >        txt += '    fi\n'
257 >        txt += 'elif [ $middleware == OSG ]; then\n'
258 >        txt += '    echo "LFC catalog setting to be implemented for OSG"\n'
259          txt += 'fi\n'
260          #####
261          if int(self.register_data) == 1:
262 <           txt += 'export LFN='+self.LFN+'\n'
263 <           txt += 'lfc-ls $LFN\n'
264 <           txt += 'result=$?\n'
265 <           txt += 'echo $result\n'
262 >           txt += 'if [ $middleware == LCG ]; then \n'
263 >           txt += '    export LFN='+self.LFN+'\n'
264 >           txt += '    lfc-ls $LFN\n'
265 >           txt += '    result=$?\n'
266 >           txt += '    echo $result\n'
267             ### creation of LFN dir in LFC catalog, under /grid/cms dir  
268 <           txt += 'if [ $result != 0 ]; then\n'
269 <           txt += '   lfc-mkdir $LFN\n'
270 <           txt += '   result=$?\n'
271 <           txt += '   echo $result\n'
268 >           txt += '    if [ $result != 0 ]; then\n'
269 >           txt += '       lfc-mkdir $LFN\n'
270 >           txt += '       result=$?\n'
271 >           txt += '       echo $result\n'
272 >           txt += '    fi\n'
273 >           txt += 'elif [ $middleware == OSG ]; then\n'
274 >           txt += '    echo " Files registration to be implemented for OSG"\n'
275             txt += 'fi\n'
276             txt += '\n'
277 <        txt += 'CloseCEs=`edg-brokerinfo getCE`\n'
278 <        txt += 'echo "CloseCEs = $CloseCEs"\n'
279 <        txt += 'CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
280 <        txt += 'echo "CE = $CE"\n'
277 >
278 >           if self.VO:
279 >              txt += 'export VO='+self.VO+'\n'
280 >           if self.LFN:
281 >              txt += 'if [ $middleware == LCG ]; then \n'
282 >              txt += '    export LFN='+self.LFN+'\n'
283 >              txt += 'fi\n'
284 >              txt += '\n'
285 >
286 >        txt += 'if [ $middleware == LCG ]; then\n'
287 >        txt += '    CloseCEs=`edg-brokerinfo getCE`\n'
288 >        txt += '    echo "CloseCEs = $CloseCEs"\n'
289 >        txt += '    CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
290 >        txt += '    echo "CE = $CE"\n'
291 >        txt += 'elif [ $middleware == OSG ]; then \n'
292 >        txt += '    if [ $OSG_JOB_CONTACT ]; then \n'
293 > #        txt += '        CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n'
294 >        txt += '        CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print ${args[0]}}\'` \n'
295 >        txt += '    else \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'
306 >
307          return txt
308  
309      def wsCopyInput(self):
# Line 204 | Line 316 | class SchedulerEdg(Scheduler):
316              #print "self.copy_input_data = ", self.copy_input_data
317          except KeyError: self.copy_input_data = 0
318          if int(self.copy_input_data) == 1:
319 <           txt += '#\n'
320 <           txt += '#   Copy Input Data from SE to this WN\n'
321 <           txt += '#\n'
319 >        ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
320 >           txt += 'if [ $middleware == OSG ]; then\n'
321 >           txt += '   #\n'
322 >           txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
323 >           txt += '   #\n'
324 >           txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
325 >           txt += 'elif [ $middleware == LCG ]; then \n'
326 >           txt += '   #\n'
327 >           txt += '   #   Copy Input Data from SE to this WN\n'
328 >           txt += '   #\n'
329   ### changed by georgia (put a loop copying more than one input files per jobs)          
330 <           txt +='for input_file in $cur_file_list \n'
331 <           txt +='do \n'
332 <           txt +=' lcg-cp --vo $VO lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
333 <           txt +=' copy_input_exit_status=$?\n'
334 <           txt +=' echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
335 <           txt +=' if [ $copy_input_exit_status -ne 0 ]; then \n'
336 <           txt +='    echo "Problems with copying to WN" \n'
337 <           txt +=' else \n'
338 <           txt +='    echo "input copied into WN" \n'
339 <           txt +=' fi \n'
340 <           txt +='done \n'
330 >           txt += '   for input_file in $cur_file_list \n'
331 >           txt += '   do \n'
332 >           #### FEDE
333 >           #txt += '      echo "which lcg-cp" \n'
334 >           #txt += '      which lcg-cp \n'
335 >           #########
336 >           txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
337 >           txt += '      copy_input_exit_status=$?\n'
338 >           txt += '      echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
339 >           txt += '      if [ $copy_input_exit_status -ne 0 ]; then \n'
340 >           txt += '         echo "Problems with copying to WN" \n'
341 >           txt += '      else \n'
342 >           txt += '         echo "input copied into WN" \n'
343 >           txt += '      fi \n'
344 >           txt += '   done \n'
345   ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
346 <           txt +='for file in $cur_pu_list \n'
347 <           txt +='do \n'
348 <           txt +=' lcg-cp --vo $VO lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
349 <           txt +=' copy_input_exit_status=$?\n'
350 <           txt +=' echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
351 <           txt +=' if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
352 <           txt +='    echo "Problems with copying pu to WN" \n'
353 <           txt +=' else \n'
354 <           txt +='    echo "input pu files copied into WN" \n'
355 <           txt +=' fi \n'
356 <           txt +='done \n'
357 <           txt +='\n'
358 <           txt +='### Check SCRATCH space available on WN : \n'
359 <           txt +='df -h \n'
346 >           txt += '   for file in $cur_pu_list \n'
347 >           txt += '   do \n'
348 >           #### FEDE
349 >           #txt += '      echo "which lcg-cp" \n'
350 >           #txt += '      which lcg-cp \n'
351 >           #########
352 >           txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
353 >           txt += '      copy_input_pu_exit_status=$?\n'
354 >           txt += '      echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
355 >           txt += '      if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
356 >           txt += '         echo "Problems with copying pu to WN" \n'
357 >           txt += '      else \n'
358 >           txt += '         echo "input pu files copied into WN" \n'
359 >           txt += '      fi \n'
360 >           txt += '   done \n'
361 >           txt += '   \n'
362 >           txt += '   ### Check SCRATCH space available on WN : \n'
363 >           txt += '   df -h \n'
364 >           txt += 'fi \n'
365 >          
366          return txt
367  
368      def wsCopyOutput(self):
# Line 246 | Line 375 | class SchedulerEdg(Scheduler):
375             txt += '#\n'
376             txt += '#   Copy output to SE = $SE\n'
377             txt += '#\n'
378 <           txt += 'if [ $exe_result -eq 0 ]; then\n'
378 >           #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'
382 >           txt += '        source $OSG_APP/glite/setup_glite_ui.sh\n'
383 >           txt += '        export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n'
384 >           txt += '        echo "export X509_CERT_DIR=$X509_CERT_DIR"\n'
385 >           txt += '    fi \n'
386             txt += '    for out_file in $file_list ; do\n'
387 <           txt += '        echo "Trying to copy output file to $SE "\n'
388 <           txt += '        echo "lcg-cp --vo cms -t 1200 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
389 < #           txt += '        echo "globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
254 <           txt += '        exitstring=`lcg-cp --vo cms -t 1200 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
255 < #           txt += '        exitstring=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
387 >           txt += '        echo "Trying to copy output file to $SE using lcg-cp"\n'
388 >           txt += '        echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
389 >           txt += '        exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
390             txt += '        copy_exit_status=$?\n'
391 <           txt += '        echo "COPY_EXIT_STATUS = $copy_exit_status"\n'
391 >           txt += '        echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
392             txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
393             txt += '        if [ $copy_exit_status -ne 0 ]; then\n'
394 <           txt += '            echo "Problems with SE = $SE"\n'
394 >           txt += '            echo "Possible problem with SE = $SE"\n'
395             txt += '            echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
396             txt += '            echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
397 +           txt += '            echo "lcg-cp failed, attempting srmcp"\n'
398 +           txt += '            echo "mkdir -p $HOME/.srmconfig"\n'
399 +           txt += '            mkdir -p $HOME/.srmconfig\n'
400 +           txt += '            if [ $middleware == LCG ]; then\n'
401 +           txt += '               echo "srmcp -retry_num 5 -retry_timeout 480000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
402 +           txt += '               exitstring=`srmcp -retry_num 5 -retry_timeout 480000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
403 +           txt += '            elif [ $middleware == OSG ]; then\n'
404 +           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'
405 +           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'
406 +           txt += '            fi \n'
407 +           txt += '            copy_exit_status=$?\n'
408 +           txt += '            echo "COPY_EXIT_STATUS for srm = $copy_exit_status"\n'
409 +           txt += '            echo "STAGE_OUT = $copy_exit_status"\n'
410 +           txt += '            if [ $copy_exit_status -ne 0 ]; then\n'
411 +           txt += '               echo "Problems with SE = $SE"\n'
412 +           txt += '               echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
413 +           txt += '               echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
414 +           txt += '               echo "lcg-cp and srm failed"\n'
415 +           txt += '               echo "If storage_path in your config file contains a ? you may need a \? instead."\n'
416 +           txt += '            else\n'
417 +           txt += '               echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
418 +           txt += '               echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
419 +           txt += '               echo "output copied into $SE/$SE_PATH directory"\n'
420 +           txt += '               echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
421 +           txt += '               echo "srmcp succeeded"\n'
422 +           txt += '            fi\n'
423             txt += '        else\n'
424             txt += '            echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
425             txt += '            echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
426             txt += '            echo "output copied into $SE/$SE_PATH directory"\n'
427             txt += '            echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
428 +           txt += '            echo "lcg-cp succeeded"\n'
429             txt += '         fi\n'
430             txt += '     done\n'
431 <           txt += 'fi\n'
431 >           #txt += 'fi\n'
432          return txt
433  
434      def wsRegisterOutput(self):
# Line 277 | Line 438 | class SchedulerEdg(Scheduler):
438  
439          txt = ''
440          if int(self.register_data) == 1:
441 +        ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
442 +           txt += 'if [ $middleware == OSG ]; then\n'
443 +           txt += '   #\n'
444 +           txt += '   #   Register output to LFC deactivated in OSG mode\n'
445 +           txt += '   #\n'
446 +           txt += '   echo "Register output to LFC deactivated in OSG mode"\n'
447 +           txt += 'elif [ $middleware == LCG ]; then \n'
448             txt += '#\n'
449             txt += '#  Register output to LFC\n'
450             txt += '#\n'
451 <           txt += 'if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
452 <           txt += '   for out_file in $file_list ; do\n'
453 <           txt += '      echo "Trying to register the output file into LFC"\n'
454 <           txt += '      echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n'
455 <           txt += '      lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n'
456 <           txt += '      register_exit_status=$?\n'
457 <           txt += '      echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
458 <           txt += '      echo "STAGE_OUT = $register_exit_status"\n'
459 <           txt += '      if [ $register_exit_status -ne 0 ]; then \n'
460 <           txt += '         echo "Problems with the registration to LFC" \n'
293 <           txt += '         echo "Try with srm protocol" \n'
294 <           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n'
295 <           txt += '         lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n'
451 >           #txt += '   if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
452 >           txt += '   if [ $copy_exit_status -eq 0 ]; then\n'
453 >           txt += '      for out_file in $file_list ; do\n'
454 >           txt += '         echo "Trying to register the output file into LFC"\n'
455 >           #### FEDE
456 >           #txt += '         echo "which lcg-rf" \n'
457 >           #txt += '         which lcg-rf \n'
458 >           #########
459 >           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n'
460 >           txt += '         lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n'
461             txt += '         register_exit_status=$?\n'
462             txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
463             txt += '         echo "STAGE_OUT = $register_exit_status"\n'
464             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
465 <           txt += '            echo "Problems with the registration into LFC" \n'
465 >           txt += '            echo "Problems with the registration to LFC" \n'
466 >           txt += '            echo "Try with srm protocol" \n'
467 >           #### FEDE
468 >           #txt += '            echo "which lcg-rf" \n'
469 >           #txt += '            which lcg-rf \n'
470 >           #########
471 >           txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n'
472 >           txt += '            lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n'
473 >           txt += '            register_exit_status=$?\n'
474 >           txt += '            echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
475 >           txt += '            echo "STAGE_OUT = $register_exit_status"\n'
476 >           txt += '            if [ $register_exit_status -ne 0 ]; then \n'
477 >           txt += '               echo "Problems with the registration into LFC" \n'
478 >           txt += '            fi \n'
479 >           txt += '         else \n'
480 >           txt += '            echo "output registered to LFC"\n'
481             txt += '         fi \n'
482 <           txt += '      else \n'
483 <           txt += '         echo "output registered to LFC"\n'
484 <           txt += '      fi \n'
485 <           txt += '      echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
486 <           txt += '   done\n'
487 <           txt += 'elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
488 <           txt += '   echo "Trying to copy output file to CloseSE"\n'
489 <           txt += '   CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
490 <           txt += '   for out_file in $file_list ; do\n'
491 <           txt += '      echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n'
492 <           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'
493 <           txt += '      register_exit_status=$?\n'
494 <           txt += '      echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
495 <           txt += '      echo "STAGE_OUT = $register_exit_status"\n'
496 <           txt += '      if [ $register_exit_status -ne 0 ]; then \n'
497 <           txt += '         echo "Problems with CloseSE" \n'
498 <           txt += '      else \n'
499 <           txt += '         echo "The program was successfully executed"\n'
500 <           txt += '         echo "SE = $CLOSE_SE"\n'
501 <           txt += '         echo "LFN for the file is LFN=${LFN}/$out_file"\n'
502 <           txt += '      fi \n'
503 <           txt += '      echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
504 <           txt += '   done\n'
505 <           txt += 'else\n'
506 <           txt += '   echo "Problem with the executable"\n'
482 >           txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
483 >           txt += '      done\n'
484 >           #txt += '   elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
485 >           txt += '   else \n'
486 >           txt += '      echo "Trying to copy output file to CloseSE"\n'
487 >           txt += '      CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
488 >           txt += '      for out_file in $file_list ; do\n'
489 >           #### FEDE
490 >           #txt += '         echo "which lcg-cr" \n'
491 >           #txt += '         which lcg-cr \n'
492 >           #########
493 >           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'
494 >           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'
495 >           txt += '         register_exit_status=$?\n'
496 >           txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
497 >           txt += '         echo "STAGE_OUT = $register_exit_status"\n'
498 >           txt += '         if [ $register_exit_status -ne 0 ]; then \n'
499 >           txt += '            echo "Problems with CloseSE or Catalog" \n'
500 >           txt += '         else \n'
501 >           txt += '            echo "The program was successfully executed"\n'
502 >           txt += '            echo "SE = $CLOSE_SE"\n'
503 >           txt += '            echo "LFN for the file is LFN=${LFN}/$out_file"\n'
504 >           txt += '         fi \n'
505 >           txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
506 >           txt += '      done\n'
507 >           #txt += '   else\n'
508 >           #txt += '      echo "Problem with the executable"\n'
509 >           txt += '   fi \n'
510 >           txt += '   exit_status=$register_exit_status\n'
511             txt += 'fi \n'
512          return txt
513  
# Line 344 | Line 528 | class SchedulerEdg(Scheduler):
528          self.checkProxy()
529          jdl = common.job_list[nj].jdlFilename()
530          cmd = 'edg-job-list-match ' + self.configOpt_() + jdl
531 <        cmd_out = runCommand(cmd,0,10)
531 >        cmd_out = runCommand(cmd,0,45)
532          if not cmd_out:
533              raise CrabException("ERROR: "+cmd+" failed!")
534  
# Line 405 | Line 589 | class SchedulerEdg(Scheduler):
589          [sites.append(it) for it in CEs if not sites.count(it)]
590  
591          common.logger.debug(5,"All Sites :"+str(sites))
592 +        common.logger.message("Matched Sites :"+str(sites))
593          return len(sites)
594  
595      def noMatchFound_(self, jdl):
# Line 501 | Line 686 | class SchedulerEdg(Scheduler):
686  
687          # Determine the output directory name
688          dir = common.work_space.resDir()
689 <        dir += os.getlogin()
689 >        dir += os.environ['USER']
690          dir += '_' + os.path.basename(id)
691          return dir
692  
# Line 541 | Line 726 | class SchedulerEdg(Scheduler):
726          jdl.write(jt_string)
727  
728          ### only one .sh  JDL has arguments:
544        firstEvent = common.jobDB.firstEvent(nj)
545        maxEvents = common.jobDB.maxEvents(nj)
546        jdl.write('Arguments = "' + str(nj+1)+' '+str(firstEvent)+' '+str(maxEvents)+'";\n')
729  
730 +        ### Fabio
731 +        jdl.write('Arguments = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'";\n')
732          inp_box = 'InputSandbox = { '
733          inp_box = inp_box + '"' + script + '",'
734  
# Line 559 | Line 743 | class SchedulerEdg(Scheduler):
743  
744          # Marco (VERY TEMPORARY ML STUFF)
745          inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\
746 +                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + '", "'+\
747                    os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\
748                    os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\
749                    os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"'
# Line 601 | Line 786 | class SchedulerEdg(Scheduler):
786  
787  
788          req='Requirements = '
789 +        noreq=req
790          req = req + jbt.getRequirements()
605 #        ### if at least a CE exists ...
606 #        if common.analisys_common_info['sites']:
607 #           if common.analisys_common_info['sw_version']:
608 #                req='Requirements = '
609 #                req=req + 'Member("VO-cms-' + \
610 #                     common.analisys_common_info['sw_version'] + \
611 #                     '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
612 #            if len(common.analisys_common_info['sites'])>0:
613 #                req = req + ' && ('
614 #                for i in range(len(common.analisys_common_info['sites'])):
615 #                    req = req + 'other.GlueCEInfoHostName == "' \
616 #                         + common.analisys_common_info['sites'][i] + '"'
617 #                    if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ):
618 #                        req = req + ' || '
619 #            req = req + ')'
791          #### and USER REQUIREMENT
792          if self.EDG_requirements:
793 <            if (req == 'Requirement = '):
794 <                req = req + self.EDG_requirements
795 <            else:
796 <                req = req +  ' && ' + self.EDG_requirements
793 >            if (req != noreq):
794 >                req = req +  ' && '
795 >            req = req + self.EDG_requirements
796 >        #### FEDE #####
797 >        if self.EDG_ce_white_list:
798 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
799 >            #print "req = ", req
800 >            for i in range(len(ce_white_list)):
801 >                if i == 0:
802 >                    if (req != noreq):
803 >                        req = req +  ' && '
804 >                    req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
805 >                    pass
806 >                else:
807 >                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
808 >            req = req + ')'
809 >        
810 >        if self.EDG_ce_black_list:
811 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
812 >            for ce in ce_black_list:
813 >                if (req != noreq):
814 >                    req = req +  ' && '
815 >                req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
816 >                pass
817 >
818 >        ###############
819 >        clockTime=480
820          if self.EDG_clock_time:
821 <            if (req == 'Requirement = '):
822 <                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
823 <            else:
824 <                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
825 <                
821 >            clockTime= self.EDG_clock_time
822 >        if (req != noreq):
823 >            req = req + ' && '
824 >        req = req + '((other.GlueCEPolicyMaxWallClockTime == 0) || (other.GlueCEPolicyMaxWallClockTime>='+str(clockTime)+'))'
825 >
826 >        cpuTime=1000
827          if self.EDG_cpu_time:
828 <            if (req == 'Requirement = '):
829 <                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
830 <            else:
831 <                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
832 <        if (req != 'Requirement = '):
828 >            cpuTime=self.EDG_cpu_time
829 >        if (req != noreq):
830 >            req = req + ' && '
831 >        req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))'
832 >
833 >        if (req != noreq):
834              req = req + ';\n'
835              jdl.write(req)
836                                                                                                                                                              
# Line 644 | Line 840 | class SchedulerEdg(Scheduler):
840              jdl.write('RetryCount = '+self.EDG_retry_count+';\n')
841              pass
842  
843 +        jdl.write('MyProxyServer = "' + self.proxyServer + '";\n')
844 +
845          jdl.close()
846          return
847  
# Line 653 | Line 851 | class SchedulerEdg(Scheduler):
851          """
852          if (self.proxyValid): return
853          timeleft = -999
854 <        minTimeLeft=10 # in hours
855 <        cmd = 'grid-proxy-info -e -v '+str(minTimeLeft)+':00'
856 <        # SL Here I have to use os.system since the stupid command exit with >0 if no valid proxy is found
857 <        cmd_out = os.system(cmd)
858 <        if (cmd_out>0):
859 <            common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 100h\n")
860 <            cmd = 'grid-proxy-init -valid 100:00'
854 >        minTimeLeft=10*3600 # in seconds
855 >
856 >        minTimeLeftServer = 100 # in hours
857 >
858 >        #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
859 >        #cmd = 'voms-proxy-info -timeleft'
860 >        mustRenew = 0
861 >        timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null')
862 >        timeLeftServer = -999
863 >        if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal):
864 >            mustRenew = 1
865 >        else:
866 >            timeLeftServer = runCommand('voms-proxy-info -actimeleft 2>/dev/null | head -1')
867 >            if not timeLeftServer or not isInt(timeLeftServer):
868 >                mustRenew = 1
869 >            elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft:
870 >                mustRenew = 1
871 >            pass
872 >        pass
873 >
874 >        if mustRenew:
875 >            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")
876 >            cmd = 'voms-proxy-init -voms cms -valid 96:00'
877              try:
878                  # SL as above: damn it!
879                  out = os.system(cmd)
# Line 670 | Line 884 | class SchedulerEdg(Scheduler):
884              # cmd = 'grid-proxy-info -timeleft'
885              # cmd_out = runCommand(cmd,0,20)
886              pass
887 +
888 +        ## now I do have a voms proxy valid, and I check the myproxy server
889 +        renewProxy = 0
890 +        cmd = 'myproxy-info -d -s '+self.proxyServer
891 +        cmd_out = runCommand(cmd,0,20)
892 +        if not cmd_out:
893 +            common.logger.message('No credential delegated to myproxy server '+self.proxyServer+' will do now')
894 +            renewProxy = 1
895 +        else:
896 +            # if myproxy exist but not long enough, renew
897 +            reTime = re.compile( r'timeleft: (\d+)' )
898 +            #print "<"+str(reTime.search( cmd_out ).group(1))+">"
899 +            if reTime.match( cmd_out ):
900 +                time = reTime.search( line ).group(1)
901 +                if time < minTimeLeftServer:
902 +                    renewProxy = 1
903 +                    common.logger.message('No credential delegation will expire in '+time+' hours: renew it')
904 +                pass
905 +            pass
906 +        
907 +        # if not, create one.
908 +        if renewProxy:
909 +            cmd = 'myproxy-init -d -n -s '+self.proxyServer
910 +            out = os.system(cmd)
911 +            if (out>0):
912 +                raise CrabException("Unable to delegate the proxy to myproxyserver "+self.proxyServer+" !\n")
913 +            pass
914 +
915 +        # cache proxy validity
916          self.proxyValid=1
917          return
918 <    
918 >
919      def configOpt_(self):
920          edg_ui_cfg_opt = ' '
921          if self.edg_config:
922 <          edg_ui_cfg_opt = ' -c ' + self.edg_config + ' '
922 >            edg_ui_cfg_opt = ' -c ' + self.edg_config + ' '
923          if self.edg_config_vo:
924 <          edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' '
924 >            edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' '
925          return edg_ui_cfg_opt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines