ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/SchedulerGlite.py
Revision: 1.64
Committed: Sat Nov 8 11:57:03 2008 UTC (16 years, 5 months ago) by spiga
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_4_3_pre7, CRAB_2_4_3_pre6, CRAB_2_4_3_pre5, CRAB_2_4_3_pre3, CRAB_2_4_3_pre2, CRAB_2_4_3_pre1, CRAB_2_4_2, CRAB_2_4_2_pre3
Changes since 1.63: +3 -3 lines
Log Message:
skip wms Auth. is set to 1 by default.

File Contents

# User Rev Content
1 ewv 1.62 """
2     CRAB interface to BossLite gLite Scheduler
3     """
4    
5 spiga 1.64 __revision__ = "$Id: SchedulerGlite.py,v 1.63 2008/10/17 10:52:33 slacapra Exp $"
6     __version__ = "$Revision: 1.63 $"
7 ewv 1.62
8 slacapra 1.31 from SchedulerGrid import SchedulerGrid
9 spiga 1.2 from crab_logger import Logger
10     from crab_exceptions import *
11     from crab_util import *
12 fanzago 1.4 from GliteConfig import *
13 spiga 1.47 import EdgLoggingInfo
14 spiga 1.2 import common
15    
16     import os, sys, time
17    
18 slacapra 1.31 class SchedulerGlite(SchedulerGrid):
19 slacapra 1.33 def __init__(self, name="GLITE"):
20     SchedulerGrid.__init__(self,name)
21 slacapra 1.31
22 fanzago 1.54 self.OSBsize = 55000000
23 spiga 1.51
24 slacapra 1.31 def configure(self,cfg_params):
25     SchedulerGrid.configure(self, cfg_params)
26 ewv 1.61 self.environment_unique_identifier = '$GLITE_WMS_JOBID'
27 slacapra 1.3
28 spiga 1.51 def realSchedParams(self,cfg_params):
29     """
30 ewv 1.61 Return dictionary with specific parameters, to use
31     with real scheduler
32 spiga 1.51 """
33     self.rb_param_file=''
34 slacapra 1.63 if (not cfg_params.has_key('EDG.rb')):
35 slacapra 1.60 cfg_params['EDG.rb']='CERN'
36     self.rb_param_file=common.scheduler.rb_configure(cfg_params.get("EDG.rb"))
37 spiga 1.51 self.wms_service=cfg_params.get("EDG.wms_service",'')
38 spiga 1.64 self.skipWMSAuth=cfg_params.get("EDG.skipwmsauth",1)
39 spiga 1.51 params = { 'service' : self.wms_service, \
40 afanfani 1.55 'config' : self.rb_param_file, \
41 ewv 1.61 'skipWMSAuth' : self.skipWMSAuth
42 spiga 1.51 }
43     return params
44 ewv 1.61
45 spiga 1.51
46 fanzago 1.4 def rb_configure(self, RB):
47 slacapra 1.31 if not RB: return None
48     glite_config = None
49     rb_param_file = None
50 fanzago 1.4
51     gliteConfig = GliteConfig(RB)
52 slacapra 1.31 glite_config = gliteConfig.config()
53 fanzago 1.4
54 slacapra 1.31 if (glite_config ):
55 spiga 1.40 rb_param_file = glite_config
56 slacapra 1.31 return rb_param_file
57 fanzago 1.4
58 spiga 1.36 def ce_list(self):
59 spiga 1.2 """
60 ewv 1.42 Returns string with requirement CE related
61 spiga 1.2 """
62 ewv 1.42 req = ''
63 spiga 1.2 if self.EDG_ce_white_list:
64 mcinquil 1.32 ce_white_list = self.EDG_ce_white_list
65 slacapra 1.13 tmpCe=[]
66     concString = '&&'
67     for ce in ce_white_list:
68     tmpCe.append('RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId)')
69 mcinquil 1.20 if len(tmpCe) == 1:
70     req += " && (" + concString.join(tmpCe) + ") "
71     elif len(tmpCe) > 1:
72     firstCE = 0
73     for reqTemp in tmpCe:
74     if firstCE == 0:
75     req += " && ( (" + reqTemp + ") "
76     firstCE = 1
77     elif firstCE > 0:
78     req += " || (" + reqTemp + ") "
79     if firstCE > 0:
80     req += ") "
81 ewv 1.28
82 spiga 1.2 if self.EDG_ce_black_list:
83 mcinquil 1.32 ce_black_list = self.EDG_ce_black_list
84 slacapra 1.13 tmpCe=[]
85     concString = '&&'
86 spiga 1.2 for ce in ce_black_list:
87 slacapra 1.13 tmpCe.append('(!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))')
88 spiga 1.36 if len(tmpCe): req += " && (" + concString.join(tmpCe) + ") "
89    
90     # requirement added to skip gliteCE
91     req += '&& (!RegExp("blah", other.GlueCEUniqueId))'
92    
93 spiga 1.41 return req,self.EDG_ce_white_list,self.EDG_ce_black_list
94 spiga 1.36
95 slacapra 1.60 def se_list(self, dest):
96 spiga 1.36 """
97 ewv 1.42 Returns string with requirement SE related
98     """
99 slacapra 1.60 hostList=self.findSites_(dest)
100 spiga 1.36 req=''
101     reqtmp=[]
102     concString = '||'
103    
104     for arg in hostList:
105     reqtmp.append(' Member("'+arg+'" , other.GlueCESEBindGroupSEUniqueID) ')
106    
107     if len(reqtmp): req += " && (" + concString.join(reqtmp) + ") "
108 spiga 1.11
109 spiga 1.36 return req
110    
111     def jdlParam(self):
112     """
113 ewv 1.42 Returns
114     """
115 spiga 1.36 req=''
116     if self.EDG_addJdlParam:
117 ewv 1.42 if self.EDG_addJdlParam[-1] == '': self.EDG_addJdlParam= self.EDG_addJdlParam[:-1]
118 spiga 1.36 for p in self.EDG_addJdlParam:
119 ewv 1.61 req+=string.strip(p)+';\n'
120 spiga 1.36 return req
121    
122     def specific_req(self):
123     """
124     Returns string with specific requirements
125 ewv 1.42 """
126 spiga 1.36 req=''
127 spiga 1.2 if self.EDG_clock_time:
128 slacapra 1.13 if (not req == ' '): req = req + ' && '
129     req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
130 spiga 1.2
131     if self.EDG_cpu_time:
132 slacapra 1.13 if (not req == ' '): req = req + ' && '
133     req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
134 ewv 1.42
135 spiga 1.36 return req
136 ewv 1.28
137 spiga 1.39 def sched_parameter(self,i,task):
138     """
139     Returns string with requirements and scheduler-specific parameters
140     """
141 ewv 1.61 dest= task.jobs[i-1]['dlsDestination']
142 spiga 1.39
143     req=''
144     req +=task['jobType']
145    
146     sched_param=''
147 slacapra 1.60 sched_param+='Requirements = ' + req +self.specific_req() + self.se_list(dest) +\
148 ewv 1.61 self.ce_list()[0] +';\n'
149     if self.EDG_addJdlParam: sched_param+=self.jdlParam()
150 spiga 1.39 sched_param+='MyProxyServer = "' + self.proxyServer + '";\n'
151     sched_param+='VirtualOrganisation = "' + self.VO + '";\n'
152     sched_param+='RetryCount = '+str(self.EDG_retry_count)+';\n'
153     sched_param+='ShallowRetryCount = '+str(self.EDG_shallow_retry_count)+';\n'
154    
155     return sched_param
156 ewv 1.42
157 spiga 1.47 def decodeLogInfo(self, file):
158     """
159     Parse logging info file and return main info
160     """
161     loggingInfo = EdgLoggingInfo.EdgLoggingInfo()
162     reason = loggingInfo.decodeReason(file)
163     return reason
164    
165 slacapra 1.60 def findSites_(self, sites):
166 spiga 1.39 itr4 =[]
167     if len(sites)>0 and sites[0]=="":
168     return itr4
169     if sites != [""]:
170 slacapra 1.60 replicas = self.blackWhiteListParser.checkBlackList(sites)
171 spiga 1.39 if len(replicas)!=0:
172 slacapra 1.60 replicas = self.blackWhiteListParser.checkWhiteList(replicas)
173 ewv 1.42
174 spiga 1.39 itr4 = replicas
175     return itr4
176    
177 ewv 1.61
178 spiga 1.51 def wsExitFunc(self):
179     """
180     """
181     txt = '\n'
182    
183     txt += '#\n'
184     txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
185     txt += '#\n\n'
186    
187     txt += 'func_exit() { \n'
188     txt += self.wsExitFunc_common()
189     ### specific Glite check for OSB
190     txt += ' tar zcvf ${out_files}.tgz ${final_list}\n'
191     txt += ' tmp_size=`ls -gGrta ${out_files}.tgz | awk \'{ print $3 }\'`\n'
192 ewv 1.61 txt += ' rm ${out_files}.tgz\n'
193 spiga 1.51 txt += ' size=`expr $tmp_size`\n'
194     txt += ' echo "Total Output dimension: $size"\n'
195 ewv 1.61 txt += ' limit='+str(self.OSBsize) +' \n'
196 spiga 1.51 txt += ' echo "WARNING: output files size limit is set to: $limit"\n'
197 spiga 1.53 txt += ' if [ "$limit" -lt "$size" ]; then\n'
198 spiga 1.51 txt += ' exceed=1\n'
199     txt += ' job_exit_code=70000\n'
200     txt += ' echo "Output Sanbox too big. Produced output is lost "\n'
201     txt += ' else\n'
202     txt += ' exceed=0\n'
203 spiga 1.53 txt += ' echo "Total Output dimension $size is fine."\n'
204 spiga 1.51 txt += ' fi\n'
205    
206     txt += ' echo "JOB_EXIT_STATUS = $job_exit_code"\n'
207     txt += ' echo "JobExitCode=$job_exit_code" >> $RUNTIME_AREA/$repo\n'
208     txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
209     txt += ' if [ $exceed -ne 1 ]; then\n'
210     txt += ' tar zcvf ${out_files}.tgz ${final_list}\n'
211     txt += ' else\n'
212     txt += ' tar zcvf ${out_files}.tgz CMSSW_${NJob}.stdout CMSSW_${NJob}.stderr\n'
213     txt += ' fi\n'
214     txt += ' exit $job_exit_code\n'
215    
216     txt += '}\n'
217     return txt