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.30 by slacapra, Thu Jan 10 16:36:06 2008 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 >                if self.EDG_addJdlParam[-1] == '': self.EDG_addJdlParam= self.EDG_addJdlParam[:-1]
122 >                for p in self.EDG_addJdlParam:
123 >                    param_file.write(string.strip(p)+';\n')
124 >
125 >            param_file.close()
126  
127      def wsSetupEnvironment(self):
128          """
# Line 115 | 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'
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'
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'
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'
169          txt += '    exit 1 \n'
170          txt += 'fi \n'
171  
145        txt += '# report first time to DashBoard \n'
172          txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
173 <        txt += 'rm -f $RUNTIME_AREA/$repo \n'
148 <        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
149 <        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
150 <        
173 >
174          txt += '\n\n'
175  
153        if int(self.copy_data) == 1:
154           if self.SE:
155              txt += 'export SE='+self.SE+'\n'
156              txt += 'echo "SE = $SE"\n'
157           if self.SE_PATH:
158              if ( self.SE_PATH[-1] != '/' ) : self.SE_PATH = self.SE_PATH + '/'
159              txt += 'export SE_PATH='+self.SE_PATH+'\n'
160              txt += 'echo "SE_PATH = $SE_PATH"\n'
176  
177          txt += 'export VO='+self.VO+'\n'
163        ### some line for LFC catalog setting
164        txt += 'if [ $middleware == LCG ]; then \n'
165        txt += '    if [[ $LCG_CATALOG_TYPE != \''+self.lcg_catalog_type+'\' ]]; then\n'
166        txt += '        export LCG_CATALOG_TYPE='+self.lcg_catalog_type+'\n'
167        txt += '    fi\n'
168        txt += '    if [[ $LFC_HOST != \''+self.lfc_host+'\' ]]; then\n'
169        txt += '        export LFC_HOST='+self.lfc_host+'\n'
170        txt += '    fi\n'
171        txt += '    if [[ $LFC_HOME != \''+self.lfc_home+'\' ]]; then\n'
172        txt += '        export LFC_HOME='+self.lfc_home+'\n'
173        txt += '    fi\n'
174        txt += 'elif [ $middleware == OSG ]; then\n'
175        txt += '    echo "LFC catalog setting to be implemented for OSG"\n'
176        txt += 'fi\n'
177        #####
178        if int(self.register_data) == 1:
179           txt += 'if [ $middleware == LCG ]; then \n'
180           txt += '    export LFN='+self.LFN+'\n'
181           txt += '    lfc-ls $LFN\n'
182           txt += '    result=$?\n'
183           txt += '    echo $result\n'
184           ### creation of LFN dir in LFC catalog, under /grid/cms dir  
185           txt += '    if [ $result != 0 ]; then\n'
186           txt += '       lfc-mkdir $LFN\n'
187           txt += '       result=$?\n'
188           txt += '       echo $result\n'
189           txt += '    fi\n'
190           txt += 'elif [ $middleware == OSG ]; then\n'
191           txt += '    echo " Files registration to be implemented for OSG"\n'
192           txt += 'fi\n'
193           txt += '\n'
194
195           if self.VO:
196              txt += 'export VO='+self.VO+'\n'
197           if self.LFN:
198              txt += 'if [ $middleware == LCG ]; then \n'
199              txt += '    export LFN='+self.LFN+'\n'
200              txt += 'fi\n'
201              txt += '\n'
178  
179 <        txt += 'if [ $middleware == LCG ]; then\n'
179 >        txt += 'if [ $middleware == LCG ]; then\n'
180          txt += '    CloseCEs=`glite-brokerinfo getCE`\n'
181          txt += '    echo "CloseCEs = $CloseCEs"\n'
182          txt += '    CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
# Line 213 | Line 189 | class SchedulerGlite(SchedulerEdg):
189          txt += '        echo "JOB_EXIT_STATUS = 10099" \n'
190          txt += '        echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n'
191          txt += '        dumpStatus $RUNTIME_AREA/$repo \n'
216        txt += '        rm -f $RUNTIME_AREA/$repo \n'
217        txt += '        echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
218        txt += '        echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
192          txt += '        exit 1 \n'
193          txt += '    fi \n'
194 <        txt += 'fi \n'
194 >        txt += 'fi \n'
195  
196          return txt
197 <        
197 >
198      def loggingInfo(self, id):
199          """
200          retrieve the logging info from logging and bookkeeping and return it
201          """
202          self.checkProxy()
203 <        cmd = 'glite-job-logging-info -v 2 ' + id
203 >        cmd = 'glite-job-logging-info -v 3 ' + id
204          cmd_out = runCommand(cmd)
205          return cmd_out
206  
# Line 238 | Line 211 | class SchedulerGlite(SchedulerEdg):
211          return cmd_out
212  
213      def findSites_(self, n):
214 <        itr4 =[]
214 >        itr4 = []
215          sites = common.jobDB.destination(n)
216 <        if len(sites)>0 and sites[0]=="Any":
216 >        if len(sites)>0 and sites[0]=="":
217              return itr4
218 <        if sites != [""]:
219 <            return sites
218 >        if sites != [""]:
219 >            ##Addedd Daniele
220 >            replicas = self.blackWhiteListParser.checkBlackList(sites,n)
221 >            if len(replicas)!=0:
222 >                replicas = self.blackWhiteListParser.checkWhiteList(replicas,n)
223 >
224 >            itr4 = replicas
225 >            #####
226 >        return itr4
227 >
228 >    def tOut(self, list):
229 >        return 180

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines