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.36 by spiga, Mon Mar 3 20:40:56 2008 UTC vs.
Revision 1.49 by ewv, Thu Apr 24 15:10:42 2008 UTC

# Line 3 | Line 3 | from crab_logger import Logger
3   from crab_exceptions import *
4   from crab_util import *
5   from GliteConfig import *
6 + import EdgLoggingInfo
7   import common
8  
9   import os, sys, time
# Line 13 | Line 14 | class SchedulerGlite(SchedulerGrid):
14  
15      def configure(self,cfg_params):
16          SchedulerGrid.configure(self, cfg_params)
17 +        self.checkProxy()
18          self.environment_unique_identifier = 'GLITE_WMS_JOBID'
19  
20      def rb_configure(self, RB):
# Line 24 | Line 26 | class SchedulerGlite(SchedulerGrid):
26          glite_config = gliteConfig.config()
27  
28          if (glite_config ):
29 <            rb_param_file = 'WMSconfig = '+glite_config+';\n'
29 >            rb_param_file = glite_config
30          return rb_param_file
31  
32      def ce_list(self):
33          """
34 <        Returns string with requirement CE related    
34 >        Returns string with requirement CE related
35          """
36 <        req = ''  
36 >        req = ''
37          if self.EDG_ce_white_list:
38              ce_white_list = self.EDG_ce_white_list
39              tmpCe=[]
# Line 62 | Line 64 | class SchedulerGlite(SchedulerGrid):
64          # requirement added to skip gliteCE
65          req += '&& (!RegExp("blah", other.GlueCEUniqueId))'
66  
67 <        return req
67 >        return req,self.EDG_ce_white_list,self.EDG_ce_black_list
68  
69 <    def se_list(self, id):
69 >    def se_list(self, id, dest):
70          """
71 <        Returns string with requirement SE related    
72 <        """  
73 <        hostList=self.findSites_(id)
71 >        Returns string with requirement SE related
72 >        """
73 >        hostList=self.findSites_(id,dest)
74          req=''
75          reqtmp=[]
76          concString = '||'
# Line 82 | Line 84 | class SchedulerGlite(SchedulerGrid):
84  
85      def jdlParam(self):
86          """
87 <        Returns
88 <        """
87 >        Returns
88 >        """
89          req=''
90          if self.EDG_addJdlParam:
91 <            if self.EDG_addJdlParam[-1] == '': self.EDG_addJdlParam= self.EDG_addJdlParam[:-1]
91 >            if self.EDG_addJdlParam[-1] == '': self.EDG_addJdlParam= self.EDG_addJdlParam[:-1]
92              for p in self.EDG_addJdlParam:
93               #   param_file.write(string.strip(p)+';\n')
94                  req+=string.strip(p)+';\n' ## BL--DS
# Line 95 | Line 97 | class SchedulerGlite(SchedulerGrid):
97      def specific_req(self):
98          """
99          Returns string with specific requirements
100 <        """
100 >        """
101          req=''
102          if self.EDG_clock_time:
103              if (not req == ' '): req = req + ' && '
# Line 104 | Line 106 | class SchedulerGlite(SchedulerGrid):
106          if self.EDG_cpu_time:
107              if (not req == ' '): req = req + ' && '
108              req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
109 <        
109 >
110          return req
111  
112 <    def sched_parameter(self):
112 >    def sched_fix_parameter(self):
113          """
114          Returns string with requirements and scheduler-specific parameters
115          """
116 <        index = int(common._db.nJobs()) - 1
117 <        job = common.job_list[index]
116 >        index = int(common._db.nJobs())
117 >        job = common.job_list[index-1]
118          jbt = job.type()
117
118      ### To Be Removed BL--DS
119      #  lastDest=''
120      #  first = []
121      #  last  = []
122      #  for n in range(common.jobDB.nJobs()):
123      #      currDest=common.jobDB.destination(n)
124      #      if (currDest!=lastDest):
125      #          lastDest = currDest
126      #          first.append(n)
127      #          if n != 0:last.append(n-1)
128      #  if len(first)>len(last) :last.append(common.jobDB.nJobs())
129
119          req = ''
120          req = req + jbt.getRequirements()
121  
122          if self.EDG_requirements:
123              if (not req == ' '): req = req +  ' && '
124              req = req + self.EDG_requirements
136        sched_param=''
137        sched_param='""pippo""'
125  
126 <        ### Temporary Problem with quote and py2sqlite.... under investigation..        
127 <        for i in range(index):
141 <           # sched_param+='Requirements = ' + req +self.specific_req() + self.se_list(i) +\
142 <           #                                 self.ce_list() +';\n' ## BL--DS
143 <           # if self.EDG_addJdlParam: sched_param+=self.jdlParam() ## BL--DS
144 <           # if (self.rb_param_file): sched_param+=self.rb_param_file ## BL--DS
145 <           # print sched_param
146 <            run_jobReq={'schedulerAttributes':sched_param}## DS--BL
147 <            common._db.updateRunJob_(i,run_jobReq)        
148 <
149 <    def wsSetupEnvironment(self):
150 <        """
151 <        Returns part of a job script which does scheduler-specific work.
152 <        """
153 <        txt = ''
154 <        txt += '# strip arguments\n'
155 <        txt += 'echo "strip arguments"\n'
156 <        txt += 'args=("$@")\n'
157 <        txt += 'nargs=$#\n'
158 <        txt += 'shift $nargs\n'
159 <        txt += "# job number (first parameter for job wrapper)\n"
160 <        txt += "NJob=${args[0]}; export NJob\n"
161 <
162 <        txt += '# job identification to DashBoard \n'
163 <        txt += 'MonitorJobID=`echo ${NJob}_$GLITE_WMS_JOBID`\n'
164 <        txt += 'SyncGridJobId=`echo $GLITE_WMS_JOBID`\n'
165 <        txt += 'MonitorID=`echo ' + self._taskId + '`\n'
166 <        txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
167 <        txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
168 <        txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
169 <
170 <        txt += 'echo "middleware discovery: " \n'
171 <        txt += 'if [ $VO_CMS_SW_DIR ]; then \n'
172 <        txt += '    middleware=LCG \n'
173 <        txt += '    echo "SyncCE=`glite-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
174 <        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
175 <        txt += '    echo ">>> middleware =$middleware" \n'
176 <        txt += 'elif [ $OSG_APP ]; then \n'
177 <        txt += '    middleware=OSG \n'
178 <        txt += '    if [ $OSG_JOB_CONTACT ]; then \n'
179 <        txt += '        SyncCE="$OSG_JOB_CONTACT"; \n'
180 <        txt += '        echo "SyncCE=$SyncCE" | tee -a $RUNTIME_AREA/$repo ;\n'
181 <        txt += '    else\n'
182 <        txt += '        echo "not reporting SyncCE";\n'
183 <        txt += '    fi\n';
184 <        txt += '    echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
185 <        txt += '    echo ">>> middleware =$middleware" \n'
186 <        txt += 'else \n'
187 <        txt += '    echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
188 <        txt += '    echo "JOB_EXIT_STATUS = 10030" \n'
189 <        txt += '    echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n'
190 <        txt += '    dumpStatus $RUNTIME_AREA/$repo \n'
191 <        txt += '    exit 1 \n'
192 <        txt += 'fi \n'
193 <
194 <        txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
195 <
196 <        txt += '\n\n'
197 <
198 <        txt += 'export VO='+self.VO+'\n'
199 <        txt += 'if [ $middleware == LCG ]; then\n'
200 <        txt += '    CloseCEs=`glite-brokerinfo getCE`\n'
201 <        txt += '    echo "CloseCEs = $CloseCEs"\n'
202 <        txt += '    CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
203 <        txt += '    echo "CE = $CE"\n'
204 <        txt += 'elif [ $middleware == OSG ]; then \n'
205 <        txt += '    if [ $OSG_JOB_CONTACT ]; then \n'
206 <        txt += '        CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n'
207 <        txt += '    else \n'
208 <        txt += '        echo "ERROR ==> OSG mode in setting CE name from OSG_JOB_CONTACT" \n'
209 <        txt += '        job_exit_code=10099\n'
210 <        txt += '        func_exit \n'
211 <        #txt += '        echo "SET_CMS_ENV 10099 ==> OSG mode: ERROR in setting CE name from OSG_JOB_CONTACT" \n'
212 <        #txt += '        echo "JOB_EXIT_STATUS = 10099" \n'
213 <        #txt += '        echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n'
214 <        #txt += '        dumpStatus $RUNTIME_AREA/$repo \n'
215 <        #txt += '        exit 1 \n'
216 <        txt += '    fi \n'
217 <        txt += 'fi \n'
126 >        Task_Req={'jobType':req}## DS--BL
127 >        common._db.updateTask_(Task_Req)
128  
129 <        return txt
220 <
221 <    def loggingInfo(self, id):
129 >    def sched_parameter(self,i,task):
130          """
131 <        retrieve the logging info from logging and bookkeeping and return it
131 >        Returns string with requirements and scheduler-specific parameters
132          """
133 <        self.checkProxy()
134 <        cmd = 'glite-job-logging-info -v 3 ' + id
135 <        cmd_out = runCommand(cmd)
136 <        return cmd_out
137 <
138 <    def queryDetailedStatus(self, id):
139 <        """ Query a detailed status of the job with id """
140 <        cmd = 'glite-job-status '+id
141 <        cmd_out = runCommand(cmd)
142 <        return cmd_out
133 >        dest=  task.jobs[i-1]['dlsDestination'] ## DS--BL
134 >
135 >        req=''
136 >        req +=task['jobType']
137 >
138 >        sched_param=''
139 >        sched_param+='Requirements = ' + req +self.specific_req() + self.se_list(i,dest) +\
140 >                                        self.ce_list()[0] +';\n' ## BL--DS
141 >        if self.EDG_addJdlParam: sched_param+=self.jdlParam() ## BL--DS
142 >        sched_param+='MyProxyServer = "' + self.proxyServer + '";\n'
143 >        sched_param+='VirtualOrganisation = "' + self.VO + '";\n'
144 >        sched_param+='RetryCount = '+str(self.EDG_retry_count)+';\n'
145 >        sched_param+='ShallowRetryCount = '+str(self.EDG_shallow_retry_count)+';\n'
146 >
147 >        return sched_param
148 >
149 >    def decodeLogInfo(self, file):
150 >        """
151 >        Parse logging info file and return main info
152 >        """
153 >        loggingInfo = EdgLoggingInfo.EdgLoggingInfo()
154 >        reason = loggingInfo.decodeReason(file)
155 >        return reason
156 >
157 >    def findSites_(self, n, sites):
158 >        itr4 =[]
159 >        if len(sites)>0 and sites[0]=="":
160 >            return itr4
161 >        if sites != [""]:
162 >            ##Addedd Daniele
163 >            replicas = self.blackWhiteListParser.checkBlackList(sites,n)
164 >            if len(replicas)!=0:
165 >                replicas = self.blackWhiteListParser.checkWhiteList(replicas,n)
166 >
167 >            itr4 = replicas
168 >            #####
169 >        return itr4
170 >
171 >
172  
173  
174      def tOut(self, list):

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines