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.90 by slacapra, Fri Oct 6 15:50:17 2006 UTC vs.
Revision 1.129 by slacapra, Tue Jul 17 14:08:24 2007 UTC

# Line 21 | Line 21 | class SchedulerEdg(Scheduler):
21          return
22  
23      def configure(self, cfg_params):
24 + ##Addedd Daniele
25 + ######################################        
26  
27 +        SEBlackList = []
28          try:
29 <            RB = cfg_params["EDG.rb"]
30 <            edgConfig = EdgConfig(RB)
31 <            self.edg_config = edgConfig.config()
32 <            self.edg_config_vo = edgConfig.configVO()
29 >            tmpBad = string.split(cfg_params['EDG.se_black_list'],',')
30 >            for tmp in tmpBad:
31 >                tmp=string.strip(tmp)
32 >                SEBlackList.append(tmp)
33          except KeyError:
34 <            self.edg_config = ''
35 <            self.edg_config_vo = ''
34 >            pass
35 >        common.logger.debug(5,'SEBlackList: '+str(SEBlackList))
36 >        self.reSEBlackList=[]
37 >        for bad in SEBlackList:
38 >            self.reSEBlackList.append(re.compile( string.lower(bad) ))
39  
40 +        SEWhiteList = []
41 +        try:
42 +            tmpGood = string.split(cfg_params['EDG.se_white_list'],',')
43 +            for tmp in tmpGood:
44 +                tmp=string.strip(tmp)
45 +                SEWhiteList.append(tmp)
46 +        except KeyError:
47 +            pass
48 +        common.logger.debug(5,'SEWhiteList: '+str(SEWhiteList))
49 +        self.reSEWhiteList=[]
50 +        for good in SEWhiteList:
51 +            self.reSEWhiteList.append(re.compile( string.lower(good) ))
52 +
53 +
54 + ######################################        
55 +        try:
56 +            RB=cfg_params["EDG.rb"]
57 +            self.rb_param_file=self.rb_configure(RB)
58 +        except KeyError:
59 +            self.rb_param_file=''
60 +            pass
61          try:
62              self.proxyServer = cfg_params["EDG.proxy_server"]
63          except KeyError:
# Line 38 | Line 65 | class SchedulerEdg(Scheduler):
65          common.logger.debug(5,'Setting myproxy server to '+self.proxyServer)
66  
67          try:
68 +            self.group = cfg_params["EDG.group"]
69 +        except KeyError:
70 +            self.group = None
71 +            
72 +        try:
73              self.role = cfg_params["EDG.role"]
74          except KeyError:
75              self.role = None
# Line 45 | Line 77 | class SchedulerEdg(Scheduler):
77          try: self.LCG_version = cfg_params["EDG.lcg_version"]
78          except KeyError: self.LCG_version = '2'
79  
48        try: self.EDG_requirements = cfg_params['EDG.requirements']
49        except KeyError: self.EDG_requirements = ''
50
51        try: self.EDG_retry_count = cfg_params['EDG.retry_count']
52        except KeyError: self.EDG_retry_count = ''
53
80          try:
81              self.EDG_ce_black_list = cfg_params['EDG.ce_black_list']
56            #print "self.EDG_ce_black_list = ", self.EDG_ce_black_list
82          except KeyError:
83              self.EDG_ce_black_list  = ''
84  
85          try:
86              self.EDG_ce_white_list = cfg_params['EDG.ce_white_list']
62            #print "self.EDG_ce_white_list = ", self.EDG_ce_white_list
87          except KeyError: self.EDG_ce_white_list = ''
88  
89          try: self.VO = cfg_params['EDG.virtual_organization']
90          except KeyError: self.VO = 'cms'
91  
92 +        try: self.copy_input_data = cfg_params["USER.copy_input_data"]
93 +        except KeyError: self.copy_input_data = 0
94 +
95          try: self.return_data = cfg_params['USER.return_data']
96 <        except KeyError: self.return_data = 1
96 >        except KeyError: self.return_data = 0
97  
98          try:
99              self.copy_data = cfg_params["USER.copy_data"]
# Line 86 | Line 113 | class SchedulerEdg(Scheduler):
113             msg = msg + 'Please modify return_data and copy_data value in your crab.cfg file\n'
114             raise CrabException(msg)
115  
116 +        ########### FEDE FOR DBS2 ##############################
117 +        try:
118 +            self.publish_data = cfg_params["USER.publish_data"]
119 +            if int(self.publish_data) == 1:
120 +                try:
121 +                    self.publish_data_name = cfg_params['USER.publish_data_name']
122 +                except KeyError:
123 +                    msg = "Error. The [USER] section does not have 'publish_data_name'"
124 +                    raise CrabException(msg)
125 +                try:
126 +                    tmp = runCommand("voms-proxy-info -identity")
127 +                    tmp = string.split(tmp,'/')
128 +                    reCN=re.compile(r'CN=')
129 +                    for t in tmp:
130 +                        if reCN.match(t):
131 +                            self.UserGridName=string.strip((t.replace('CN=','')).replace(' ',''))
132 +                        
133 +                    #self.UserGridName = string.strip(runCommand("voms-proxy-info -identity | awk -F\'CN\' \'{print $2$3$4}\' | tr -d \'=/ \'"))
134 +                except:
135 +                    msg = "Error. Problem with voms-proxy-info -identity command"
136 +                    raise CrabException(msg)
137 +        except KeyError: self.publish_data = 0
138 +
139 +        if ( int(self.copy_data) == 0 and int(self.publish_data) == 1 ):
140 +           msg = 'Warning: publish_data = 1 must be used with copy_data = 1\n'
141 +           msg = msg + 'Please modify copy_data value in your crab.cfg file\n'
142 +           common.logger.message(msg)
143 +           raise CrabException(msg)
144 +        #################################################
145 +
146          try:
147              self.lfc_host = cfg_params['EDG.lfc_host']
148          except KeyError:
# Line 128 | Line 185 | class SchedulerEdg(Scheduler):
185  
186          try: self.EDG_requirements = cfg_params['EDG.requirements']
187          except KeyError: self.EDG_requirements = ''
188 <                                                                                                                                                            
188 >
189 >        try: self.EDG_addJdlParam = string.split(cfg_params['EDG.additional_jdl_parameters'],',')
190 >        except KeyError: self.EDG_addJdlParam = []
191 >
192          try: self.EDG_retry_count = cfg_params['EDG.retry_count']
193          except KeyError: self.EDG_retry_count = ''
194 <                                                                                                                                                            
194 >
195 >        try: self.EDG_shallow_retry_count= cfg_params['EDG.shallow_retry_count']
196 >        except KeyError: self.EDG_shallow_retry_count = ''
197 >
198          try: self.EDG_clock_time = cfg_params['EDG.max_wall_clock_time']
199          except KeyError: self.EDG_clock_time= ''
200 <                                                                                                                                                            
200 >
201          try: self.EDG_cpu_time = cfg_params['EDG.max_cpu_time']
202          except KeyError: self.EDG_cpu_time = ''
203  
# Line 164 | Line 227 | class SchedulerEdg(Scheduler):
227          try: self.schedulerName = cfg_params['CRAB.scheduler']
228          except KeyError: self.scheduler = ''
229  
230 +        try: self.dontCheckProxy=int(cfg_params["EDG.dont_check_proxy"])
231 +        except KeyError: self.dontCheckProxy = 0
232 +
233          return
234      
235  
236 +    def rb_configure(self, RB):
237 +        self.edg_config = ''
238 +        self.edg_config_vo = ''
239 +        self.rb_param_file = ''
240 +
241 +        edgConfig = EdgConfig(RB)
242 +        self.edg_config = edgConfig.config()
243 +        self.edg_config_vo = edgConfig.configVO()
244 +
245 +        if (self.edg_config and self.edg_config_vo != ''):
246 +            self.rb_param_file = 'RBconfig = "'+self.edg_config+'";\nRBconfigVO = "'+self.edg_config_vo+'";\n'
247 +            #print "rb_param_file = ", self.rb_param_file
248 +        return self.rb_param_file
249 +      
250 +
251      def sched_parameter(self):
252          """
253          Returns file with requirements and scheduler-specific parameters
# Line 175 | Line 256 | class SchedulerEdg(Scheduler):
256          job = common.job_list[index]
257          jbt = job.type()
258          
259 <        lastDest=''
259 >        lastBlock=-1
260          first = []
180        last  = []
261          for n in range(common.jobDB.nJobs()):
262 <            currDest=common.jobDB.destination(n)
263 <            if (currDest!=lastDest):
264 <                lastDest = currDest
262 >            currBlock=common.jobDB.block(n)
263 >            if (currBlock!=lastBlock):
264 >                lastBlock = currBlock
265                  first.append(n)
186                if n != 0:last.append(n-1)
187        if len(first)>len(last) :last.append(common.jobDB.nJobs())
266    
267          req = ''
268          req = req + jbt.getRequirements()
# Line 194 | Line 272 | class SchedulerEdg(Scheduler):
272                  req = req + self.EDG_requirements
273              else:
274                  req = req +  ' && ' + self.EDG_requirements
275 +
276          if self.EDG_ce_white_list:
277              ce_white_list = string.split(self.EDG_ce_white_list,',')
278              for i in range(len(ce_white_list)):
279                  if i == 0:
280                      if (req == ' '):
281 <                        req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
281 >                        req = req + '((RegExp("' + string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))'
282                      else:
283 <                        req = req +  ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
283 >                        req = req +  ' && ((RegExp("' +  string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))'
284                      pass
285                  else:
286 <                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
286 >                    req = req +  ' || (RegExp("' +  string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))'
287              req = req + ')'
288          
289          if self.EDG_ce_black_list:
290              ce_black_list = string.split(self.EDG_ce_black_list,',')
291              for ce in ce_black_list:
292                  if (req == ' '):
293 <                    req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
293 >                    req = req + '(!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))'
294                  else:
295 <                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
295 >                    req = req +  ' && (!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))'
296                  pass
297          if self.EDG_clock_time:
298              if (req == ' '):
# Line 228 | Line 307 | class SchedulerEdg(Scheduler):
307                  req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
308                  
309          for i in range(len(first)): # Add loop DS
310 +            groupReq = req
311              self.param='sched_param_'+str(i)+'.clad'
312              param_file = open(common.work_space.shareDir()+'/'+self.param, 'w')
313  
314              itr4=self.findSites_(first[i])
315 <            if (itr4 != []):
316 <                req1=''  
317 <                for arg in itr4:
238 <                    req1 = req + ' && anyMatch(other.storage.CloseSEs, ('+str(arg)+'))'
239 <            param_file.write('Requirements = '+req1 +';\n')  
315 >            for arg in itr4:
316 >                groupReq = groupReq + ' && anyMatch(other.storage.CloseSEs, ('+str(arg)+'))'
317 >            param_file.write('Requirements = '+groupReq +';\n')  
318    
319 <            if (self.edg_config and self.edg_config_vo != ''):
320 <                param_file.write('RBconfig = "'+self.edg_config+'";\n')  
321 <                param_file.write('RBconfigVO = "'+self.edg_config_vo+'";')
319 >            if (self.rb_param_file != ''):
320 >                param_file.write(self.rb_param_file)  
321 >
322 >            if len(self.EDG_addJdlParam):
323 >                for p in self.EDG_addJdlParam:
324 >                    param_file.write(p)
325  
326              param_file.close()  
327  
# Line 280 | Line 361 | class SchedulerEdg(Scheduler):
361          txt += '    echo "middleware =$middleware" \n'
362          txt += 'elif [ $VO_CMS_SW_DIR ]; then \n'
363          txt += '    middleware=LCG \n'
364 <        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
364 >   #     txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
365 >        txt += '    echo "SyncCE=`glite-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
366          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
367          txt += '    echo "middleware =$middleware" \n'
368          txt += 'else \n'
# Line 302 | Line 384 | class SchedulerEdg(Scheduler):
384          
385          txt += '\n\n'
386  
387 <        if int(self.copy_data) == 1:
388 <           if self.SE:
389 <              txt += 'export SE='+self.SE+'\n'
390 <              txt += 'echo "SE = $SE"\n'
391 <           if self.SE_PATH:
392 <              if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
393 <              txt += 'export SE_PATH='+self.SE_PATH+'\n'
394 <              txt += 'echo "SE_PATH = $SE_PATH"\n'
387 > #        if int(self.copy_data) == 1:
388 > #           if self.SE:
389 > #              txt += 'export SE='+self.SE+'\n'
390 > #              txt += 'echo "SE = $SE"\n'
391 > #           if self.SE_PATH:
392 > #              if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
393 > #              txt += 'export SE_PATH='+self.SE_PATH+'\n'
394 > #              txt += 'echo "SE_PATH = $SE_PATH"\n'
395  
396          txt += 'export VO='+self.VO+'\n'
397          ### add some line for LFC catalog setting
# Line 353 | Line 435 | class SchedulerEdg(Scheduler):
435                txt += '\n'
436  
437          txt += 'if [ $middleware == LCG ]; then\n'
438 <        txt += '    CloseCEs=`edg-brokerinfo getCE`\n'
438 >    #    txt += '    CloseCEs=`edg-brokerinfo getCE`\n'
439 >        txt += '    CloseCEs=`glite-brokerinfo getCE`\n'
440          txt += '    echo "CloseCEs = $CloseCEs"\n'
441          txt += '    CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
442          txt += '    echo "CE = $CE"\n'
# Line 379 | Line 462 | class SchedulerEdg(Scheduler):
462          Copy input data from SE to WN    
463          """
464          txt = ''
465 +        if not self.copy_input_data: return txt
466  
467          ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
468          txt += 'if [ $middleware == OSG ]; then\n'
# Line 427 | Line 511 | class SchedulerEdg(Scheduler):
511          to copy produced output into a storage element.
512          """
513          txt = ''
514 +
515 +        ##### FEDE MOVED FROM SET_ENVIRONMENT ##############
516 +        
517 +        SE_PATH=''
518          if int(self.copy_data) == 1:
519 +           if self.SE:
520 +              txt += 'export SE='+self.SE+'\n'
521 +              txt += 'echo "SE = $SE"\n'
522 +           if self.SE_PATH:
523 +              if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
524 +              SE_PATH=self.SE_PATH
525 +              ####### FEDE FOR DBS2
526 +              if int(self.publish_data) == 1:
527 +                  txt += '### publish_data = 1 so the SE path where to copy the output is: \n'
528 +                  #txt += 'subject=`voms-proxy-info -subject | awk -F\'CN\' \'{print $2$3$4}\' | tr -d \'=/ \'` \n'
529 +                  #txt += 'echo "subject = $subject" \n'
530 +                  #path_add = '${subject}/'+ self.publish_data_name +'_${PSETHASH}/'
531 +                  path_add = self.UserGridName + '/' + self.publish_data_name +'_${PSETHASH}/'
532 +                  SE_PATH = SE_PATH + path_add
533 +
534 +              txt += 'export SE_PATH='+SE_PATH+'\n'
535 +              txt += 'echo "SE_PATH = $SE_PATH"\n'
536 +
537 +        ##########################################################  
538 +
539 +        #if int(self.copy_data) == 1:
540             txt += '#\n'
541             txt += '#   Copy output to SE = $SE\n'
542             txt += '#\n'
# Line 438 | Line 547 | class SchedulerEdg(Scheduler):
547             txt += '        export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n'
548             txt += '        echo "export X509_CERT_DIR=$X509_CERT_DIR"\n'
549             txt += '    fi \n'
550 +
551             txt += '    for out_file in $file_list ; do\n'
552 <           txt += '        echo "Trying to copy output file to $SE using lcg-cp"\n'
553 <           if common.logger.debugLevel() >= 5:
554 <               txt += '        echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
555 <               txt += '        exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
556 <           else:
557 <               txt += '        echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
558 <               txt += '        exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
552 >           txt += '        echo "Trying to copy output file to $SE using srmcp"\n'
553 >           # txt += '        echo "mkdir -p $HOME/.srmconfig"\n'
554 >           # txt += '        mkdir -p $HOME/.srmconfig\n'
555 >           txt += '        if [ $middleware == LCG ]; then\n'
556 >           txt += '           echo "srmcp -retry_num 3 -retry_timeout 480000 file:///`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
557 >           txt += '           exitstring=`srmcp -retry_num 3 -retry_timeout 480000 file:///\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
558 >           txt += '        elif [ $middleware == OSG ]; then\n'
559 >           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'
560 >           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'
561 >           txt += '        fi \n'
562             txt += '        copy_exit_status=$?\n'
563 <           txt += '        echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
563 >           txt += '        echo "COPY_EXIT_STATUS for srmcp = $copy_exit_status"\n'
564             txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
565 +
566             txt += '        if [ $copy_exit_status -ne 0 ]; then\n'
567             txt += '            echo "Possible problem with SE = $SE"\n'
568             txt += '            echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
569             txt += '            echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
570 <           txt += '            echo "lcg-cp failed.  For verbose lcg-cp output, use command line option -debug 5."\n'
571 <           txt += '            echo "lcg-cp failed, attempting srmcp"\n'
572 <           txt += '            echo "mkdir -p $HOME/.srmconfig"\n'
573 <           txt += '            mkdir -p $HOME/.srmconfig\n'
574 <           txt += '            if [ $middleware == LCG ]; then\n'
575 <           txt += '               echo "srmcp -retry_num 5 -retry_timeout 480000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
576 <           txt += '               exitstring=`srmcp -retry_num 5 -retry_timeout 480000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
577 <           txt += '            elif [ $middleware == OSG ]; then\n'
578 <           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'
579 <           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'
580 <           txt += '            fi \n'
570 >           txt += '            echo "srmcp failed, attempting lcg-cp."\n'
571 >           if common.logger.debugLevel() >= 5:
572 >               ########### FEDE CHANGES TO WRITE IN SRM LNL.INFN.IT #################
573 >               txt += '            echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
574 >               txt += '            exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
575 >               #txt += '            echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
576 >               #txt += '            exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
577 >           else:              
578 >               txt += '            echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
579 >               txt += '            exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
580 >               #txt += '            echo "lcg-cp --vo $VO -t 2400 file://`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
581 >               #txt += '            exitstring=`lcg-cp --vo $VO -t 2400 file://\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
582             txt += '            copy_exit_status=$?\n'
583 <           txt += '            echo "COPY_EXIT_STATUS for srm = $copy_exit_status"\n'
583 >           txt += '            echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
584             txt += '            echo "STAGE_OUT = $copy_exit_status"\n'
585 +
586             txt += '            if [ $copy_exit_status -ne 0 ]; then\n'
587             txt += '               echo "Problems with SE = $SE"\n'
588             txt += '               echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
589             txt += '               echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
590 <           txt += '               echo "lcg-cp and srm failed"\n'
591 <           txt += '               echo "If storage_path in your config file contains a ? you may need a \? instead."\n'
590 >           txt += '               echo "srmcp and lcg-cp and failed!"\n'
591 >           txt += '               SE=""\n'
592 >           txt += '               echo "SE = $SE"\n'
593 >           txt += '               SE_PATH=""\n'
594 >           txt += '               echo "SE_PATH = $SE_PATH"\n'
595             txt += '            else\n'
596             txt += '               echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
597             txt += '               echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
598             txt += '               echo "output copied into $SE/$SE_PATH directory"\n'
599             txt += '               echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
600 <           txt += '               echo "srmcp succeeded"\n'
600 >           txt += '               echo "lcg-cp succeeded"\n'
601             txt += '            fi\n'
602             txt += '        else\n'
603             txt += '            echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
604             txt += '            echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
605             txt += '            echo "output copied into $SE/$SE_PATH directory"\n'
606             txt += '            echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
607 <           txt += '            echo "lcg-cp succeeded"\n'
607 >           txt += '            echo "srmcp succeeded"\n'
608             txt += '         fi\n'
609             txt += '     done\n'
610 +           txt += '     exit_status=$copy_exit_status\n'
611          return txt
612  
613      def wsRegisterOutput(self):
# Line 533 | Line 653 | class SchedulerEdg(Scheduler):
653             txt += '      done\n'
654             txt += '   else \n'
655             txt += '      echo "Trying to copy output file to CloseSE"\n'
656 <           txt += '      CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
656 > #          txt += '      CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
657 >           txt += '      CLOSE_SE=`glite-brokerinfo getCloseSEs | head -1`\n'
658             txt += '      for out_file in $file_list ; do\n'
659             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'
660             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'
# Line 560 | Line 681 | class SchedulerEdg(Scheduler):
681          """
682          self.checkProxy()
683          cmd = 'edg-job-get-logging-info -v 2 ' + id
563        #cmd_out = os.popen(cmd)
684          cmd_out = runCommand(cmd)
685          return cmd_out
686  
567    def getExitStatus(self, id):
568        return self.getStatusAttribute_(id, 'exit_code')
569
570    def queryStatus(self, id):
571        return self.getStatusAttribute_(id, 'status')
572
573    def queryDest(self, id):  
574        return self.getStatusAttribute_(id, 'destination')
575
576
577    def getStatusAttribute_(self, id, attr):
578        """ Query a status of the job with id """
579
580        self.checkProxy()
581        hstates = {}
582        Status = importName('edg_wl_userinterface_common_LbWrapper', 'Status')
583        # Bypass edg-job-status interfacing directly to C++ API
584        # Job attribute vector to retrieve status without edg-job-status
585        level = 0
586        # Instance of the Status class provided by LB API
587        jobStat = Status()
588        st = 0
589        jobStat.getStatus(id, level)
590        err, apiMsg = jobStat.get_error()
591        if err:
592            common.logger.debug(5,'Error caught' + apiMsg)
593            return None
594        else:
595            for i in range(len(self.states)):
596                # Fill an hash table with all information retrieved from LB API
597                hstates[ self.states[i] ] = jobStat.loadStatus(st)[i]
598            result = jobStat.loadStatus(st)[self.states.index(attr)]
599            return result
600
687      def queryDetailedStatus(self, id):
688          """ Query a detailed status of the job with id """
689          cmd = 'edg-job-status '+id
690          cmd_out = runCommand(cmd)
691          return cmd_out
692  
693 <    ##### FEDE ######        
693 > ##Addedd Daniele
694 > # #######################################################################
695 >    def checkBlackList(self, Sites, fileblocks):
696 >        """
697 >        select sites that are not excluded by the user (via SE black list)
698 >        """
699 >        goodSites = []
700 >        for aSite in Sites:
701 >            common.logger.debug(10,'Site '+aSite)
702 >            good=1
703 >            for re in self.reSEBlackList:
704 >                if re.search(string.lower(aSite)):
705 >                    common.logger.debug(5,'SE in black list, skipping site '+aSite)
706 >                    good=0
707 >                pass
708 >            if good: goodSites.append(aSite)
709 >        if len(goodSites) == 0:
710 >            msg = "No sites hosting the block %s after BlackList" % fileblocks
711 >            common.logger.debug(5,msg)
712 >            common.logger.debug(5,"Proceeding without this block.\n")
713 >        else:
714 >            common.logger.debug(5,"Selected sites for block "+str(fileblocks)+" via BlackList are "+str(goodSites)+"\n")
715 >        return goodSites
716 >
717 > # #######################################################################
718 >    def checkWhiteList(self, Sites, fileblocks):
719 >        """
720 >        select sites that are defined by the user (via SE white list)
721 >        """
722 >        if len(self.reSEWhiteList)==0: return Sites
723 >        goodSites = []
724 >        for aSite in Sites:
725 >            good=0
726 >            for re in self.reSEWhiteList:
727 >                if re.search(string.lower(aSite)):
728 >                    common.logger.debug(5,'SE in white list, adding site '+aSite)
729 >                    good=1
730 >                pass
731 >            if good: goodSites.append(aSite)
732 >        
733 >        if len(goodSites) == 0:
734 >            msg = "No sites hosting the block %s after WhiteList" % fileblocks
735 >            common.logger.debug(5,msg)
736 >            common.logger.debug(5,"Proceeding without this block.\n")
737 >        else:
738 >            common.logger.debug(5,"Selected sites for block "+str(fileblocks)+" via WhiteList are "+str(goodSites)+"\n")
739 >      
740 >        return goodSites
741 >
742 > # #######################################################################
743      def findSites_(self, n):
744          itr4 =[]
745 +
746          sites = common.jobDB.destination(n)
747 <        if len(sites)>0 and sites[0]=="Any":
747 >
748 >        if len(sites)>0 and sites[0]=="":
749              return itr4
750 +
751          itr = ''
752          if sites != [""]:#CarlosDaniele
753 <            for site in sites:
753 >            ##Addedd Daniele
754 >            replicas = self.checkBlackList(sites,n)
755 >            if len(replicas)!=0:
756 >                replicas = self.checkWhiteList(replicas,n)
757 >              
758 >            if len(replicas)==0:
759 >                msg = 'No sites remaining that host any part of the requested data! Exiting... '
760 >                raise CrabException(msg)
761 >            #####        
762 >           # for site in sites:
763 >            for site in replicas:
764                  #itr = itr + 'target.GlueSEUniqueID==&quot;'+site+'&quot; || '
765                  itr = itr + 'target.GlueSEUniqueID=="'+site+'" || '
766              itr = itr[0:-4]
# Line 620 | Line 768 | class SchedulerEdg(Scheduler):
768          return itr4
769  
770      def createXMLSchScript(self, nj, argsList):
623   # def createXMLSchScript(self, nj):
771        
772          """
773          Create a XML-file for BOSS4.
# Line 636 | Line 783 | class SchedulerEdg(Scheduler):
783          jbt = job.type()
784          
785          inp_sandbox = jbt.inputSandbox(index)
786 <        out_sandbox = jbt.outputSandbox(index)
786 >        #out_sandbox = jbt.outputSandbox(index)
787          """
788          [end] FIX-ME
789          """
# Line 652 | Line 799 | class SchedulerEdg(Scheduler):
799          dir = string.split(common.work_space.topDir(), '/')
800          taskName = dir[len(dir)-2]
801    
655        to_writeReq = ''
802          to_write = ''
803  
804          req=' '
805          req = req + jbt.getRequirements()
806  
661
662        #sites = common.jobDB.destination(nj)
663        #if len(sites)>0 and sites[0]!="Any":
664        #    req = req + ' && anyMatch(other.storage.CloseSEs, (_ITR4_))'
665        #req = req    
666    
807          if self.EDG_requirements:
808              if (req == ' '):
809                  req = req + self.EDG_requirements
# Line 706 | Line 846 | class SchedulerEdg(Scheduler):
846              to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n'
847              pass
848  
849 +        if ( self.EDG_shallow_retry_count ):              
850 +            to_write = to_write + 'ShallowRetryCount = "'+self.EDG_shallow_retry_count+'"\n'
851 +            pass
852 +
853          to_write = to_write + 'MyProxyServer = "&quot;' + self.proxyServer + '&quot;"\n'
854          to_write = to_write + 'VirtualOrganisation = "&quot;' + self.VO + '&quot;"\n'
855  
856 <                #TaskName  
856 >        #TaskName  
857          dir = string.split(common.work_space.topDir(), '/')
858          taskName = dir[len(dir)-2]
859  
860          xml.write(str(title))
861 <        xml.write('<task name="' +str(taskName)+'">\n')
861 >        #xml.write('<task name="' +str(taskName)+'" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache">\n')
862 >
863 >        #xml.write('<task name="' +str(taskName)+ '" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache"' + '" task_info="' + os.path.expandvars('X509_USER_PROXY') + '">\n')
864 >        xml.write('<task name="' +str(taskName)+ '" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache"' + ' task_info="' + os.environ["X509_USER_PROXY"] + '">\n')
865          xml.write(jt_string)
866          
867          if (to_write != ''):
# Line 741 | Line 888 | class SchedulerEdg(Scheduler):
888          indy: here itr4
889          '''
890          
891 <
892 <        xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n')
891 >        xml.write('<chain name="' +str(taskName)+'__ITR1_" scheduler="'+str(self.schedulerName)+'">\n')
892 >       # xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n')
893          xml.write(jt_string)
894  
895          #executable
# Line 755 | Line 902 | class SchedulerEdg(Scheduler):
902          xml.write('<program>\n')
903          xml.write('<exec> ' + os.path.basename(script) +' </exec>\n')
904          xml.write(jt_string)
905 <    
759 <          
760 <        ### only one .sh  JDL has arguments:
761 <        ### Fabio
762 < #        xml.write('args = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'"\n')
905 >
906          xml.write('<args> <![CDATA[\n _ITR2_ \n]]> </args>\n')
907          xml.write('<program_types> crabjob </program_types>\n')
908 <        inp_box = script + ','
908 >        inp_box = common.work_space.pathForTgz() + 'job/' + jbt.scriptName + ','
909  
910          if inp_sandbox != None:
911              for fl in inp_sandbox:
# Line 770 | Line 913 | class SchedulerEdg(Scheduler):
913                  pass
914              pass
915  
916 <        inp_box = inp_box + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + ',' +\
917 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + ','+\
918 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + ','+\
919 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + ','+\
920 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py')
921 <
779 <        if (not jbt.additional_inbox_files == []):
780 <            inp_box = inp_box + ','
781 <            for addFile in jbt.additional_inbox_files:
782 <                addFile = os.path.abspath(addFile)
783 <                inp_box = inp_box+''+addFile+','
784 <                pass
916 > #        if (not jbt.additional_inbox_files == []):
917 > #            inp_box = inp_box + ','
918 > #            for addFile in jbt.additional_inbox_files:
919 > #                #addFile = os.path.abspath(addFile)
920 > #                inp_box = inp_box+''+addFile+','
921 > #                pass
922  
923          if inp_box[-1] == ',' : inp_box = inp_box[:-1]
924          inp_box = '<infiles> <![CDATA[\n' + inp_box + '\n]]> </infiles>\n'
# Line 812 | Line 949 | class SchedulerEdg(Scheduler):
949          INDY
950          something similar should be also done for infiles (if it makes sense!)
951          """
952 +        # Stuff to be returned _always_ via sandbox
953 +        for fl in jbt.output_file_sandbox:
954 +            out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ','
955 +            pass
956 +        pass
957 +
958 +        # via sandbox iif required return_data
959          if int(self.return_data) == 1:
960              for fl in jbt.output_file:
961                  out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ','
# Line 840 | Line 984 | class SchedulerEdg(Scheduler):
984          Function to check the Globus proxy.
985          """
986          if (self.proxyValid): return
987 <        timeleft = -999
987 >
988 >        ### Just return if asked to do so
989 >        if (self.dontCheckProxy==1):
990 >            self.proxyValid=1
991 >            return
992 >
993          minTimeLeft=10*3600 # in seconds
994  
995          minTimeLeftServer = 100 # in hours
# Line 860 | Line 1009 | class SchedulerEdg(Scheduler):
1009          pass
1010  
1011          if mustRenew:
1012 <            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")
1013 <            cmd = 'voms-proxy-init -voms '+self.VO+' -valid 96:00'
1012 >            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")
1013 >            cmd = 'voms-proxy-init -voms '+self.VO
1014 >            if self.group:
1015 >                cmd += ':/'+self.VO+'/'+self.group
1016              if self.role:
1017 <                cmd = 'voms-proxy-init -voms '+self.VO+':/'+self.VO+'/role='+self.role+' -valid 96:00'
1017 >                cmd += '/role='+self.role
1018 >            cmd += ' -valid 192:00'
1019              try:
1020                  # SL as above: damn it!
1021 +                common.logger.debug(10,cmd)
1022                  out = os.system(cmd)
1023                  if (out>0): raise CrabException("Unable to create a valid proxy!\n")
1024              except:
# Line 885 | Line 1038 | class SchedulerEdg(Scheduler):
1038              reTime = re.compile( r'timeleft: (\d+)' )
1039              #print "<"+str(reTime.search( cmd_out ).group(1))+">"
1040              if reTime.match( cmd_out ):
1041 <                time = reTime.search( line ).group(1)
1041 >                time = reTime.search( cmd_out ).group(1)
1042                  if time < minTimeLeftServer:
1043                      renewProxy = 1
1044                      common.logger.message('No credential delegation will expire in '+time+' hours: renew it')
# Line 911 | Line 1064 | class SchedulerEdg(Scheduler):
1064          if self.edg_config_vo:
1065              edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' '
1066          return edg_ui_cfg_opt
1067 +
1068 +    def submitTout(self, list):
1069 +        return 120
1070 +
1071 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines