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.2 by spiga, Fri Oct 6 16:29:12 2006 UTC vs.
Revision 1.28 by ewv, Wed Nov 14 16:35:21 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
9  
10   class SchedulerGlite(SchedulerEdg):
11      def __init__(self):
12 <            SchedulerEdg.__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 18 | 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 27 | 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:
40 <                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:
60 <                    req = req +  ' && (!RegExp("' + ce + '", other.GlueCEUniqueId))'
61 <                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
65 <            else:
66 <                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:
72 <                req = req + ' && other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
73 <                
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 <            if (itr4 != []):
101 <                req1=[]  
102 <                j = 0
103 <                concString = '||'
104 <                for arg in itr4:
105 <                    print "ITR: ", arg
106 <                    #############
107 <                    # MC Changed matching syntax to avoid gang matching
108 <                    #############
109 <                    req1.append(' Member("'+arg+'" , other.GlueCESEBindGroupSEUniqueID) ')
110 <            param_file.write('Requirements = ' + req + " && (" + concString.join(req1) + ');\n')  
111 <  
112 <            if (self.edg_config and self.edg_config_vo != ''):
113 <                param_file.write('RBconfig = "'+self.edg_config+'";\n')  
93 <                param_file.write('RBconfigVO = "'+self.edg_config_vo+'";')
100 >            reqSites=''
101 >            reqtmp=[]
102 >            concString = '||'
103 >
104 >            #############
105 >            # MC Changed matching syntax to avoid gang matching
106 >            #############
107 >            for arg in itr4:
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.close()  
115 >            param_file.write('Requirements = ' + req + reqSites )
116 >
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  
126      def wsSetupEnvironment(self):
127          """
# Line 115 | Line 144 | class SchedulerGlite(SchedulerEdg):
144          txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
145          txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
146  
147 <        txt += 'echo "middleware discovery " \n'
147 >        txt += 'echo "middleware discovery: " \n'
148          txt += 'if [ $VO_CMS_SW_DIR ]; then \n'
149          txt += '    middleware=LCG \n'
150          txt += '    echo "SyncCE=`glite-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
151          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
152 <        txt += '    echo "middleware =$middleware" \n'
124 <        txt += 'elif [ $GRID3_APP_DIR ]; then\n'
125 <        txt += '    middleware=OSG \n'
126 <        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
127 <        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
128 <        txt += '    echo "middleware =$middleware" \n'
152 >        txt += '    echo ">>> middleware =$middleware" \n'
153          txt += 'elif [ $OSG_APP ]; then \n'
154          txt += '    middleware=OSG \n'
155 <        txt += '    echo "SyncCE=`echo $EDG_WL_LOG_DESTINATION`" | tee -a $RUNTIME_AREA/$repo \n'
155 >        txt += '    if [ $OSG_JOB_CONTACT ]; then \n'
156 >        txt += '        SyncCE="$OSG_JOB_CONTACT"; \n'
157 >        txt += '        echo "SyncCE=$SyncCE" | tee -a $RUNTIME_AREA/$repo ;\n'
158 >        txt += '    else\n'
159 >        txt += '        echo "not reporting SyncCE";\n'
160 >        txt += '    fi\n';
161          txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
162 <        txt += '    echo "middleware =$middleware" \n'
162 >        txt += '    echo ">>> middleware =$middleware" \n'
163          txt += 'else \n'
164          txt += '    echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
165          txt += '    echo "JOB_EXIT_STATUS = 10030" \n'
166          txt += '    echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n'
167          txt += '    dumpStatus $RUNTIME_AREA/$repo \n'
139        txt += '    rm -f $RUNTIME_AREA/$repo \n'
140        txt += '    echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
141        txt += '    echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
168          txt += '    exit 1 \n'
169          txt += 'fi \n'
170  
145        txt += '# report first time to DashBoard \n'
171          txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
172 <        txt += 'rm -f $RUNTIME_AREA/$repo \n'
173 <        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
174 <        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
175 <        
172 >        #txt += 'rm -f $RUNTIME_AREA/$repo \n'
173 >        #txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
174 >        #txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
175 >
176          txt += '\n\n'
177  
178 <        if int(self.copy_data) == 1:
179 <           if self.SE:
180 <              txt += 'export SE='+self.SE+'\n'
181 <              txt += 'echo "SE = $SE"\n'
182 <           if self.SE_PATH:
183 <              if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
184 <              txt += 'export SE_PATH='+self.SE_PATH+'\n'
185 <              txt += 'echo "SE_PATH = $SE_PATH"\n'
178 >        #if int(self.copy_data) == 1:
179 >        #   if self.SE:
180 >        #      txt += 'export SE='+self.SE+'\n'
181 >        #      txt += 'echo "SE = $SE"\n'
182 >        #   if self.SE_PATH:
183 >        #      if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
184 >        #      txt += 'export SE_PATH='+self.SE_PATH+'\n'
185 >        #      txt += 'echo "SE_PATH = $SE_PATH"\n'
186  
187          txt += 'export VO='+self.VO+'\n'
188 <        ### some line for LFC catalog setting
189 <        txt += 'if [ $middleware == LCG ]; then \n'
190 <        txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
191 <        txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
192 <        txt += '    fi\n'
193 <        txt += '    if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
194 <        txt += '        export LFC_HOST='+self.lfc_host+'\n'
195 <        txt += '    fi\n'
196 <        txt += '    if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
197 <        txt += '        export LFC_HOME='+self.lfc_home+'\n'
198 <        txt += '    fi\n'
199 <        txt += 'elif [ $middleware == OSG ]; then\n'
200 <        txt += '    echo "LFC catalog setting to be implemented for OSG"\n'
201 <        txt += 'fi\n'
188 >        ### some line for LFC catalog setting
189 >        #txt += 'if [ $middleware == LCG ]; then \n'
190 >        #txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
191 >        #txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
192 >        #txt += '    fi\n'
193 >        #txt += '    if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
194 >        #txt += '        export LFC_HOST='+self.lfc_host+'\n'
195 >        #txt += '    fi\n'
196 >        #txt += '    if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
197 >        #txt += '        export LFC_HOME='+self.lfc_home+'\n'
198 >        #txt += '    fi\n'
199 >        #txt += 'elif [ $middleware == OSG ]; then\n'
200 >        #txt += '    echo "LFC catalog setting to be implemented for OSG"\n'
201 >        #txt += 'fi\n'
202          #####
203 <        if int(self.register_data) == 1:
204 <           txt += 'if [ $middleware == LCG ]; then \n'
205 <           txt += '    export LFN='+self.LFN+'\n'
206 <           txt += '    lfc-ls $LFN\n'
207 <           txt += '    result=$?\n'
208 <           txt += '    echo $result\n'
209 <           ### creation of LFN dir in LFC catalog, under /grid/cms dir  
210 <           txt += '    if [ $result != 0 ]; then\n'
211 <           txt += '       lfc-mkdir $LFN\n'
212 <           txt += '       result=$?\n'
213 <           txt += '       echo $result\n'
214 <           txt += '    fi\n'
215 <           txt += 'elif [ $middleware == OSG ]; then\n'
216 <           txt += '    echo " Files registration to be implemented for OSG"\n'
217 <           txt += 'fi\n'
218 <           txt += '\n'
219 <
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'
201 <              txt += '\n'
203 >        #if int(self.register_data) == 1:
204 >        #   txt += 'if [ $middleware == LCG ]; then \n'
205 >        #   txt += '    export LFN='+self.LFN+'\n'
206 >        #   txt += '    lfc-ls $LFN\n'
207 >        #   txt += '    result=$?\n'
208 >        #   txt += '    echo $result\n'
209 >        #   ### creation of LFN dir in LFC catalog, under /grid/cms dir
210 >        #   txt += '    if [ $result != 0 ]; then\n'
211 >        #   txt += '       lfc-mkdir $LFN\n'
212 >        #   txt += '       result=$?\n'
213 >        #   txt += '       echo $result\n'
214 >        #   txt += '    fi\n'
215 >        #   txt += 'elif [ $middleware == OSG ]; then\n'
216 >        #   txt += '    echo " Files registration to be implemented for OSG"\n'
217 >        #   txt += 'fi\n'
218 >        #   txt += '\n'
219 >        #   if self.VO:
220 >        #      txt += 'export VO='+self.VO+'\n'
221 >        #   if self.LFN:
222 >        #      txt += 'if [ $middleware == LCG ]; then \n'
223 >        #      txt += '    export LFN='+self.LFN+'\n'
224 >        #      txt += 'fi\n'
225 >        #      txt += '\n'
226  
227 <        txt += 'if [ $middleware == LCG ]; then\n'
227 >        txt += 'if [ $middleware == LCG ]; then\n'
228          txt += '    CloseCEs=`glite-brokerinfo getCE`\n'
229          txt += '    echo "CloseCEs = $CloseCEs"\n'
230          txt += '    CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
# Line 213 | Line 237 | class SchedulerGlite(SchedulerEdg):
237          txt += '        echo "JOB_EXIT_STATUS = 10099" \n'
238          txt += '        echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n'
239          txt += '        dumpStatus $RUNTIME_AREA/$repo \n'
240 <        txt += '        rm -f $RUNTIME_AREA/$repo \n'
241 <        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
242 <        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
240 >        #txt += '        rm -f $RUNTIME_AREA/$repo \n'
241 >        #txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
242 >        #txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
243          txt += '        exit 1 \n'
244          txt += '    fi \n'
245 <        txt += 'fi \n'
245 >        txt += 'fi \n'
246  
247          return txt
248 <        
248 >
249      def loggingInfo(self, id):
250          """
251          retrieve the logging info from logging and bookkeeping and return it
252          """
253          self.checkProxy()
254 <        cmd = 'glite-job-logging-info -v 2 ' + id
254 >        cmd = 'glite-job-logging-info -v 3 ' + id
255          cmd_out = runCommand(cmd)
256          return cmd_out
257  
# Line 238 | Line 262 | class SchedulerGlite(SchedulerEdg):
262          return cmd_out
263  
264      def findSites_(self, n):
265 <        itr4 =[]
265 >        itr4 = []
266          sites = common.jobDB.destination(n)
267 <        if len(sites)>0 and sites[0]=="Any":
267 >        if len(sites)>0 and sites[0]=="":
268              return itr4
269 <        if sites != [""]:
270 <            return sites
269 >        if sites != [""]:
270 >            ##Addedd Daniele
271 >            replicas = self.blackWhiteListParser.checkBlackList(sites,n)
272 >            if len(replicas)!=0:
273 >                replicas = self.blackWhiteListParser.checkWhiteList(replicas,n)
274 >
275 >            #if len(replicas)==0:
276 >                #msg = 'No sites remaining that host any part of the requested data! Exiting... '
277 >                #raise CrabException(msg)
278 >            itr4 = replicas
279 >            #####
280 >        return itr4
281 >
282 >    def tOut(self, list):
283 >        return 180

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines