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.64 by gutsche, Tue Jun 27 02:31:31 2006 UTC vs.
Revision 1.115 by corvo, Fri May 18 10:01:45 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  
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 128 | Line 126 | class SchedulerEdg(Scheduler):
126  
127          try: self.EDG_requirements = cfg_params['EDG.requirements']
128          except KeyError: self.EDG_requirements = ''
129 <                                                                                                                                                            
129 >
130 >        try: self.EDG_addJdlParam = string.split(cfg_params['EDG.additional_jdl_parameters'],',')
131 >        except KeyError: self.EDG_addJdlParam = []
132 >
133          try: self.EDG_retry_count = cfg_params['EDG.retry_count']
134          except KeyError: self.EDG_retry_count = ''
135 <                                                                                                                                                            
135 >
136 >        try: self.EDG_shallow_retry_count= cfg_params['EDG.shallow_retry_count']
137 >        except KeyError: self.EDG_shallow_retry_count = ''
138 >
139          try: self.EDG_clock_time = cfg_params['EDG.max_wall_clock_time']
140          except KeyError: self.EDG_clock_time= ''
141 <                                                                                                                                                            
141 >
142          try: self.EDG_cpu_time = cfg_params['EDG.max_cpu_time']
143          except KeyError: self.EDG_cpu_time = ''
144  
# Line 158 | Line 162 | class SchedulerEdg(Scheduler):
162          except:
163              self._taskId = ''
164  
165 +        try: self.jobtypeName = cfg_params['CRAB.jobtype']
166 +        except KeyError: self.jobtypeName = ''
167 +
168 +        try: self.schedulerName = cfg_params['CRAB.scheduler']
169 +        except KeyError: self.scheduler = ''
170 +
171 +        try: self.dontCheckProxy=cfg_params["EDG.dont_check_proxy"]
172 +        except KeyError: self.dontCheckProxy = 0
173 +
174          return
175      
176  
177 +    def rb_configure(self, RB):
178 +        self.edg_config = ''
179 +        self.edg_config_vo = ''
180 +        self.rb_param_file = ''
181 +
182 +        edgConfig = EdgConfig(RB)
183 +        self.edg_config = edgConfig.config()
184 +        self.edg_config_vo = edgConfig.configVO()
185 +
186 +        if (self.edg_config and self.edg_config_vo != ''):
187 +            self.rb_param_file = 'RBconfig = "'+self.edg_config+'";\nRBconfigVO = "'+self.edg_config_vo+'";'
188 +            #print "rb_param_file = ", self.rb_param_file
189 +        return self.rb_param_file
190 +      
191 +
192      def sched_parameter(self):
193          """
194 <        Returns file with scheduler-specific parameters
194 >        Returns file with requirements and scheduler-specific parameters
195          """
196 <      
197 <        if (self.edg_config and self.edg_config_vo != ''):
198 <            self.param='sched_param.clad'
196 >        index = int(common.jobDB.nJobs()) - 1
197 >        job = common.job_list[index]
198 >        jbt = job.type()
199 >        
200 >        lastBlock=-1
201 >        first = []
202 >        for n in range(common.jobDB.nJobs()):
203 >            currBlock=common.jobDB.block(n)
204 >            if (currBlock!=lastBlock):
205 >                lastBlock = currBlock
206 >                first.append(n)
207 >  
208 >        req = ''
209 >        req = req + jbt.getRequirements()
210 >    
211 >        if self.EDG_requirements:
212 >            if (req == ' '):
213 >                req = req + self.EDG_requirements
214 >            else:
215 >                req = req +  ' && ' + self.EDG_requirements
216 >
217 >        if self.EDG_ce_white_list:
218 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
219 >            for i in range(len(ce_white_list)):
220 >                if i == 0:
221 >                    if (req == ' '):
222 >                        req = req + '((RegExp("' + string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))'
223 >                    else:
224 >                        req = req +  ' && ((RegExp("' +  string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))'
225 >                    pass
226 >                else:
227 >                    req = req +  ' || (RegExp("' +  string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))'
228 >            req = req + ')'
229 >        
230 >        if self.EDG_ce_black_list:
231 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
232 >            for ce in ce_black_list:
233 >                if (req == ' '):
234 >                    req = req + '(!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))'
235 >                else:
236 >                    req = req +  ' && (!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))'
237 >                pass
238 >        if self.EDG_clock_time:
239 >            if (req == ' '):
240 >                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
241 >            else:
242 >                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
243 >
244 >        if self.EDG_cpu_time:
245 >            if (req == ' '):
246 >                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
247 >            else:
248 >                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
249 >                
250 >        for i in range(len(first)): # Add loop DS
251 >            groupReq = req
252 >            self.param='sched_param_'+str(i)+'.clad'
253              param_file = open(common.work_space.shareDir()+'/'+self.param, 'w')
254 <            param_file.write('RBconfig = "'+self.edg_config+'";\n')  
255 <            param_file.write('RBconfigVO = "'+self.edg_config_vo+'";')
254 >
255 >            itr4=self.findSites_(first[i])
256 >            for arg in itr4:
257 >                groupReq = groupReq + ' && anyMatch(other.storage.CloseSEs, ('+str(arg)+'))'
258 >            param_file.write('Requirements = '+groupReq +';\n')  
259 >  
260 >            if (self.rb_param_file != ''):
261 >                param_file.write(self.rb_param_file)  
262 >
263 >            if len(self.EDG_addJdlParam):
264 >                for p in self.EDG_addJdlParam:
265 >                    param_file.write(p)
266 >
267              param_file.close()  
268 <            return 1
176 <        else:
177 <            return 0
268 >
269  
270      def wsSetupEnvironment(self):
271          """
272          Returns part of a job script which does scheduler-specific work.
273          """
274          txt = ''
275 +        txt += '# strip arguments\n'
276 +        txt += 'echo "strip arguments"\n'
277 +        txt += 'args=("$@")\n'
278 +        txt += 'nargs=$#\n'
279 +        txt += 'shift $nargs\n'
280          txt += "# job number (first parameter for job wrapper)\n"
281 <        txt += "NJob=$1\n"
281 >        #txt += "NJob=$1\n"
282 >        txt += "NJob=${args[0]}\n"
283  
284          txt += '# job identification to DashBoard \n'
285          txt += 'MonitorJobID=`echo ${NJob}_$EDG_WL_JOBID`\n'
# Line 193 | Line 290 | class SchedulerEdg(Scheduler):
290          txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
291  
292          txt += 'echo "middleware discovery " \n'
293 <        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'
293 >        txt += 'if [ $GRID3_APP_DIR ]; then\n'
294          txt += '    middleware=OSG \n'
295          txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
296          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
# Line 208 | Line 300 | class SchedulerEdg(Scheduler):
300          txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
301          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
302          txt += '    echo "middleware =$middleware" \n'
303 +        txt += 'elif [ $VO_CMS_SW_DIR ]; then \n'
304 +        txt += '    middleware=LCG \n'
305 +        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
306 +        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
307 +        txt += '    echo "middleware =$middleware" \n'
308          txt += 'else \n'
309          txt += '    echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
310          txt += '    echo "JOB_EXIT_STATUS = 10030" \n'
# Line 215 | Line 312 | class SchedulerEdg(Scheduler):
312          txt += '    dumpStatus $RUNTIME_AREA/$repo \n'
313          txt += '    rm -f $RUNTIME_AREA/$repo \n'
314          txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
218        txt += '    echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
315          txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
316          txt += '    exit 1 \n'
317          txt += 'fi \n'
# Line 224 | Line 320 | class SchedulerEdg(Scheduler):
320          txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
321          txt += 'rm -f $RUNTIME_AREA/$repo \n'
322          txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
227        txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
323          txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
324          
325          txt += '\n\n'
# Line 239 | Line 334 | class SchedulerEdg(Scheduler):
334                txt += 'echo "SE_PATH = $SE_PATH"\n'
335  
336          txt += 'export VO='+self.VO+'\n'
337 <        ### FEDE: add some line for LFC catalog setting
337 >        ### add some line for LFC catalog setting
338          txt += 'if [ $middleware == LCG ]; then \n'
339          txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
340          txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
# Line 294 | Line 389 | class SchedulerEdg(Scheduler):
389          txt += '        dumpStatus $RUNTIME_AREA/$repo \n'
390          txt += '        rm -f $RUNTIME_AREA/$repo \n'
391          txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
297        txt += '        echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
392          txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
393          txt += '        exit 1 \n'
394          txt += '    fi \n'
# Line 307 | Line 401 | class SchedulerEdg(Scheduler):
401          Copy input data from SE to WN    
402          """
403          txt = ''
404 <        try:
405 <            self.copy_input_data = common.analisys_common_info['copy_input_data']
312 <            #print "self.copy_input_data = ", self.copy_input_data
313 <        except KeyError: self.copy_input_data = 0
314 <        if int(self.copy_input_data) == 1:
404 >        if not self.copy_input_data: return txt
405 >
406          ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
407 <           txt += 'if [ $middleware == OSG ]; then\n'
408 <           txt += '   #\n'
409 <           txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
410 <           txt += '   #\n'
411 <           txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
412 <           txt += 'elif [ $middleware == LCG ]; then \n'
413 <           txt += '   #\n'
414 <           txt += '   #   Copy Input Data from SE to this WN\n'
415 <           txt += '   #\n'
416 < ### changed by georgia (put a loop copying more than one input files per jobs)          
417 <           txt += '   for input_file in $cur_file_list \n'
418 <           txt += '   do \n'
419 <           txt += '    lcg-cp --vo $VO lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
420 <           txt += '    copy_input_exit_status=$?\n'
421 <           txt += '    echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
422 <           txt += '    if [ $copy_input_exit_status -ne 0 ]; then \n'
423 <           txt += '       echo "Problems with copying to WN" \n'
424 <           txt += '    else \n'
425 <           txt += '       echo "input copied into WN" \n'
426 <           txt += '    fi \n'
427 <           txt += '   done \n'
428 < ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
429 <           txt += '   for file in $cur_pu_list \n'
430 <           txt += '   do \n'
431 <           txt += '    lcg-cp --vo $VO lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
432 <           txt += '    copy_input_exit_status=$?\n'
433 <           txt += '    echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
434 <           txt += '    if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
435 <           txt += '       echo "Problems with copying pu to WN" \n'
436 <           txt += '    else \n'
437 <           txt += '       echo "input pu files copied into WN" \n'
438 <           txt += '    fi \n'
439 <           txt += '   done \n'
440 <           txt += '   \n'
441 <           txt += '   ### Check SCRATCH space available on WN : \n'
442 <           txt += '   df -h \n'
443 <           txt += 'fi \n'
407 >        txt += 'if [ $middleware == OSG ]; then\n'
408 >        txt += '   #\n'
409 >        txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
410 >        txt += '   #\n'
411 >        txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
412 >        txt += 'elif [ $middleware == LCG ]; then \n'
413 >        txt += '   #\n'
414 >        txt += '   #   Copy Input Data from SE to this WN\n'
415 >        txt += '   #\n'
416 >        ### changed by georgia (put a loop copying more than one input files per jobs)          
417 >        txt += '   for input_file in $cur_file_list \n'
418 >        txt += '   do \n'
419 >        txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
420 >        txt += '      copy_input_exit_status=$?\n'
421 >        txt += '      echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
422 >        txt += '      if [ $copy_input_exit_status -ne 0 ]; then \n'
423 >        txt += '         echo "Problems with copying to WN" \n'
424 >        txt += '      else \n'
425 >        txt += '         echo "input copied into WN" \n'
426 >        txt += '      fi \n'
427 >        txt += '   done \n'
428 >        ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
429 >        txt += '   for file in $cur_pu_list \n'
430 >        txt += '   do \n'
431 >        txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
432 >        txt += '      copy_input_pu_exit_status=$?\n'
433 >        txt += '      echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
434 >        txt += '      if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
435 >        txt += '         echo "Problems with copying pu to WN" \n'
436 >        txt += '      else \n'
437 >        txt += '         echo "input pu files copied into WN" \n'
438 >        txt += '      fi \n'
439 >        txt += '   done \n'
440 >        txt += '   \n'
441 >        txt += '   ### Check SCRATCH space available on WN : \n'
442 >        txt += '   df -h \n'
443 >        txt += 'fi \n'
444            
445          return txt
446  
# Line 363 | Line 454 | class SchedulerEdg(Scheduler):
454             txt += '#\n'
455             txt += '#   Copy output to SE = $SE\n'
456             txt += '#\n'
457 <           txt += 'if [ $exe_result -eq 0 ]; then\n'
457 >           txt += '    if [ $middleware == OSG ]; then\n'
458 >           txt += '        echo "X509_USER_PROXY = $X509_USER_PROXY"\n'
459 >           txt += '        echo "source $OSG_APP/glite/setup_glite_ui.sh"\n'
460 >           txt += '        source $OSG_APP/glite/setup_glite_ui.sh\n'
461 >           txt += '        export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n'
462 >           txt += '        echo "export X509_CERT_DIR=$X509_CERT_DIR"\n'
463 >           txt += '    fi \n'
464 >
465             txt += '    for out_file in $file_list ; do\n'
466 <           txt += '        echo "Trying to copy output file to $SE "\n'
467 <           ## OLI_Daniele globus-* for OSG, lcg-* for LCG
468 <           txt += '        if [ $middleware == OSG ]; then\n'
469 <           txt += '           echo "globus-url-copy file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
470 <           txt += '           globus-url-copy file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1 \n'
471 <           txt += '           copy_exit_status=$? \n'
472 <           txt += '        elif [ $middleware == LCG ]; then \n'
473 <           txt += '           echo "lcg-cp --vo cms -t 1200 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
474 <           txt += '           lcg-cp --vo cms -t 1200 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1\n'
475 <           txt += '           copy_exit_status=$? \n'
476 <           txt += '        fi \n'
477 <           txt += '        echo "COPY_EXIT_STATUS = $copy_exit_status"\n'
466 >           txt += '        echo "Trying to copy output file to $SE using srmcp"\n'
467 >           txt += '        echo "mkdir -p $HOME/.srmconfig"\n'
468 >           txt += '        mkdir -p $HOME/.srmconfig\n'
469 >           txt += '        if [ $middleware == LCG ]; then\n'
470 >           txt += '           echo "srmcp -retry_num 3 -retry_timeout 480000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
471 >           txt += '           exitstring=`srmcp -retry_num 3 -retry_timeout 480000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
472 >           txt += '        elif [ $middleware == OSG ]; then\n'
473 >           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'
474 >           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'
475 >           txt += '        fi \n'
476 >           txt += '        copy_exit_status=$?\n'
477 >           txt += '        echo "COPY_EXIT_STATUS for srmcp = $copy_exit_status"\n'
478             txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
479 +
480             txt += '        if [ $copy_exit_status -ne 0 ]; then\n'
481 <           txt += '            echo "Problems with SE = $SE"\n'
481 >           txt += '            echo "Possible problem with SE = $SE"\n'
482             txt += '            echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
483             txt += '            echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
484 +           txt += '            echo "srmcp failed, attempting lcg-cp."\n'
485 +           if common.logger.debugLevel() >= 5:
486 +               txt += '            echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
487 +               txt += '            exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
488 +           else:              
489 +               txt += '            echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
490 +               txt += '            exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
491 +           txt += '            copy_exit_status=$?\n'
492 +           txt += '            echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
493 +           txt += '            echo "STAGE_OUT = $copy_exit_status"\n'
494 +
495 +           txt += '            if [ $copy_exit_status -ne 0 ]; then\n'
496 +           txt += '               echo "Problems with SE = $SE"\n'
497 +           txt += '               echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
498 +           txt += '               echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
499 +           txt += '               echo "srmcp and lcg-cp and failed!"\n'
500 +           txt += '               SE=""\n'
501 +           txt += '               echo "SE = $SE"\n'
502 +           txt += '               SE_PATH=""\n'
503 +           txt += '               echo "SE_PATH = $SE_PATH"\n'
504 +           txt += '            else\n'
505 +           txt += '               echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
506 +           txt += '               echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
507 +           txt += '               echo "output copied into $SE/$SE_PATH directory"\n'
508 +           txt += '               echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
509 +           txt += '               echo "lcg-cp succeeded"\n'
510 +           txt += '            fi\n'
511             txt += '        else\n'
512             txt += '            echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
513             txt += '            echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
514             txt += '            echo "output copied into $SE/$SE_PATH directory"\n'
515             txt += '            echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
516 +           txt += '            echo "srmcp succeeded"\n'
517             txt += '         fi\n'
518             txt += '     done\n'
519 <           txt += 'fi\n'
519 >           txt += '     exit_status=$copy_exit_status\n'
520          return txt
521  
522      def wsRegisterOutput(self):
# Line 409 | Line 536 | class SchedulerEdg(Scheduler):
536             txt += '#\n'
537             txt += '#  Register output to LFC\n'
538             txt += '#\n'
539 <           txt += '   if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
539 >           txt += '   if [ $copy_exit_status -eq 0 ]; then\n'
540             txt += '      for out_file in $file_list ; do\n'
541             txt += '         echo "Trying to register the output file into LFC"\n'
542 <           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file"\n'
543 <           txt += '         lcg-rf -l $LFN/$out_file --vo $VO sfn://$SE$SE_PATH/$out_file 2>&1 \n'
542 >           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n'
543 >           txt += '         lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n'
544             txt += '         register_exit_status=$?\n'
545             txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
546             txt += '         echo "STAGE_OUT = $register_exit_status"\n'
547             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
548             txt += '            echo "Problems with the registration to LFC" \n'
549             txt += '            echo "Try with srm protocol" \n'
550 <           txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file"\n'
551 <           txt += '            lcg-rf -l $LFN/$out_file --vo $VO srm://$SE$SE_PATH/$out_file 2>&1 \n'
550 >           txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n'
551 >           txt += '            lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n'
552             txt += '            register_exit_status=$?\n'
553             txt += '            echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
554             txt += '            echo "STAGE_OUT = $register_exit_status"\n'
# Line 433 | Line 560 | class SchedulerEdg(Scheduler):
560             txt += '         fi \n'
561             txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
562             txt += '      done\n'
563 <           txt += '   elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
563 >           txt += '   else \n'
564             txt += '      echo "Trying to copy output file to CloseSE"\n'
565             txt += '      CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
566             txt += '      for out_file in $file_list ; do\n'
567 <           txt += '         echo "lcg-cr -v -l lfn:${LFN}/$out_file -d $CLOSE_SE -P $LFN/$out_file --vo $VO file://`pwd`/$out_file" \n'
568 <           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'
567 >           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'
568 >           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'
569             txt += '         register_exit_status=$?\n'
570             txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
571             txt += '         echo "STAGE_OUT = $register_exit_status"\n'
572             txt += '         if [ $register_exit_status -ne 0 ]; then \n'
573 <           txt += '            echo "Problems with CloseSE" \n'
573 >           txt += '            echo "Problems with CloseSE or Catalog" \n'
574             txt += '         else \n'
575             txt += '            echo "The program was successfully executed"\n'
576             txt += '            echo "SE = $CLOSE_SE"\n'
# Line 451 | Line 578 | class SchedulerEdg(Scheduler):
578             txt += '         fi \n'
579             txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
580             txt += '      done\n'
454           txt += '   else\n'
455           txt += '      echo "Problem with the executable"\n'
581             txt += '   fi \n'
582 +           txt += '   exit_status=$register_exit_status\n'
583             txt += 'fi \n'
584          return txt
585  
# Line 463 | Line 589 | class SchedulerEdg(Scheduler):
589          """
590          self.checkProxy()
591          cmd = 'edg-job-get-logging-info -v 2 ' + id
466        #cmd_out = os.popen(cmd)
592          cmd_out = runCommand(cmd)
593          return cmd_out
594  
595 <    def listMatch(self, nj):
596 <        """
597 <        Check the compatibility of available resources
598 <        """
599 <        self.checkProxy()
475 <        jdl = common.job_list[nj].jdlFilename()
476 <        cmd = 'edg-job-list-match ' + self.configOpt_() + jdl
477 <        cmd_out = runCommand(cmd,0,10)
478 <        if not cmd_out:
479 <            raise CrabException("ERROR: "+cmd+" failed!")
595 >    def queryDetailedStatus(self, id):
596 >        """ Query a detailed status of the job with id """
597 >        cmd = 'edg-job-status '+id
598 >        cmd_out = runCommand(cmd)
599 >        return cmd_out
600  
601 <        return self.parseListMatch_(cmd_out, jdl)
601 >    ##### FEDE ######        
602 >    def findSites_(self, n):
603 >        itr4 =[]
604 >        sites = common.jobDB.destination(n)
605 >        if len(sites)>0 and sites[0]=="Any":
606 >            return itr4
607 >        itr = ''
608 >        if sites != [""]:#CarlosDaniele
609 >            for site in sites:
610 >                #itr = itr + 'target.GlueSEUniqueID==&quot;'+site+'&quot; || '
611 >                itr = itr + 'target.GlueSEUniqueID=="'+site+'" || '
612 >            itr = itr[0:-4]
613 >            itr4.append( itr )
614 >        return itr4
615  
616 <    def parseListMatch_(self, out, jdl):
616 >    def createXMLSchScript(self, nj, argsList):
617 >      
618          """
619 <        Parse the f* output of edg-list-match and produce something sensible
619 >        Create a XML-file for BOSS4.
620          """
621 <        reComment = re.compile( r'^\**$' )
488 <        reEmptyLine = re.compile( r'^$' )
489 <        reVO = re.compile( r'Selected Virtual Organisation name.*' )
490 <        reLine = re.compile( r'.*')
491 <        reCE = re.compile( r'(.*:.*)')
492 <        reCEId = re.compile( r'CEId.*')
493 <        reNO = re.compile( r'No Computing Element matching' )
494 <        reRB = re.compile( r'Connecting to host' )
495 <        next = 0
496 <        CEs=[]
497 <        Match=0
498 <
499 <        #print out
500 <        lines = reLine.findall(out)
501 <
502 <        i=0
503 <        CEs=[]
504 <        for line in lines:
505 <            string.strip(line)
506 <            #print line
507 <            if reNO.match( line ):
508 <                common.logger.debug(5,line)
509 <                return 0
510 <                pass
511 <            if reVO.match( line ):
512 <                VO =reVO.match( line ).group()
513 <                common.logger.debug(5,"VO "+VO)
514 <                pass
515 <
516 <            if reRB.match( line ):
517 <                RB = reRB.match(line).group()
518 <                common.logger.debug(5,"RB "+RB)
519 <                pass
520 <
521 <            if reCEId.search( line ):
522 <                for lineCE in lines[i:-1]:
523 <                    if reCE.match( lineCE ):
524 <                        CE = string.strip(reCE.search(lineCE).group(1))
525 <                        CEs.append(CE.split(':')[0])
526 <                        pass
527 <                    pass
528 <                pass
529 <            i=i+1
530 <            pass
531 <
532 <        common.logger.debug(5,"All CE :"+str(CEs))
533 <
534 <        sites = []
535 <        [sites.append(it) for it in CEs if not sites.count(it)]
536 <
537 <        common.logger.debug(5,"All Sites :"+str(sites))
538 <        common.logger.message("Matched Sites :"+str(sites))
539 <        return len(sites)
540 <
541 <    def noMatchFound_(self, jdl):
542 <        reReq = re.compile( r'Requirements' )
543 <        reString = re.compile( r'"\S*"' )
544 <        f = file(jdl,'r')
545 <        for line in f.readlines():
546 <            line= line.strip()
547 <            if reReq.match(line):
548 <                for req in reString.findall(line):
549 <                    if re.search("VO",req):
550 <                        common.logger.message( "SW required: "+req)
551 <                        continue
552 <                    if re.search('"\d+',req):
553 <                        common.logger.message("Other req  : "+req)
554 <                        continue
555 <                    common.logger.message( "CE required: "+req)
556 <                break
557 <            pass
558 <        raise CrabException("No compatible resources found!")
559 <
560 <    def submit(self, nj):
621 >  #      job = common.job_list[nj]
622          """
623 <        Submit one EDG job.
623 >        INDY
624 >        [begin] FIX-ME:
625 >        I would pass jobType instead of job
626          """
627 <
628 <        self.checkProxy()
629 <        jid = None
630 <        jdl = common.job_list[nj].jdlFilename()
631 <
632 <        cmd = 'edg-job-submit ' + self.configOpt_() + jdl
570 <        cmd_out = runCommand(cmd)
571 <        if cmd_out != None:
572 <            reSid = re.compile( r'https.+' )
573 <            jid = reSid.search(cmd_out).group()
574 <            pass
575 <        return jid
576 <
577 <    def resubmit(self, nj_list):
627 >        index = nj - 1
628 >        job = common.job_list[index]
629 >        jbt = job.type()
630 >        
631 >        inp_sandbox = jbt.inputSandbox(index)
632 >        #out_sandbox = jbt.outputSandbox(index)
633          """
634 <        Prepare jobs to be submit
634 >        [end] FIX-ME
635          """
581        return
582
583    def getExitStatus(self, id):
584        return self.getStatusAttribute_(id, 'exit_code')
585
586    def queryStatus(self, id):
587        return self.getStatusAttribute_(id, 'status')
636  
637 <    def queryDest(self, id):  
638 <        return self.getStatusAttribute_(id, 'destination')
639 <
640 <
641 <    def getStatusAttribute_(self, id, attr):
642 <        """ Query a status of the job with id """
595 <
596 <        self.checkProxy()
597 <        hstates = {}
598 <        Status = importName('edg_wl_userinterface_common_LbWrapper', 'Status')
599 <        # Bypass edg-job-status interfacing directly to C++ API
600 <        # Job attribute vector to retrieve status without edg-job-status
601 <        level = 0
602 <        # Instance of the Status class provided by LB API
603 <        jobStat = Status()
604 <        st = 0
605 <        jobStat.getStatus(id, level)
606 <        err, apiMsg = jobStat.get_error()
607 <        if err:
608 <            common.logger.debug(5,'Error caught' + apiMsg)
609 <            return None
610 <        else:
611 <            for i in range(len(self.states)):
612 <                # Fill an hash table with all information retrieved from LB API
613 <                hstates[ self.states[i] ] = jobStat.loadStatus(st)[i]
614 <            result = jobStat.loadStatus(st)[ self.states.index(attr) ]
615 <            return result
637 >        
638 >        title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n'
639 >        jt_string = ''
640 >        
641 >        xml_fname = str(self.jobtypeName)+'.xml'
642 >        xml = open(common.work_space.shareDir()+'/'+xml_fname, 'a')
643  
644 <    def queryDetailedStatus(self, id):
645 <        """ Query a detailed status of the job with id """
646 <        cmd = 'edg-job-status '+id
647 <        cmd_out = runCommand(cmd)
648 <        return cmd_out
644 >        #TaskName  
645 >        dir = string.split(common.work_space.topDir(), '/')
646 >        taskName = dir[len(dir)-2]
647 >  
648 >        to_write = ''
649  
650 <    def getOutput(self, id):
651 <        """
625 <        Get output for a finished job with id.
626 <        Returns the name of directory with results.
627 <        """
650 >        req=' '
651 >        req = req + jbt.getRequirements()
652  
653 <        self.checkProxy()
654 <        cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() + ' ' + id
655 <        cmd_out = runCommand(cmd)
653 >        if self.EDG_requirements:
654 >            if (req == ' '):
655 >                req = req + self.EDG_requirements
656 >            else:
657 >                req = req +  ' && ' + self.EDG_requirements
658 >        if self.EDG_ce_white_list:
659 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
660 >            for i in range(len(ce_white_list)):
661 >                if i == 0:
662 >                    if (req == ' '):
663 >                        req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
664 >                    else:
665 >                        req = req +  ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
666 >                    pass
667 >                else:
668 >                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
669 >            req = req + ')'
670 >        
671 >        if self.EDG_ce_black_list:
672 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
673 >            for ce in ce_black_list:
674 >                if (req == ' '):
675 >                    req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
676 >                else:
677 >                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
678 >                pass
679 >        if self.EDG_clock_time:
680 >            if (req == ' '):
681 >                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
682 >            else:
683 >                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
684  
685 <        # Determine the output directory name
686 <        dir = common.work_space.resDir()
687 <        dir += os.environ['USER']
688 <        dir += '_' + os.path.basename(id)
689 <        return dir
685 >        if self.EDG_cpu_time:
686 >            if (req == ' '):
687 >                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
688 >            else:
689 >                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
690 >                                                                                          
691 >        if ( self.EDG_retry_count ):              
692 >            to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n'
693 >            pass
694  
695 <    def cancel(self, id):
696 <        """ Cancel the EDG job with id """
697 <        self.checkProxy()
642 <        cmd = 'edg-job-cancel --noint ' + id
643 <        cmd_out = runCommand(cmd)
644 <        return cmd_out
695 >        if ( self.EDG_shallow_retry_count ):              
696 >            to_write = to_write + 'ShallowRetryCount = "'+self.EDG_shallow_retry_count+'"\n'
697 >            pass
698  
699 <    def createSchScript(self, nj):
700 <        """
648 <        Create a JDL-file for EDG.
649 <        """
699 >        to_write = to_write + 'MyProxyServer = "&quot;' + self.proxyServer + '&quot;"\n'
700 >        to_write = to_write + 'VirtualOrganisation = "&quot;' + self.VO + '&quot;"\n'
701  
702 <        job = common.job_list[nj]
703 <        jbt = job.type()
704 <        inp_sandbox = jbt.inputSandbox(nj)
705 <        out_sandbox = jbt.outputSandbox(nj)
706 <        inp_storage_subdir = ''
702 >        #TaskName  
703 >        dir = string.split(common.work_space.topDir(), '/')
704 >        taskName = dir[len(dir)-2]
705 >
706 >        xml.write(str(title))
707 >        xml.write('<task name="' +str(taskName)+'" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache">\n')
708 >        xml.write(jt_string)
709          
710 <        title = '# This JDL was generated by '+\
711 <                common.prog_name+' (version '+common.prog_version_str+')\n'
712 <        jt_string = ''
713 <
710 >        if (to_write != ''):
711 >            xml.write('<extraTags\n')
712 >            xml.write(to_write)
713 >            xml.write('/>\n')
714 >            pass
715  
716 +        xml.write('<iterator>\n')
717 +        xml.write('\t<iteratorRule name="ITR1">\n')
718 +        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ' </ruleElement>\n')
719 +        xml.write('\t</iteratorRule>\n')
720 +        xml.write('\t<iteratorRule name="ITR2">\n')
721 +        for arg in argsList:
722 +            xml.write('\t\t<ruleElement> <![CDATA[\n'+ arg + '\n\t\t]]> </ruleElement>\n')
723 +            pass
724 +        xml.write('\t</iteratorRule>\n')
725 +        #print jobList
726 +        xml.write('\t<iteratorRule name="ITR3">\n')
727 +        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ':1:6 </ruleElement>\n')
728 +        xml.write('\t</iteratorRule>\n')
729 +
730 +        '''
731 +        indy: here itr4
732 +        '''
733          
663        SPL = inp_storage_subdir
664        if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/'
734  
735 <        jdl_fname = job.jdlFilename()
736 <        jdl = open(jdl_fname, 'w')
668 <        jdl.write(title)
735 >        xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n')
736 >        xml.write(jt_string)
737  
738 <        script = job.scriptFilename()
671 <        jdl.write('Executable = "' + os.path.basename(script) +'";\n')
672 <        jdl.write(jt_string)
673 <
674 <        ### only one .sh  JDL has arguments:
738 >        #executable
739  
740 <        ### Fabio
741 <        jdl.write('Arguments = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'";\n')
742 <        inp_box = 'InputSandbox = { '
743 <        inp_box = inp_box + '"' + script + '",'
740 >        """
741 >        INDY
742 >        script depends on jobType: it should be probably get in a different way
743 >        """        
744 >        script = job.scriptFilename()
745 >        xml.write('<program>\n')
746 >        xml.write('<exec> ' + os.path.basename(script) +' </exec>\n')
747 >        xml.write(jt_string)
748 >
749 >        xml.write('<args> <![CDATA[\n _ITR2_ \n]]> </args>\n')
750 >        xml.write('<program_types> crabjob </program_types>\n')
751 >        inp_box = common.work_space.pathForTgz() + 'job/' + jbt.scriptName + ','
752  
753          if inp_sandbox != None:
754              for fl in inp_sandbox:
755 <                inp_box = inp_box + ' "' + fl + '",'
755 >                inp_box = inp_box + '' + fl + ','
756                  pass
757              pass
758  
759 <        #if common.use_jam:
760 <        #   inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",'
761 <
762 <        # Marco (VERY TEMPORARY ML STUFF)
763 <        inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\
764 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + '", "'+\
693 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\
694 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\
695 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"'
696 <        # End Marco
697 <
698 <        if (not jbt.additional_inbox_files == []):
699 <            inp_box = inp_box + ', '
700 <            for addFile in jbt.additional_inbox_files:
701 <                addFile = os.path.abspath(addFile)
702 <                inp_box = inp_box+' "'+addFile+'",'
703 <                pass
759 > #        if (not jbt.additional_inbox_files == []):
760 > #            inp_box = inp_box + ','
761 > #            for addFile in jbt.additional_inbox_files:
762 > #                #addFile = os.path.abspath(addFile)
763 > #                inp_box = inp_box+''+addFile+','
764 > #                pass
765  
766          if inp_box[-1] == ',' : inp_box = inp_box[:-1]
767 <        inp_box = inp_box + ' };\n'
768 <        jdl.write(inp_box)
708 <
709 <        jdl.write('StdOutput     = "' + job.stdout() + '";\n')
710 <        jdl.write('StdError      = "' + job.stderr() + '";\n')
767 >        inp_box = '<infiles> <![CDATA[\n' + inp_box + '\n]]> </infiles>\n'
768 >        xml.write(inp_box)
769          
770 +        base = jbt.name()
771 +        stdout = base + '__ITR3_.stdout'
772 +        stderr = base + '__ITR3_.stderr'
773          
774 <        if job.stdout() == job.stderr():
775 <          out_box = 'OutputSandbox = { "' + \
776 <                    job.stdout() + '", ".BrokerInfo",'
777 <        else:
778 <          out_box = 'OutputSandbox = { "' + \
779 <                    job.stdout() + '", "' + \
719 <                    job.stderr() + '", ".BrokerInfo",'
774 >        xml.write('<stderr> ' + stderr + '</stderr>\n')
775 >        xml.write('<stdout> ' + stdout + '</stdout>\n')
776 >        
777 >
778 >        out_box = stdout + ',' + \
779 >                  stderr + ',.BrokerInfo,'
780  
781 +        """
782          if int(self.return_data) == 1:
783              if out_sandbox != None:
784                  for fl in out_sandbox:
785 <                    out_box = out_box + ' "' + fl + '",'
785 >                    out_box = out_box + '' + fl + ','
786                      pass
787                  pass
788              pass
789 <                                                                                                                                                            
729 <        if out_box[-1] == ',' : out_box = out_box[:-1]
730 <        out_box = out_box + ' };'
731 <        jdl.write(out_box+'\n')
789 >        """
790  
791 +        """
792 +        INDY
793 +        something similar should be also done for infiles (if it makes sense!)
794 +        """
795 +        # Stuff to be returned _always_ via sandbox
796 +        for fl in jbt.output_file_sandbox:
797 +            out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ','
798 +            pass
799 +        pass
800  
801 <        req='Requirements = '
802 <        noreq=req
803 <        req = req + jbt.getRequirements()
804 <        #### and USER REQUIREMENT
738 <        if self.EDG_requirements:
739 <            if (req != noreq):
740 <                req = req +  ' && '
741 <            req = req + self.EDG_requirements
742 <        #### FEDE #####
743 <        if self.EDG_ce_white_list:
744 <            ce_white_list = string.split(self.EDG_ce_white_list,',')
745 <            #print "req = ", req
746 <            for i in range(len(ce_white_list)):
747 <                if i == 0:
748 <                    if (req != noreq):
749 <                        req = req +  ' && '
750 <                    req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
751 <                    pass
752 <                else:
753 <                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
754 <            req = req + ')'
755 <        
756 <        if self.EDG_ce_black_list:
757 <            ce_black_list = string.split(self.EDG_ce_black_list,',')
758 <            for ce in ce_black_list:
759 <                if (req != noreq):
760 <                    req = req +  ' && '
761 <                req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
801 >        # via sandbox iif required return_data
802 >        if int(self.return_data) == 1:
803 >            for fl in jbt.output_file:
804 >                out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ','
805                  pass
806 +            pass
807  
808 <        ###############
809 <        clockTime=480
810 <        if self.EDG_clock_time:
811 <            clockTime= self.EDG_clock_time
812 <        if (req != noreq):
769 <            req = req + ' && '
770 <        req = req + '((other.GlueCEPolicyMaxWallClockTime == 0) || (other.GlueCEPolicyMaxWallClockTime>='+str(clockTime)+'))'
808 >        if out_box[-1] == ',' : out_box = out_box[:-1]
809 >        out_box = '<outfiles> <![CDATA[\n' + out_box + '\n]]></outfiles>\n'
810 >        xml.write(out_box)
811 >
812 >        xml.write('<BossAttr> crabjob.INTERNAL_ID=_ITR1_ </BossAttr>\n')
813  
814 <        cpuTime=1000
815 <        if self.EDG_cpu_time:
774 <            cpuTime=self.EDG_cpu_time
775 <        if (req != noreq):
776 <            req = req + ' && '
777 <        req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))'
778 <
779 <        if (req != noreq):
780 <            req = req + ';\n'
781 <            jdl.write(req)
782 <                                                                                                                                                            
783 <        jdl.write('VirtualOrganisation = "' + self.VO + '";\n')
814 >        xml.write('</program>\n')
815 >        xml.write('</chain>\n')
816  
817 <        if ( self.EDG_retry_count ):              
818 <            jdl.write('RetryCount = '+self.EDG_retry_count+';\n')
787 <            pass
817 >        xml.write('</iterator>\n')
818 >        xml.write('</task>\n')
819  
820 <        jdl.write('MyProxyServer = "' + self.proxyServer + '";\n')
820 >        xml.close()
821 >      
822  
791        jdl.close()
823          return
824  
825      def checkProxy(self):
# Line 796 | Line 827 | class SchedulerEdg(Scheduler):
827          Function to check the Globus proxy.
828          """
829          if (self.proxyValid): return
830 <        timeleft = -999
830 >
831 >        ### Just return if asked to do so
832 >        if (self.dontCheckProxy):
833 >            self.proxyValid=1
834 >            return
835 >
836          minTimeLeft=10*3600 # in seconds
837  
838          minTimeLeftServer = 100 # in hours
839  
804        #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
805        #cmd = 'voms-proxy-info -timeleft'
840          mustRenew = 0
841 <        timeLeftLocal = runCommand('voms-proxy-info -timeleft')
841 >        timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null')
842          timeLeftServer = -999
843          if not timeLeftLocal or int(timeLeftLocal) <= 0 or not isInt(timeLeftLocal):
844              mustRenew = 1
845          else:
846 <            timeLeftServer = runCommand('voms-proxy-info -actimeleft | head -1')
846 >            timeLeftServer = runCommand('voms-proxy-info -actimeleft 2>/dev/null | head -1')
847              if not timeLeftServer or not isInt(timeLeftServer):
848                  mustRenew = 1
849              elif timeLeftLocal<minTimeLeft or timeLeftServer<minTimeLeft:
# Line 818 | Line 852 | class SchedulerEdg(Scheduler):
852          pass
853  
854          if mustRenew:
855 <            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")
856 <            cmd = 'voms-proxy-init -voms cms -valid 96:00'
855 >            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")
856 >            cmd = 'voms-proxy-init -voms '+self.VO
857 >            if self.group:
858 >                cmd += ':/'+self.VO+'/'+self.group
859 >            if self.role:
860 >                cmd += '/role='+self.role
861 >            cmd += ' -valid 192:00'
862              try:
863                  # SL as above: damn it!
864 +                common.logger.debug(10,cmd)
865                  out = os.system(cmd)
866                  if (out>0): raise CrabException("Unable to create a valid proxy!\n")
867              except:
868                  msg = "Unable to create a valid proxy!\n"
869                  raise CrabException(msg)
830            # cmd = 'grid-proxy-info -timeleft'
831            # cmd_out = runCommand(cmd,0,20)
870              pass
871  
872          ## now I do have a voms proxy valid, and I check the myproxy server
# Line 843 | Line 881 | class SchedulerEdg(Scheduler):
881              reTime = re.compile( r'timeleft: (\d+)' )
882              #print "<"+str(reTime.search( cmd_out ).group(1))+">"
883              if reTime.match( cmd_out ):
884 <                time = reTime.search( line ).group(1)
884 >                time = reTime.search( cmd_out ).group(1)
885                  if time < minTimeLeftServer:
886                      renewProxy = 1
887                      common.logger.message('No credential delegation will expire in '+time+' hours: renew it')

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines