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

Comparing COMP/CRAB/python/SchedulerGlite.py (file contents):
Revision 1.3 by slacapra, Mon Oct 9 15:30:41 2006 UTC vs.
Revision 1.21 by fanzago, Fri Oct 5 12:55:05 2007 UTC

# Line 1 | Line 1
1 #from Scheduler import Scheduler
1   from SchedulerEdg import SchedulerEdg
2   from crab_logger import Logger
3   from crab_exceptions import *
4   from crab_util import *
5 < from EdgConfig import *
5 > from GliteConfig import *
6   import common
7  
8   import os, sys, time
# Line 12 | Line 11 | class SchedulerGlite(SchedulerEdg):
11      def __init__(self):
12          SchedulerEdg.__init__(self)
13  
14 +    def rb_configure(self, RB):
15 +        self.glite_config = ''
16 +        self.rb_param_file = ''
17 +
18 +        gliteConfig = GliteConfig(RB)
19 +        self.glite_config = gliteConfig.config()
20 +
21 +        if (self.glite_config != ''):
22 +            self.rb_param_file = 'WMSconfig = '+self.glite_config+';\n'
23 +            #print "rb_param_file = ", self.rb_param_file
24 +        return self.rb_param_file
25 +
26      def sched_parameter(self):
27          """
28          Returns file with requirements and scheduler-specific parameters
# Line 33 | Line 44 | class SchedulerGlite(SchedulerEdg):
44    
45          req = ''
46          req = req + jbt.getRequirements()
47 <    
47 >  
48 >  
49          if self.EDG_requirements:
50 <            if (req == ' '):
51 <                req = req + self.EDG_requirements
52 <            else:
41 <                req = req +  ' && ' + self.EDG_requirements
50 >            if (not req == ' '): req = req +  ' && '
51 >            req = req + self.EDG_requirements
52 >
53          if self.EDG_ce_white_list:
54              ce_white_list = string.split(self.EDG_ce_white_list,',')
55 <            for i in range(len(ce_white_list)):
56 <                if i == 0:
57 <                    if (req == ' '):
58 <                        req = req + '((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
59 <                    else:
60 <                        req = req +  ' && ((RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
61 <                    pass
62 <                else:
63 <                    req = req +  ' || (RegExp("' + ce_white_list[i] + '", other.GlueCEUniqueId))'
64 <            req = req + ')'
55 >            tmpCe=[]
56 >            concString = '&&'
57 >            for ce in ce_white_list:
58 >                tmpCe.append('RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId)')
59 >            ### MATTY' FIX: if more then one CE: && -> ||
60 >            #print "list CE: " + str(tmpCe)
61 >            if len(tmpCe) == 1:
62 >                req +=  " && (" + concString.join(tmpCe) + ") "
63 >            elif len(tmpCe) > 1:
64 >                firstCE = 0
65 >                for reqTemp in tmpCe:
66 >                    #print reqTemp
67 >                    if firstCE == 0:
68 >                        #print "adding: "+str(" && ( (" + reqTemp + ") ")
69 >                        req += " && ( (" + reqTemp + ") "
70 >                        firstCE = 1
71 >                    elif firstCE > 0:
72 >                        #print "adding: "+str(" || (" + reqTemp + ") ")
73 >                        req += " || (" + reqTemp + ") "
74 >                if firstCE > 0:
75 >                    req += ") "
76 >            ## old code
77 > #            if len(tmpCe): req = req + " && (" + concString.join(tmpCe) + ") "
78          
79          if self.EDG_ce_black_list:
80              ce_black_list = string.split(self.EDG_ce_black_list,',')
81 +            tmpCe=[]
82 +            concString = '&&'
83              for ce in ce_black_list:
84 <                if (req == ' '):
85 <                    req = req + '(!RegExp("' + ce + '", other.GlueCEUniqueId))'
86 <                else:
61 <                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
62 <                pass
84 >                tmpCe.append('(!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))')
85 >            if len(tmpCe): req = req + " && (" + concString.join(tmpCe) + ") "
86 >
87          if self.EDG_clock_time:
88 <            if (req == ' '):
89 <                req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
66 <            else:
67 <                req = req + ' && other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
88 >            if (not req == ' '): req = req + ' && '
89 >            req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
90  
91          if self.EDG_cpu_time:
92 <            if (req == ' '):
93 <                req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
72 <            else:
73 <                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
92 >            if (not req == ' '): req = req + ' && '
93 >            req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
94                  
95          for i in range(len(first)): # Add loop DS
96              self.param='sched_param_'+str(i)+'.clad'
97              param_file = open(common.work_space.shareDir()+'/'+self.param, 'w')
98  
99              itr4=self.findSites_(first[i])
100 <            req1=[]  
101 <            j = 0
100 >            reqSites=''
101 >            reqtmp=[]  
102              concString = '||'
103 +
104 +            #############
105 +            # MC Changed matching syntax to avoid gang matching
106 +            #############
107              for arg in itr4:
108 <                #############
109 <                # MC Changed matching syntax to avoid gang matching
110 <                #############
111 <                req1.append(' Member("'+arg+'" , other.GlueCESEBindGroupSEUniqueID) ')
112 <            if len(req1): req = req + " && (" + concString.join(req1) + ')'
113 <            req = req + ';\n'
114 <            param_file.write('Requirements = ' + req )
108 >                reqtmp.append(' Member("'+arg+'" , other.GlueCESEBindGroupSEUniqueID) ')
109 >
110 >            if len(reqtmp): reqSites = reqSites + " && (" + concString.join(reqtmp) + ") "
111 >
112 >            # requirement added to skip gliteCE
113 >            reqSites = reqSites + '&& (!RegExp("blah", other.GlueCEUniqueId));\n'
114 >
115 >            param_file.write('Requirements = ' + req + reqSites )
116    
117 <            if (self.edg_config and self.edg_config_vo != ''):
118 <                param_file.write('RBconfig = "'+self.edg_config+'";\n')  
119 <                param_file.write('RBconfigVO = "'+self.edg_config_vo+'";')
117 >            if (self.rb_param_file != ''):
118 >                param_file.write(self.rb_param_file)  
119 >
120 >            if len(self.EDG_addJdlParam):
121 >                for p in self.EDG_addJdlParam:
122 >                    param_file.write(p)
123  
124              param_file.close()  
125  
# Line 124 | Line 152 | class SchedulerGlite(SchedulerEdg):
152          txt += '    echo "middleware =$middleware" \n'
153          txt += 'elif [ $GRID3_APP_DIR ]; then\n'
154          txt += '    middleware=OSG \n'
155 <        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
155 >        txt += '    echo "SyncCE=`echo $GLITE_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
156          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
157          txt += '    echo "middleware =$middleware" \n'
158          txt += 'elif [ $OSG_APP ]; then \n'
159          txt += '    middleware=OSG \n'
160 <        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
160 >        txt += '    echo "SyncCE=`echo $GLITE_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
161          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
162          txt += '    echo "middleware =$middleware" \n'
163          txt += 'else \n'
# Line 151 | Line 179 | class SchedulerGlite(SchedulerEdg):
179          
180          txt += '\n\n'
181  
182 <        if int(self.copy_data) == 1:
183 <           if self.SE:
184 <              txt += 'export SE='+self.SE+'\n'
185 <              txt += 'echo "SE = $SE"\n'
186 <           if self.SE_PATH:
187 <              if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
188 <              txt += 'export SE_PATH='+self.SE_PATH+'\n'
189 <              txt += 'echo "SE_PATH = $SE_PATH"\n'
182 >        #if int(self.copy_data) == 1:
183 >        #   if self.SE:
184 >        #      txt += 'export SE='+self.SE+'\n'
185 >        #      txt += 'echo "SE = $SE"\n'
186 >        #   if self.SE_PATH:
187 >        #      if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
188 >        #      txt += 'export SE_PATH='+self.SE_PATH+'\n'
189 >        #      txt += 'echo "SE_PATH = $SE_PATH"\n'
190  
191          txt += 'export VO='+self.VO+'\n'
192          ### some line for LFC catalog setting
193 <        txt += 'if [ $middleware == LCG ]; then \n'
194 <        txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
195 <        txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
196 <        txt += '    fi\n'
197 <        txt += '    if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
198 <        txt += '        export LFC_HOST='+self.lfc_host+'\n'
199 <        txt += '    fi\n'
200 <        txt += '    if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
201 <        txt += '        export LFC_HOME='+self.lfc_home+'\n'
202 <        txt += '    fi\n'
203 <        txt += 'elif [ $middleware == OSG ]; then\n'
204 <        txt += '    echo "LFC catalog setting to be implemented for OSG"\n'
205 <        txt += 'fi\n'
193 >        #txt += 'if [ $middleware == LCG ]; then \n'
194 >        #txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
195 >        #txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
196 >        #txt += '    fi\n'
197 >        #txt += '    if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
198 >        #txt += '        export LFC_HOST='+self.lfc_host+'\n'
199 >        #txt += '    fi\n'
200 >        #txt += '    if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
201 >        #txt += '        export LFC_HOME='+self.lfc_home+'\n'
202 >        #txt += '    fi\n'
203 >        #txt += 'elif [ $middleware == OSG ]; then\n'
204 >        #txt += '    echo "LFC catalog setting to be implemented for OSG"\n'
205 >        #txt += 'fi\n'
206          #####
207 <        if int(self.register_data) == 1:
208 <           txt += 'if [ $middleware == LCG ]; then \n'
209 <           txt += '    export LFN='+self.LFN+'\n'
210 <           txt += '    lfc-ls $LFN\n'
211 <           txt += '    result=$?\n'
212 <           txt += '    echo $result\n'
213 <           ### creation of LFN dir in LFC catalog, under /grid/cms dir  
214 <           txt += '    if [ $result != 0 ]; then\n'
215 <           txt += '       lfc-mkdir $LFN\n'
216 <           txt += '       result=$?\n'
217 <           txt += '       echo $result\n'
218 <           txt += '    fi\n'
219 <           txt += 'elif [ $middleware == OSG ]; then\n'
220 <           txt += '    echo " Files registration to be implemented for OSG"\n'
221 <           txt += 'fi\n'
222 <           txt += '\n'
223 <
224 <           if self.VO:
225 <              txt += 'export VO='+self.VO+'\n'
226 <           if self.LFN:
227 <              txt += 'if [ $middleware == LCG ]; then \n'
228 <              txt += '    export LFN='+self.LFN+'\n'
229 <              txt += 'fi\n'
202 <              txt += '\n'
207 >        #if int(self.register_data) == 1:
208 >        #   txt += 'if [ $middleware == LCG ]; then \n'
209 >        #   txt += '    export LFN='+self.LFN+'\n'
210 >        #   txt += '    lfc-ls $LFN\n'
211 >        #   txt += '    result=$?\n'
212 >        #   txt += '    echo $result\n'
213 >        #   ### creation of LFN dir in LFC catalog, under /grid/cms dir  
214 >        #   txt += '    if [ $result != 0 ]; then\n'
215 >        #   txt += '       lfc-mkdir $LFN\n'
216 >        #   txt += '       result=$?\n'
217 >        #   txt += '       echo $result\n'
218 >        #   txt += '    fi\n'
219 >        #   txt += 'elif [ $middleware == OSG ]; then\n'
220 >        #   txt += '    echo " Files registration to be implemented for OSG"\n'
221 >        #   txt += 'fi\n'
222 >        #   txt += '\n'
223 >        #   if self.VO:
224 >        #      txt += 'export VO='+self.VO+'\n'
225 >        #   if self.LFN:
226 >        #      txt += 'if [ $middleware == LCG ]; then \n'
227 >        #      txt += '    export LFN='+self.LFN+'\n'
228 >        #      txt += 'fi\n'
229 >        #      txt += '\n'
230  
231          txt += 'if [ $middleware == LCG ]; then\n'
232          txt += '    CloseCEs=`glite-brokerinfo getCE`\n'
# Line 228 | Line 255 | class SchedulerGlite(SchedulerEdg):
255          retrieve the logging info from logging and bookkeeping and return it
256          """
257          self.checkProxy()
258 <        cmd = 'glite-job-logging-info -v 2 ' + id
258 >        cmd = 'glite-job-logging-info -v 3 ' + id
259          cmd_out = runCommand(cmd)
260          return cmd_out
261  
# Line 239 | Line 266 | class SchedulerGlite(SchedulerEdg):
266          return cmd_out
267  
268      def findSites_(self, n):
269 +        itr4 = []
270          sites = common.jobDB.destination(n)
271          if len(sites)>0 and sites[0]=="":
272 <            return []
273 <        return sites
272 >            return itr4
273 >        if sites != [""]:
274 >            ##Addedd Daniele
275 >            replicas = self.blackWhiteListParser.checkBlackList(sites,n)
276 >            if len(replicas)!=0:
277 >                replicas = self.blackWhiteListParser.checkWhiteList(replicas,n)
278 >              
279 >            if len(replicas)==0:
280 >                msg = 'No sites remaining that host any part of the requested data! Exiting... '
281 >                raise CrabException(msg)
282 >            itr4 = replicas
283 >            #####        
284 >        return itr4
285 >
286 >    def submitTout(self, list):
287 >        return 180

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines