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.31 by slacapra, Tue Dec 6 13:18:48 2005 UTC vs.
Revision 1.80 by slacapra, Wed Sep 20 17:29:52 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:
41 +            self.role = cfg_params["EDG.rb"]
42 +        except KeyError:
43 +            self.role = None
44 +            
45 +        try:
46 +            self.role = cfg_params["EDG.role"]
47 +        except KeyError:
48 +            self.role = None
49 +            
50          try: self.LCG_version = cfg_params["EDG.lcg_version"]
51          except KeyError: self.LCG_version = '2'
52  
# Line 36 | Line 56 | class SchedulerEdg(Scheduler):
56          try: self.EDG_retry_count = cfg_params['EDG.retry_count']
57          except KeyError: self.EDG_retry_count = ''
58  
59 +        try:
60 +            self.EDG_ce_black_list = cfg_params['EDG.ce_black_list']
61 +            #print "self.EDG_ce_black_list = ", self.EDG_ce_black_list
62 +        except KeyError:
63 +            self.EDG_ce_black_list  = ''
64 +
65 +        try:
66 +            self.EDG_ce_white_list = cfg_params['EDG.ce_white_list']
67 +            #print "self.EDG_ce_white_list = ", self.EDG_ce_white_list
68 +        except KeyError: self.EDG_ce_white_list = ''
69 +
70          try: self.VO = cfg_params['EDG.virtual_organization']
71          except KeyError: self.VO = 'cms'
72  
73          try: self.return_data = cfg_params['USER.return_data']
74          except KeyError: self.return_data = 1
75  
76 +        try:
77 +             self.copy_input_data = common.analisys_common_info['copy_input_data']
78 +             #print "self.copy_input_data = ", self.copy_input_data
79 +        except KeyError: self.copy_input_data = 0
80 +
81          try:
82              self.copy_data = cfg_params["USER.copy_data"]
83              if int(self.copy_data) == 1:
# Line 59 | Line 95 | class SchedulerEdg(Scheduler):
95             msg = 'Warning: return_data = 0 and copy_data = 0 ==> your exe output will be lost\n'
96             msg = msg + 'Please modify return_data and copy_data value in your crab.cfg file\n'
97             raise CrabException(msg)
98 +
99 +        try:
100 +            self.lfc_host = cfg_params['EDG.lfc_host']
101 +        except KeyError:
102 +            msg = "Error. The [EDG] section does not have 'lfc_host' value"
103 +            msg = msg + " it's necessary to know the LFC host name"
104 +            common.logger.message(msg)
105 +            raise CrabException(msg)
106 +        try:
107 +            self.lcg_catalog_type = cfg_params['EDG.lcg_catalog_type']
108 +        except KeyError:
109 +            msg = "Error. The [EDG] section does not have 'lcg_catalog_type' value"
110 +            msg = msg + " it's necessary to know the catalog type"
111 +            common.logger.message(msg)
112 +            raise CrabException(msg)
113 +        try:
114 +            self.lfc_home = cfg_params['EDG.lfc_home']
115 +        except KeyError:
116 +            msg = "Error. The [EDG] section does not have 'lfc_home' value"
117 +            msg = msg + " it's necessary to know the home catalog dir"
118 +            common.logger.message(msg)
119 +            raise CrabException(msg)
120        
121          try:
122              self.register_data = cfg_params["USER.register_data"]
# Line 67 | Line 125 | class SchedulerEdg(Scheduler):
125                      self.LFN = cfg_params['USER.lfn_dir']
126                  except KeyError:
127                      msg = "Error. The [USER] section does not have 'lfn_dir' value"
128 <                    msg = msg + " it's necessary for RLS registration"
128 >                    msg = msg + " it's necessary for LCF registration"
129                      common.logger.message(msg)
130                      raise CrabException(msg)
131          except KeyError: self.register_data = 0
# Line 104 | Line 162 | class SchedulerEdg(Scheduler):
162          sys.path.append(libPath)
163  
164          self.proxyValid=0
165 +
166 +        try:
167 +            self._taskId = cfg_params['taskId']
168 +        except:
169 +            self._taskId = ''
170 +
171          return
172      
173  
# Line 126 | Line 190 | class SchedulerEdg(Scheduler):
190          """
191          Returns part of a job script which does scheduler-specific work.
192          """
129
193          txt = ''
194 +        txt += '# strip arguments\n'
195 +        txt += 'echo "strip arguments"\n'
196 +        txt += 'args=("$@")\n'
197 +        txt += 'nargs=$#\n'
198 +        txt += 'shift $nargs\n'
199 +        txt += "# job number (first parameter for job wrapper)\n"
200 +        #txt += "NJob=$1\n"
201 +        txt += "NJob=${args[0]}\n"
202 +
203 +        txt += '# job identification to DashBoard \n'
204 +        txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n'
205 +        txt += 'SyncGridJobId=`echo $EDG_WL_JOBID`\n'
206 +        txt += 'MonitorID=`echo ' + self._taskId + '`\n'
207 +        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
208 +        txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
209 +        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
210 +
211 +        txt += 'echo "middleware discovery " \n'
212 +        txt += 'if [ $VO_CMS_SW_DIR ]; then \n'
213 +        txt += '    middleware=LCG \n'
214 +        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | 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 += 'elif [ $GRID3_APP_DIR ]; then\n'
218 +        txt += '    middleware=OSG \n'
219 +        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
220 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
221 +        txt += '    echo "middleware =$middleware" \n'
222 +        txt += 'elif [ $OSG_APP ]; then \n'
223 +        txt += '    middleware=OSG \n'
224 +        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
225 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
226 +        txt += '    echo "middleware =$middleware" \n'
227 +        txt += 'else \n'
228 +        txt += '    echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
229 +        txt += '    echo "JOB_EXIT_STATUS = 10030" \n'
230 +        txt += '    echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n'
231 +        txt += '    dumpStatus $RUNTIME_AREA/$repo \n'
232 +        txt += '    rm -f $RUNTIME_AREA/$repo \n'
233 +        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
234 +        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
235 +        txt += '    exit 1 \n'
236 +        txt += 'fi \n'
237 +
238 +        txt += '# report first time to DashBoard \n'
239 +        txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
240 +        txt += 'rm -f $RUNTIME_AREA/$repo \n'
241 +        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
242 +        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
243 +        
244 +        txt += '\n\n'
245 +
246          if int(self.copy_data) == 1:
247             if self.SE:
248                txt += 'export SE='+self.SE+'\n'
# Line 136 | Line 251 | class SchedulerEdg(Scheduler):
251                if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
252                txt += 'export SE_PATH='+self.SE_PATH+'\n'
253                txt += 'echo "SE_PATH = $SE_PATH"\n'
254 <                                                                                                                                                            
254 >
255 >        txt += 'export VO='+self.VO+'\n'
256 >        ### FEDE: add some line for LFC catalog setting
257 >        txt += 'if [ $middleware == LCG ]; then \n'
258 >        txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
259 >        txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
260 >        txt += '    fi\n'
261 >        txt += '    if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
262 >        txt += '        export LFC_HOST='+self.lfc_host+'\n'
263 >        txt += '    fi\n'
264 >        txt += '    if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
265 >        txt += '        export LFC_HOME='+self.lfc_home+'\n'
266 >        txt += '    fi\n'
267 >        txt += 'elif [ $middleware == OSG ]; then\n'
268 >        txt += '    echo "LFC catalog setting to be implemented for OSG"\n'
269 >        txt += 'fi\n'
270 >        #####
271          if int(self.register_data) == 1:
272 +           txt += 'if [ $middleware == LCG ]; then \n'
273 +           txt += '    export LFN='+self.LFN+'\n'
274 +           txt += '    lfc-ls $LFN\n'
275 +           txt += '    result=$?\n'
276 +           txt += '    echo $result\n'
277 +           ### creation of LFN dir in LFC catalog, under /grid/cms dir  
278 +           txt += '    if [ $result != 0 ]; then\n'
279 +           txt += '       lfc-mkdir $LFN\n'
280 +           txt += '       result=$?\n'
281 +           txt += '       echo $result\n'
282 +           txt += '    fi\n'
283 +           txt += 'elif [ $middleware == OSG ]; then\n'
284 +           txt += '    echo " Files registration to be implemented for OSG"\n'
285 +           txt += 'fi\n'
286 +           txt += '\n'
287 +
288             if self.VO:
289                txt += 'export VO='+self.VO+'\n'
290             if self.LFN:
291 <              txt += 'export LFN='+self.LFN+'\n'
291 >              txt += 'if [ $middleware == LCG ]; then \n'
292 >              txt += '    export LFN='+self.LFN+'\n'
293 >              txt += 'fi\n'
294                txt += '\n'
295 <        txt += 'CloseCEs=`edg-brokerinfo getCE`\n'
296 <        txt += 'echo "CloseCEs = $CloseCEs"\n'
297 <        txt += 'CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
298 <        txt += 'echo "CE = $CE"\n'
295 >
296 >        txt += 'if [ $middleware == LCG ]; then\n'
297 >        txt += '    CloseCEs=`edg-brokerinfo getCE`\n'
298 >        txt += '    echo "CloseCEs = $CloseCEs"\n'
299 >        txt += '    CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
300 >        txt += '    echo "CE = $CE"\n'
301 >        txt += 'elif [ $middleware == OSG ]; then \n'
302 >        txt += '    if [ $OSG_JOB_CONTACT ]; then \n'
303 >        txt += '        CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print ${args[0]}}\'` \n'
304 >        txt += '    else \n'
305 >        txt += '        echo "SET_CMS_ENV 10099 ==> OSG mode: ERROR in setting CE name from OSG_JOB_CONTACT" \n'
306 >        txt += '        echo "JOB_EXIT_STATUS = 10099" \n'
307 >        txt += '        echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n'
308 >        txt += '        dumpStatus $RUNTIME_AREA/$repo \n'
309 >        txt += '        rm -f $RUNTIME_AREA/$repo \n'
310 >        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
311 >        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
312 >        txt += '        exit 1 \n'
313 >        txt += '    fi \n'
314 >        txt += 'fi \n'
315 >
316 >        return txt
317 >
318 >    def wsCopyInput(self):
319 >        """
320 >        Copy input data from SE to WN    
321 >        """
322 >        txt = ''
323 >        try:
324 >            self.copy_input_data = common.analisys_common_info['copy_input_data']
325 >            #print "self.copy_input_data = ", self.copy_input_data
326 >        except KeyError: self.copy_input_data = 0
327 >        if int(self.copy_input_data) == 1:
328 >        ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
329 >           txt += 'if [ $middleware == OSG ]; then\n'
330 >           txt += '   #\n'
331 >           txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
332 >           txt += '   #\n'
333 >           txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
334 >           txt += 'elif [ $middleware == LCG ]; then \n'
335 >           txt += '   #\n'
336 >           txt += '   #   Copy Input Data from SE to this WN\n'
337 >           txt += '   #\n'
338 > ### changed by georgia (put a loop copying more than one input files per jobs)          
339 >           txt += '   for input_file in $cur_file_list \n'
340 >           txt += '   do \n'
341 >           #### FEDE
342 >           #txt += '      echo "which lcg-cp" \n'
343 >           #txt += '      which lcg-cp \n'
344 >           #########
345 >           txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
346 >           txt += '      copy_input_exit_status=$?\n'
347 >           txt += '      echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
348 >           txt += '      if [ $copy_input_exit_status -ne 0 ]; then \n'
349 >           txt += '         echo "Problems with copying to WN" \n'
350 >           txt += '      else \n'
351 >           txt += '         echo "input copied into WN" \n'
352 >           txt += '      fi \n'
353 >           txt += '   done \n'
354 > ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
355 >           txt += '   for file in $cur_pu_list \n'
356 >           txt += '   do \n'
357 >           #### FEDE
358 >           #txt += '      echo "which lcg-cp" \n'
359 >           #txt += '      which lcg-cp \n'
360 >           #########
361 >           txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
362 >           txt += '      copy_input_pu_exit_status=$?\n'
363 >           txt += '      echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
364 >           txt += '      if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
365 >           txt += '         echo "Problems with copying pu to WN" \n'
366 >           txt += '      else \n'
367 >           txt += '         echo "input pu files copied into WN" \n'
368 >           txt += '      fi \n'
369 >           txt += '   done \n'
370 >           txt += '   \n'
371 >           txt += '   ### Check SCRATCH space available on WN : \n'
372 >           txt += '   df -h \n'
373 >           txt += 'fi \n'
374 >          
375          return txt
376  
377      def wsCopyOutput(self):
# Line 156 | Line 381 | class SchedulerEdg(Scheduler):
381          """
382          txt = ''
383          if int(self.copy_data) == 1:
159           copy = 'globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file'
384             txt += '#\n'
385             txt += '#   Copy output to SE = $SE\n'
386             txt += '#\n'
387 <           txt += 'if [ $exe_result -eq 0 ]; then\n'
388 <           txt += '  for out_file in $file_list ; do\n'
389 <           txt += '    echo "Trying to copy output file to $SE "\n'
390 <           txt += '    echo "'+copy+'"\n'
391 <           txt += '    '+copy+' 2>&1\n'
392 <           txt += '    copy_exit_status=$?\n'
393 <           txt += '    echo "COPY_EXIT_STATUS = $copy_exit_status"\n'
170 <           txt += '    echo "STAGE_OUT = $copy_exit_status"\n'
171 <           txt += '    if [ $copy_exit_status -ne 0 ]; then \n'
172 <           txt += '       echo "Problems with SE= $SE" \n'
173 <           txt += '    else \n'
174 <           txt += '       echo "output copied into $SE/$SE_PATH directory"\n'
387 >           #txt += 'if [ $exe_result -eq 0 ]; then\n'
388 >           txt += '    if [ $middleware == OSG ]; then\n'
389 >           txt += '        echo "X509_USER_PROXY = $X509_USER_PROXY"\n'
390 >           txt += '        echo "source $OSG_APP/glite/setup_glite_ui.sh"\n'
391 >           txt += '        source $OSG_APP/glite/setup_glite_ui.sh\n'
392 >           txt += '        export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n'
393 >           txt += '        echo "export X509_CERT_DIR=$X509_CERT_DIR"\n'
394             txt += '    fi \n'
395 <           txt += '  done\n'
396 <           txt += 'fi \n'
395 >           txt += '    for out_file in $file_list ; do\n'
396 >           txt += '        echo "Trying to copy output file to $SE using lcg-cp"\n'
397 >           if common.logger.debugLevel() >= 5:
398 >               txt += '        echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
399 >               txt += '        exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
400 >           else:
401 >               txt += '        echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
402 >               txt += '        exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
403 >           txt += '        copy_exit_status=$?\n'
404 >           txt += '        echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
405 >           txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
406 >           txt += '        if [ $copy_exit_status -ne 0 ]; then\n'
407 >           txt += '            echo "Possible problem with SE = $SE"\n'
408 >           txt += '            echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
409 >           txt += '            echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
410 >           txt += '            echo "lcg-cp failed.  For verbose lcg-cp output, use command line option -debug 5."\n'
411 >           txt += '            echo "lcg-cp failed, attempting srmcp"\n'
412 >           txt += '            echo "mkdir -p $HOME/.srmconfig"\n'
413 >           txt += '            mkdir -p $HOME/.srmconfig\n'
414 >           txt += '            if [ $middleware == LCG ]; then\n'
415 >           txt += '               echo "srmcp -retry_num 5 -retry_timeout 480000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
416 >           txt += '               exitstring=`srmcp -retry_num 5 -retry_timeout 480000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
417 >           txt += '            elif [ $middleware == OSG ]; then\n'
418 >           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'
419 >           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'
420 >           txt += '            fi \n'
421 >           txt += '            copy_exit_status=$?\n'
422 >           txt += '            echo "COPY_EXIT_STATUS for srm = $copy_exit_status"\n'
423 >           txt += '            echo "STAGE_OUT = $copy_exit_status"\n'
424 >           txt += '            if [ $copy_exit_status -ne 0 ]; then\n'
425 >           txt += '               echo "Problems with SE = $SE"\n'
426 >           txt += '               echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
427 >           txt += '               echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
428 >           txt += '               echo "lcg-cp and srm failed"\n'
429 >           txt += '               echo "If storage_path in your config file contains a ? you may need a \? instead."\n'
430 >           txt += '            else\n'
431 >           txt += '               echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
432 >           txt += '               echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
433 >           txt += '               echo "output copied into $SE/$SE_PATH directory"\n'
434 >           txt += '               echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
435 >           txt += '               echo "srmcp succeeded"\n'
436 >           txt += '            fi\n'
437 >           txt += '        else\n'
438 >           txt += '            echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
439 >           txt += '            echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
440 >           txt += '            echo "output copied into $SE/$SE_PATH directory"\n'
441 >           txt += '            echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
442 >           txt += '            echo "lcg-cp succeeded"\n'
443 >           txt += '         fi\n'
444 >           txt += '     done\n'
445 >           #txt += 'fi\n'
446          return txt
447  
448      def wsRegisterOutput(self):
# Line 184 | Line 452 | class SchedulerEdg(Scheduler):
452  
453          txt = ''
454          if int(self.register_data) == 1:
455 +        ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
456 +           txt += 'if [ $middleware == OSG ]; then\n'
457 +           txt += '   #\n'
458 +           txt += '   #   Register output to LFC deactivated in OSG mode\n'
459 +           txt += '   #\n'
460 +           txt += '   echo "Register output to LFC deactivated in OSG mode"\n'
461 +           txt += 'elif [ $middleware == LCG ]; then \n'
462             txt += '#\n'
463 <           txt += '#  Register output to RLS\n'
463 >           txt += '#  Register output to LFC\n'
464             txt += '#\n'
465 <           txt += 'if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
466 <           txt += '   for out_file in $file_list ; do\n'
467 <           txt += '      echo "Trying to register the output file into RLS"\n'
468 <           txt += '      echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n'
469 <           txt += '      lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$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 the registration to RLS" \n'
200 <           txt += '         echo "Try with srm protocol" \n'
201 <           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n'
202 <           txt += '         lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n'
465 >           #txt += '   if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
466 >           txt += '   if [ $copy_exit_status -eq 0 ]; then\n'
467 >           txt += '      for out_file in $file_list ; do\n'
468 >           txt += '         echo "Trying to register the output file into LFC"\n'
469 >           #### FEDE
470 >           #txt += '         echo "which lcg-rf" \n'
471 >           #txt += '         which lcg-rf \n'
472 >           #########
473 >           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n'
474 >           txt += '         lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n'
475             txt += '         register_exit_status=$?\n'
476             txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
477             txt += '         echo "STAGE_OUT = $register_exit_status"\n'
478             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
479 <           txt += '            echo "Problems with the registration into RLS" \n'
479 >           txt += '            echo "Problems with the registration to LFC" \n'
480 >           txt += '            echo "Try with srm protocol" \n'
481 >           #### FEDE
482 >           #txt += '            echo "which lcg-rf" \n'
483 >           #txt += '            which lcg-rf \n'
484 >           #########
485 >           txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n'
486 >           txt += '            lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n'
487 >           txt += '            register_exit_status=$?\n'
488 >           txt += '            echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
489 >           txt += '            echo "STAGE_OUT = $register_exit_status"\n'
490 >           txt += '            if [ $register_exit_status -ne 0 ]; then \n'
491 >           txt += '               echo "Problems with the registration into LFC" \n'
492 >           txt += '            fi \n'
493 >           txt += '         else \n'
494 >           txt += '            echo "output registered to LFC"\n'
495             txt += '         fi \n'
496 <           txt += '      else \n'
497 <           txt += '         echo "output registered to RLS"\n'
498 <           txt += '      fi \n'
499 <           txt += '   done\n'
500 <           txt += 'elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
501 <           txt += '   echo "Trying to copy output file to CloseSE"\n'
502 <           txt += '   CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
503 <           txt += '   for out_file in $file_list ; do\n'
504 <           txt += '      echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n'
505 <           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'
506 <           txt += '      register_exit_status=$?\n'
507 <           txt += '      echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
508 <           txt += '      echo "STAGE_OUT = $register_exit_status"\n'
509 <           txt += '      if [ $register_exit_status -ne 0 ]; then \n'
510 <           txt += '         echo "Problems with CloseSE" \n'
511 <           txt += '      else \n'
512 <           txt += '         echo "The program was successfully executed"\n'
513 <           txt += '         echo "SE = $CLOSE_SE"\n'
514 <           txt += '         echo "LFN for the file is LFN=${LFN}/$out_file"\n'
515 <           txt += '      fi \n'
516 <           txt += '   done\n'
517 <           txt += 'else\n'
518 <           txt += '   echo "Problem with the executable"\n'
496 >           txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
497 >           txt += '      done\n'
498 >           #txt += '   elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
499 >           txt += '   else \n'
500 >           txt += '      echo "Trying to copy output file to CloseSE"\n'
501 >           txt += '      CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
502 >           txt += '      for out_file in $file_list ; do\n'
503 >           #### FEDE
504 >           #txt += '         echo "which lcg-cr" \n'
505 >           #txt += '         which lcg-cr \n'
506 >           #########
507 >           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'
508 >           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'
509 >           txt += '         register_exit_status=$?\n'
510 >           txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
511 >           txt += '         echo "STAGE_OUT = $register_exit_status"\n'
512 >           txt += '         if [ $register_exit_status -ne 0 ]; then \n'
513 >           txt += '            echo "Problems with CloseSE or Catalog" \n'
514 >           txt += '         else \n'
515 >           txt += '            echo "The program was successfully executed"\n'
516 >           txt += '            echo "SE = $CLOSE_SE"\n'
517 >           txt += '            echo "LFN for the file is LFN=${LFN}/$out_file"\n'
518 >           txt += '         fi \n'
519 >           txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
520 >           txt += '      done\n'
521 >           #txt += '   else\n'
522 >           #txt += '      echo "Problem with the executable"\n'
523 >           txt += '   fi \n'
524 >           txt += '   exit_status=$register_exit_status\n'
525             txt += 'fi \n'
526          return txt
527  
# Line 237 | Line 530 | class SchedulerEdg(Scheduler):
530          retrieve the logging info from logging and bookkeeping and return it
531          """
532          self.checkProxy()
240      #  id = common.jobDB.jobId(nj)
533          cmd = 'edg-job-get-logging-info -v 2 ' + id
534 <        cmd_out = os.popen(cmd)
535 <      #  cmd_out = runCommand(cmd)
534 >        #cmd_out = os.popen(cmd)
535 >        cmd_out = runCommand(cmd)
536          return cmd_out
537  
538      def listMatch(self, nj):
# Line 250 | Line 542 | class SchedulerEdg(Scheduler):
542          self.checkProxy()
543          jdl = common.job_list[nj].jdlFilename()
544          cmd = 'edg-job-list-match ' + self.configOpt_() + jdl
545 <        # myCmd = os.popen(cmd)
546 <        # cmd_out = myCmd.readlines()
547 <        # myCmd.close()
548 <        cmd_out = runCommand(cmd,0,240)
545 >        cmd_out = runCommand(cmd,0,45)
546 >        if not cmd_out:
547 >            raise CrabException("ERROR: "+cmd+" failed!")
548 >
549          return self.parseListMatch_(cmd_out, jdl)
550  
551      def parseListMatch_(self, out, jdl):
# Line 311 | Line 603 | class SchedulerEdg(Scheduler):
603          [sites.append(it) for it in CEs if not sites.count(it)]
604  
605          common.logger.debug(5,"All Sites :"+str(sites))
606 +        common.logger.message("Matched Sites :"+str(sites))
607          return len(sites)
608  
609      def noMatchFound_(self, jdl):
# Line 349 | Line 642 | class SchedulerEdg(Scheduler):
642              pass
643          return jid
644  
645 +    def resubmit(self, nj_list):
646 +        """
647 +        Prepare jobs to be submit
648 +        """
649 +        return
650 +
651      def getExitStatus(self, id):
652          return self.getStatusAttribute_(id, 'exit_code')
653  
# Line 389 | Line 688 | class SchedulerEdg(Scheduler):
688          cmd_out = runCommand(cmd)
689          return cmd_out
690  
691 <    def getOutput(self, id):
691 >    ##### FEDE ######        
692 >    def findSites_(self, n_tot_job):
693 >        itr4 = []
694 >       # print "n_tot_job = ", n_tot_job
695 >        for n in range(n_tot_job):
696 >            sites = common.jobDB.destination(n)
697 >            if len(sites)>0 and sites[0]=="Any": continue
698 >
699 >            #job = common.job_list[n]
700 >            #jbt = job.type()
701 >           # print "common.jobDB.destination(n) = ", common.jobDB.destination(n)
702 >           # print "sites = ", sites
703 >            itr = ''
704 >            for site in sites:
705 >                #itr = itr + 'target.GlueSEUniqueID==&quot;'+site+'&quot; || '
706 >                itr = itr + 'target.GlueSEUniqueID=="'+site+'" || '
707 >                pass
708 >            # remove last ||
709 >            itr = itr[0:-4]
710 >            itr4.append( itr )
711 >        # remove last ,
712 >       # print "itr4 = ", itr4
713 >        return itr4
714 >
715 >    def createXMLSchScript(self, nj, argsList):
716 >   # def createXMLSchScript(self, nj):
717 >        """
718 >        Create a XML-file for BOSS4.
719 >        """
720 >  #      job = common.job_list[nj]
721 >        """
722 >        INDY
723 >        [begin] da rivedere:
724 >        in particolare passerei il jobType ed eliminerei le dipendenze da job
725 >        """
726 >        index = nj - 1
727 >        job = common.job_list[index]
728 >        jbt = job.type()
729 >        
730 >        inp_sandbox = jbt.inputSandbox(index)
731 >        out_sandbox = jbt.outputSandbox(index)
732          """
733          Get output for a finished job with id.
734          Returns the name of directory with results.
# Line 401 | Line 740 | class SchedulerEdg(Scheduler):
740  
741          # Determine the output directory name
742          dir = common.work_space.resDir()
743 <        dir += os.getlogin()
743 >        dir += os.environ['USER']
744          dir += '_' + os.path.basename(id)
745          return dir
746  
408    def cancel(self, id):
409        """ Cancel the EDG job with id """
410        self.checkProxy()
411        cmd = 'edg-job-cancel --noint ' + id
412        cmd_out = runCommand(cmd)
413        return cmd_out
414
747      def createSchScript(self, nj):
748          """
749          Create a JDL-file for EDG.
# Line 441 | Line 773 | class SchedulerEdg(Scheduler):
773          jdl.write(jt_string)
774  
775          ### only one .sh  JDL has arguments:
444        firstEvent = common.jobDB.firstEvent(nj)
445        maxEvents = common.jobDB.maxEvents(nj)
446        jdl.write('Arguments = "' + str(nj+1)+' '+str(firstEvent)+' '+str(maxEvents)+'";\n')
776  
777 +        ### Fabio
778 +        jdl.write('Arguments = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'";\n')
779          inp_box = 'InputSandbox = { '
780          inp_box = inp_box + '"' + script + '",'
781  
# Line 457 | Line 788 | class SchedulerEdg(Scheduler):
788          #if common.use_jam:
789          #   inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",'
790  
791 <        for addFile in jbt.additional_inbox_files:
792 <            addFile = os.path.abspath(addFile)
793 <            inp_box = inp_box+' "'+addFile+'",'
794 <            pass
791 >        # Marco (VERY TEMPORARY ML STUFF)
792 >        inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\
793 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + '", "'+\
794 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\
795 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\
796 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"'
797 >        # End Marco
798 >
799 >        if (not jbt.additional_inbox_files == []):
800 >            inp_box = inp_box + ', '
801 >            for addFile in jbt.additional_inbox_files:
802 >                addFile = os.path.abspath(addFile)
803 >                inp_box = inp_box+' "'+addFile+'",'
804 >                pass
805  
806          if inp_box[-1] == ',' : inp_box = inp_box[:-1]
807          inp_box = inp_box + ' };\n'
# Line 490 | Line 831 | class SchedulerEdg(Scheduler):
831          out_box = out_box + ' };'
832          jdl.write(out_box+'\n')
833  
834 <        ### if at least a CE exists ...
835 <        if common.analisys_common_info['sites']:
836 <            if common.analisys_common_info['sw_version']:
837 <                req='Requirements = '
838 <                req=req + 'Member("VO-cms-' + \
839 <                     common.analisys_common_info['sw_version'] + \
840 <                     '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
841 <            if len(common.analisys_common_info['sites'])>0:
842 <                req = req + ' && ('
843 <                for i in range(len(common.analisys_common_info['sites'])):
844 <                    req = req + 'other.GlueCEInfoHostName == "' \
845 <                         + common.analisys_common_info['sites'][i] + '"'
846 <                    if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ):
847 <                        req = req + ' || '
834 >
835 >        req='Requirements = '
836 >        noreq=req
837 >        req = req + jbt.getRequirements(nj)
838 >        #### and USER REQUIREMENT
839 >        if self.EDG_requirements:
840 >            if (req != noreq):
841 >                req = req +  ' && '
842 >            req = req + self.EDG_requirements
843 >        #### FEDE #####
844 >        if self.EDG_ce_white_list:
845 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
846 >            #print "req = ", req
847 >            for i in range(len(ce_white_list)):
848 >                if i == 0:
849 >                    if (req != noreq):
850 >                        req = req +  ' && '
851 >                    req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
852 >                    pass
853 >                else:
854 >                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
855              req = req + ')'
856 +        
857 +        if self.EDG_ce_black_list:
858 +            ce_black_list = string.split(self.EDG_ce_black_list,',')
859 +            for ce in ce_black_list:
860 +                if (req != noreq):
861 +                    req = req +  ' && '
862 +                req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
863 +                pass
864 +
865 +        ###############
866 +        clockTime=480
867 +        if self.EDG_clock_time:
868 +            clockTime= self.EDG_clock_time
869 +        if (req != noreq):
870 +            req = req + ' && '
871 +        req = req + '((other.GlueCEPolicyMaxWallClockTime == 0) || (other.GlueCEPolicyMaxWallClockTime>='+str(clockTime)+'))'
872 +
873 +        cpuTime=1000
874 +        if self.EDG_cpu_time:
875 +            cpuTime=self.EDG_cpu_time
876 +        if (req != noreq):
877 +            req = req + ' && '
878 +        req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))'
879  
880 <            #### and USER REQUIREMENT
510 <            if self.EDG_requirements:
511 <                req = req +  ' && ' + self.EDG_requirements
512 <            if self.EDG_clock_time:
513 <                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
514 <            if self.EDG_cpu_time:
515 <                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
880 >        if (req != noreq):
881              req = req + ';\n'
882              jdl.write(req)
883                                                                                                                                                              
# Line 522 | Line 887 | class SchedulerEdg(Scheduler):
887              jdl.write('RetryCount = '+self.EDG_retry_count+';\n')
888              pass
889  
890 +        jdl.write('MyProxyServer = "' + self.proxyServer + '";\n')
891 +
892          jdl.close()
893          return
894  
# Line 531 | Line 898 | class SchedulerEdg(Scheduler):
898          """
899          if (self.proxyValid): return
900          timeleft = -999
901 <        minTimeLeft=10 # in hours
902 <        cmd = 'grid-proxy-info -e -v '+str(minTimeLeft)+':00'
903 <        try: cmd_out = runCommand(cmd,0)
904 <        except: print cmd_out
905 <        if (cmd_out == None or cmd_out=='1'):
906 <            common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 100h\n")
907 <            cmd = 'grid-proxy-init -valid 100:00'
901 >        minTimeLeft=10*3600 # in seconds
902 >
903 >        minTimeLeftServer = 100 # in hours
904 >
905 >        #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
906 >        #cmd = 'voms-proxy-info -timeleft'
907 >        mustRenew = 0
908 >        timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null')
909 >        timeLeftServer = -999
910 >        if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal):
911 >            mustRenew = 1
912 >        else:
913 >            timeLeftServer = runCommand('voms-proxy-info -actimeleft 2>/dev/null | head -1')
914 >            if not timeLeftServer or not isInt(timeLeftServer):
915 >                mustRenew = 1
916 >            elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft:
917 >                mustRenew = 1
918 >            pass
919 >        pass
920 >
921 >        if mustRenew:
922 >            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")
923 >            cmd = 'voms-proxy-init -voms '+self.VO+' -valid 96:00'
924 >            if self.role:
925 >                cmd = 'voms-proxy-init -voms '+self.VO+':/'+self.VO+'/role='+self.role+' -valid 96:00'
926              try:
927 +                # SL as above: damn it!
928                  out = os.system(cmd)
929                  if (out>0): raise CrabException("Unable to create a valid proxy!\n")
930              except:
931                  msg = "Unable to create a valid proxy!\n"
932                  raise CrabException(msg)
547            cmd = 'grid-proxy-info -timeleft'
548            cmd_out = runCommand(cmd,0)
933              pass
934 +
935 +        ## now I do have a voms proxy valid, and I check the myproxy server
936 +        renewProxy = 0
937 +        cmd = 'myproxy-info -d -s '+self.proxyServer
938 +        cmd_out = runCommand(cmd,0,20)
939 +        if not cmd_out:
940 +            common.logger.message('No credential delegated to myproxy server '+self.proxyServer+' will do now')
941 +            renewProxy = 1
942 +        else:
943 +            # if myproxy exist but not long enough, renew
944 +            reTime = re.compile( r'timeleft: (\d+)' )
945 +            #print "<"+str(reTime.search( cmd_out ).group(1))+">"
946 +            if reTime.match( cmd_out ):
947 +                time = reTime.search( line ).group(1)
948 +                if time < minTimeLeftServer:
949 +                    renewProxy = 1
950 +                    common.logger.message('No credential delegation will expire in '+time+' hours: renew it')
951 +                pass
952 +            pass
953 +        
954 +        # if not, create one.
955 +        if renewProxy:
956 +            cmd = 'myproxy-init -d -n -s '+self.proxyServer
957 +            out = os.system(cmd)
958 +            if (out>0):
959 +                raise CrabException("Unable to delegate the proxy to myproxyserver "+self.proxyServer+" !\n")
960 +            pass
961 +
962 +        # cache proxy validity
963          self.proxyValid=1
964          return
965 <    
965 >
966      def configOpt_(self):
967          edg_ui_cfg_opt = ' '
968          if self.edg_config:
969 <          edg_ui_cfg_opt = ' -c ' + self.edg_config + ' '
969 >            edg_ui_cfg_opt = ' -c ' + self.edg_config + ' '
970          if self.edg_config_vo:
971 <          edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' '
971 >            edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' '
972          return edg_ui_cfg_opt

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines