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.7 by slacapra, Tue Oct 17 09:52:57 2006 UTC vs.
Revision 1.29 by spiga, Fri Dec 7 16:50:13 2007 UTC

# Line 30 | Line 30 | class SchedulerGlite(SchedulerEdg):
30          index = int(common.jobDB.nJobs()) - 1
31          job = common.job_list[index]
32          jbt = job.type()
33 <        
33 >
34          lastDest=''
35          first = []
36          last  = []
# Line 39 | Line 39 | class SchedulerGlite(SchedulerEdg):
39              if (currDest!=lastDest):
40                  lastDest = currDest
41                  first.append(n)
42 <                if n != 0:last.append(n-1)
42 >                if n != 0:last.append(n-1)
43          if len(first)>len(last) :last.append(common.jobDB.nJobs())
44 <  
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:
52 <                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 + ')'
65 <        
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:
72 <                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
73 <                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
77 <            else:
78 <                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
94 <            else:
84 <                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
85 <                
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              reqSites=''
101 <            reqtmp=[]  
93 <            j = 0
101 >            reqtmp=[]
102              concString = '||'
103 +
104 +            #############
105 +            # MC Changed matching syntax to avoid gang matching
106 +            #############
107              for arg in itr4:
96                #############
97                # MC Changed matching syntax to avoid gang matching
98                #############
108                  reqtmp.append(' Member("'+arg+'" , other.GlueCESEBindGroupSEUniqueID) ')
109 <            if len(reqtmp): reqSites = reqSites + " && (" + concString.join(reqtmp) + ')'
110 <            reqSites = reqSites + ';\n'
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 <  
116 >
117              if (self.rb_param_file != ''):
118 <                param_file.write(self.rb_param_file)  
118 >                param_file.write(self.rb_param_file)
119  
120              if len(self.EDG_addJdlParam):
121 +                if self.EDG_addJdlParam[-1] == '': self.EDG_addJdlParam= self.EDG_addJdlParam[:-1]
122                  for p in self.EDG_addJdlParam:
123 <                    param_file.write(p)
123 >                    param_file.write(string.strip(p)+';\n')
124  
125 <            param_file.close()  
125 >            param_file.close()
126  
127      def wsSetupEnvironment(self):
128          """
# Line 131 | Line 145 | class SchedulerGlite(SchedulerEdg):
145          txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
146          txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
147  
148 <        txt += 'echo "middleware discovery " \n'
148 >        txt += 'echo "middleware discovery: " \n'
149          txt += 'if [ $VO_CMS_SW_DIR ]; then \n'
150          txt += '    middleware=LCG \n'
151          txt += '    echo "SyncCE=`glite-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
152          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
153 <        txt += '    echo "middleware =$middleware" \n'
140 <        txt += 'elif [ $GRID3_APP_DIR ]; then\n'
141 <        txt += '    middleware=OSG \n'
142 <        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
143 <        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
144 <        txt += '    echo "middleware =$middleware" \n'
153 >        txt += '    echo ">>> middleware =$middleware" \n'
154          txt += 'elif [ $OSG_APP ]; then \n'
155          txt += '    middleware=OSG \n'
156 <        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
156 >        txt += '    if [ $OSG_JOB_CONTACT ]; then \n'
157 >        txt += '        SyncCE="$OSG_JOB_CONTACT"; \n'
158 >        txt += '        echo "SyncCE=$SyncCE" | tee -a $RUNTIME_AREA/$repo ;\n'
159 >        txt += '    else\n'
160 >        txt += '        echo "not reporting SyncCE";\n'
161 >        txt += '    fi\n';
162          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
163 <        txt += '    echo "middleware =$middleware" \n'
163 >        txt += '    echo ">>> middleware =$middleware" \n'
164          txt += 'else \n'
165          txt += '    echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
166          txt += '    echo "JOB_EXIT_STATUS = 10030" \n'
167          txt += '    echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n'
168          txt += '    dumpStatus $RUNTIME_AREA/$repo \n'
155        txt += '    rm -f $RUNTIME_AREA/$repo \n'
156        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
157        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
169          txt += '    exit 1 \n'
170          txt += 'fi \n'
171  
161        txt += '# report first time to DashBoard \n'
172          txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
173 <        txt += 'rm -f $RUNTIME_AREA/$repo \n'
174 <        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
175 <        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
176 <        
173 >        #txt += 'rm -f $RUNTIME_AREA/$repo \n'
174 >        #txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
175 >        #txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
176 >
177          txt += '\n\n'
178  
179 <        if int(self.copy_data) == 1:
180 <           if self.SE:
181 <              txt += 'export SE='+self.SE+'\n'
182 <              txt += 'echo "SE = $SE"\n'
183 <           if self.SE_PATH:
184 <              if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
185 <              txt += 'export SE_PATH='+self.SE_PATH+'\n'
186 <              txt += 'echo "SE_PATH = $SE_PATH"\n'
179 >        #if int(self.copy_data) == 1:
180 >        #   if self.SE:
181 >        #      txt += 'export SE='+self.SE+'\n'
182 >        #      txt += 'echo "SE = $SE"\n'
183 >        #   if self.SE_PATH:
184 >        #      if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
185 >        #      txt += 'export SE_PATH='+self.SE_PATH+'\n'
186 >        #      txt += 'echo "SE_PATH = $SE_PATH"\n'
187  
188          txt += 'export VO='+self.VO+'\n'
189 <        ### some line for LFC catalog setting
190 <        txt += 'if [ $middleware == LCG ]; then \n'
191 <        txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
192 <        txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
193 <        txt += '    fi\n'
194 <        txt += '    if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
195 <        txt += '        export LFC_HOST='+self.lfc_host+'\n'
196 <        txt += '    fi\n'
197 <        txt += '    if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
198 <        txt += '        export LFC_HOME='+self.lfc_home+'\n'
199 <        txt += '    fi\n'
200 <        txt += 'elif [ $middleware == OSG ]; then\n'
201 <        txt += '    echo "LFC catalog setting to be implemented for OSG"\n'
202 <        txt += 'fi\n'
189 >        ### some line for LFC catalog setting
190 >        #txt += 'if [ $middleware == LCG ]; then \n'
191 >        #txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
192 >        #txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
193 >        #txt += '    fi\n'
194 >        #txt += '    if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
195 >        #txt += '        export LFC_HOST='+self.lfc_host+'\n'
196 >        #txt += '    fi\n'
197 >        #txt += '    if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
198 >        #txt += '        export LFC_HOME='+self.lfc_home+'\n'
199 >        #txt += '    fi\n'
200 >        #txt += 'elif [ $middleware == OSG ]; then\n'
201 >        #txt += '    echo "LFC catalog setting to be implemented for OSG"\n'
202 >        #txt += 'fi\n'
203          #####
204 <        if int(self.register_data) == 1:
205 <           txt += 'if [ $middleware == LCG ]; then \n'
206 <           txt += '    export LFN='+self.LFN+'\n'
207 <           txt += '    lfc-ls $LFN\n'
208 <           txt += '    result=$?\n'
209 <           txt += '    echo $result\n'
210 <           ### creation of LFN dir in LFC catalog, under /grid/cms dir  
211 <           txt += '    if [ $result != 0 ]; then\n'
212 <           txt += '       lfc-mkdir $LFN\n'
213 <           txt += '       result=$?\n'
214 <           txt += '       echo $result\n'
215 <           txt += '    fi\n'
216 <           txt += 'elif [ $middleware == OSG ]; then\n'
217 <           txt += '    echo " Files registration to be implemented for OSG"\n'
218 <           txt += 'fi\n'
219 <           txt += '\n'
220 <
221 <           if self.VO:
222 <              txt += 'export VO='+self.VO+'\n'
223 <           if self.LFN:
224 <              txt += 'if [ $middleware == LCG ]; then \n'
225 <              txt += '    export LFN='+self.LFN+'\n'
226 <              txt += 'fi\n'
217 <              txt += '\n'
204 >        #if int(self.register_data) == 1:
205 >        #   txt += 'if [ $middleware == LCG ]; then \n'
206 >        #   txt += '    export LFN='+self.LFN+'\n'
207 >        #   txt += '    lfc-ls $LFN\n'
208 >        #   txt += '    result=$?\n'
209 >        #   txt += '    echo $result\n'
210 >        #   ### creation of LFN dir in LFC catalog, under /grid/cms dir
211 >        #   txt += '    if [ $result != 0 ]; then\n'
212 >        #   txt += '       lfc-mkdir $LFN\n'
213 >        #   txt += '       result=$?\n'
214 >        #   txt += '       echo $result\n'
215 >        #   txt += '    fi\n'
216 >        #   txt += 'elif [ $middleware == OSG ]; then\n'
217 >        #   txt += '    echo " Files registration to be implemented for OSG"\n'
218 >        #   txt += 'fi\n'
219 >        #   txt += '\n'
220 >        #   if self.VO:
221 >        #      txt += 'export VO='+self.VO+'\n'
222 >        #   if self.LFN:
223 >        #      txt += 'if [ $middleware == LCG ]; then \n'
224 >        #      txt += '    export LFN='+self.LFN+'\n'
225 >        #      txt += 'fi\n'
226 >        #      txt += '\n'
227  
228 <        txt += 'if [ $middleware == LCG ]; then\n'
228 >        txt += 'if [ $middleware == LCG ]; then\n'
229          txt += '    CloseCEs=`glite-brokerinfo getCE`\n'
230          txt += '    echo "CloseCEs = $CloseCEs"\n'
231          txt += '    CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
# Line 229 | Line 238 | class SchedulerGlite(SchedulerEdg):
238          txt += '        echo "JOB_EXIT_STATUS = 10099" \n'
239          txt += '        echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n'
240          txt += '        dumpStatus $RUNTIME_AREA/$repo \n'
241 <        txt += '        rm -f $RUNTIME_AREA/$repo \n'
242 <        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
243 <        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
241 >        #txt += '        rm -f $RUNTIME_AREA/$repo \n'
242 >        #txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
243 >        #txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
244          txt += '        exit 1 \n'
245          txt += '    fi \n'
246 <        txt += 'fi \n'
246 >        txt += 'fi \n'
247  
248          return txt
249 <        
249 >
250      def loggingInfo(self, id):
251          """
252          retrieve the logging info from logging and bookkeeping and return it
253          """
254          self.checkProxy()
255 <        cmd = 'glite-job-logging-info -v 2 ' + id
255 >        cmd = 'glite-job-logging-info -v 3 ' + id
256          cmd_out = runCommand(cmd)
257          return cmd_out
258  
# Line 254 | Line 263 | class SchedulerGlite(SchedulerEdg):
263          return cmd_out
264  
265      def findSites_(self, n):
266 +        itr4 = []
267          sites = common.jobDB.destination(n)
268          if len(sites)>0 and sites[0]=="":
269 <            return []
270 <        return sites
269 >            return itr4
270 >        if sites != [""]:
271 >            ##Addedd Daniele
272 >            replicas = self.blackWhiteListParser.checkBlackList(sites,n)
273 >            if len(replicas)!=0:
274 >                replicas = self.blackWhiteListParser.checkWhiteList(replicas,n)
275 >
276 >            #if len(replicas)==0:
277 >                #msg = 'No sites remaining that host any part of the requested data! Exiting... '
278 >                #raise CrabException(msg)
279 >            itr4 = replicas
280 >            #####
281 >        return itr4
282 >
283 >    def tOut(self, list):
284 >        return 180

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines