ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/SchedulerEdg.py
(Generate patch)

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines