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.75 by mkirn, Fri Jul 28 18:04:01 2006 UTC vs.
Revision 1.133.2.4 by fanzago, Fri Oct 12 12:56:30 2007 UTC

# Line 3 | Line 3 | from crab_logger import Logger
3   from crab_exceptions import *
4   from crab_util import *
5   from EdgConfig import *
6 + from BlackWhiteListParser import BlackWhiteListParser
7   import common
8  
9   import os, sys, time
# Line 22 | Line 23 | class SchedulerEdg(Scheduler):
23  
24      def configure(self, cfg_params):
25  
26 +        # init BlackWhiteListParser
27 +        self.blackWhiteListParser = BlackWhiteListParser(cfg_params)
28 +
29 +        self.proxyValid=0
30 +        try: self.dontCheckProxy=int(cfg_params["EDG.dont_check_proxy"])
31 +        except KeyError: self.dontCheckProxy = 0
32 +
33          try:
34 <            RB = cfg_params["EDG.rb"]
35 <            edgConfig = EdgConfig(RB)
28 <            self.edg_config = edgConfig.config()
29 <            self.edg_config_vo = edgConfig.configVO()
34 >            RB=cfg_params["EDG.rb"]
35 >            self.rb_param_file=self.rb_configure(RB)
36          except KeyError:
37 <            self.edg_config = ''
38 <            self.edg_config_vo = ''
33 <
37 >            self.rb_param_file=''
38 >            pass
39          try:
40              self.proxyServer = cfg_params["EDG.proxy_server"]
41          except KeyError:
42              self.proxyServer = 'myproxy.cern.ch'
43          common.logger.debug(5,'Setting myproxy server to '+self.proxyServer)
44  
45 <        try: self.LCG_version = cfg_params["EDG.lcg_version"]
46 <        except KeyError: self.LCG_version = '2'
47 <
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 = ''
45 >        try:
46 >            self.group = cfg_params["EDG.group"]
47 >        except KeyError:
48 >            self.group = None
49 >            
50 >        try:
51 >            self.role = cfg_params["EDG.role"]
52 >        except KeyError:
53 >            self.role = None
54 >            
55 >        #try: self.LCG_version = cfg_params["EDG.lcg_version"]
56 >        #except KeyError: self.LCG_version = '2'
57  
58          try:
59              self.EDG_ce_black_list = cfg_params['EDG.ce_black_list']
51            #print "self.EDG_ce_black_list = ", self.EDG_ce_black_list
60          except KeyError:
61              self.EDG_ce_black_list  = ''
62  
63          try:
64              self.EDG_ce_white_list = cfg_params['EDG.ce_white_list']
57            #print "self.EDG_ce_white_list = ", self.EDG_ce_white_list
65          except KeyError: self.EDG_ce_white_list = ''
66  
67          try: self.VO = cfg_params['EDG.virtual_organization']
68          except KeyError: self.VO = 'cms'
69  
70 <        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
70 >        try: self.copy_input_data = cfg_params["USER.copy_input_data"]
71          except KeyError: self.copy_input_data = 0
72  
73 +        try: self.return_data = cfg_params['USER.return_data']
74 +        except KeyError: self.return_data = 0
75 +
76          try:
77              self.copy_data = cfg_params["USER.copy_data"]
78              if int(self.copy_data) == 1:
# Line 82 | Line 87 | class SchedulerEdg(Scheduler):
87          except KeyError: self.copy_data = 0
88  
89          if ( int(self.return_data) == 0 and int(self.copy_data) == 0 ):
90 <           msg = 'Warning: return_data = 0 and copy_data = 0 ==> your exe output will be lost\n'
90 >           msg = 'Error: return_data = 0 and copy_data = 0 ==> your exe output will be lost\n'
91             msg = msg + 'Please modify return_data and copy_data value in your crab.cfg file\n'
92             raise CrabException(msg)
93  
94 <        try:
95 <            self.lfc_host = cfg_params['EDG.lfc_host']
96 <        except KeyError:
97 <            msg = "Error. The [EDG] section does not have 'lfc_host' value"
98 <            msg = msg + " it's necessary to know the LFC host name"
99 <            common.logger.message(msg)
95 <            raise CrabException(msg)
96 <        try:
97 <            self.lcg_catalog_type = cfg_params['EDG.lcg_catalog_type']
98 <        except KeyError:
99 <            msg = "Error. The [EDG] section does not have 'lcg_catalog_type' value"
100 <            msg = msg + " it's necessary to know the catalog type"
101 <            common.logger.message(msg)
102 <            raise CrabException(msg)
103 <        try:
104 <            self.lfc_home = cfg_params['EDG.lfc_home']
105 <        except KeyError:
106 <            msg = "Error. The [EDG] section does not have 'lfc_home' value"
107 <            msg = msg + " it's necessary to know the home catalog dir"
108 <            common.logger.message(msg)
109 <            raise CrabException(msg)
110 <      
94 >        if ( int(self.return_data) == 1 and int(self.copy_data) == 1 ):
95 >           msg = 'Error: return_data and copy_data cannot be set both to 1\n'
96 >           msg = msg + 'Please modify return_data or copy_data value in your crab.cfg file\n'
97 >           raise CrabException(msg)
98 >
99 >        ########### FEDE FOR DBS2 ##############################
100          try:
101 <            self.register_data = cfg_params["USER.register_data"]
102 <            if int(self.register_data) == 1:
101 >            self.publish_data = cfg_params["USER.publish_data"]
102 >            self.checkProxy()
103 >            if int(self.publish_data) == 1:
104                  try:
105 <                    self.LFN = cfg_params['USER.lfn_dir']
105 >                    self.publish_data_name = cfg_params['USER.publish_data_name']
106                  except KeyError:
107 <                    msg = "Error. The [USER] section does not have 'lfn_dir' value"
108 <                    msg = msg + " it's necessary for LCF registration"
109 <                    common.logger.message(msg)
107 >                    msg = "Error. The [USER] section does not have 'publish_data_name'"
108 >                    raise CrabException(msg)
109 >                try:
110 >                    tmp = runCommand("voms-proxy-info -identity")
111 >                    tmp = string.split(tmp,'/')
112 >                    reCN=re.compile(r'CN=')
113 >                    for t in tmp:
114 >                        if reCN.match(t):
115 >                            self.UserGridName=string.strip((t.replace('CN=','')).replace(' ',''))
116 >                        
117 >                    #self.UserGridName = string.strip(runCommand("voms-proxy-info -identity | awk -F\'CN\' \'{print $2$3$4}\' | tr -d \'=/ \'"))
118 >                except:
119 >                    msg = "Error. Problem with voms-proxy-info -identity command"
120                      raise CrabException(msg)
121 <        except KeyError: self.register_data = 0
121 >        except KeyError: self.publish_data = 0
122  
123 <        if ( int(self.copy_data) == 0 and int(self.register_data) == 1 ):
124 <           msg = 'Warning: register_data = 1 must be used with copy_data = 1\n'
123 >        if ( int(self.copy_data) == 0 and int(self.publish_data) == 1 ):
124 >           msg = 'Warning: publish_data = 1 must be used with copy_data = 1\n'
125             msg = msg + 'Please modify copy_data value in your crab.cfg file\n'
126             common.logger.message(msg)
127             raise CrabException(msg)
128 +        #################################################
129 +
130 +        #try:
131 +        #    self.lfc_host = cfg_params['EDG.lfc_host']
132 +        #except KeyError:
133 +        #    msg = "Error. The [EDG] section does not have 'lfc_host' value"
134 +        #    msg = msg + " it's necessary to know the LFC host name"
135 +        #    common.logger.message(msg)
136 +        #    raise CrabException(msg)
137 +        #try:
138 +        #    self.lcg_catalog_type = cfg_params['EDG.lcg_catalog_type']
139 +        #except KeyError:
140 +        #    msg = "Error. The [EDG] section does not have 'lcg_catalog_type' value"
141 +        #    msg = msg + " it's necessary to know the catalog type"
142 +        #    common.logger.message(msg)
143 +        #    raise CrabException(msg)
144 +        #try:
145 +        #    self.lfc_home = cfg_params['EDG.lfc_home']
146 +        #except KeyError:
147 +        #    msg = "Error. The [EDG] section does not have 'lfc_home' value"
148 +        #    msg = msg + " it's necessary to know the home catalog dir"
149 +        #    common.logger.message(msg)
150 +        #    raise CrabException(msg)
151 +      
152 +        #try:
153 +        #    self.register_data = cfg_params["USER.register_data"]
154 +        #    if int(self.register_data) == 1:
155 +        #        try:
156 +        #            self.LFN = cfg_params['USER.lfn_dir']
157 +        #        except KeyError:
158 +        #            msg = "Error. The [USER] section does not have 'lfn_dir' value"
159 +        #            msg = msg + " it's necessary for LCF registration"
160 +        #            common.logger.message(msg)
161 +        #            raise CrabException(msg)
162 +        #except KeyError: self.register_data = 0
163 +
164 +        #if ( int(self.copy_data) == 0 and int(self.register_data) == 1 ):
165 +        #   msg = 'Warning: register_data = 1 must be used with copy_data = 1\n'
166 +        #   msg = msg + 'Please modify copy_data value in your crab.cfg file\n'
167 +        #   common.logger.message(msg)
168 +        #   raise CrabException(msg)
169  
170          try: self.EDG_requirements = cfg_params['EDG.requirements']
171          except KeyError: self.EDG_requirements = ''
172 <                                                                                                                                                            
172 >
173 >        try: self.EDG_addJdlParam = string.split(cfg_params['EDG.additional_jdl_parameters'],',')
174 >        except KeyError: self.EDG_addJdlParam = []
175 >
176          try: self.EDG_retry_count = cfg_params['EDG.retry_count']
177          except KeyError: self.EDG_retry_count = ''
178 <                                                                                                                                                            
178 >
179 >        try: self.EDG_shallow_retry_count= cfg_params['EDG.shallow_retry_count']
180 >        except KeyError: self.EDG_shallow_retry_count = ''
181 >
182          try: self.EDG_clock_time = cfg_params['EDG.max_wall_clock_time']
183          except KeyError: self.EDG_clock_time= ''
184 <                                                                                                                                                            
184 >
185          try: self.EDG_cpu_time = cfg_params['EDG.max_cpu_time']
186          except KeyError: self.EDG_cpu_time = ''
187  
# Line 151 | Line 198 | class SchedulerEdg(Scheduler):
198          libPath=os.path.join(path, "lib", "python")
199          sys.path.append(libPath)
200  
154        self.proxyValid=0
155
201          try:
202              self._taskId = cfg_params['taskId']
203          except:
204              self._taskId = ''
205  
206 +        try: self.jobtypeName = cfg_params['CRAB.jobtype']
207 +        except KeyError: self.jobtypeName = ''
208 +
209 +        try: self.schedulerName = cfg_params['CRAB.scheduler']
210 +        except KeyError: self.scheduler = ''
211 +
212          return
213      
214  
215 +    def rb_configure(self, RB):
216 +        self.edg_config = ''
217 +        self.edg_config_vo = ''
218 +        self.rb_param_file = ''
219 +
220 +        edgConfig = EdgConfig(RB)
221 +        self.edg_config = edgConfig.config()
222 +        self.edg_config_vo = edgConfig.configVO()
223 +
224 +        if (self.edg_config and self.edg_config_vo != ''):
225 +            self.rb_param_file = 'RBconfig = "'+self.edg_config+'";\nRBconfigVO = "'+self.edg_config_vo+'";\n'
226 +            #print "rb_param_file = ", self.rb_param_file
227 +        return self.rb_param_file
228 +      
229 +
230      def sched_parameter(self):
231          """
232 <        Returns file with scheduler-specific parameters
232 >        Returns file with requirements and scheduler-specific parameters
233          """
234 <      
235 <        if (self.edg_config and self.edg_config_vo != ''):
236 <            self.param='sched_param.clad'
234 >        index = int(common.jobDB.nJobs()) - 1
235 >        job = common.job_list[index]
236 >        jbt = job.type()
237 >        
238 >        lastBlock=-1
239 >        first = []
240 >        for n in range(common.jobDB.nJobs()):
241 >            currBlock=common.jobDB.block(n)
242 >            if (currBlock!=lastBlock):
243 >                lastBlock = currBlock
244 >                first.append(n)
245 >  
246 >        req = ''
247 >        req = req + jbt.getRequirements()
248 >    
249 >        if self.EDG_requirements:
250 >            if (req == ' '):
251 >                req = req + self.EDG_requirements
252 >            else:
253 >                req = req +  ' && ' + self.EDG_requirements
254 >
255 >        if self.EDG_ce_white_list:
256 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
257 >            for i in range(len(ce_white_list)):
258 >                if i == 0:
259 >                    if (req == ' '):
260 >                        req = req + '((RegExp("' + string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))'
261 >                    else:
262 >                        req = req +  ' && ((RegExp("' +  string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))'
263 >                    pass
264 >                else:
265 >                    req = req +  ' || (RegExp("' +  string.strip(ce_white_list[i]) + '", other.GlueCEUniqueId))'
266 >            req = req + ')'
267 >        
268 >        if self.EDG_ce_black_list:
269 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
270 >            for ce in ce_black_list:
271 >                if (req == ' '):
272 >                    req = req + '(!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))'
273 >                else:
274 >                    req = req +  ' && (!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))'
275 >                pass
276 >        if self.EDG_clock_time:
277 >            if (req == ' '):
278 >                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
279 >            else:
280 >                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
281 >
282 >        if self.EDG_cpu_time:
283 >            if (req == ' '):
284 >                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
285 >            else:
286 >                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
287 >                
288 >        for i in range(len(first)): # Add loop DS
289 >            groupReq = req
290 >            self.param='sched_param_'+str(i)+'.clad'
291              param_file = open(common.work_space.shareDir()+'/'+self.param, 'w')
292 <            param_file.write('RBconfig = "'+self.edg_config+'";\n')  
293 <            param_file.write('RBconfigVO = "'+self.edg_config_vo+'";')
292 >
293 >            itr4=self.findSites_(first[i])
294 >            for arg in itr4:
295 >                groupReq = groupReq + ' && anyMatch(other.storage.CloseSEs, ('+str(arg)+'))'
296 >            param_file.write('Requirements = '+groupReq +';\n')  
297 >  
298 >            if (self.rb_param_file != ''):
299 >                param_file.write(self.rb_param_file)  
300 >
301 >            if len(self.EDG_addJdlParam):
302 >                for p in self.EDG_addJdlParam:
303 >                    param_file.write(p)
304 >
305              param_file.close()  
306 <            return 1
176 <        else:
177 <            return 0
306 >
307  
308      def wsSetupEnvironment(self):
309          """
# Line 199 | Line 328 | class SchedulerEdg(Scheduler):
328          txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
329  
330          txt += 'echo "middleware discovery " \n'
331 <        txt += 'if [ $VO_CMS_SW_DIR ]; then \n'
203 <        txt += '    middleware=LCG \n'
204 <        txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
205 <        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
206 <        txt += '    echo "middleware =$middleware" \n'
207 <        txt += 'elif [ $GRID3_APP_DIR ]; then\n'
331 >        txt += 'if [ $GRID3_APP_DIR ]; then\n'
332          txt += '    middleware=OSG \n'
333 <        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
333 >        txt += '    if [ $GLOBUS_GRAM_JOB_CONTACT ]; then \n'
334 >        txt += '        SyncCE=`echo "echo $GLOBUS_GRAM_JOB_CONTACT" | cut -d: -f2 | sed \'s/\/\///\'`;\n'
335 >        txt += '        echo "SyncCE=$SyncCE"  | tee -a $RUNTIME_AREA/$repo ;\n'
336 >        txt += '    else\n'
337 >        txt += '        echo "not reporting SyncCE";\n'
338 >        txt += '    fi\n';
339          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
340          txt += '    echo "middleware =$middleware" \n'
341          txt += 'elif [ $OSG_APP ]; then \n'
342          txt += '    middleware=OSG \n'
343 <        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
343 >        txt += '    if [ $GLOBUS_GRAM_JOB_CONTACT ]; then \n'
344 >        txt += '        SyncCE=`echo "echo $GLOBUS_GRAM_JOB_CONTACT" | cut -d: -f2 | sed \'s/\/\///\'`;\n'
345 >        txt += '        echo "SyncCE=$SyncCE"  | tee -a $RUNTIME_AREA/$repo ;\n'
346 >        txt += '    else\n'
347 >        txt += '        echo "not reporting SyncCE";\n'
348 >        txt += '    fi\n';
349 >        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
350 >        txt += '    echo "middleware =$middleware" \n'
351 >        txt += 'elif [ $VO_CMS_SW_DIR ]; then \n'
352 >        txt += '    middleware=LCG \n'
353 >   #     txt += '    echo "SyncCE=`edg-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
354 >        txt += '    echo "SyncCE=`glite-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
355          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
356          txt += '    echo "middleware =$middleware" \n'
357          txt += 'else \n'
# Line 233 | Line 373 | class SchedulerEdg(Scheduler):
373          
374          txt += '\n\n'
375  
376 <        if int(self.copy_data) == 1:
377 <           if self.SE:
378 <              txt += 'export SE='+self.SE+'\n'
379 <              txt += 'echo "SE = $SE"\n'
380 <           if self.SE_PATH:
381 <              if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
382 <              txt += 'export SE_PATH='+self.SE_PATH+'\n'
383 <              txt += 'echo "SE_PATH = $SE_PATH"\n'
376 > #        if int(self.copy_data) == 1:
377 > #           if self.SE:
378 > #              txt += 'export SE='+self.SE+'\n'
379 > #              txt += 'echo "SE = $SE"\n'
380 > #           if self.SE_PATH:
381 > #              if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
382 > #              txt += 'export SE_PATH='+self.SE_PATH+'\n'
383 > #              txt += 'echo "SE_PATH = $SE_PATH"\n'
384  
385          txt += 'export VO='+self.VO+'\n'
386 <        ### FEDE: add some line for LFC catalog setting
387 <        txt += 'if [ $middleware == LCG ]; then \n'
388 <        txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
389 <        txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
390 <        txt += '    fi\n'
391 <        txt += '    if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
392 <        txt += '        export LFC_HOST='+self.lfc_host+'\n'
393 <        txt += '    fi\n'
394 <        txt += '    if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
395 <        txt += '        export LFC_HOME='+self.lfc_home+'\n'
396 <        txt += '    fi\n'
397 <        txt += 'elif [ $middleware == OSG ]; then\n'
398 <        txt += '    echo "LFC catalog setting to be implemented for OSG"\n'
399 <        txt += 'fi\n'
386 >        ### add some line for LFC catalog setting
387 >        #txt += 'if [ $middleware == LCG ]; then \n'
388 >        #txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
389 >        #txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
390 >        #txt += '    fi\n'
391 >        #txt += '    if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
392 >        #txt += '        export LFC_HOST='+self.lfc_host+'\n'
393 >        #txt += '    fi\n'
394 >        #txt += '    if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
395 >        #txt += '        export LFC_HOME='+self.lfc_home+'\n'
396 >        #txt += '    fi\n'
397 >        #txt += 'elif [ $middleware == OSG ]; then\n'
398 >        #txt += '    echo "LFC catalog setting to be implemented for OSG"\n'
399 >        #txt += 'fi\n'
400          #####
401 <        if int(self.register_data) == 1:
402 <           txt += 'if [ $middleware == LCG ]; then \n'
403 <           txt += '    export LFN='+self.LFN+'\n'
404 <           txt += '    lfc-ls $LFN\n'
405 <           txt += '    result=$?\n'
406 <           txt += '    echo $result\n'
407 <           ### creation of LFN dir in LFC catalog, under /grid/cms dir  
408 <           txt += '    if [ $result != 0 ]; then\n'
409 <           txt += '       lfc-mkdir $LFN\n'
410 <           txt += '       result=$?\n'
411 <           txt += '       echo $result\n'
412 <           txt += '    fi\n'
413 <           txt += 'elif [ $middleware == OSG ]; then\n'
414 <           txt += '    echo " Files registration to be implemented for OSG"\n'
415 <           txt += 'fi\n'
416 <           txt += '\n'
417 <
418 <           if self.VO:
419 <              txt += 'export VO='+self.VO+'\n'
420 <           if self.LFN:
421 <              txt += 'if [ $middleware == LCG ]; then \n'
422 <              txt += '    export LFN='+self.LFN+'\n'
423 <              txt += 'fi\n'
284 <              txt += '\n'
401 >        #if int(self.register_data) == 1:
402 >        #   txt += 'if [ $middleware == LCG ]; then \n'
403 >        #   txt += '    export LFN='+self.LFN+'\n'
404 >        #   txt += '    lfc-ls $LFN\n'
405 >        #   txt += '    result=$?\n'
406 >        #   txt += '    echo $result\n'
407 >        #   ### creation of LFN dir in LFC catalog, under /grid/cms dir  
408 >        #   txt += '    if [ $result != 0 ]; then\n'
409 >        #   txt += '       lfc-mkdir $LFN\n'
410 >        #   txt += '       result=$?\n'
411 >        #   txt += '       echo $result\n'
412 >        #   txt += '    fi\n'
413 >        #   txt += 'elif [ $middleware == OSG ]; then\n'
414 >        #   txt += '    echo " Files registration to be implemented for OSG"\n'
415 >        #   txt += 'fi\n'
416 >        #   txt += '\n'
417 >        #   if self.VO:
418 >        #      txt += 'export VO='+self.VO+'\n'
419 >        #   if self.LFN:
420 >        #      txt += 'if [ $middleware == LCG ]; then \n'
421 >        #      txt += '    export LFN='+self.LFN+'\n'
422 >        #      txt += 'fi\n'
423 >        #      txt += '\n'
424  
425          txt += 'if [ $middleware == LCG ]; then\n'
426 <        txt += '    CloseCEs=`edg-brokerinfo getCE`\n'
426 >    #    txt += '    CloseCEs=`edg-brokerinfo getCE`\n'
427 >        txt += '    CloseCEs=`glite-brokerinfo getCE`\n'
428          txt += '    echo "CloseCEs = $CloseCEs"\n'
429          txt += '    CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
430          txt += '    echo "CE = $CE"\n'
# Line 310 | Line 450 | class SchedulerEdg(Scheduler):
450          Copy input data from SE to WN    
451          """
452          txt = ''
453 <        try:
454 <            self.copy_input_data = common.analisys_common_info['copy_input_data']
315 <            #print "self.copy_input_data = ", self.copy_input_data
316 <        except KeyError: self.copy_input_data = 0
317 <        if int(self.copy_input_data) == 1:
453 >        if not self.copy_input_data: return txt
454 >
455          ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
456 <           txt += 'if [ $middleware == OSG ]; then\n'
457 <           txt += '   #\n'
458 <           txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
459 <           txt += '   #\n'
460 <           txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
461 <           txt += 'elif [ $middleware == LCG ]; then \n'
462 <           txt += '   #\n'
463 <           txt += '   #   Copy Input Data from SE to this WN\n'
464 <           txt += '   #\n'
465 < ### changed by georgia (put a loop copying more than one input files per jobs)          
466 <           txt += '   for input_file in $cur_file_list \n'
467 <           txt += '   do \n'
468 <           #### FEDE
469 <           #txt += '      echo "which lcg-cp" \n'
470 <           #txt += '      which lcg-cp \n'
471 <           #########
472 <           txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
473 <           txt += '      copy_input_exit_status=$?\n'
474 <           txt += '      echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
475 <           txt += '      if [ $copy_input_exit_status -ne 0 ]; then \n'
476 <           txt += '         echo "Problems with copying to WN" \n'
477 <           txt += '      else \n'
478 <           txt += '         echo "input copied into WN" \n'
479 <           txt += '      fi \n'
480 <           txt += '   done \n'
481 < ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
482 <           txt += '   for file in $cur_pu_list \n'
483 <           txt += '   do \n'
484 <           #### FEDE
485 <           #txt += '      echo "which lcg-cp" \n'
486 <           #txt += '      which lcg-cp \n'
487 <           #########
488 <           txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
489 <           txt += '      copy_input_pu_exit_status=$?\n'
490 <           txt += '      echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
491 <           txt += '      if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
492 <           txt += '         echo "Problems with copying pu to WN" \n'
356 <           txt += '      else \n'
357 <           txt += '         echo "input pu files copied into WN" \n'
358 <           txt += '      fi \n'
359 <           txt += '   done \n'
360 <           txt += '   \n'
361 <           txt += '   ### Check SCRATCH space available on WN : \n'
362 <           txt += '   df -h \n'
363 <           txt += 'fi \n'
456 >        txt += 'if [ $middleware == OSG ]; then\n'
457 >        txt += '   #\n'
458 >        txt += '   #   Copy Input Data from SE to this WN deactivated in OSG mode\n'
459 >        txt += '   #\n'
460 >        txt += '   echo "Copy Input Data from SE to this WN deactivated in OSG mode"\n'
461 >        txt += 'elif [ $middleware == LCG ]; then \n'
462 >        txt += '   #\n'
463 >        txt += '   #   Copy Input Data from SE to this WN\n'
464 >        txt += '   #\n'
465 >        ### changed by georgia (put a loop copying more than one input files per jobs)          
466 >        txt += '   for input_file in $cur_file_list \n'
467 >        txt += '   do \n'
468 >        txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$input_lfn/$input_file file:`pwd`/$input_file 2>&1\n'
469 >        txt += '      copy_input_exit_status=$?\n'
470 >        txt += '      echo "COPY_INPUT_EXIT_STATUS = $copy_input_exit_status"\n'
471 >        txt += '      if [ $copy_input_exit_status -ne 0 ]; then \n'
472 >        txt += '         echo "Problems with copying to WN" \n'
473 >        txt += '      else \n'
474 >        txt += '         echo "input copied into WN" \n'
475 >        txt += '      fi \n'
476 >        txt += '   done \n'
477 >        ### copy a set of PU ntuples (same for each jobs -- but accessed randomly)
478 >        txt += '   for file in $cur_pu_list \n'
479 >        txt += '   do \n'
480 >        txt += '      lcg-cp --vo $VO --verbose -t 1200 lfn:$pu_lfn/$file file:`pwd`/$file 2>&1\n'
481 >        txt += '      copy_input_pu_exit_status=$?\n'
482 >        txt += '      echo "COPY_INPUT_PU_EXIT_STATUS = $copy_input_pu_exit_status"\n'
483 >        txt += '      if [ $copy_input_pu_exit_status -ne 0 ]; then \n'
484 >        txt += '         echo "Problems with copying pu to WN" \n'
485 >        txt += '      else \n'
486 >        txt += '         echo "input pu files copied into WN" \n'
487 >        txt += '      fi \n'
488 >        txt += '   done \n'
489 >        txt += '   \n'
490 >        txt += '   ### Check SCRATCH space available on WN : \n'
491 >        txt += '   df -h \n'
492 >        txt += 'fi \n'
493            
494          return txt
495  
# Line 369 | Line 498 | class SchedulerEdg(Scheduler):
498          Write a CopyResults part of a job script, e.g.
499          to copy produced output into a storage element.
500          """
501 <        txt = ''
373 <        if int(self.copy_data) == 1:
374 <           txt += '#\n'
375 <           txt += '#   Copy output to SE = $SE\n'
376 <           txt += '#\n'
377 <           #txt += 'if [ $exe_result -eq 0 ]; then\n'
378 <           txt += '    if [ $middleware == OSG ]; then\n'
379 <           txt += '        echo "X509_USER_PROXY = $X509_USER_PROXY"\n'
380 <           txt += '        echo "source $OSG_APP/glite/setup_glite_ui.sh"\n'
381 <           txt += '        source $OSG_APP/glite/setup_glite_ui.sh\n'
382 <           txt += '        export X509_CERT_DIR=$OSG_APP/glite/etc/grid-security/certificates\n'
383 <           txt += '        echo "export X509_CERT_DIR=$X509_CERT_DIR"\n'
384 <           txt += '    fi \n'
385 <           txt += '    for out_file in $file_list ; do\n'
386 <           txt += '        echo "Trying to copy output file to $SE using lcg-cp"\n'
387 <           txt += '        echo "lcg-cp --vo $VO -t 2400 --verbose file://`pwd`/$out_file gsiftp://${SE}${SE_PATH}$out_file"\n'
388 <           txt += '        exitstring=`lcg-cp --vo $VO -t 2400 --verbose file://\`pwd\`/$out_file gsiftp://${SE}${SE_PATH}$out_file 2>&1`\n'
389 <           txt += '        copy_exit_status=$?\n'
390 <           txt += '        echo "COPY_EXIT_STATUS for lcg-cp = $copy_exit_status"\n'
391 <           txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
392 <           txt += '        if [ $copy_exit_status -ne 0 ]; then\n'
393 <           txt += '            echo "Possible problem with SE = $SE"\n'
394 <           txt += '            echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
395 <           txt += '            echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
396 <           txt += '            echo "lcg-cp failed, attempting srmcp"\n'
397 <           txt += '            echo "mkdir -p $HOME/.srmconfig"\n'
398 <           txt += '            mkdir -p $HOME/.srmconfig\n'
399 <           txt += '            if [ $middleware == LCG ]; then\n'
400 <           txt += '               echo "srmcp -retry_num 5 -retry_timeout 480000 file:////`pwd`/$out_file srm://${SE}:8443${SE_PATH}$out_file"\n'
401 <           txt += '               exitstring=`srmcp -retry_num 5 -retry_timeout 480000 file:////\`pwd\`/$out_file srm://${SE}:8443${SE_PATH}$out_file 2>&1`\n'
402 <           txt += '            elif [ $middleware == OSG ]; then\n'
403 <           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'
404 <           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'
405 <           txt += '            fi \n'
406 <           txt += '            copy_exit_status=$?\n'
407 <           txt += '            echo "COPY_EXIT_STATUS for srm = $copy_exit_status"\n'
408 <           txt += '            echo "STAGE_OUT = $copy_exit_status"\n'
409 <           txt += '            if [ $copy_exit_status -ne 0 ]; then\n'
410 <           txt += '               echo "Problems with SE = $SE"\n'
411 <           txt += '               echo "StageOutExitStatus = 198" | tee -a $RUNTIME_AREA/$repo\n'
412 <           txt += '               echo "StageOutExitStatusReason = $exitstring" | tee -a $RUNTIME_AREA/$repo\n'
413 <           txt += '               echo "lcg-cp and srm failed"\n'
414 <           txt += '               echo "If storage_path in your config file contains a ? you may need a \? instead."\n'
415 <           txt += '            else\n'
416 <           txt += '               echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
417 <           txt += '               echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
418 <           txt += '               echo "output copied into $SE/$SE_PATH directory"\n'
419 <           txt += '               echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
420 <           txt += '               echo "srmcp succeeded"\n'
421 <           txt += '            fi\n'
422 <           txt += '        else\n'
423 <           txt += '            echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
424 <           txt += '            echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
425 <           txt += '            echo "output copied into $SE/$SE_PATH directory"\n'
426 <           txt += '            echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
427 <           txt += '            echo "lcg-cp succeeded"\n'
428 <           txt += '         fi\n'
429 <           txt += '     done\n'
430 <           #txt += 'fi\n'
431 <        return txt
501 >        txt = '\n'
502  
503 <    def wsRegisterOutput(self):
504 <        """
505 <        Returns part of a job script which does scheduler-specific work.
436 <        """
503 >        txt += '#\n'
504 >        txt += '# COPY OUTPUT FILE TO SE\n'
505 >        txt += '#\n\n'
506  
507 <        txt = ''
508 <        if int(self.register_data) == 1:
509 <        ## OLI_Daniele deactivate for OSG (wait for LCG UI installed on OSG)
510 <           txt += 'if [ $middleware == OSG ]; then\n'
511 <           txt += '   #\n'
512 <           txt += '   #   Register output to LFC deactivated in OSG mode\n'
513 <           txt += '   #\n'
514 <           txt += '   echo "Register output to LFC deactivated in OSG mode"\n'
515 <           txt += 'elif [ $middleware == LCG ]; then \n'
516 <           txt += '#\n'
517 <           txt += '#  Register output to LFC\n'
518 <           txt += '#\n'
519 <           #txt += '   if [[ $exe_result -eq 0 && $copy_exit_status -eq 0 ]]; then\n'
520 <           txt += '   if [ $copy_exit_status -eq 0 ]; then\n'
521 <           txt += '      for out_file in $file_list ; do\n'
522 <           txt += '         echo "Trying to register the output file into LFC"\n'
523 <           #### FEDE
524 <           #txt += '         echo "which lcg-rf" \n'
525 <           #txt += '         which lcg-rf \n'
526 <           #########
527 <           txt += '         echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1"\n'
528 <           txt += '         lcg-rf -l $LFN/$out_file --vo $VO -t 1200 sfn://$SE$SE_PATH/$out_file 2>&1 \n'
529 <           txt += '         register_exit_status=$?\n'
530 <           txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
531 <           txt += '         echo "STAGE_OUT = $register_exit_status"\n'
532 <           txt += '         if [ $register_exit_status -ne 0 ]; then \n'
533 <           txt += '            echo "Problems with the registration to LFC" \n'
534 <           txt += '            echo "Try with srm protocol" \n'
535 <           #### FEDE
536 <           #txt += '            echo "which lcg-rf" \n'
537 <           #txt += '            which lcg-rf \n'
538 <           #########
539 <           txt += '            echo "lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1"\n'
540 <           txt += '            lcg-rf -l $LFN/$out_file --vo $VO -t 1200 srm://$SE$SE_PATH/$out_file 2>&1 \n'
541 <           txt += '            register_exit_status=$?\n'
542 <           txt += '            echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
543 <           txt += '            echo "STAGE_OUT = $register_exit_status"\n'
544 <           txt += '            if [ $register_exit_status -ne 0 ]; then \n'
545 <           txt += '               echo "Problems with the registration into LFC" \n'
546 <           txt += '            fi \n'
547 <           txt += '         else \n'
548 <           txt += '            echo "output registered to LFC"\n'
549 <           txt += '         fi \n'
550 <           txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
551 <           txt += '      done\n'
552 <           #txt += '   elif [[ $exe_result -eq 0 && $copy_exit_status -ne 0 ]]; then \n'
553 <           txt += '   else \n'
554 <           txt += '      echo "Trying to copy output file to CloseSE"\n'
555 <           txt += '      CLOSE_SE=`edg-brokerinfo getCloseSEs | head -1`\n'
556 <           txt += '      for out_file in $file_list ; do\n'
488 <           #### FEDE
489 <           #txt += '         echo "which lcg-cr" \n'
490 <           #txt += '         which lcg-cr \n'
491 <           #########
492 <           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'
493 <           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'
494 <           txt += '         register_exit_status=$?\n'
495 <           txt += '         echo "REGISTER_EXIT_STATUS = $register_exit_status"\n'
496 <           txt += '         echo "STAGE_OUT = $register_exit_status"\n'
497 <           txt += '         if [ $register_exit_status -ne 0 ]; then \n'
498 <           txt += '            echo "Problems with CloseSE or Catalog" \n'
499 <           txt += '         else \n'
500 <           txt += '            echo "The program was successfully executed"\n'
501 <           txt += '            echo "SE = $CLOSE_SE"\n'
502 <           txt += '            echo "LFN for the file is LFN=${LFN}/$out_file"\n'
503 <           txt += '         fi \n'
504 <           txt += '         echo "StageOutExitStatus = $register_exit_status" | tee -a $RUNTIME_AREA/$repo\n'
505 <           txt += '      done\n'
506 <           #txt += '   else\n'
507 <           #txt += '      echo "Problem with the executable"\n'
508 <           txt += '   fi \n'
509 <           txt += '   exit_status=$register_exit_status\n'
510 <           txt += 'fi \n'
507 >        SE_PATH=''
508 >        if int(self.copy_data) == 1:
509 >            if self.SE:
510 >                txt += 'export SE='+self.SE+'\n'
511 >                txt += 'echo "SE = $SE"\n'
512 >            if self.SE_PATH:
513 >                if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
514 >                SE_PATH=self.SE_PATH
515 >            if int(self.publish_data) == 1:
516 >                txt += '### publish_data = 1 so the SE path where to copy the output is: \n'
517 >                path_add = self.UserGridName + '/' + self.publish_data_name +'_${PSETHASH}/'
518 >                SE_PATH = SE_PATH + path_add
519 >            txt += 'export SE_PATH='+SE_PATH+'\n'
520 >            txt += 'echo "SE_PATH = $SE_PATH"\n'
521 >            
522 >            txt += 'echo "####################################################"\n'
523 >            txt += 'echo "# Copy output files from WN = `hostname` to SE = $SE"\n'
524 >            txt += 'echo "####################################################"\n'
525 >            
526 >            txt += 'if [ $output_exit_status -eq 60302 ]; then\n'
527 >            txt += '    echo "--> No output file to copy to $SE"\n'
528 >            txt += '    copy_exit_status=$output_exit_status\n'
529 >            txt += '    echo "COPY_EXIT_STATUS = $copy_exit_status"\n'
530 >            txt += 'else\n'
531 >            txt += '    for out_file in $file_list ; do\n'
532 >            txt += '        echo "Trying to copy output file to $SE"\n'
533 >            txt += '        cmscp $out_file ${SE} ${SE_PATH} $out_file $middleware\n'
534 >            txt += '        copy_exit_status=$?\n'
535 >            txt += '        echo "COPY_EXIT_STATUS = $copy_exit_status"\n'
536 >            txt += '        echo "STAGE_OUT = $copy_exit_status"\n'
537 >            txt += '        if [ $copy_exit_status -ne 0 ]; then\n'
538 >            txt += '            echo "Problem copying $out_file to $SE $SE_PATH"\n'
539 >            txt += '            echo "StageOutExitStatus = $copy_exit_status " | tee -a $RUNTIME_AREA/$repo\n'
540 >            txt += '            copy_exit_status=60307\n'
541 >            txt += '        else\n'
542 >            txt += '            echo "StageOutSE = $SE" | tee -a $RUNTIME_AREA/$repo\n'
543 >            txt += '            echo "StageOutCatalog = " | tee -a $RUNTIME_AREA/$repo\n'
544 >            txt += '            echo "output copied into $SE/$SE_PATH directory"\n'
545 >            txt += '            echo "StageOutExitStatus = 0" | tee -a $RUNTIME_AREA/$repo\n'
546 >            txt += '        fi\n'
547 >            txt += '    done\n'
548 >            txt += '    if [ $copy_exit_status -ne 0 ]; then\n'
549 >            txt += '        SE=""\n'
550 >            txt += '        echo "SE = $SE"\n'
551 >            txt += '        SE_PATH=""\n'
552 >            txt += '        echo "SE_PATH = $SE_PATH"\n'
553 >            txt += '    fi\n'
554 >            txt += 'fi\n'
555 >            txt += 'exit_status=$copy_exit_status\n'
556 >            pass
557          return txt
558  
559      def loggingInfo(self, id):
# Line 516 | Line 562 | class SchedulerEdg(Scheduler):
562          """
563          self.checkProxy()
564          cmd = 'edg-job-get-logging-info -v 2 ' + id
519        #cmd_out = os.popen(cmd)
565          cmd_out = runCommand(cmd)
566          return cmd_out
567  
568 <    def listMatch(self, nj):
569 <        """
570 <        Check the compatibility of available resources
571 <        """
572 <        self.checkProxy()
528 <        jdl = common.job_list[nj].jdlFilename()
529 <        cmd = 'edg-job-list-match ' + self.configOpt_() + jdl
530 <        cmd_out = runCommand(cmd,0,45)
531 <        if not cmd_out:
532 <            raise CrabException("ERROR: "+cmd+" failed!")
533 <
534 <        return self.parseListMatch_(cmd_out, jdl)
535 <
536 <    def parseListMatch_(self, out, jdl):
537 <        """
538 <        Parse the f* output of edg-list-match and produce something sensible
539 <        """
540 <        reComment = re.compile( r'^\**$' )
541 <        reEmptyLine = re.compile( r'^$' )
542 <        reVO = re.compile( r'Selected Virtual Organisation name.*' )
543 <        reLine = re.compile( r'.*')
544 <        reCE = re.compile( r'(.*:.*)')
545 <        reCEId = re.compile( r'CEId.*')
546 <        reNO = re.compile( r'No Computing Element matching' )
547 <        reRB = re.compile( r'Connecting to host' )
548 <        next = 0
549 <        CEs=[]
550 <        Match=0
551 <
552 <        #print out
553 <        lines = reLine.findall(out)
554 <
555 <        i=0
556 <        CEs=[]
557 <        for line in lines:
558 <            string.strip(line)
559 <            #print line
560 <            if reNO.match( line ):
561 <                common.logger.debug(5,line)
562 <                return 0
563 <                pass
564 <            if reVO.match( line ):
565 <                VO =reVO.match( line ).group()
566 <                common.logger.debug(5,"VO "+VO)
567 <                pass
568 <
569 <            if reRB.match( line ):
570 <                RB = reRB.match(line).group()
571 <                common.logger.debug(5,"RB "+RB)
572 <                pass
568 >    def queryDetailedStatus(self, id):
569 >        """ Query a detailed status of the job with id """
570 >        cmd = 'edg-job-status '+id
571 >        cmd_out = runCommand(cmd)
572 >        return cmd_out
573  
574 <            if reCEId.search( line ):
575 <                for lineCE in lines[i:-1]:
576 <                    if reCE.match( lineCE ):
577 <                        CE = string.strip(reCE.search(lineCE).group(1))
578 <                        CEs.append(CE.split(':')[0])
579 <                        pass
580 <                    pass
581 <                pass
582 <            i=i+1
583 <            pass
574 >    def findSites_(self, n):
575 >        itr4 =[]
576  
577 <        common.logger.debug(5,"All CE :"+str(CEs))
577 >        sites = common.jobDB.destination(n)
578  
579 <        sites = []
580 <        [sites.append(it) for it in CEs if not sites.count(it)]
579 >        if len(sites)>0 and sites[0]=="":
580 >            return itr4
581  
582 <        common.logger.debug(5,"All Sites :"+str(sites))
583 <        common.logger.message("Matched Sites :"+str(sites))
584 <        return len(sites)
585 <
586 <    def noMatchFound_(self, jdl):
587 <        reReq = re.compile( r'Requirements' )
588 <        reString = re.compile( r'"\S*"' )
589 <        f = file(jdl,'r')
590 <        for line in f.readlines():
591 <            line= line.strip()
592 <            if reReq.match(line):
593 <                for req in reString.findall(line):
594 <                    if re.search("VO",req):
595 <                        common.logger.message( "SW required: "+req)
596 <                        continue
597 <                    if re.search('"\d+',req):
598 <                        common.logger.message("Other req  : "+req)
599 <                        continue
600 <                    common.logger.message( "CE required: "+req)
609 <                break
610 <            pass
611 <        raise CrabException("No compatible resources found!")
582 >        itr = ''
583 >        if sites != [""]:#CarlosDaniele
584 >            ##Addedd Daniele
585 >            replicas = self.blackWhiteListParser.checkBlackList(sites,n)
586 >            if len(replicas)!=0:
587 >                replicas = self.blackWhiteListParser.checkWhiteList(replicas,n)
588 >              
589 >            if len(replicas)==0:
590 >                itr = itr + 'target.GlueSEUniqueID=="NONE" '
591 >                #msg = 'No sites remaining that host any part of the requested data! Exiting... '
592 >                #raise CrabException(msg)
593 >            #####        
594 >           # for site in sites:
595 >            for site in replicas:
596 >                #itr = itr + 'target.GlueSEUniqueID==&quot;'+site+'&quot; || '
597 >                itr = itr + 'target.GlueSEUniqueID=="'+site+'" || '
598 >            itr = itr[0:-4]
599 >            itr4.append( itr )
600 >        return itr4
601  
602 <    def submit(self, nj):
602 >    def createXMLSchScript(self, nj, argsList):
603 >      
604          """
605 <        Submit one EDG job.
605 >        Create a XML-file for BOSS4.
606          """
607 <
618 <        self.checkProxy()
619 <        jid = None
620 <        jdl = common.job_list[nj].jdlFilename()
621 <
622 <        cmd = 'edg-job-submit ' + self.configOpt_() + jdl
623 <        cmd_out = runCommand(cmd)
624 <        if cmd_out != None:
625 <            reSid = re.compile( r'https.+' )
626 <            jid = reSid.search(cmd_out).group()
627 <            pass
628 <        return jid
629 <
630 <    def resubmit(self, nj_list):
607 >  #      job = common.job_list[nj]
608          """
609 <        Prepare jobs to be submit
609 >        INDY
610 >        [begin] FIX-ME:
611 >        I would pass jobType instead of job
612 >        """
613 >        index = nj - 1
614 >        job = common.job_list[index]
615 >        jbt = job.type()
616 >        
617 >        inp_sandbox = jbt.inputSandbox(index)
618 >        #out_sandbox = jbt.outputSandbox(index)
619 >        """
620 >        [end] FIX-ME
621          """
634        return
635
636    def getExitStatus(self, id):
637        return self.getStatusAttribute_(id, 'exit_code')
638
639    def queryStatus(self, id):
640        return self.getStatusAttribute_(id, 'status')
641
642    def queryDest(self, id):  
643        return self.getStatusAttribute_(id, 'destination')
644
645
646    def getStatusAttribute_(self, id, attr):
647        """ Query a status of the job with id """
622  
623 <        self.checkProxy()
624 <        hstates = {}
625 <        Status = importName('edg_wl_userinterface_common_LbWrapper', 'Status')
626 <        # Bypass edg-job-status interfacing directly to C++ API
627 <        # Job attribute vector to retrieve status without edg-job-status
628 <        level = 0
655 <        # Instance of the Status class provided by LB API
656 <        jobStat = Status()
657 <        st = 0
658 <        jobStat.getStatus(id, level)
659 <        err, apiMsg = jobStat.get_error()
660 <        if err:
661 <            common.logger.debug(5,'Error caught' + apiMsg)
662 <            return None
663 <        else:
664 <            for i in range(len(self.states)):
665 <                # Fill an hash table with all information retrieved from LB API
666 <                hstates[ self.states[i] ] = jobStat.loadStatus(st)[i]
667 <            result = jobStat.loadStatus(st)[ self.states.index(attr) ]
668 <            return result
623 >        
624 >        title = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n'
625 >        jt_string = ''
626 >        
627 >        xml_fname = str(self.jobtypeName)+'.xml'
628 >        xml = open(common.work_space.shareDir()+'/'+xml_fname, 'a')
629  
630 <    def queryDetailedStatus(self, id):
631 <        """ Query a detailed status of the job with id """
632 <        cmd = 'edg-job-status '+id
633 <        cmd_out = runCommand(cmd)
634 <        return cmd_out
630 >        #TaskName  
631 >        dir = string.split(common.work_space.topDir(), '/')
632 >        taskName = dir[len(dir)-2]
633 >  
634 >        to_write = ''
635  
636 <    def getOutput(self, id):
637 <        """
678 <        Get output for a finished job with id.
679 <        Returns the name of directory with results.
680 <        """
636 >        req=' '
637 >        req = req + jbt.getRequirements()
638  
639 <        self.checkProxy()
640 <        cmd = 'edg-job-get-output --dir ' + common.work_space.resDir() + ' ' + id
641 <        cmd_out = runCommand(cmd)
639 >        if self.EDG_requirements:
640 >            if (req == ' '):
641 >                req = req + self.EDG_requirements
642 >            else:
643 >                req = req +  ' && ' + self.EDG_requirements
644 >        if self.EDG_ce_white_list:
645 >            ce_white_list = string.split(self.EDG_ce_white_list,',')
646 >            for i in range(len(ce_white_list)):
647 >                if i == 0:
648 >                    if (req == ' '):
649 >                        req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
650 >                    else:
651 >                        req = req +  ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
652 >                    pass
653 >                else:
654 >                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
655 >            req = req + ')'
656 >        
657 >        if self.EDG_ce_black_list:
658 >            ce_black_list = string.split(self.EDG_ce_black_list,',')
659 >            for ce in ce_black_list:
660 >                if (req == ' '):
661 >                    req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
662 >                else:
663 >                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
664 >                pass
665 >        if self.EDG_clock_time:
666 >            if (req == ' '):
667 >                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
668 >            else:
669 >                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
670  
671 <        # Determine the output directory name
672 <        dir = common.work_space.resDir()
673 <        dir += os.environ['USER']
674 <        dir += '_' + os.path.basename(id)
675 <        return dir
671 >        if self.EDG_cpu_time:
672 >            if (req == ' '):
673 >                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
674 >            else:
675 >                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
676 >                                                                                          
677 >        if ( self.EDG_retry_count ):              
678 >            to_write = to_write + 'RetryCount = "'+self.EDG_retry_count+'"\n'
679 >            pass
680  
681 <    def cancel(self, id):
682 <        """ Cancel the EDG job with id """
683 <        self.checkProxy()
695 <        cmd = 'edg-job-cancel --noint ' + id
696 <        cmd_out = runCommand(cmd)
697 <        return cmd_out
681 >        if ( self.EDG_shallow_retry_count ):              
682 >            to_write = to_write + 'ShallowRetryCount = "'+self.EDG_shallow_retry_count+'"\n'
683 >            pass
684  
685 <    def createSchScript(self, nj):
686 <        """
701 <        Create a JDL-file for EDG.
702 <        """
685 >        to_write = to_write + 'MyProxyServer = "&quot;' + self.proxyServer + '&quot;"\n'
686 >        to_write = to_write + 'VirtualOrganisation = "&quot;' + self.VO + '&quot;"\n'
687  
688 <        job = common.job_list[nj]
689 <        jbt = job.type()
690 <        inp_sandbox = jbt.inputSandbox(nj)
691 <        out_sandbox = jbt.outputSandbox(nj)
692 <        inp_storage_subdir = ''
688 >        #TaskName  
689 >        dir = string.split(common.work_space.topDir(), '/')
690 >        taskName = dir[len(dir)-2]
691 >
692 >        xml.write(str(title))
693 >        #xml.write('<task name="' +str(taskName)+'" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache">\n')
694 >
695 >        #xml.write('<task name="' +str(taskName)+ '" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache"' + '" task_info="' + os.path.expandvars('X509_USER_PROXY') + '">\n')
696 >        x509_cmd = 'ls /tmp/x509up_u`id -u`'
697 >        x509=runCommand(x509_cmd).strip()
698 >        xml.write('<task name="' +str(taskName)+ '" sub_path="' +common.work_space.pathForTgz() + 'share/.boss_cache"' + ' task_info="' + str(x509) + '">\n')
699 >        xml.write(jt_string)
700          
701 <        title = '# This JDL was generated by '+\
702 <                common.prog_name+' (version '+common.prog_version_str+')\n'
703 <        jt_string = ''
704 <
701 >        if (to_write != ''):
702 >            xml.write('<extraTags\n')
703 >            xml.write(to_write)
704 >            xml.write('/>\n')
705 >            pass
706  
707 +        xml.write('<iterator>\n')
708 +        xml.write('\t<iteratorRule name="ITR1">\n')
709 +        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ' </ruleElement>\n')
710 +        xml.write('\t</iteratorRule>\n')
711 +        xml.write('\t<iteratorRule name="ITR2">\n')
712 +        for arg in argsList:
713 +            xml.write('\t\t<ruleElement> <![CDATA[\n'+ arg + '\n\t\t]]> </ruleElement>\n')
714 +            pass
715 +        xml.write('\t</iteratorRule>\n')
716 +        #print jobList
717 +        xml.write('\t<iteratorRule name="ITR3">\n')
718 +        xml.write('\t\t<ruleElement> 1:'+ str(nj) + ':1:6 </ruleElement>\n')
719 +        xml.write('\t</iteratorRule>\n')
720 +
721 +        '''
722 +        indy: here itr4
723 +        '''
724          
725 <        SPL = inp_storage_subdir
726 <        if ( SPL and SPL[-1] != '/' ) : SPL = SPL + '/'
725 >        xml.write('<chain name="' +str(taskName)+'__ITR1_" scheduler="'+str(self.schedulerName)+'">\n')
726 >       # xml.write('<chain scheduler="'+str(self.schedulerName)+'">\n')
727 >        xml.write(jt_string)
728  
729 <        jdl_fname = job.jdlFilename()
720 <        jdl = open(jdl_fname, 'w')
721 <        jdl.write(title)
729 >        #executable
730  
731 +        """
732 +        INDY
733 +        script depends on jobType: it should be probably get in a different way
734 +        """        
735          script = job.scriptFilename()
736 <        jdl.write('Executable = "' + os.path.basename(script) +'";\n')
737 <        jdl.write(jt_string)
738 <
739 <        ### only one .sh  JDL has arguments:
740 <
741 <        ### Fabio
742 <        jdl.write('Arguments = "' + str(nj+1)+' '+ jbt.getJobTypeArguments(nj, "EDG") +'";\n')
731 <        inp_box = 'InputSandbox = { '
732 <        inp_box = inp_box + '"' + script + '",'
736 >        xml.write('<program>\n')
737 >        xml.write('<exec> ' + os.path.basename(script) +' </exec>\n')
738 >        xml.write(jt_string)
739 >
740 >        xml.write('<args> <![CDATA[\n _ITR2_ \n]]> </args>\n')
741 >        xml.write('<program_types> crabjob </program_types>\n')
742 >        inp_box = common.work_space.pathForTgz() + 'job/' + jbt.scriptName + ','
743  
744          if inp_sandbox != None:
745              for fl in inp_sandbox:
746 <                inp_box = inp_box + ' "' + fl + '",'
746 >                inp_box = inp_box + '' + fl + ','
747                  pass
748              pass
749  
750 <        #if common.use_jam:
751 <        #   inp_box = inp_box+' "'+common.bin_dir+'/'+common.run_jam+'",'
752 <
753 <        # Marco (VERY TEMPORARY ML STUFF)
754 <        inp_box = inp_box+' "' + os.path.abspath(os.environ['CRABDIR']+'/python/'+'report.py') + '", "' +\
755 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'DashboardAPI.py') + '", "'+\
746 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'Logger.py') + '", "'+\
747 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'ProcInfo.py') + '", "'+\
748 <                  os.path.abspath(os.environ['CRABDIR']+'/python/'+'apmon.py') + '"'
749 <        # End Marco
750 <
751 <        if (not jbt.additional_inbox_files == []):
752 <            inp_box = inp_box + ', '
753 <            for addFile in jbt.additional_inbox_files:
754 <                addFile = os.path.abspath(addFile)
755 <                inp_box = inp_box+' "'+addFile+'",'
756 <                pass
750 > #        if (not jbt.additional_inbox_files == []):
751 > #            inp_box = inp_box + ','
752 > #            for addFile in jbt.additional_inbox_files:
753 > #                #addFile = os.path.abspath(addFile)
754 > #                inp_box = inp_box+''+addFile+','
755 > #                pass
756  
757          if inp_box[-1] == ',' : inp_box = inp_box[:-1]
758 <        inp_box = inp_box + ' };\n'
759 <        jdl.write(inp_box)
761 <
762 <        jdl.write('StdOutput     = "' + job.stdout() + '";\n')
763 <        jdl.write('StdError      = "' + job.stderr() + '";\n')
758 >        inp_box = '<infiles> <![CDATA[\n' + inp_box + '\n]]> </infiles>\n'
759 >        xml.write(inp_box)
760          
761 +        base = jbt.name()
762 +        stdout = base + '__ITR3_.stdout'
763 +        stderr = base + '__ITR3_.stderr'
764 +        
765 +        xml.write('<stderr> ' + stderr + '</stderr>\n')
766 +        xml.write('<stdout> ' + stdout + '</stdout>\n')
767          
766        if job.stdout() == job.stderr():
767          out_box = 'OutputSandbox = { "' + \
768                    job.stdout() + '", ".BrokerInfo",'
769        else:
770          out_box = 'OutputSandbox = { "' + \
771                    job.stdout() + '", "' + \
772                    job.stderr() + '", ".BrokerInfo",'
768  
769 +        out_box = stdout + ',' + \
770 +                  stderr + ',.BrokerInfo,'
771 +
772 +        """
773          if int(self.return_data) == 1:
774              if out_sandbox != None:
775                  for fl in out_sandbox:
776 <                    out_box = out_box + ' "' + fl + '",'
776 >                    out_box = out_box + '' + fl + ','
777                      pass
778                  pass
779              pass
780 <                                                                                                                                                            
782 <        if out_box[-1] == ',' : out_box = out_box[:-1]
783 <        out_box = out_box + ' };'
784 <        jdl.write(out_box+'\n')
780 >        """
781  
782 +        """
783 +        INDY
784 +        something similar should be also done for infiles (if it makes sense!)
785 +        """
786 +        # Stuff to be returned _always_ via sandbox
787 +        for fl in jbt.output_file_sandbox:
788 +            out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ','
789 +            pass
790 +        pass
791  
792 <        req='Requirements = '
793 <        noreq=req
794 <        req = req + jbt.getRequirements()
795 <        #### and USER REQUIREMENT
791 <        if self.EDG_requirements:
792 <            if (req != noreq):
793 <                req = req +  ' && '
794 <            req = req + self.EDG_requirements
795 <        #### FEDE #####
796 <        if self.EDG_ce_white_list:
797 <            ce_white_list = string.split(self.EDG_ce_white_list,',')
798 <            #print "req = ", req
799 <            for i in range(len(ce_white_list)):
800 <                if i == 0:
801 <                    if (req != noreq):
802 <                        req = req +  ' && '
803 <                    req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
804 <                    pass
805 <                else:
806 <                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
807 <            req = req + ')'
808 <        
809 <        if self.EDG_ce_black_list:
810 <            ce_black_list = string.split(self.EDG_ce_black_list,',')
811 <            for ce in ce_black_list:
812 <                if (req != noreq):
813 <                    req = req +  ' && '
814 <                req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
792 >        # via sandbox iif required return_data
793 >        if int(self.return_data) == 1:
794 >            for fl in jbt.output_file:
795 >                out_box = out_box + '' + jbt.numberFile_(fl, '_ITR1_') + ','
796                  pass
797 +            pass
798  
799 <        ###############
800 <        clockTime=480
801 <        if self.EDG_clock_time:
802 <            clockTime= self.EDG_clock_time
803 <        if (req != noreq):
822 <            req = req + ' && '
823 <        req = req + '((other.GlueCEPolicyMaxWallClockTime == 0) || (other.GlueCEPolicyMaxWallClockTime>='+str(clockTime)+'))'
799 >        if out_box[-1] == ',' : out_box = out_box[:-1]
800 >        out_box = '<outfiles> <![CDATA[\n' + out_box + '\n]]></outfiles>\n'
801 >        xml.write(out_box)
802 >
803 >        xml.write('<BossAttr> crabjob.INTERNAL_ID=_ITR1_ </BossAttr>\n')
804  
805 <        cpuTime=1000
806 <        if self.EDG_cpu_time:
827 <            cpuTime=self.EDG_cpu_time
828 <        if (req != noreq):
829 <            req = req + ' && '
830 <        req = req + '((other.GlueCEPolicyMaxCPUTime == 0) || (other.GlueCEPolicyMaxCPUTime>='+str(cpuTime)+'))'
831 <
832 <        if (req != noreq):
833 <            req = req + ';\n'
834 <            jdl.write(req)
835 <                                                                                                                                                            
836 <        jdl.write('VirtualOrganisation = "' + self.VO + '";\n')
805 >        xml.write('</program>\n')
806 >        xml.write('</chain>\n')
807  
808 <        if ( self.EDG_retry_count ):              
809 <            jdl.write('RetryCount = '+self.EDG_retry_count+';\n')
840 <            pass
808 >        xml.write('</iterator>\n')
809 >        xml.write('</task>\n')
810  
811 <        jdl.write('MyProxyServer = "' + self.proxyServer + '";\n')
811 >        xml.close()
812 >      
813  
844        jdl.close()
814          return
815  
816      def checkProxy(self):
# Line 849 | Line 818 | class SchedulerEdg(Scheduler):
818          Function to check the Globus proxy.
819          """
820          if (self.proxyValid): return
821 <        timeleft = -999
821 >
822 >        ### Just return if asked to do so
823 >        if (self.dontCheckProxy==1):
824 >            self.proxyValid=1
825 >            return
826 >
827          minTimeLeft=10*3600 # in seconds
828  
829          minTimeLeftServer = 100 # in hours
830  
857        #cmd = 'voms-proxy-info -exists -valid '+str(minTimeLeft)+':00'
858        #cmd = 'voms-proxy-info -timeleft'
831          mustRenew = 0
832          timeLeftLocal = runCommand('voms-proxy-info -timeleft 2>/dev/null')
833          timeLeftServer = -999
# Line 871 | Line 843 | class SchedulerEdg(Scheduler):
843          pass
844  
845          if mustRenew:
846 <            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")
847 <            cmd = 'voms-proxy-init -voms cms -valid 96:00'
846 >            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")
847 >            cmd = 'voms-proxy-init -voms '+self.VO
848 >            if self.group:
849 >                cmd += ':/'+self.VO+'/'+self.group
850 >            if self.role:
851 >                cmd += '/role='+self.role
852 >            cmd += ' -valid 192:00'
853              try:
854                  # SL as above: damn it!
855 +                common.logger.debug(10,cmd)
856                  out = os.system(cmd)
857                  if (out>0): raise CrabException("Unable to create a valid proxy!\n")
858              except:
859                  msg = "Unable to create a valid proxy!\n"
860                  raise CrabException(msg)
883            # cmd = 'grid-proxy-info -timeleft'
884            # cmd_out = runCommand(cmd,0,20)
861              pass
862  
863          ## now I do have a voms proxy valid, and I check the myproxy server
# Line 892 | Line 868 | class SchedulerEdg(Scheduler):
868              common.logger.message('No credential delegated to myproxy server '+self.proxyServer+' will do now')
869              renewProxy = 1
870          else:
871 <            # if myproxy exist but not long enough, renew
872 <            reTime = re.compile( r'timeleft: (\d+)' )
873 <            #print "<"+str(reTime.search( cmd_out ).group(1))+">"
874 <            if reTime.match( cmd_out ):
875 <                time = reTime.search( line ).group(1)
876 <                if time < minTimeLeftServer:
877 <                    renewProxy = 1
878 <                    common.logger.message('No credential delegation will expire in '+time+' hours: renew it')
871 >            ## minimum time: 5 days
872 >            minTime = 4 * 24 * 3600
873 >            ## regex to extract the right information
874 >            myproxyRE = re.compile("timeleft: (?P<hours>[\\d]*):(?P<minutes>[\\d]*):(?P<seconds>[\\d]*)")
875 >            for row in cmd_out.split("\n"):
876 >                g = myproxyRE.search(row)
877 >                if g:
878 >                    hours = g.group("hours")
879 >                    minutes = g.group("minutes")
880 >                    seconds = g.group("seconds")
881 >                    timeleft = int(hours)*3600 + int(minutes)*60 + int(seconds)
882 >                    if timeleft < minTime:
883 >                        renewProxy = 1
884 >                        common.logger.message('Your proxy will expire in:\n\t'+hours+' hours '+minutes+' minutes '+seconds+' seconds\n')
885 >                        common.logger.message('Need to renew it:')
886 >                    pass
887                  pass
888              pass
889          
# Line 922 | Line 906 | class SchedulerEdg(Scheduler):
906          if self.edg_config_vo:
907              edg_ui_cfg_opt += ' --config-vo ' + self.edg_config_vo + ' '
908          return edg_ui_cfg_opt
909 +
910 +    def submitTout(self, list):
911 +        return 120
912 +
913 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines