ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/SchedulerGlite.py
Revision: 1.37
Committed: Tue Mar 4 11:09:13 2008 UTC (17 years, 1 month ago) by fanzago
Content type: text/x-python
Branch: MAIN
Changes since 1.36: +32 -19 lines
Log Message:
re-added some changes for clean of wrapper

File Contents

# User Rev Content
1 slacapra 1.31 from SchedulerGrid import SchedulerGrid
2 spiga 1.2 from crab_logger import Logger
3     from crab_exceptions import *
4     from crab_util import *
5 fanzago 1.4 from GliteConfig import *
6 spiga 1.2 import common
7    
8     import os, sys, time
9    
10 slacapra 1.31 class SchedulerGlite(SchedulerGrid):
11 slacapra 1.33 def __init__(self, name="GLITE"):
12     SchedulerGrid.__init__(self,name)
13 slacapra 1.31
14     def configure(self,cfg_params):
15     SchedulerGrid.configure(self, cfg_params)
16     self.environment_unique_identifier = 'GLITE_WMS_JOBID'
17 slacapra 1.3
18 fanzago 1.4 def rb_configure(self, RB):
19 slacapra 1.31 if not RB: return None
20     glite_config = None
21     rb_param_file = None
22 fanzago 1.4
23     gliteConfig = GliteConfig(RB)
24 slacapra 1.31 glite_config = gliteConfig.config()
25 fanzago 1.4
26 slacapra 1.31 if (glite_config ):
27     rb_param_file = 'WMSconfig = '+glite_config+';\n'
28     return rb_param_file
29 fanzago 1.4
30 spiga 1.36 def ce_list(self):
31 spiga 1.2 """
32 spiga 1.36 Returns string with requirement CE related
33 spiga 1.2 """
34 spiga 1.36 req = ''
35 spiga 1.2 if self.EDG_ce_white_list:
36 mcinquil 1.32 ce_white_list = self.EDG_ce_white_list
37 slacapra 1.13 tmpCe=[]
38     concString = '&&'
39     for ce in ce_white_list:
40     tmpCe.append('RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId)')
41 mcinquil 1.20 if len(tmpCe) == 1:
42     req += " && (" + concString.join(tmpCe) + ") "
43     elif len(tmpCe) > 1:
44     firstCE = 0
45     for reqTemp in tmpCe:
46     if firstCE == 0:
47     req += " && ( (" + reqTemp + ") "
48     firstCE = 1
49     elif firstCE > 0:
50     req += " || (" + reqTemp + ") "
51     if firstCE > 0:
52     req += ") "
53 ewv 1.28
54 spiga 1.2 if self.EDG_ce_black_list:
55 mcinquil 1.32 ce_black_list = self.EDG_ce_black_list
56 slacapra 1.13 tmpCe=[]
57     concString = '&&'
58 spiga 1.2 for ce in ce_black_list:
59 slacapra 1.13 tmpCe.append('(!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))')
60 spiga 1.36 if len(tmpCe): req += " && (" + concString.join(tmpCe) + ") "
61    
62     # requirement added to skip gliteCE
63     req += '&& (!RegExp("blah", other.GlueCEUniqueId))'
64    
65     return req
66    
67     def se_list(self, id):
68     """
69     Returns string with requirement SE related
70     """
71     hostList=self.findSites_(id)
72     req=''
73     reqtmp=[]
74     concString = '||'
75    
76     for arg in hostList:
77     reqtmp.append(' Member("'+arg+'" , other.GlueCESEBindGroupSEUniqueID) ')
78    
79     if len(reqtmp): req += " && (" + concString.join(reqtmp) + ") "
80 spiga 1.11
81 spiga 1.36 return req
82    
83     def jdlParam(self):
84     """
85     Returns
86     """
87     req=''
88     if self.EDG_addJdlParam:
89     if self.EDG_addJdlParam[-1] == '': self.EDG_addJdlParam= self.EDG_addJdlParam[:-1]
90     for p in self.EDG_addJdlParam:
91     # param_file.write(string.strip(p)+';\n')
92     req+=string.strip(p)+';\n' ## BL--DS
93     return req
94    
95     def specific_req(self):
96     """
97     Returns string with specific requirements
98     """
99     req=''
100 spiga 1.2 if self.EDG_clock_time:
101 slacapra 1.13 if (not req == ' '): req = req + ' && '
102     req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
103 spiga 1.2
104     if self.EDG_cpu_time:
105 slacapra 1.13 if (not req == ' '): req = req + ' && '
106     req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
107 spiga 1.36
108     return req
109 ewv 1.28
110 spiga 1.36 def sched_parameter(self):
111     """
112     Returns string with requirements and scheduler-specific parameters
113     """
114     index = int(common._db.nJobs()) - 1
115     job = common.job_list[index]
116     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 spiga 1.2
130 spiga 1.36 req = ''
131     req = req + jbt.getRequirements()
132 slacapra 1.13
133 spiga 1.36 if self.EDG_requirements:
134     if (not req == ' '): req = req + ' && '
135     req = req + self.EDG_requirements
136     sched_param=''
137     sched_param='""pippo""'
138 spiga 1.2
139 spiga 1.36 ### Temporary Problem with quote and py2sqlite.... under investigation..
140     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 spiga 1.2
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 ewv 1.34 txt += "NJob=${args[0]}; export NJob\n"
161 spiga 1.2
162     txt += '# job identification to DashBoard \n'
163 fanzago 1.37 #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 += 'MonitorJobID=${NJob}_$GLITE_WMS_JOBID \n'
167     txt += 'SyncGridJobId=$GLITE_WMS_JOBID \n'
168     txt += 'MonitorID='+self._taskId+' \n'
169     txt += 'echo "MonitorJobID=$MonitorJobID" > $RUNTIME_AREA/$repo \n'
170     txt += 'echo "SyncGridJobId=$SyncGridJobId" >> $RUNTIME_AREA/$repo \n'
171     txt += 'echo "MonitorID=$MonitorID" >> $RUNTIME_AREA/$repo\n'
172     #txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
173     #txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
174     #txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
175 spiga 1.2
176 fanzago 1.37 #txt += 'echo "middleware discovery: " \n'
177     txt += 'echo ">>> GridFlavour discovery: " \n'
178 spiga 1.2 txt += 'if [ $VO_CMS_SW_DIR ]; then \n'
179 fanzago 1.37 txt += ' middleware=LCG\n'
180     #txt += ' echo "SyncCE=`glite-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
181     txt += ' echo "SyncCE=`glite-brokerinfo getCE`" >> $RUNTIME_AREA/$repo \n'
182     #txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
183     txt += ' echo "GridFlavour=$middleware" | tee -a $RUNTIME_AREA/$repo \n'
184     #txt += ' echo ">>> middleware =$middleware" \n'
185 spiga 1.2 txt += 'elif [ $OSG_APP ]; then \n'
186     txt += ' middleware=OSG \n'
187 mcinquil 1.25 txt += ' if [ $OSG_JOB_CONTACT ]; then \n'
188     txt += ' SyncCE="$OSG_JOB_CONTACT"; \n'
189 fanzago 1.37 #txt += ' echo "SyncCE=$SyncCE" | tee -a $RUNTIME_AREA/$repo ;\n'
190     txt += ' echo "SyncCE=$SyncCE" >> $RUNTIME_AREA/$repo ;\n'
191 mcinquil 1.22 txt += ' else\n'
192     txt += ' echo "not reporting SyncCE";\n'
193     txt += ' fi\n';
194 fanzago 1.37 txt += ' echo "GridFlavour=$middleware" | tee -a $RUNTIME_AREA/$repo \n'
195     #txt += ' echo ">>> middleware =$middleware" \n'
196 spiga 1.2 txt += 'else \n'
197 fanzago 1.37 txt += ' echo "ERROR ==> GridFlavour not identified" \n'
198     txt += ' job_exit_code=10030\n'
199     txt += ' func_exit \n'
200     #txt += ' echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
201     #txt += ' echo "JOB_EXIT_STATUS = 10030" \n'
202     #txt += ' echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n'
203     #txt += ' dumpStatus $RUNTIME_AREA/$repo \n'
204     #txt += ' exit 1 \n'
205 spiga 1.2 txt += 'fi \n'
206    
207     txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
208 ewv 1.28
209 spiga 1.2 txt += '\n\n'
210    
211     txt += 'export VO='+self.VO+'\n'
212 ewv 1.28 txt += 'if [ $middleware == LCG ]; then\n'
213 spiga 1.2 txt += ' CloseCEs=`glite-brokerinfo getCE`\n'
214     txt += ' echo "CloseCEs = $CloseCEs"\n'
215     txt += ' CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
216     txt += ' echo "CE = $CE"\n'
217     txt += 'elif [ $middleware == OSG ]; then \n'
218     txt += ' if [ $OSG_JOB_CONTACT ]; then \n'
219     txt += ' CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n'
220     txt += ' else \n'
221 fanzago 1.35 txt += ' echo "ERROR ==> OSG mode in setting CE name from OSG_JOB_CONTACT" \n'
222     txt += ' job_exit_code=10099\n'
223     txt += ' func_exit \n'
224     #txt += ' echo "SET_CMS_ENV 10099 ==> OSG mode: ERROR in setting CE name from OSG_JOB_CONTACT" \n'
225     #txt += ' echo "JOB_EXIT_STATUS = 10099" \n'
226     #txt += ' echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n'
227     #txt += ' dumpStatus $RUNTIME_AREA/$repo \n'
228     #txt += ' exit 1 \n'
229 spiga 1.2 txt += ' fi \n'
230 ewv 1.28 txt += 'fi \n'
231 spiga 1.2
232     return txt
233 ewv 1.28
234 spiga 1.2 def loggingInfo(self, id):
235     """
236     retrieve the logging info from logging and bookkeeping and return it
237     """
238     self.checkProxy()
239 slacapra 1.8 cmd = 'glite-job-logging-info -v 3 ' + id
240 spiga 1.2 cmd_out = runCommand(cmd)
241     return cmd_out
242    
243     def queryDetailedStatus(self, id):
244     """ Query a detailed status of the job with id """
245     cmd = 'glite-job-status '+id
246     cmd_out = runCommand(cmd)
247     return cmd_out
248    
249 spiga 1.14
250 mcinquil 1.27 def tOut(self, list):
251 mcinquil 1.18 return 180