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.46 by slacapra, Fri Apr 11 14:54:22 2008 UTC vs.
Revision 1.52 by spiga, Mon May 5 23:48:23 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 11 | Line 12 | class SchedulerGlite(SchedulerGrid):
12      def __init__(self, name="GLITE"):
13          SchedulerGrid.__init__(self,name)
14  
15 +        self.OSBsize = 55000
16 +
17      def configure(self,cfg_params):
18          SchedulerGrid.configure(self, cfg_params)
19          self.checkProxy()
20          self.environment_unique_identifier = 'GLITE_WMS_JOBID'
21  
22 +    def realSchedParams(self,cfg_params):
23 +        """
24 +        Return dictionary with specific parameters, to use
25 +        with real scheduler  
26 +        """
27 +        self.rb_param_file=''
28 +        if (cfg_params.has_key('EDG.rb')):
29 +            self.rb_param_file=common.scheduler.rb_configure(cfg_params.get("EDG.rb"))
30 +        self.wms_service=cfg_params.get("EDG.wms_service",'')
31 +        params = { 'service' : self.wms_service, \
32 +                   'config' : self.rb_param_file
33 +                 }
34 +        return  params
35 +      
36 +
37      def rb_configure(self, RB):
38          if not RB: return None
39          glite_config = None
# Line 129 | Line 147 | class SchedulerGlite(SchedulerGrid):
147          """
148          Returns string with requirements and scheduler-specific parameters
149          """
150 <        print i
133 <        dest=  eval(task.jobs[i-1]['dlsDestination']) ## DS--BL
150 >        dest=  task.jobs[i-1]['dlsDestination'] ## DS--BL
151  
152          req=''
153          req +=task['jobType']
# Line 146 | Line 163 | class SchedulerGlite(SchedulerGrid):
163  
164          return sched_param
165  
166 <    def wsSetupEnvironment(self):
150 <        """
151 <        Returns part of a job script which does scheduler-specific work.
152 <        """
153 <        txt = SchedulerGrid.wsSetupEnvironment(self)
154 <
155 <        txt += 'export VO='+self.VO+'\n'
156 <        txt += 'if [ $middleware == LCG ]; then\n'
157 <        txt += '    CloseCEs=`glite-brokerinfo getCE`\n'
158 <        txt += '    echo "CloseCEs = $CloseCEs"\n'
159 <        txt += '    CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
160 <        txt += '    echo "CE = $CE"\n'
161 <        txt += 'elif [ $middleware == OSG ]; then \n'
162 <        txt += '    if [ $OSG_JOB_CONTACT ]; then \n'
163 <        txt += '        CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n'
164 <        txt += '    else \n'
165 <        txt += '        echo "ERROR ==> OSG mode in setting CE name from OSG_JOB_CONTACT" \n'
166 <        txt += '        job_exit_code=10099\n'
167 <        txt += '        func_exit\n'
168 <        txt += '    fi \n'
169 <        txt += 'fi \n'
170 <
171 <        return txt
172 <
173 <    def loggingInfo(self, id):
166 >    def decodeLogInfo(self, file):
167          """
168 <        retrieve the logging info from logging and bookkeeping and return it
168 >        Parse logging info file and return main info
169          """
170 <        self.checkProxy()
171 <        cmd = 'glite-job-logging-info -v 3 ' + id
172 <        cmd_out = runCommand(cmd)
180 <        return cmd_out
181 <
182 <    def queryDetailedStatus(self, id):
183 <        """ Query a detailed status of the job with id """
184 <        cmd = 'glite-job-status '+id
185 <        cmd_out = runCommand(cmd)
186 <        return cmd_out
170 >        loggingInfo = EdgLoggingInfo.EdgLoggingInfo()
171 >        reason = loggingInfo.decodeReason(file)
172 >        return reason
173  
174      def findSites_(self, n, sites):
175          itr4 =[]
# Line 199 | Line 185 | class SchedulerGlite(SchedulerGrid):
185              #####
186          return itr4
187  
188 +    
189 +    def wsExitFunc(self):
190 +        """
191 +        """
192 +        txt = '\n'
193  
194 +        txt += '#\n'
195 +        txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
196 +        txt += '#\n\n'
197 +
198 +        txt += 'func_exit() { \n'
199 +        txt += self.wsExitFunc_common()
200 +        ### specific Glite check for OSB
201 +        txt += '    tar zcvf ${out_files}.tgz  ${final_list}\n'
202 +        txt += '    tmp_size=`ls -gGrta ${out_files}.tgz | awk \'{ print $3 }\'`\n'
203 +        txt += '    rm ${out_files}.tgz\n'  
204 +        txt += '    size=`expr $tmp_size`\n'
205 +        txt += '    echo "Total Output dimension: $size"\n'
206 +        txt += '    limit='+str(self.OSBsize) +' \n'  
207 +        txt += '    echo "WARNING: output files size limit is set to: $limit"\n'
208 +        txt += '    if [ "$limit" -lt "$sum" ]; then\n'
209 +        txt += '        exceed=1\n'
210 +        txt += '        job_exit_code=70000\n'
211 +        txt += '        echo "Output Sanbox too big. Produced output is lost "\n'
212 +        txt += '    else\n'
213 +        txt += '        exceed=0\n'
214 +        txt += '        echo "Total Output dimension $sum is fine."\n'
215 +        txt += '    fi\n'
216 +
217 +        txt += '    echo "JOB_EXIT_STATUS = $job_exit_code"\n'
218 +        txt += '    echo "JobExitCode=$job_exit_code" >> $RUNTIME_AREA/$repo\n'
219 +        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
220 +        txt += '    if [ $exceed -ne 1 ]; then\n'
221 +        txt += '        tar zcvf ${out_files}.tgz  ${final_list}\n'
222 +        txt += '    else\n'
223 +        txt += '        tar zcvf ${out_files}.tgz CMSSW_${NJob}.stdout CMSSW_${NJob}.stderr\n'
224 +        txt += '    fi\n'
225 +        txt += '    exit $job_exit_code\n'
226  
227 +        txt += '}\n'
228 +        return txt
229  
230 <    def tOut(self, list):
231 <        return 180
230 >    def userName(self):
231 >        """ return the user name """
232 >        tmp=runCommand("voms-proxy-info -identity")
233 >        return tmp.strip()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines