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.23 by spiga, Tue Nov 8 13:27:11 2005 UTC vs.
Revision 1.50 by slacapra, Thu Apr 13 15:59:08 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  
27        try: self.edg_config_vo = cfg_params["EDG.config_vo"]
28        except KeyError: self.edg_config_vo = ''
34  
35          try: self.LCG_version = cfg_params["EDG.lcg_version"]
36          except KeyError: self.LCG_version = '2'
# Line 36 | Line 41 | class SchedulerEdg(Scheduler):
41          try: self.EDG_retry_count = cfg_params['EDG.retry_count']
42          except KeyError: self.EDG_retry_count = ''
43  
44 +        try:
45 +            self.EDG_ce_black_list = cfg_params['EDG.ce_black_list']
46 +            #print "self.EDG_ce_black_list = ", self.EDG_ce_black_list
47 +        except KeyError:
48 +            self.EDG_ce_black_list  = ''
49 +
50 +        try:
51 +            self.EDG_ce_white_list = cfg_params['EDG.ce_white_list']
52 +            #print "self.EDG_ce_white_list = ", self.EDG_ce_white_list
53 +        except KeyError: self.EDG_ce_white_list = ''
54 +
55          try: self.VO = cfg_params['EDG.virtual_organization']
56          except KeyError: self.VO = 'cms'
57  
58          try: self.return_data = cfg_params['USER.return_data']
59 <        except KeyError: self.return_data = ''
59 >        except KeyError: self.return_data = 1
60 >
61 >        try:
62 >             self.copy_input_data = common.analisys_common_info['copy_input_data']
63 >             #print "self.copy_input_data = ", self.copy_input_data
64 >        except KeyError: self.copy_input_data = 0
65  
66          try:
67              self.copy_data = cfg_params["USER.copy_data"]
68 <            try:
69 <                self.SE = cfg_params['USER.storage_element']
70 <                self.SE_PATH = cfg_params['USER.storage_path']
71 <            except KeyError:
72 <                msg = "Error. The [USER] section does not have 'storage_element'"
73 <                msg = msg + " and/or 'storage_path' entries, necessary to copy the output"
74 <                common.logger.message(msg)
75 <                raise CrabException(msg)
76 <        except KeyError: self.copy_data = ''
68 >            if int(self.copy_data) == 1:
69 >                try:
70 >                    self.SE = cfg_params['USER.storage_element']
71 >                    self.SE_PATH = cfg_params['USER.storage_path']
72 >                except KeyError:
73 >                    msg = "Error. The [USER] section does not have 'storage_element'"
74 >                    msg = msg + " and/or 'storage_path' entries, necessary to copy the output"
75 >                    common.logger.message(msg)
76 >                    raise CrabException(msg)
77 >        except KeyError: self.copy_data = 0
78 >
79 >        if ( int(self.return_data) == 0 and int(self.copy_data) == 0 ):
80 >           msg = 'Warning: return_data = 0 and copy_data = 0 ==> your exe output will be lost\n'
81 >           msg = msg + 'Please modify return_data and copy_data value in your crab.cfg file\n'
82 >           raise CrabException(msg)
83  
84 +        try:
85 +            self.lfc_host = cfg_params['EDG.lfc_host']
86 +        except KeyError:
87 +            msg = "Error. The [EDG] section does not have 'lfc_host' value"
88 +            msg = msg + " it's necessary to know the LFC host name"
89 +            common.logger.message(msg)
90 +            raise CrabException(msg)
91 +        try:
92 +            self.lcg_catalog_type = cfg_params['EDG.lcg_catalog_type']
93 +        except KeyError:
94 +            msg = "Error. The [EDG] section does not have 'lcg_catalog_type' value"
95 +            msg = msg + " it's necessary to know the catalog type"
96 +            common.logger.message(msg)
97 +            raise CrabException(msg)
98 +        try:
99 +            self.lfc_home = cfg_params['EDG.lfc_home']
100 +        except KeyError:
101 +            msg = "Error. The [EDG] section does not have 'lfc_home' value"
102 +            msg = msg + " it's necessary to know the home catalog dir"
103 +            common.logger.message(msg)
104 +            raise CrabException(msg)
105 +      
106          try:
107              self.register_data = cfg_params["USER.register_data"]
108 <            try:
109 <                 self.LFN = cfg_params['USER.lfn_dir']
110 <            except KeyError:
111 <                msg = "Error. The [USER] section does not have 'lfn_dir' value"
112 <                msg = msg + " it's necessary for RLS registration"
113 <                common.logger.message(msg)
114 <                raise CrabException(msg)
115 <        except KeyError: self.register_data= ''
108 >            if int(self.register_data) == 1:
109 >                try:
110 >                    self.LFN = cfg_params['USER.lfn_dir']
111 >                except KeyError:
112 >                    msg = "Error. The [USER] section does not have 'lfn_dir' value"
113 >                    msg = msg + " it's necessary for LCF registration"
114 >                    common.logger.message(msg)
115 >                    raise CrabException(msg)
116 >        except KeyError: self.register_data = 0
117 >
118 >        if ( int(self.copy_data) == 0 and int(self.register_data) == 1 ):
119 >           msg = 'Warning: register_data = 1 must be used with copy_data = 1\n'
120 >           msg = msg + 'Please modify copy_data value in your crab.cfg file\n'
121 >           common.logger.message(msg)
122 >           raise CrabException(msg)
123  
124          try: self.EDG_requirements = cfg_params['EDG.requirements']
125          except KeyError: self.EDG_requirements = ''
# Line 113 | Line 169 | class SchedulerEdg(Scheduler):
169          """
170          Returns part of a job script which does scheduler-specific work.
171          """
116
172          txt = ''
173 <        if self.copy_data:
173 >        txt += 'echo "middleware discovery " \n'
174 >        txt += 'if [ $VO_CMS_SW_DIR ]; then\n'
175 >        txt += '    middleware=LCG \n'
176 >        txt += '    echo "middleware =$middleware" \n'
177 >        txt += 'elif [ $GRID3_APP_DIR ]; then\n'
178 >        txt += '    middleware=OSG \n'
179 >        txt += '    echo "middleware =$middleware" \n'
180 >        txt += 'elif [ $OSG_APP ]; then \n'
181 >        txt += '    middleware=OSG \n'
182 >        txt += '    echo "middleware =$middleware" \n'
183 >        txt += 'else \n'
184 >        txt += '    echo "SET_CMS_ENV 1 ==> middleware not identified" \n'
185 >        txt += '    echo "JOB_EXIT_STATUS = 1"\n'
186 >        txt += '    exit 1\n'
187 >        txt += 'fi\n'
188 >
189 >        txt += '\n\n'
190 >
191 >        txt += 'if [ $middleware == LCG ]; then \n'
192 >        txt += '    echo "SyncGridJobId=`echo $EDG_WL_JOBID`" | tee -a $RUNTIME_AREA/$repo\n'
193 >        txt += 'fi\n'
194 >
195 >        if int(self.copy_data) == 1:
196             if self.SE:
197                txt += 'export SE='+self.SE+'\n'
198                txt += 'echo "SE = $SE"\n'
# Line 123 | Line 200 | class SchedulerEdg(Scheduler):
200                if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
201                txt += 'export SE_PATH='+self.SE_PATH+'\n'
202                txt += 'echo "SE_PATH = $SE_PATH"\n'
203 <                                                                                                                                                            
204 <        if self.register_data:
203 >
204 >        txt += 'export VO='+self.VO+'\n'
205 >        ### FEDE: add some line for LFC catalog setting
206 >        txt += 'if [ $middleware == LCG ]; then \n'
207 >        txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
208 >        txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
209 >        txt += '    fi\n'
210 >        txt += '    if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
211 >        txt += '        export LFC_HOST='+self.lfc_host+'\n'
212 >        txt += '    fi\n'
213 >        txt += '    if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
214 >        txt += '        export LFC_HOME='+self.lfc_home+'\n'
215 >        txt += '    fi\n'
216 >        txt += 'elif [ $middleware == OSG ]; then\n'
217 >        txt += '    echo "LFC catalog setting to be implemented for OSG"\n'
218 >        txt += 'fi\n'
219 >        #####
220 >        if int(self.register_data) == 1:
221 >           txt += 'if [ $middleware == LCG ]; then \n'
222 >           txt += '    export LFN='+self.LFN+'\n'
223 >           txt += '    lfc-ls $LFN\n'
224 >           txt += '    result=$?\n'
225 >           txt += '    echo $result\n'
226 >           ### creation of LFN dir in LFC catalog, under /grid/cms dir  
227 >           txt += '    if [ $result != 0 ]; then\n'
228 >           txt += '       lfc-mkdir $LFN\n'
229 >           txt += '       result=$?\n'
230 >           txt += '       echo $result\n'
231 >           txt += '    fi\n'
232 >           txt += 'elif [ $middleware == OSG ]; then\n'
233 >           txt += '    echo " Files registration to be implemented for OSG"\n'
234 >           txt += 'fi\n'
235 >           txt += '\n'
236 >
237             if self.VO:
238                txt += 'export VO='+self.VO+'\n'
239             if self.LFN:
240 <              txt += 'export LFN='+self.LFN+'\n'
240 >              txt += 'if [ $middleware == LCG ]; then \n'
241 >              txt += '    export LFN='+self.LFN+'\n'
242 >              txt += 'fi\n'
243                txt += '\n'
244 <        txt += 'CloseCEs=`edg-brokerinfo getCE`\n'
245 <        txt += 'echo "CloseCEs = $CloseCEs"\n'
246 <        txt += 'CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
247 <        txt += 'echo "CE = $CE"\n'
244 >
245 >        txt += 'if [ $middleware == LCG ]; then\n'
246 >        txt += '    CloseCEs=`edg-brokerinfo getCE`\n'
247 >        txt += '    echo "CloseCEs = $CloseCEs"\n'
248 >        txt += '    CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
249 >        txt += '    echo "CE = $CE"\n'
250 >        txt += 'elif [ $middleware == OSG ]; then \n'
251 >        txt += '    if [ $OSG_JOB_CONTACT ]; then \n'
252 >        txt += '        CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n'
253 >        txt += '    else \n'
254 >        txt += '        echo "SET_ENV 1 ==> ERROR in setting CE name - OSG mode -" \n'
255 >        txt += '        exit 1 \n'
256 >        txt += '    fi \n'
257 >        txt += 'fi \n'
258 >
259 >        return txt
260 >
261 >    def wsCopyInput(self):
262 >        """
263 >        Copy input data from SE to WN    
264 >        """
265 >        txt = ''
266 >        try:
267 >            self.copy_input_data = common.analisys_common_info['copy_input_data']
268 >            #print "self.copy_input_data = ", self.copy_input_data
269 >        except KeyError: self.copy_input_data = 0
270 >        if int(self.copy_input_data) == 1:
271 >        ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
272 >           txt += 'if [ $middleware == OSG ]; then\n'
273 >           txt += '   #\n'
274 >           txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
275 >           txt += '   #\n'
276 >           txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
277 >           txt += 'elif [ $middleware == LCG ]; then \n'
278 >           txt += '   #\n'
279 >           txt += '   #   Copy Input Data from SE to this WN\n'
280 >           txt += '   #\n'
281 > ### changed by georgia (put a loop copying more than one input files per jobs)          
282 >           txt += '   for input_file in $cur_file_list \n'
283 >           txt += '   do \n'
284 >           txt += '    lcg-cp --vo $VO lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
285 >           txt += '    copy_input_exit_status=$?\n'
286 >           txt += '    echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
287 >           txt += '    if [ $copy_input_exit_status -ne 0 ]; then \n'
288 >           txt += '       echo "Problems with copying to WN" \n'
289 >           txt += '    else \n'
290 >           txt += '       echo "input copied into WN" \n'
291 >           txt += '    fi \n'
292 >           txt += '   done \n'
293 > ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
294 >           txt += '   for file in $cur_pu_list \n'
295 >           txt += '   do \n'
296 >           txt += '    lcg-cp --vo $VO lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
297 >           txt += '    copy_input_exit_status=$?\n'
298 >           txt += '    echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
299 >           txt += '    if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
300 >           txt += '       echo "Problems with copying pu to WN" \n'
301 >           txt += '    else \n'
302 >           txt += '       echo "input pu files copied into WN" \n'
303 >           txt += '    fi \n'
304 >           txt += '   done \n'
305 >           txt += '   \n'
306 >           txt += '   ### Check SCRATCH space available on WN : \n'
307 >           txt += '   df -h \n'
308 >           txt += 'fi \n'
309 >          
310          return txt
311  
312      def wsCopyOutput(self):
# Line 142 | Line 315 | class SchedulerEdg(Scheduler):
315          to copy produced output into a storage element.
316          """
317          txt = ''
318 <        if self.copy_data:
146 <           copy = 'globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file'
318 >        if int(self.copy_data) == 1:
319             txt += '#\n'
320             txt += '#   Copy output to SE = $SE\n'
321             txt += '#\n'
150           #### per orca l'exit_status non e' affidabile.....
151           #txt += 'if [ $executable_exit_status -eq 0 ]; then\n'
322             txt += 'if [ $exe_result -eq 0 ]; then\n'
323 <           txt += '  for out_file in $file_list ; do\n'
324 <           txt += '    echo "Trying to copy output file to $SE "\n'
325 <           txt += '    echo "'+copy+'"\n'
326 <           txt += '    '+copy+' 2>&1\n'
327 <           txt += '    copy_exit_status=$?\n'
328 <           txt += '    echo "COPY_EXIT_STATUS = $copy_exit_status"\n'
329 <           txt += '    echo "STAGE_OUT = $copy_exit_status"\n'
330 <           txt += '    if [ $copy_exit_status -ne 0 ]; then \n'
331 <           txt += '       echo "Problems with SE= $SE" \n'
332 <           txt += '    else \n'
333 <           txt += '       echo "output copied into $SE/$SE_PATH directory"\n'
334 <           txt += '    fi \n'
335 <           txt += '  done\n'
336 <           txt += 'fi \n'
323 >           txt += '    for out_file in $file_list ; do\n'
324 >           txt += '        echo "Trying to copy output file to $SE "\n'
325 >           ## OLI_Daniele globus-* for OSG, lcg-* for LCG
326 >           txt += '        if [ $middleware == OSG ]; then\n'
327 >           txt += '           echo "globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
328 >           txt += '           copy_exit_status=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
329 >           #txt += '           exitstring=`globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
330 >           txt += '        elif [ $middleware == LCG ]; then \n'
331 >           txt += '           echo "lcg-cp --vo cms -t 1200 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
332 >           txt += '           copy_exit_status=`lcg-cp --vo cms -t 1200 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
333 >           #txt += '           exitstring=`lcg-cp --vo cms -t 30 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
334 >           txt += '        fi \n'
335 >           #txt += '        copy_exit_status=$?\n'
336 >           txt += '        echo "COPY_EXIT_STATUS = $copy_exit_status"\n'
337 >           txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
338 >           txt += '        if [ $copy_exit_status -ne 0 ]; then\n'
339 >           txt += '            echo "Problems with SE = $SE"\n'
340 >           txt += '            echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
341 >           txt += '            echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
342 >           txt += '        else\n'
343 >           txt += '            echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
344 >           txt += '            echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
345 >           txt += '            echo "output copied into $SE/$SE_PATH directory"\n'
346 >           txt += '            echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
347 >           txt += '         fi\n'
348 >           txt += '     done\n'
349 >           txt += 'fi\n'
350          return txt
351  
352      def wsRegisterOutput(self):
# Line 172 | Line 355 | class SchedulerEdg(Scheduler):
355          """
356  
357          txt = ''
358 <        if self.register_data:
358 >        if int(self.register_data) == 1:
359 >        ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
360 >           txt += 'if [ $middleware == OSG ]; then\n'
361 >           txt += '   #\n'
362 >           txt += '   #   Register output to LFC deactivated in OSG mode\n'
363 >           txt += '   #\n'
364 >           txt += '   echo "Register output to LFC deactivated in OSG mode"\n'
365 >           txt += 'elif [ $middleware == LCG ]; then \n'
366             txt += '#\n'
367 <           txt += '#  Register output to RLS\n'
367 >           txt += '#  Register output to LFC\n'
368             txt += '#\n'
369 <           ### analogo
370 <           #txt += 'if [[ $executable_exit_status -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
371 <           txt += 'if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
372 <           txt += '   for out_file in $file_list ; do\n'
373 <           txt += '      echo "Trying to register the output file into RLS"\n'
184 <           txt += '      echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n'
185 <           txt += '      lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n'
186 <           txt += '      register_exit_status=$?\n'
187 <           txt += '      echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
188 <           txt += '      echo "STAGE_OUT = $register_exit_status"\n'
189 <           txt += '      if [ $register_exit_status -ne 0 ]; then \n'
190 <           txt += '         echo "Problems with the registration to RLS" \n'
191 <           txt += '         echo "Try with srm protocol" \n'
192 <           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n'
193 <           txt += '         lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n'
369 >           txt += '   if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
370 >           txt += '      for out_file in $file_list ; do\n'
371 >           txt += '         echo "Trying to register the output file into LFC"\n'
372 >           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n'
373 >           txt += '         lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n'
374             txt += '         register_exit_status=$?\n'
375             txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
376             txt += '         echo "STAGE_OUT = $register_exit_status"\n'
377             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
378 <           txt += '            echo "Problems with the registration into RLS" \n'
378 >           txt += '            echo "Problems with the registration to LFC" \n'
379 >           txt += '            echo "Try with srm protocol" \n'
380 >           txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n'
381 >           txt += '            lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n'
382 >           txt += '            register_exit_status=$?\n'
383 >           txt += '            echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
384 >           txt += '            echo "STAGE_OUT = $register_exit_status"\n'
385 >           txt += '            if [ $register_exit_status -ne 0 ]; then \n'
386 >           txt += '               echo "Problems with the registration into LFC" \n'
387 >           txt += '            fi \n'
388 >           txt += '         else \n'
389 >           txt += '            echo "output registered to LFC"\n'
390             txt += '         fi \n'
391 <           txt += '      else \n'
392 <           txt += '         echo "output registered to RLS"\n'
393 <           txt += '      fi \n'
394 <           txt += '   done\n'
395 <           txt += 'elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
396 <           txt += '   echo "Trying to copy output file to CloseSE"\n'
397 <           txt += '   CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
398 <           txt += '   for out_file in $file_list ; do\n'
399 <           txt += '      echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n'
400 <           txt += '      lcg-cr -v -l lfn:${LFN}/$out_file -d $SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file 2>&1 \n'
401 <           txt += '      register_exit_status=$?\n'
402 <           txt += '      echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
403 <           txt += '      echo "STAGE_OUT = $register_exit_status"\n'
404 <           txt += '      if [ $register_exit_status -ne 0 ]; then \n'
405 <           txt += '         echo "Problems with CloseSE" \n'
406 <           txt += '      else \n'
407 <           txt += '         echo "The program was successfully executed"\n'
408 <           txt += '         echo "SE = $CLOSE_SE"\n'
409 <           txt += '         echo "LFN for the file is LFN=${LFN}/$out_file"\n'
410 <           txt += '      fi \n'
411 <           txt += '   done\n'
412 <           txt += 'else\n'
413 <           txt += '   echo "Problem with the executable"\n'
391 >           txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
392 >           txt += '      done\n'
393 >           txt += '   elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
394 >           txt += '      echo "Trying to copy output file to CloseSE"\n'
395 >           txt += '      CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
396 >           txt += '      for out_file in $file_list ; do\n'
397 >           txt += '         echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n'
398 >           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'
399 >           txt += '         register_exit_status=$?\n'
400 >           txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
401 >           txt += '         echo "STAGE_OUT = $register_exit_status"\n'
402 >           txt += '         if [ $register_exit_status -ne 0 ]; then \n'
403 >           txt += '            echo "Problems with CloseSE" \n'
404 >           txt += '         else \n'
405 >           txt += '            echo "The program was successfully executed"\n'
406 >           txt += '            echo "SE = $CLOSE_SE"\n'
407 >           txt += '            echo "LFN for the file is LFN=${LFN}/$out_file"\n'
408 >           txt += '         fi \n'
409 >           txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
410 >           txt += '      done\n'
411 >           txt += '   else\n'
412 >           txt += '      echo "Problem with the executable"\n'
413 >           txt += '   fi \n'
414             txt += 'fi \n'
415          return txt
225        #####################
416  
417      def loggingInfo(self, id):
418          """
419          retrieve the logging info from logging and bookkeeping and return it
420          """
421          self.checkProxy()
422 <      #  id = common.jobDB.jobId(nj)
423 <        cmd = 'edg-job-get-logging-info -v 2 ' + self.configOpt_() + id
422 >        cmd = 'edg-job-get-logging-info -v 2 ' + id
423 >        #cmd_out = os.popen(cmd)
424          cmd_out = runCommand(cmd)
425          return cmd_out
426  
# Line 241 | Line 431 | class SchedulerEdg(Scheduler):
431          self.checkProxy()
432          jdl = common.job_list[nj].jdlFilename()
433          cmd = 'edg-job-list-match ' + self.configOpt_() + jdl
434 <        cmd_out = runCommand(cmd)
434 >        cmd_out = runCommand(cmd,0,10)
435 >        if not cmd_out:
436 >            raise CrabException("ERROR: "+cmd+" failed!")
437 >
438          return self.parseListMatch_(cmd_out, jdl)
439  
440      def parseListMatch_(self, out, jdl):
441 +        """
442 +        Parse the f* output of edg-list-match and produce something sensible
443 +        """
444          reComment = re.compile( r'^\**$' )
445          reEmptyLine = re.compile( r'^$' )
446          reVO = re.compile( r'Selected Virtual Organisation name.*' )
447 <        reCE = re.compile( r'CEId.*\n((.*:.*)\n)*' )
447 >        reLine = re.compile( r'.*')
448 >        reCE = re.compile( r'(.*:.*)')
449 >        reCEId = re.compile( r'CEId.*')
450          reNO = re.compile( r'No Computing Element matching' )
451          reRB = re.compile( r'Connecting to host' )
452          next = 0
453          CEs=[]
454          Match=0
455  
456 <        if reNO.match( out ):
457 <            common.logger.debug(5,out)
458 <            self.noMatchFound_(jdl)
459 <            Match=0
460 <            pass
461 <        if reVO.match( out ):
462 <            VO =reVO.match( out ).group()
463 <            common.logger.debug(5, 'VO           :'+VO)
464 <            pass
456 >        #print out
457 >        lines = reLine.findall(out)
458 >
459 >        i=0
460 >        CEs=[]
461 >        for line in lines:
462 >            string.strip(line)
463 >            #print line
464 >            if reNO.match( line ):
465 >                common.logger.debug(5,line)
466 >                return 0
467 >                pass
468 >            if reVO.match( line ):
469 >                VO =reVO.match( line ).group()
470 >                common.logger.debug(5,"VO "+VO)
471 >                pass
472  
473 <        if reRB.match( out ):
474 <            RB =reRB.match(out).group()
475 <            common.logger.debug(5, 'Using RB     :'+RB)
473 >            if reRB.match( line ):
474 >                RB = reRB.match(line).group()
475 >                common.logger.debug(5,"RB "+RB)
476 >                pass
477 >
478 >            if reCEId.search( line ):
479 >                for lineCE in lines[i:-1]:
480 >                    if reCE.match( lineCE ):
481 >                        CE = string.strip(reCE.search(lineCE).group(1))
482 >                        CEs.append(CE.split(':')[0])
483 >                        pass
484 >                    pass
485 >                pass
486 >            i=i+1
487              pass
488  
489 <        if reCE.search( out ):
274 <            groups=reCE.search(out).groups()
275 <            for CE in groups:
276 <                tmp = string.strip(CE)
277 <                CEs.append(tmp)
278 <                common.logger.debug(5, 'Matched CE   :'+tmp)
279 <                Match=Match+1
280 <            pass
489 >        common.logger.debug(5,"All CE :"+str(CEs))
490  
491 <        return Match
491 >        sites = []
492 >        [sites.append(it) for it in CEs if not sites.count(it)]
493 >
494 >        common.logger.debug(5,"All Sites :"+str(sites))
495 >        return len(sites)
496  
497      def noMatchFound_(self, jdl):
498          reReq = re.compile( r'Requirements' )
# Line 317 | Line 530 | class SchedulerEdg(Scheduler):
530              pass
531          return jid
532  
533 +    def resubmit(self, nj_list):
534 +        """
535 +        Prepare jobs to be submit
536 +        """
537 +        return
538 +
539      def getExitStatus(self, id):
540          return self.getStatusAttribute_(id, 'exit_code')
541  
# Line 342 | Line 561 | class SchedulerEdg(Scheduler):
561          jobStat.getStatus(id, level)
562          err, apiMsg = jobStat.get_error()
563          if err:
564 <            print 'Error caught', apiMsg
346 <            common.log.message(apiMsg)
564 >            common.logger.debug(5,'Error caught' + apiMsg)
565              return None
566          else:
567              for i in range(len(self.states)):
# Line 426 | Line 644 | class SchedulerEdg(Scheduler):
644          #if common.use_jam:
645          #   inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",'
646  
647 <        for addFile in jbt.additional_inbox_files:
648 <            addFile = os.path.abspath(addFile)
649 <            inp_box = inp_box+' "'+addFile+'",'
650 <            pass
647 >        # Marco (VERY TEMPORARY ML STUFF)
648 >        inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\
649 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + '", "'+\
650 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\
651 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\
652 >                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"'
653 >        # End Marco
654 >
655 >        if (not jbt.additional_inbox_files == []):
656 >            inp_box = inp_box + ', '
657 >            for addFile in jbt.additional_inbox_files:
658 >                addFile = os.path.abspath(addFile)
659 >                inp_box = inp_box+' "'+addFile+'",'
660 >                pass
661  
662          if inp_box[-1] == ',' : inp_box = inp_box[:-1]
663          inp_box = inp_box + ' };\n'
# Line 447 | Line 675 | class SchedulerEdg(Scheduler):
675                      job.stdout() + '", "' + \
676                      job.stderr() + '", ".BrokerInfo",'
677  
678 <        if self.return_data :
678 >        if int(self.return_data) == 1:
679              if out_sandbox != None:
680                  for fl in out_sandbox:
681                      out_box = out_box + ' "' + fl + '",'
# Line 459 | Line 687 | class SchedulerEdg(Scheduler):
687          out_box = out_box + ' };'
688          jdl.write(out_box+'\n')
689  
462        ### if at least a CE exists ...
463        if common.analisys_common_info['sites']:
464            if common.analisys_common_info['sw_version']:
465                req='Requirements = '
466                req=req + 'Member("VO-cms-' + \
467                     common.analisys_common_info['sw_version'] + \
468                     '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
469            if len(common.analisys_common_info['sites'])>0:
470                req = req + ' && ('
471                for i in range(len(common.analisys_common_info['sites'])):
472                    req = req + 'other.GlueCEInfoHostName == "' \
473                         + common.analisys_common_info['sites'][i] + '"'
474                    if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ):
475                        req = req + ' || '
476            req = req + ')'
690  
691 <            #### and USER REQUIREMENT
692 <            if self.EDG_requirements:
691 >        req='Requirements = '
692 >        req = req + jbt.getRequirements()
693 > #        ### if at least a CE exists ...
694 > #        if common.analisys_common_info['sites']:
695 > #           if common.analisys_common_info['sw_version']:
696 > #                req='Requirements = '
697 > #                req=req + 'Member("VO-cms-' + \
698 > #                     common.analisys_common_info['sw_version'] + \
699 > #                     '", other.GlueHostApplicationSoftwareRunTimeEnvironment)'
700 > #            if len(common.analisys_common_info['sites'])>0:
701 > #                req = req + ' && ('
702 > #                for i in range(len(common.analisys_common_info['sites'])):
703 > #                    req = req + 'other.GlueCEInfoHostName == "' \
704 > #                         + common.analisys_common_info['sites'][i] + '"'
705 > #                    if ( i < (int(len(common.analisys_common_info['sites']) - 1)) ):
706 > #                        req = req + ' || '
707 > #            req = req + ')'
708 >        #### and USER REQUIREMENT
709 >        if self.EDG_requirements:
710 >            if (req == 'Requirement = '):
711 >                req = req + self.EDG_requirements
712 >            else:
713                  req = req +  ' && ' + self.EDG_requirements
714 <            if self.EDG_clock_time:
714 >        #### FEDE #####
715 >        if self.EDG_ce_white_list:
716 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
717 >            #print "req = ", req
718 >            for i in range(len(ce_white_list)):
719 >                if i == 0:
720 >                    if (req == 'Requirement = '):
721 >                        req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
722 >                    else:
723 >                        req = req +  ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
724 >                    pass
725 >                else:
726 >                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
727 >            req = req + ')'
728 >        
729 >        if self.EDG_ce_black_list:
730 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
731 >            for ce in ce_black_list:
732 >                if (req == 'Requirement = '):
733 >                    req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
734 >                else:
735 >                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
736 >                pass
737 >        ###############
738 >        if self.EDG_clock_time:
739 >            if (req == 'Requirement = '):
740 >                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
741 >            else:
742                  req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
743 <            if self.EDG_cpu_time:
743 >
744 >        if self.EDG_cpu_time:
745 >            if (req == 'Requirement = '):
746 >                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
747 >            else:
748                  req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
749 +        if (req != 'Requirement = '):
750              req = req + ';\n'
751              jdl.write(req)
752                                                                                                                                                              
# Line 500 | Line 765 | class SchedulerEdg(Scheduler):
765          """
766          if (self.proxyValid): return
767          timeleft = -999
768 <        minTimeLeft=10 # in hours
769 <        cmd = 'grid-proxy-info -e -v '+str(minTimeLeft)+':00'
770 <        try: cmd_out = runCommand(cmd,0)
771 <        except: print cmd_out
772 <        if (cmd_out == None or cmd_out=='1'):
773 <            common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 100h\n")
774 <            cmd = 'grid-proxy-init -valid 100:00'
768 >        minTimeLeft=10*3600 # in seconds
769 >        #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
770 >        #cmd = 'voms-proxy-info -timeleft'
771 >        mustRenew = 0
772 >        timeLeftLocal = runCommand('voms-proxy-info -timeleft')
773 >        timeLeftServer = -999
774 >        if not timeLeftLocal or not isInt(timeLeftLocal):
775 >            mustRenew = 1
776 >        else:
777 >            timeLeftServer = runCommand('voms-proxy-info -actimeleft')
778 >            if not timeLeftServer or not isInt(timeLeftServer):
779 >                mustRenew = 1
780 >            elif timeLeftServer<minTimeLeft or timeLeftServer<minTimeLeft:
781 >                mustRenew = 1
782 >            pass
783 >        pass
784 >
785 >        if (mustRenew):
786 >            common.logger.message( "No valid proxy found or timeleft too short!\n Creating a user proxy with default length of 24h\n")
787 >            cmd = 'voms-proxy-init -voms cms -valid 100:00'
788              try:
789 +                # SL as above: damn it!
790                  out = os.system(cmd)
791                  if (out>0): raise CrabException("Unable to create a valid proxy!\n")
792              except:
793                  msg = "Unable to create a valid proxy!\n"
794                  raise CrabException(msg)
516            cmd = 'grid-proxy-info -timeleft'
517            cmd_out = runCommand(cmd,0)
518            #print cmd_out, time.time()
519            #time.time(cms_out)
795              pass
796          self.proxyValid=1
797          return
798 <    
798 >
799      def configOpt_(self):
800          edg_ui_cfg_opt = ' '
801          if self.edg_config:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines