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.73.2.2 by fanzago, Wed Jul 19 10:53:40 2006 UTC vs.
Revision 1.122 by corvo, Tue Jun 26 15:31:23 2007 UTC

# Line 18 | Line 18 | class SchedulerEdg(Scheduler):
18                        "owner","parent_job", "reason","resubmitted","rsl","seed",\
19                        "stateEnterTime","stateEnterTimes","subjob_failed", \
20                        "user tags" , "status" , "status_code","hierarchy"]
21 +        
22          return
23  
24      def configure(self, cfg_params):
25 <        # test branch 2
25 >
26          try:
27 <            RB = cfg_params["EDG.rb"]
28 <            edgConfig = EdgConfig(RB)
28 <            self.edg_config = edgConfig.config()
29 <            self.edg_config_vo = edgConfig.configVO()
27 >            RB=cfg_params["EDG.rb"]
28 >            self.rb_param_file=self.rb_configure(RB)
29          except KeyError:
30 <            self.edg_config = ''
31 <            self.edg_config_vo = ''
33 <
30 >            self.rb_param_file=''
31 >            pass
32          try:
33              self.proxyServer = cfg_params["EDG.proxy_server"]
34          except KeyError:
35              self.proxyServer = 'myproxy.cern.ch'
36          common.logger.debug(5,'Setting myproxy server to '+self.proxyServer)
37  
38 +        try:
39 +            self.group = cfg_params["EDG.group"]
40 +        except KeyError:
41 +            self.group = None
42 +            
43 +        try:
44 +            self.role = cfg_params["EDG.role"]
45 +        except KeyError:
46 +            self.role = None
47 +            
48          try: self.LCG_version = cfg_params["EDG.lcg_version"]
49          except KeyError: self.LCG_version = '2'
50  
43        try: self.EDG_requirements = cfg_params['EDG.requirements']
44        except KeyError: self.EDG_requirements = ''
45
46        try: self.EDG_retry_count = cfg_params['EDG.retry_count']
47        except KeyError: self.EDG_retry_count = ''
48
51          try:
52              self.EDG_ce_black_list = cfg_params['EDG.ce_black_list']
51            #print "self.EDG_ce_black_list = ", self.EDG_ce_black_list
53          except KeyError:
54              self.EDG_ce_black_list  = ''
55  
56          try:
57              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
63 >        try: self.copy_input_data = cfg_params["USER.copy_input_data"]
64          except KeyError: self.copy_input_data = 0
65  
66 +        try: self.return_data = cfg_params['USER.return_data']
67 +        except KeyError: self.return_data = 0
68 +
69          try:
70              self.copy_data = cfg_params["USER.copy_data"]
71              if int(self.copy_data) == 1:
# Line 86 | Line 84 | class SchedulerEdg(Scheduler):
84             msg = msg + 'Please modify return_data and copy_data value in your crab.cfg file\n'
85             raise CrabException(msg)
86  
87 +        ########### FEDE FOR DBS2 ##############################
88 +        try:
89 +            self.publish_data = cfg_params["USER.publish_data"]
90 +            if int(self.publish_data) == 1:
91 +                try:
92 +                    self.publish_data_name = cfg_params['USER.publish_data_name']
93 +                except KeyError:
94 +                    msg = "Error. The [USER] section does not have 'publish_data_name'"
95 +                    common.logger.message(msg)
96 +                    raise CrabException(msg)
97 +        except KeyError: self.publish_data = 0
98 +
99 +        if ( int(self.copy_data) == 0 and int(self.publish_data) == 1 ):
100 +           msg = 'Warning: publish_data = 1 must be used with copy_data = 1\n'
101 +           msg = msg + 'Please modify copy_data value in your crab.cfg file\n'
102 +           common.logger.message(msg)
103 +           raise CrabException(msg)
104 +        #################################################
105          try:
106              self.lfc_host = cfg_params['EDG.lfc_host']
107          except KeyError:
# Line 128 | Line 144 | class SchedulerEdg(Scheduler):
144  
145          try: self.EDG_requirements = cfg_params['EDG.requirements']
146          except KeyError: self.EDG_requirements = ''
147 <                                                                                                                                                            
147 >
148 >        try: self.EDG_addJdlParam = string.split(cfg_params['EDG.additional_jdl_parameters'],',')
149 >        except KeyError: self.EDG_addJdlParam = []
150 >
151          try: self.EDG_retry_count = cfg_params['EDG.retry_count']
152          except KeyError: self.EDG_retry_count = ''
153 <                                                                                                                                                            
153 >
154 >        try: self.EDG_shallow_retry_count= cfg_params['EDG.shallow_retry_count']
155 >        except KeyError: self.EDG_shallow_retry_count = ''
156 >
157          try: self.EDG_clock_time = cfg_params['EDG.max_wall_clock_time']
158          except KeyError: self.EDG_clock_time= ''
159 <                                                                                                                                                            
159 >
160          try: self.EDG_cpu_time = cfg_params['EDG.max_cpu_time']
161          except KeyError: self.EDG_cpu_time = ''
162  
# Line 158 | Line 180 | class SchedulerEdg(Scheduler):
180          except:
181              self._taskId = ''
182  
183 +        try: self.jobtypeName = cfg_params['CRAB.jobtype']
184 +        except KeyError: self.jobtypeName = ''
185 +
186 +        try: self.schedulerName = cfg_params['CRAB.scheduler']
187 +        except KeyError: self.scheduler = ''
188 +
189 +        try: self.dontCheckProxy=cfg_params["EDG.dont_check_proxy"]
190 +        except KeyError: self.dontCheckProxy = 0
191 +
192          return
193      
194  
195 +    def rb_configure(self, RB):
196 +        self.edg_config = ''
197 +        self.edg_config_vo = ''
198 +        self.rb_param_file = ''
199 +
200 +        edgConfig = EdgConfig(RB)
201 +        self.edg_config = edgConfig.config()
202 +        self.edg_config_vo = edgConfig.configVO()
203 +
204 +        if (self.edg_config and self.edg_config_vo != ''):
205 +            self.rb_param_file = 'RBconfig = "'+self.edg_config+'";\nRBconfigVO = "'+self.edg_config_vo+'";\n'
206 +            #print "rb_param_file = ", self.rb_param_file
207 +        return self.rb_param_file
208 +      
209 +
210      def sched_parameter(self):
211          """
212 <        Returns file with scheduler-specific parameters
212 >        Returns file with requirements and scheduler-specific parameters
213          """
214 <      
215 <        if (self.edg_config and self.edg_config_vo != ''):
216 <            self.param='sched_param.clad'
214 >        index = int(common.jobDB.nJobs()) - 1
215 >        job = common.job_list[index]
216 >        jbt = job.type()
217 >        
218 >        lastBlock=-1
219 >        first = []
220 >        for n in range(common.jobDB.nJobs()):
221 >            currBlock=common.jobDB.block(n)
222 >            if (currBlock!=lastBlock):
223 >                lastBlock = currBlock
224 >                first.append(n)
225 >  
226 >        req = ''
227 >        req = req + jbt.getRequirements()
228 >    
229 >        if self.EDG_requirements:
230 >            if (req == ' '):
231 >                req = req + self.EDG_requirements
232 >            else:
233 >                req = req +  ' && ' + self.EDG_requirements
234 >
235 >        if self.EDG_ce_white_list:
236 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
237 >            for i in range(len(ce_white_list)):
238 >                if i == 0:
239 >                    if (req == ' '):
240 >                        req = req + '((RegExp("' + string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))'
241 >                    else:
242 >                        req = req +  ' && ((RegExp("' +  string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))'
243 >                    pass
244 >                else:
245 >                    req = req +  ' || (RegExp("' +  string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))'
246 >            req = req + ')'
247 >        
248 >        if self.EDG_ce_black_list:
249 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
250 >            for ce in ce_black_list:
251 >                if (req == ' '):
252 >                    req = req + '(!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))'
253 >                else:
254 >                    req = req +  ' && (!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))'
255 >                pass
256 >        if self.EDG_clock_time:
257 >            if (req == ' '):
258 >                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
259 >            else:
260 >                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
261 >
262 >        if self.EDG_cpu_time:
263 >            if (req == ' '):
264 >                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
265 >            else:
266 >                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
267 >                
268 >        for i in range(len(first)): # Add loop DS
269 >            groupReq = req
270 >            self.param='sched_param_'+str(i)+'.clad'
271              param_file = open(common.work_space.shareDir()+'/'+self.param, 'w')
272 <            param_file.write('RBconfig = "'+self.edg_config+'";\n')  
273 <            param_file.write('RBconfigVO = "'+self.edg_config_vo+'";')
272 >
273 >            itr4=self.findSites_(first[i])
274 >            for arg in itr4:
275 >                groupReq = groupReq + ' && anyMatch(other.storage.CloseSEs, ('+str(arg)+'))'
276 >            param_file.write('Requirements = '+groupReq +';\n')  
277 >  
278 >            if (self.rb_param_file != ''):
279 >                param_file.write(self.rb_param_file)  
280 >
281 >            if len(self.EDG_addJdlParam):
282 >                for p in self.EDG_addJdlParam:
283 >                    param_file.write(p)
284 >
285              param_file.close()  
286 <            return 1
176 <        else:
177 <            return 0
286 >
287  
288      def wsSetupEnvironment(self):
289          """
290          Returns part of a job script which does scheduler-specific work.
291          """
292          txt = ''
293 +        txt += '# strip arguments\n'
294 +        txt += 'echo "strip arguments"\n'
295 +        txt += 'args=("$@")\n'
296 +        txt += 'nargs=$#\n'
297 +        txt += 'shift $nargs\n'
298          txt += "# job number (first parameter for job wrapper)\n"
299 <        txt += "NJob=$1\n"
299 >        #txt += "NJob=$1\n"
300 >        txt += "NJob=${args[0]}\n"
301  
302          txt += '# job identification to DashBoard \n'
303          txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n'
# Line 193 | Line 308 | class SchedulerEdg(Scheduler):
308          txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
309  
310          txt += 'echo "middleware discovery " \n'
311 <        txt += 'if [ $VO_CMS_SW_DIR ]; then \n'
197 <        txt += '    middleware=LCG \n'
198 <        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
199 <        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
200 <        txt += '    echo "middleware =$middleware" \n'
201 <        txt += 'elif [ $GRID3_APP_DIR ]; then\n'
311 >        txt += 'if [ $GRID3_APP_DIR ]; then\n'
312          txt += '    middleware=OSG \n'
313          txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
314          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
# Line 208 | Line 318 | class SchedulerEdg(Scheduler):
318          txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
319          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
320          txt += '    echo "middleware =$middleware" \n'
321 +        txt += 'elif [ $VO_CMS_SW_DIR ]; then \n'
322 +        txt += '    middleware=LCG \n'
323 +        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
324 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
325 +        txt += '    echo "middleware =$middleware" \n'
326          txt += 'else \n'
327          txt += '    echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
328          txt += '    echo "JOB_EXIT_STATUS = 10030" \n'
# Line 227 | Line 342 | class SchedulerEdg(Scheduler):
342          
343          txt += '\n\n'
344  
345 <        if int(self.copy_data) == 1:
346 <           if self.SE:
347 <              txt += 'export SE='+self.SE+'\n'
348 <              txt += 'echo "SE = $SE"\n'
349 <           if self.SE_PATH:
350 <              if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
351 <              txt += 'export SE_PATH='+self.SE_PATH+'\n'
352 <              txt += 'echo "SE_PATH = $SE_PATH"\n'
345 > #        if int(self.copy_data) == 1:
346 > #           if self.SE:
347 > #              txt += 'export SE='+self.SE+'\n'
348 > #              txt += 'echo "SE = $SE"\n'
349 > #           if self.SE_PATH:
350 > #              if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
351 > #              txt += 'export SE_PATH='+self.SE_PATH+'\n'
352 > #              txt += 'echo "SE_PATH = $SE_PATH"\n'
353  
354          txt += 'export VO='+self.VO+'\n'
355 <        ### FEDE: add some line for LFC catalog setting
355 >        ### add some line for LFC catalog setting
356          txt += 'if [ $middleware == LCG ]; then \n'
357          txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
358          txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
# Line 304 | Line 419 | class SchedulerEdg(Scheduler):
419          Copy input data from SE to WN    
420          """
421          txt = ''
422 <        try:
423 <            self.copy_input_data = common.analisys_common_info['copy_input_data']
309 <            #print "self.copy_input_data = ", self.copy_input_data
310 <        except KeyError: self.copy_input_data = 0
311 <        if int(self.copy_input_data) == 1:
422 >        if not self.copy_input_data: return txt
423 >
424          ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
425 <           txt += 'if [ $middleware == OSG ]; then\n'
426 <           txt += '   #\n'
427 <           txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
428 <           txt += '   #\n'
429 <           txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
430 <           txt += 'elif [ $middleware == LCG ]; then \n'
431 <           txt += '   #\n'
432 <           txt += '   #   Copy Input Data from SE to this WN\n'
433 <           txt += '   #\n'
434 < ### changed by georgia (put a loop copying more than one input files per jobs)          
435 <           txt += '   for input_file in $cur_file_list \n'
436 <           txt += '   do \n'
437 <           #### FEDE
438 <           #txt += '      echo "which lcg-cp" \n'
439 <           #txt += '      which lcg-cp \n'
440 <           #########
441 <           txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
442 <           txt += '      copy_input_exit_status=$?\n'
443 <           txt += '      echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
444 <           txt += '      if [ $copy_input_exit_status -ne 0 ]; then \n'
445 <           txt += '         echo "Problems with copying to WN" \n'
446 <           txt += '      else \n'
447 <           txt += '         echo "input copied into WN" \n'
448 <           txt += '      fi \n'
449 <           txt += '   done \n'
450 < ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
451 <           txt += '   for file in $cur_pu_list \n'
452 <           txt += '   do \n'
453 <           #### FEDE
454 <           #txt += '      echo "which lcg-cp" \n'
455 <           #txt += '      which lcg-cp \n'
456 <           #########
457 <           txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
458 <           txt += '      copy_input_pu_exit_status=$?\n'
459 <           txt += '      echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
460 <           txt += '      if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
461 <           txt += '         echo "Problems with copying pu to WN" \n'
350 <           txt += '      else \n'
351 <           txt += '         echo "input pu files copied into WN" \n'
352 <           txt += '      fi \n'
353 <           txt += '   done \n'
354 <           txt += '   \n'
355 <           txt += '   ### Check SCRATCH space available on WN : \n'
356 <           txt += '   df -h \n'
357 <           txt += 'fi \n'
425 >        txt += 'if [ $middleware == OSG ]; then\n'
426 >        txt += '   #\n'
427 >        txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
428 >        txt += '   #\n'
429 >        txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
430 >        txt += 'elif [ $middleware == LCG ]; then \n'
431 >        txt += '   #\n'
432 >        txt += '   #   Copy Input Data from SE to this WN\n'
433 >        txt += '   #\n'
434 >        ### changed by georgia (put a loop copying more than one input files per jobs)          
435 >        txt += '   for input_file in $cur_file_list \n'
436 >        txt += '   do \n'
437 >        txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
438 >        txt += '      copy_input_exit_status=$?\n'
439 >        txt += '      echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
440 >        txt += '      if [ $copy_input_exit_status -ne 0 ]; then \n'
441 >        txt += '         echo "Problems with copying to WN" \n'
442 >        txt += '      else \n'
443 >        txt += '         echo "input copied into WN" \n'
444 >        txt += '      fi \n'
445 >        txt += '   done \n'
446 >        ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
447 >        txt += '   for file in $cur_pu_list \n'
448 >        txt += '   do \n'
449 >        txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
450 >        txt += '      copy_input_pu_exit_status=$?\n'
451 >        txt += '      echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
452 >        txt += '      if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
453 >        txt += '         echo "Problems with copying pu to WN" \n'
454 >        txt += '      else \n'
455 >        txt += '         echo "input pu files copied into WN" \n'
456 >        txt += '      fi \n'
457 >        txt += '   done \n'
458 >        txt += '   \n'
459 >        txt += '   ### Check SCRATCH space available on WN : \n'
460 >        txt += '   df -h \n'
461 >        txt += 'fi \n'
462            
463          return txt
464  
# Line 364 | Line 468 | class SchedulerEdg(Scheduler):
468          to copy produced output into a storage element.
469          """
470          txt = ''
471 +
472 +        ##### FEDE MOVED FROM SET_ENVIRONMENT ##############
473 +        
474 +        SE_PATH=''
475          if int(self.copy_data) == 1:
476 +           if self.SE:
477 +              txt += 'export SE='+self.SE+'\n'
478 +              txt += 'echo "SE = $SE"\n'
479 +           if self.SE_PATH:
480 +              if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
481 +              SE_PATH=self.SE_PATH
482 +              ####### FEDE FOR DBS2
483 +              if int(self.publish_data) == 1:
484 +                  txt += '### publish_data = 1 so the SE path where to copy the output is: \n'
485 +                  txt += 'subject=`voms-proxy-info -subject | awk -F\'CN\' \'{print $2$3$4}\' | tr -d \'=/ \'` \n'
486 +                  txt += 'echo "subject = $subject" \n'
487 +                  
488 +                  path_add = '${subject}/'+ self.publish_data_name +'_${PSETHASH}/'
489 +                  SE_PATH = SE_PATH + path_add
490 +
491 +              txt += 'export SE_PATH='+SE_PATH+'\n'
492 +              txt += 'echo "SE_PATH = $SE_PATH"\n'
493 +
494 +        ##########################################################  
495 +
496 +        #if int(self.copy_data) == 1:
497             txt += '#\n'
498             txt += '#   Copy output to SE = $SE\n'
499             txt += '#\n'
371           #txt += 'if [ $exe_result -eq 0 ]; then\n'
500             txt += '    if [ $middleware == OSG ]; then\n'
501             txt += '        echo "X509_USER_PROXY = $X509_USER_PROXY"\n'
502             txt += '        echo "source $OSG_APP/glite/setup_glite_ui.sh"\n'
# Line 376 | Line 504 | class SchedulerEdg(Scheduler):
504             txt += '        export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n'
505             txt += '        echo "export X509_CERT_DIR=$X509_CERT_DIR"\n'
506             txt += '    fi \n'
507 +
508             txt += '    for out_file in $file_list ; do\n'
509 <           txt += '        echo "Trying to copy output file to $SE using lcg-cp"\n'
510 <           txt += '        echo "lcg-cp --vo $VO -t 1200 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
511 <           txt += '        exitstring=`lcg-cp --vo $VO -t 1200 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
509 >           txt += '        echo "Trying to copy output file to $SE using srmcp"\n'
510 >           txt += '        echo "mkdir -p $HOME/.srmconfig"\n'
511 >           txt += '        mkdir -p $HOME/.srmconfig\n'
512 >           txt += '        if [ $middleware == LCG ]; then\n'
513 >           txt += '           echo "srmcp -retry_num 3 -retry_timeout 480000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
514 >           txt += '           exitstring=`srmcp -retry_num 3 -retry_timeout 480000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
515 >           txt += '        elif [ $middleware == OSG ]; then\n'
516 >           txt += '           echo "srmcp -retry_num 3 -retry_timeout 240000 -x509_user_trusted_certificates $X509_CERT_DIR file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
517 >           txt += '           exitstring=`srmcp -retry_num 3 -retry_timeout 240000 -x509_user_trusted_certificates $X509_CERT_DIR file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
518 >           txt += '        fi \n'
519             txt += '        copy_exit_status=$?\n'
520 <           txt += '        echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
520 >           txt += '        echo "COPY_EXIT_STATUS for srmcp = $copy_exit_status"\n'
521             txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
522 +
523             txt += '        if [ $copy_exit_status -ne 0 ]; then\n'
524             txt += '            echo "Possible problem with SE = $SE"\n'
525             txt += '            echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
526             txt += '            echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
527 <           txt += '            echo "lcg-cp failed, attempting srmcp"\n'
528 <           txt += '            echo "mkdir -p $HOME/.srmconfig"\n'
529 <           txt += '            mkdir -p $HOME/.srmconfig\n'
530 <           txt += '            if [ $middleware == LCG ]; then\n'
531 <           txt += '               echo "srmcp -retry_num 5 -retry_timeout 240000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
532 <           txt += '               exitstring=`srmcp -retry_num 5 -retry_timeout 240000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
533 <           txt += '            elif [ $middleware == OSG ]; then\n'
534 <           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'
535 <           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'
536 <           txt += '            fi \n'
527 >           txt += '            echo "srmcp failed, attempting lcg-cp."\n'
528 >           if common.logger.debugLevel() >= 5:
529 >               ########### FEDE CHANGES TO WRITE IN SRM LNL.INFN.IT #################
530 >               #txt += '            echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
531 >               #txt += '            exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
532 >               txt += '            echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
533 >               txt += '            exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
534 >           else:              
535 >               #txt += '            echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
536 >               #txt += '            exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
537 >               txt += '            echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
538 >               txt += '            exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
539             txt += '            copy_exit_status=$?\n'
540 <           txt += '            echo "COPY_EXIT_STATUS for srm = $copy_exit_status"\n'
540 >           txt += '            echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
541             txt += '            echo "STAGE_OUT = $copy_exit_status"\n'
542 +
543             txt += '            if [ $copy_exit_status -ne 0 ]; then\n'
544             txt += '               echo "Problems with SE = $SE"\n'
545             txt += '               echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
546             txt += '               echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
547 <           txt += '               echo "lcg-cp and srm failed"\n'
548 <           txt += '               echo "If storage_path in your config file contains a ? you may need a \? instead."\n'
547 >           txt += '               echo "srmcp and lcg-cp and failed!"\n'
548 >           txt += '               SE=""\n'
549 >           txt += '               echo "SE = $SE"\n'
550 >           txt += '               SE_PATH=""\n'
551 >           txt += '               echo "SE_PATH = $SE_PATH"\n'
552             txt += '            else\n'
553             txt += '               echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
554             txt += '               echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
555             txt += '               echo "output copied into $SE/$SE_PATH directory"\n'
556             txt += '               echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
557 <           txt += '               echo "srmcp succeeded"\n'
557 >           txt += '               echo "lcg-cp succeeded"\n'
558             txt += '            fi\n'
559             txt += '        else\n'
560             txt += '            echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
561             txt += '            echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
562             txt += '            echo "output copied into $SE/$SE_PATH directory"\n'
563             txt += '            echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
564 <           txt += '            echo "lcg-cp succeeded"\n'
564 >           txt += '            echo "srmcp succeeded"\n'
565             txt += '         fi\n'
566             txt += '     done\n'
567 <           #txt += 'fi\n'
567 >           txt += '     exit_status=$copy_exit_status\n'
568          return txt
569  
570      def wsRegisterOutput(self):
# Line 441 | Line 584 | class SchedulerEdg(Scheduler):
584             txt += '#\n'
585             txt += '#  Register output to LFC\n'
586             txt += '#\n'
444           #txt += '   if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
587             txt += '   if [ $copy_exit_status -eq 0 ]; then\n'
588             txt += '      for out_file in $file_list ; do\n'
589             txt += '         echo "Trying to register the output file into LFC"\n'
448           #### FEDE
449           #txt += '         echo "which lcg-rf" \n'
450           #txt += '         which lcg-rf \n'
451           #########
590             txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n'
591             txt += '         lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n'
592             txt += '         register_exit_status=$?\n'
# Line 457 | Line 595 | class SchedulerEdg(Scheduler):
595             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
596             txt += '            echo "Problems with the registration to LFC" \n'
597             txt += '            echo "Try with srm protocol" \n'
460           #### FEDE
461           #txt += '            echo "which lcg-rf" \n'
462           #txt += '            which lcg-rf \n'
463           #########
598             txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n'
599             txt += '            lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n'
600             txt += '            register_exit_status=$?\n'
# Line 474 | Line 608 | class SchedulerEdg(Scheduler):
608             txt += '         fi \n'
609             txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
610             txt += '      done\n'
477           #txt += '   elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
611             txt += '   else \n'
612             txt += '      echo "Trying to copy output file to CloseSE"\n'
613             txt += '      CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
614             txt += '      for out_file in $file_list ; do\n'
482           #### FEDE
483           #txt += '         echo "which lcg-cr" \n'
484           #txt += '         which lcg-cr \n'
485           #########
615             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'
616             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'
617             txt += '         register_exit_status=$?\n'
# Line 497 | Line 626 | class SchedulerEdg(Scheduler):
626             txt += '         fi \n'
627             txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
628             txt += '      done\n'
500           #txt += '   else\n'
501           #txt += '      echo "Problem with the executable"\n'
629             txt += '   fi \n'
630             txt += '   exit_status=$register_exit_status\n'
631             txt += 'fi \n'
# Line 510 | Line 637 | class SchedulerEdg(Scheduler):
637          """
638          self.checkProxy()
639          cmd = 'edg-job-get-logging-info -v 2 ' + id
513        #cmd_out = os.popen(cmd)
640          cmd_out = runCommand(cmd)
641          return cmd_out
642  
643 <    def listMatch(self, nj):
644 <        """
645 <        Check the compatibility of available resources
646 <        """
647 <        self.checkProxy()
522 <        jdl = common.job_list[nj].jdlFilename()
523 <        cmd = 'edg-job-list-match ' + self.configOpt_() + jdl
524 <        cmd_out = runCommand(cmd,0,10)
525 <        if not cmd_out:
526 <            raise CrabException("ERROR: "+cmd+" failed!")
643 >    def queryDetailedStatus(self, id):
644 >        """ Query a detailed status of the job with id """
645 >        cmd = 'edg-job-status '+id
646 >        cmd_out = runCommand(cmd)
647 >        return cmd_out
648  
649 <        return self.parseListMatch_(cmd_out, jdl)
649 >    def findSites_(self, n):
650 >        itr4 =[]
651 >        sites = common.jobDB.destination(n)
652 >        if len(sites)>0 and sites[0]=="Any":
653 >            return itr4
654 >        itr = ''
655 >        if sites != [""]:#CarlosDaniele
656 >            for site in sites:
657 >                #itr = itr + 'target.GlueSEUniqueID==&quot;'+site+'&quot; || '
658 >                itr = itr + 'target.GlueSEUniqueID=="'+site+'" || '
659 >            itr = itr[0:-4]
660 >            itr4.append( itr )
661 >        return itr4
662  
663 <    def parseListMatch_(self, out, jdl):
663 >    def createXMLSchScript(self, nj, argsList):
664 >      
665          """
666 <        Parse the f* output of edg-list-match and produce something sensible
666 >        Create a XML-file for BOSS4.
667          """
668 <        reComment = re.compile( r'^\**$' )
535 <        reEmptyLine = re.compile( r'^$' )
536 <        reVO = re.compile( r'Selected Virtual Organisation name.*' )
537 <        reLine = re.compile( r'.*')
538 <        reCE = re.compile( r'(.*:.*)')
539 <        reCEId = re.compile( r'CEId.*')
540 <        reNO = re.compile( r'No Computing Element matching' )
541 <        reRB = re.compile( r'Connecting to host' )
542 <        next = 0
543 <        CEs=[]
544 <        Match=0
545 <
546 <        #print out
547 <        lines = reLine.findall(out)
548 <
549 <        i=0
550 <        CEs=[]
551 <        for line in lines:
552 <            string.strip(line)
553 <            #print line
554 <            if reNO.match( line ):
555 <                common.logger.debug(5,line)
556 <                return 0
557 <                pass
558 <            if reVO.match( line ):
559 <                VO =reVO.match( line ).group()
560 <                common.logger.debug(5,"VO "+VO)
561 <                pass
562 <
563 <            if reRB.match( line ):
564 <                RB = reRB.match(line).group()
565 <                common.logger.debug(5,"RB "+RB)
566 <                pass
567 <
568 <            if reCEId.search( line ):
569 <                for lineCE in lines[i:-1]:
570 <                    if reCE.match( lineCE ):
571 <                        CE = string.strip(reCE.search(lineCE).group(1))
572 <                        CEs.append(CE.split(':')[0])
573 <                        pass
574 <                    pass
575 <                pass
576 <            i=i+1
577 <            pass
578 <
579 <        common.logger.debug(5,"All CE :"+str(CEs))
580 <
581 <        sites = []
582 <        [sites.append(it) for it in CEs if not sites.count(it)]
583 <
584 <        common.logger.debug(5,"All Sites :"+str(sites))
585 <        common.logger.message("Matched Sites :"+str(sites))
586 <        return len(sites)
587 <
588 <    def noMatchFound_(self, jdl):
589 <        reReq = re.compile( r'Requirements' )
590 <        reString = re.compile( r'"\S*"' )
591 <        f = file(jdl,'r')
592 <        for line in f.readlines():
593 <            line= line.strip()
594 <            if reReq.match(line):
595 <                for req in reString.findall(line):
596 <                    if re.search("VO",req):
597 <                        common.logger.message( "SW required: "+req)
598 <                        continue
599 <                    if re.search('"\d+',req):
600 <                        common.logger.message("Other req  : "+req)
601 <                        continue
602 <                    common.logger.message( "CE required: "+req)
603 <                break
604 <            pass
605 <        raise CrabException("No compatible resources found!")
606 <
607 <    def submit(self, nj):
668 >  #      job = common.job_list[nj]
669          """
670 <        Submit one EDG job.
670 >        INDY
671 >        [begin] FIX-ME:
672 >        I would pass jobType instead of job
673          """
674 <
675 <        self.checkProxy()
676 <        jid = None
677 <        jdl = common.job_list[nj].jdlFilename()
678 <
679 <        cmd = 'edg-job-submit ' + self.configOpt_() + jdl
617 <        cmd_out = runCommand(cmd)
618 <        if cmd_out != None:
619 <            reSid = re.compile( r'https.+' )
620 <            jid = reSid.search(cmd_out).group()
621 <            pass
622 <        return jid
623 <
624 <    def resubmit(self, nj_list):
674 >        index = nj - 1
675 >        job = common.job_list[index]
676 >        jbt = job.type()
677 >        
678 >        inp_sandbox = jbt.inputSandbox(index)
679 >        #out_sandbox = jbt.outputSandbox(index)
680          """
681 <        Prepare jobs to be submit
681 >        [end] FIX-ME
682          """
628        return
629
630    def getExitStatus(self, id):
631        return self.getStatusAttribute_(id, 'exit_code')
632
633    def queryStatus(self, id):
634        return self.getStatusAttribute_(id, 'status')
635
636    def queryDest(self, id):  
637        return self.getStatusAttribute_(id, 'destination')
683  
684 +        
685 +        title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n'
686 +        jt_string = ''
687 +        
688 +        xml_fname = str(self.jobtypeName)+'.xml'
689 +        xml = open(common.work_space.shareDir()+'/'+xml_fname, 'a')
690  
691 <    def getStatusAttribute_(self, id, attr):
692 <        """ Query a status of the job with id """
693 <
694 <        self.checkProxy()
695 <        hstates = {}
645 <        Status = importName('edg_wl_userinterface_common_LbWrapper', 'Status')
646 <        # Bypass edg-job-status interfacing directly to C++ API
647 <        # Job attribute vector to retrieve status without edg-job-status
648 <        level = 0
649 <        # Instance of the Status class provided by LB API
650 <        jobStat = Status()
651 <        st = 0
652 <        jobStat.getStatus(id, level)
653 <        err, apiMsg = jobStat.get_error()
654 <        if err:
655 <            common.logger.debug(5,'Error caught' + apiMsg)
656 <            return None
657 <        else:
658 <            for i in range(len(self.states)):
659 <                # Fill an hash table with all information retrieved from LB API
660 <                hstates[ self.states[i] ] = jobStat.loadStatus(st)[i]
661 <            result = jobStat.loadStatus(st)[ self.states.index(attr) ]
662 <            return result
663 <
664 <    def queryDetailedStatus(self, id):
665 <        """ Query a detailed status of the job with id """
666 <        cmd = 'edg-job-status '+id
667 <        cmd_out = runCommand(cmd)
668 <        return cmd_out
691 >        #TaskName  
692 >        dir = string.split(common.work_space.topDir(), '/')
693 >        taskName = dir[len(dir)-2]
694 >  
695 >        to_write = ''
696  
697 <    def getOutput(self, id):
698 <        """
672 <        Get output for a finished job with id.
673 <        Returns the name of directory with results.
674 <        """
697 >        req=' '
698 >        req = req + jbt.getRequirements()
699  
700 <        self.checkProxy()
701 <        cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() + ' ' + id
702 <        cmd_out = runCommand(cmd)
700 >        if self.EDG_requirements:
701 >            if (req == ' '):
702 >                req = req + self.EDG_requirements
703 >            else:
704 >                req = req +  ' && ' + self.EDG_requirements
705 >        if self.EDG_ce_white_list:
706 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
707 >            for i in range(len(ce_white_list)):
708 >                if i == 0:
709 >                    if (req == ' '):
710 >                        req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
711 >                    else:
712 >                        req = req +  ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
713 >                    pass
714 >                else:
715 >                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
716 >            req = req + ')'
717 >        
718 >        if self.EDG_ce_black_list:
719 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
720 >            for ce in ce_black_list:
721 >                if (req == ' '):
722 >                    req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
723 >                else:
724 >                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
725 >                pass
726 >        if self.EDG_clock_time:
727 >            if (req == ' '):
728 >                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
729 >            else:
730 >                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
731  
732 <        # Determine the output directory name
733 <        dir = common.work_space.resDir()
734 <        dir += os.environ['USER']
735 <        dir += '_' + os.path.basename(id)
736 <        return dir
732 >        if self.EDG_cpu_time:
733 >            if (req == ' '):
734 >                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
735 >            else:
736 >                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
737 >                                                                                          
738 >        if ( self.EDG_retry_count ):              
739 >            to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n'
740 >            pass
741  
742 <    def cancel(self, id):
743 <        """ Cancel the EDG job with id """
744 <        self.checkProxy()
689 <        cmd = 'edg-job-cancel --noint ' + id
690 <        cmd_out = runCommand(cmd)
691 <        return cmd_out
742 >        if ( self.EDG_shallow_retry_count ):              
743 >            to_write = to_write + 'ShallowRetryCount = "'+self.EDG_shallow_retry_count+'"\n'
744 >            pass
745  
746 <    def createSchScript(self, nj):
747 <        """
695 <        Create a JDL-file for EDG.
696 <        """
746 >        to_write = to_write + 'MyProxyServer = "&quot;' + self.proxyServer + '&quot;"\n'
747 >        to_write = to_write + 'VirtualOrganisation = "&quot;' + self.VO + '&quot;"\n'
748  
749 <        job = common.job_list[nj]
750 <        jbt = job.type()
751 <        inp_sandbox = jbt.inputSandbox(nj)
752 <        out_sandbox = jbt.outputSandbox(nj)
753 <        inp_storage_subdir = ''
749 >        #TaskName  
750 >        dir = string.split(common.work_space.topDir(), '/')
751 >        taskName = dir[len(dir)-2]
752 >
753 >        xml.write(str(title))
754 >        #xml.write('<task name="' +str(taskName)+'" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache">\n')
755 >
756 >        #xml.write('<task name="' +str(taskName)+ '" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache"' + '" task_info="' + os.path.expandvars('X509_USER_PROXY') + '">\n')
757 >        xml.write('<task name="' +str(taskName)+ '" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache"' + ' task_info="' + os.environ["X509_USER_PROXY"] + '">\n')
758 >        xml.write(jt_string)
759          
760 <        title = '# This JDL was generated by '+\
761 <                common.prog_name+' (version '+common.prog_version_str+')\n'
762 <        jt_string = ''
763 <
760 >        if (to_write != ''):
761 >            xml.write('<extraTags\n')
762 >            xml.write(to_write)
763 >            xml.write('/>\n')
764 >            pass
765  
766 +        xml.write('<iterator>\n')
767 +        xml.write('\t<iteratorRule name="ITR1">\n')
768 +        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ' </ruleElement>\n')
769 +        xml.write('\t</iteratorRule>\n')
770 +        xml.write('\t<iteratorRule name="ITR2">\n')
771 +        for arg in argsList:
772 +            xml.write('\t\t<ruleElement> <![CDATA[\n'+ arg + '\n\t\t]]> </ruleElement>\n')
773 +            pass
774 +        xml.write('\t</iteratorRule>\n')
775 +        #print jobList
776 +        xml.write('\t<iteratorRule name="ITR3">\n')
777 +        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ':1:6 </ruleElement>\n')
778 +        xml.write('\t</iteratorRule>\n')
779 +
780 +        '''
781 +        indy: here itr4
782 +        '''
783          
784 <        SPL = inp_storage_subdir
785 <        if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/'
784 >        xml.write('<chain name="' +str(taskName)+'__ITR1_" scheduler="'+str(self.schedulerName)+'">\n')
785 >       # xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n')
786 >        xml.write(jt_string)
787  
788 <        jdl_fname = job.jdlFilename()
714 <        jdl = open(jdl_fname, 'w')
715 <        jdl.write(title)
788 >        #executable
789  
790 +        """
791 +        INDY
792 +        script depends on jobType: it should be probably get in a different way
793 +        """        
794          script = job.scriptFilename()
795 <        jdl.write('Executable = "' + os.path.basename(script) +'";\n')
796 <        jdl.write(jt_string)
797 <
798 <        ### only one .sh  JDL has arguments:
799 <
800 <        ### Fabio
801 <        jdl.write('Arguments = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'";\n')
725 <        inp_box = 'InputSandbox = { '
726 <        inp_box = inp_box + '"' + script + '",'
795 >        xml.write('<program>\n')
796 >        xml.write('<exec> ' + os.path.basename(script) +' </exec>\n')
797 >        xml.write(jt_string)
798 >
799 >        xml.write('<args> <![CDATA[\n _ITR2_ \n]]> </args>\n')
800 >        xml.write('<program_types> crabjob </program_types>\n')
801 >        inp_box = common.work_space.pathForTgz() + 'job/' + jbt.scriptName + ','
802  
803          if inp_sandbox != None:
804              for fl in inp_sandbox:
805 <                inp_box = inp_box + ' "' + fl + '",'
805 >                inp_box = inp_box + '' + fl + ','
806                  pass
807              pass
808  
809 <        #if common.use_jam:
810 <        #   inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",'
811 <
812 <        # Marco (VERY TEMPORARY ML STUFF)
813 <        inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\
814 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + '", "'+\
740 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\
741 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\
742 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"'
743 <        # End Marco
744 <
745 <        if (not jbt.additional_inbox_files == []):
746 <            inp_box = inp_box + ', '
747 <            for addFile in jbt.additional_inbox_files:
748 <                addFile = os.path.abspath(addFile)
749 <                inp_box = inp_box+' "'+addFile+'",'
750 <                pass
809 > #        if (not jbt.additional_inbox_files == []):
810 > #            inp_box = inp_box + ','
811 > #            for addFile in jbt.additional_inbox_files:
812 > #                #addFile = os.path.abspath(addFile)
813 > #                inp_box = inp_box+''+addFile+','
814 > #                pass
815  
816          if inp_box[-1] == ',' : inp_box = inp_box[:-1]
817 <        inp_box = inp_box + ' };\n'
818 <        jdl.write(inp_box)
755 <
756 <        jdl.write('StdOutput     = "' + job.stdout() + '";\n')
757 <        jdl.write('StdError      = "' + job.stderr() + '";\n')
817 >        inp_box = '<infiles> <![CDATA[\n' + inp_box + '\n]]> </infiles>\n'
818 >        xml.write(inp_box)
819          
820 +        base = jbt.name()
821 +        stdout = base + '__ITR3_.stdout'
822 +        stderr = base + '__ITR3_.stderr'
823          
824 <        if job.stdout() == job.stderr():
825 <          out_box = 'OutputSandbox = { "' + \
826 <                    job.stdout() + '", ".BrokerInfo",'
827 <        else:
828 <          out_box = 'OutputSandbox = { "' + \
829 <                    job.stdout() + '", "' + \
766 <                    job.stderr() + '", ".BrokerInfo",'
824 >        xml.write('<stderr> ' + stderr + '</stderr>\n')
825 >        xml.write('<stdout> ' + stdout + '</stdout>\n')
826 >        
827 >
828 >        out_box = stdout + ',' + \
829 >                  stderr + ',.BrokerInfo,'
830  
831 +        """
832          if int(self.return_data) == 1:
833              if out_sandbox != None:
834                  for fl in out_sandbox:
835 <                    out_box = out_box + ' "' + fl + '",'
835 >                    out_box = out_box + '' + fl + ','
836                      pass
837                  pass
838              pass
839 <                                                                                                                                                            
776 <        if out_box[-1] == ',' : out_box = out_box[:-1]
777 <        out_box = out_box + ' };'
778 <        jdl.write(out_box+'\n')
839 >        """
840  
841 +        """
842 +        INDY
843 +        something similar should be also done for infiles (if it makes sense!)
844 +        """
845 +        # Stuff to be returned _always_ via sandbox
846 +        for fl in jbt.output_file_sandbox:
847 +            out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ','
848 +            pass
849 +        pass
850  
851 <        req='Requirements = '
852 <        noreq=req
853 <        req = req + jbt.getRequirements()
854 <        #### and USER REQUIREMENT
785 <        if self.EDG_requirements:
786 <            if (req != noreq):
787 <                req = req +  ' && '
788 <            req = req + self.EDG_requirements
789 <        #### FEDE #####
790 <        if self.EDG_ce_white_list:
791 <            ce_white_list = string.split(self.EDG_ce_white_list,',')
792 <            #print "req = ", req
793 <            for i in range(len(ce_white_list)):
794 <                if i == 0:
795 <                    if (req != noreq):
796 <                        req = req +  ' && '
797 <                    req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
798 <                    pass
799 <                else:
800 <                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
801 <            req = req + ')'
802 <        
803 <        if self.EDG_ce_black_list:
804 <            ce_black_list = string.split(self.EDG_ce_black_list,',')
805 <            for ce in ce_black_list:
806 <                if (req != noreq):
807 <                    req = req +  ' && '
808 <                req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
851 >        # via sandbox iif required return_data
852 >        if int(self.return_data) == 1:
853 >            for fl in jbt.output_file:
854 >                out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ','
855                  pass
856 +            pass
857  
858 <        ###############
859 <        clockTime=480
860 <        if self.EDG_clock_time:
861 <            clockTime= self.EDG_clock_time
862 <        if (req != noreq):
816 <            req = req + ' && '
817 <        req = req + '((other.GlueCEPolicyMaxWallClockTime == 0) || (other.GlueCEPolicyMaxWallClockTime>='+str(clockTime)+'))'
858 >        if out_box[-1] == ',' : out_box = out_box[:-1]
859 >        out_box = '<outfiles> <![CDATA[\n' + out_box + '\n]]></outfiles>\n'
860 >        xml.write(out_box)
861 >
862 >        xml.write('<BossAttr> crabjob.INTERNAL_ID=_ITR1_ </BossAttr>\n')
863  
864 <        cpuTime=1000
865 <        if self.EDG_cpu_time:
821 <            cpuTime=self.EDG_cpu_time
822 <        if (req != noreq):
823 <            req = req + ' && '
824 <        req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))'
825 <
826 <        if (req != noreq):
827 <            req = req + ';\n'
828 <            jdl.write(req)
829 <                                                                                                                                                            
830 <        jdl.write('VirtualOrganisation = "' + self.VO + '";\n')
864 >        xml.write('</program>\n')
865 >        xml.write('</chain>\n')
866  
867 <        if ( self.EDG_retry_count ):              
868 <            jdl.write('RetryCount = '+self.EDG_retry_count+';\n')
834 <            pass
867 >        xml.write('</iterator>\n')
868 >        xml.write('</task>\n')
869  
870 <        jdl.write('MyProxyServer = "' + self.proxyServer + '";\n')
870 >        xml.close()
871 >      
872  
838        jdl.close()
873          return
874  
875      def checkProxy(self):
# Line 843 | Line 877 | class SchedulerEdg(Scheduler):
877          Function to check the Globus proxy.
878          """
879          if (self.proxyValid): return
880 <        timeleft = -999
880 >
881 >        ### Just return if asked to do so
882 >        if (self.dontCheckProxy==1):
883 >            self.proxyValid=1
884 >            return
885 >
886          minTimeLeft=10*3600 # in seconds
887  
888          minTimeLeftServer = 100 # in hours
889  
851        #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
852        #cmd = 'voms-proxy-info -timeleft'
890          mustRenew = 0
891          timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null')
892          timeLeftServer = -999
# Line 865 | Line 902 | class SchedulerEdg(Scheduler):
902          pass
903  
904          if mustRenew:
905 <            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")
906 <            cmd = 'voms-proxy-init -voms cms -valid 96:00'
905 >            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 192h\n")
906 >            cmd = 'voms-proxy-init -voms '+self.VO
907 >            if self.group:
908 >                cmd += ':/'+self.VO+'/'+self.group
909 >            if self.role:
910 >                cmd += '/role='+self.role
911 >            cmd += ' -valid 192:00'
912              try:
913                  # SL as above: damn it!
914 +                common.logger.debug(10,cmd)
915                  out = os.system(cmd)
916                  if (out>0): raise CrabException("Unable to create a valid proxy!\n")
917              except:
918                  msg = "Unable to create a valid proxy!\n"
919                  raise CrabException(msg)
877            # cmd = 'grid-proxy-info -timeleft'
878            # cmd_out = runCommand(cmd,0,20)
920              pass
921  
922          ## now I do have a voms proxy valid, and I check the myproxy server
# Line 890 | Line 931 | class SchedulerEdg(Scheduler):
931              reTime = re.compile( r'timeleft: (\d+)' )
932              #print "<"+str(reTime.search( cmd_out ).group(1))+">"
933              if reTime.match( cmd_out ):
934 <                time = reTime.search( line ).group(1)
934 >                time = reTime.search( cmd_out ).group(1)
935                  if time < minTimeLeftServer:
936                      renewProxy = 1
937                      common.logger.message('No credential delegation will expire in '+time+' hours: renew it')
# Line 916 | Line 957 | class SchedulerEdg(Scheduler):
957          if self.edg_config_vo:
958              edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' '
959          return edg_ui_cfg_opt
960 +
961 +    def submitTout(self, list):
962 +        return 120
963 +
964 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines