ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/SchedulerGlite.py
Revision: 1.33
Committed: Tue Feb 12 15:48:53 2008 UTC (17 years, 2 months ago) by slacapra
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_1_0, CRAB_2_1_0_pre6, CRAB_2_1_0_pre5
Changes since 1.32: +2 -2 lines
Log Message:
fix scheduler name in case of glitecoll plus cleanup

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.2 def sched_parameter(self):
31     """
32     Returns file with requirements and scheduler-specific parameters
33     """
34     index = int(common.jobDB.nJobs()) - 1
35     job = common.job_list[index]
36     jbt = job.type()
37 ewv 1.28
38 spiga 1.2 lastDest=''
39     first = []
40     last = []
41     for n in range(common.jobDB.nJobs()):
42     currDest=common.jobDB.destination(n)
43     if (currDest!=lastDest):
44     lastDest = currDest
45     first.append(n)
46 ewv 1.28 if n != 0:last.append(n-1)
47 spiga 1.2 if len(first)>len(last) :last.append(common.jobDB.nJobs())
48 ewv 1.28
49 spiga 1.2 req = ''
50     req = req + jbt.getRequirements()
51 ewv 1.28
52    
53 spiga 1.2 if self.EDG_requirements:
54 slacapra 1.13 if (not req == ' '): req = req + ' && '
55     req = req + self.EDG_requirements
56    
57 spiga 1.2 if self.EDG_ce_white_list:
58 mcinquil 1.32 ce_white_list = self.EDG_ce_white_list
59 slacapra 1.13 tmpCe=[]
60     concString = '&&'
61     for ce in ce_white_list:
62     tmpCe.append('RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId)')
63 mcinquil 1.20 ### MATTY' FIX: if more then one CE: && -> ||
64     #print "list CE: " + str(tmpCe)
65     if len(tmpCe) == 1:
66     req += " && (" + concString.join(tmpCe) + ") "
67     elif len(tmpCe) > 1:
68     firstCE = 0
69     for reqTemp in tmpCe:
70     #print reqTemp
71     if firstCE == 0:
72     #print "adding: "+str(" && ( (" + reqTemp + ") ")
73     req += " && ( (" + reqTemp + ") "
74     firstCE = 1
75     elif firstCE > 0:
76     #print "adding: "+str(" || (" + reqTemp + ") ")
77     req += " || (" + reqTemp + ") "
78     if firstCE > 0:
79     req += ") "
80     ## old code
81     # if len(tmpCe): req = req + " && (" + concString.join(tmpCe) + ") "
82 ewv 1.28
83 spiga 1.2 if self.EDG_ce_black_list:
84 mcinquil 1.32 ce_black_list = self.EDG_ce_black_list
85 slacapra 1.13 tmpCe=[]
86     concString = '&&'
87 spiga 1.2 for ce in ce_black_list:
88 slacapra 1.13 tmpCe.append('(!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))')
89     if len(tmpCe): req = req + " && (" + concString.join(tmpCe) + ") "
90 spiga 1.11
91 spiga 1.2 if self.EDG_clock_time:
92 slacapra 1.13 if (not req == ' '): req = req + ' && '
93     req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
94 spiga 1.2
95     if self.EDG_cpu_time:
96 slacapra 1.13 if (not req == ' '): req = req + ' && '
97     req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
98 ewv 1.28
99 spiga 1.2 for i in range(len(first)): # Add loop DS
100     self.param='sched_param_'+str(i)+'.clad'
101     param_file = open(common.work_space.shareDir()+'/'+self.param, 'w')
102    
103     itr4=self.findSites_(first[i])
104 slacapra 1.6 reqSites=''
105 ewv 1.28 reqtmp=[]
106 slacapra 1.3 concString = '||'
107 slacapra 1.13
108     #############
109     # MC Changed matching syntax to avoid gang matching
110     #############
111 slacapra 1.3 for arg in itr4:
112 slacapra 1.6 reqtmp.append(' Member("'+arg+'" , other.GlueCESEBindGroupSEUniqueID) ')
113 slacapra 1.13
114     if len(reqtmp): reqSites = reqSites + " && (" + concString.join(reqtmp) + ") "
115    
116 spiga 1.11 # requirement added to skip gliteCE
117 slacapra 1.13 reqSites = reqSites + '&& (!RegExp("blah", other.GlueCEUniqueId));\n'
118    
119 slacapra 1.6 param_file.write('Requirements = ' + req + reqSites )
120 ewv 1.28
121 slacapra 1.31 if (self.rb_param_file):
122 ewv 1.28 param_file.write(self.rb_param_file)
123 fanzago 1.4
124 slacapra 1.31 if self.EDG_addJdlParam:
125 spiga 1.29 if self.EDG_addJdlParam[-1] == '': self.EDG_addJdlParam= self.EDG_addJdlParam[:-1]
126 slacapra 1.7 for p in self.EDG_addJdlParam:
127 spiga 1.29 param_file.write(string.strip(p)+';\n')
128 spiga 1.2
129 ewv 1.28 param_file.close()
130 spiga 1.2
131     def wsSetupEnvironment(self):
132     """
133     Returns part of a job script which does scheduler-specific work.
134     """
135     txt = ''
136     txt += '# strip arguments\n'
137     txt += 'echo "strip arguments"\n'
138     txt += 'args=("$@")\n'
139     txt += 'nargs=$#\n'
140     txt += 'shift $nargs\n'
141     txt += "# job number (first parameter for job wrapper)\n"
142     txt += "NJob=${args[0]}\n"
143    
144     txt += '# job identification to DashBoard \n'
145     txt += 'MonitorJobID=`echo ${NJob}_$GLITE_WMS_JOBID`\n'
146     txt += 'SyncGridJobId=`echo $GLITE_WMS_JOBID`\n'
147     txt += 'MonitorID=`echo ' + self._taskId + '`\n'
148     txt += 'echo "MonitorJobID=`echo $MonitorJobID`" | tee -a $RUNTIME_AREA/$repo \n'
149     txt += 'echo "SyncGridJobId=`echo $SyncGridJobId`" | tee -a $RUNTIME_AREA/$repo \n'
150     txt += 'echo "MonitorID=`echo $MonitorID`" | tee -a $RUNTIME_AREA/$repo\n'
151    
152 fanzago 1.26 txt += 'echo "middleware discovery: " \n'
153 spiga 1.2 txt += 'if [ $VO_CMS_SW_DIR ]; then \n'
154     txt += ' middleware=LCG \n'
155     txt += ' echo "SyncCE=`glite-brokerinfo getCE`" | tee -a $RUNTIME_AREA/$repo \n'
156     txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
157 fanzago 1.26 txt += ' echo ">>> middleware =$middleware" \n'
158 spiga 1.2 txt += 'elif [ $OSG_APP ]; then \n'
159     txt += ' middleware=OSG \n'
160 mcinquil 1.25 txt += ' if [ $OSG_JOB_CONTACT ]; then \n'
161     txt += ' SyncCE="$OSG_JOB_CONTACT"; \n'
162     txt += ' echo "SyncCE=$SyncCE" | tee -a $RUNTIME_AREA/$repo ;\n'
163 mcinquil 1.22 txt += ' else\n'
164     txt += ' echo "not reporting SyncCE";\n'
165     txt += ' fi\n';
166 spiga 1.2 txt += ' echo "GridFlavour=`echo $middleware`" | tee -a $RUNTIME_AREA/$repo \n'
167 fanzago 1.26 txt += ' echo ">>> middleware =$middleware" \n'
168 spiga 1.2 txt += 'else \n'
169     txt += ' echo "SET_CMS_ENV 10030 ==> middleware not identified" \n'
170     txt += ' echo "JOB_EXIT_STATUS = 10030" \n'
171     txt += ' echo "JobExitCode=10030" | tee -a $RUNTIME_AREA/$repo \n'
172     txt += ' dumpStatus $RUNTIME_AREA/$repo \n'
173     txt += ' exit 1 \n'
174     txt += 'fi \n'
175    
176     txt += 'dumpStatus $RUNTIME_AREA/$repo \n'
177 ewv 1.28
178 spiga 1.2 txt += '\n\n'
179    
180     txt += 'export VO='+self.VO+'\n'
181 ewv 1.28 txt += 'if [ $middleware == LCG ]; then\n'
182 spiga 1.2 txt += ' CloseCEs=`glite-brokerinfo getCE`\n'
183     txt += ' echo "CloseCEs = $CloseCEs"\n'
184     txt += ' CE=`echo $CloseCEs | sed -e "s/:.*//"`\n'
185     txt += ' echo "CE = $CE"\n'
186     txt += 'elif [ $middleware == OSG ]; then \n'
187     txt += ' if [ $OSG_JOB_CONTACT ]; then \n'
188     txt += ' CE=`echo $OSG_JOB_CONTACT | /usr/bin/awk -F\/ \'{print $1}\'` \n'
189     txt += ' else \n'
190     txt += ' echo "SET_CMS_ENV 10099 ==> OSG mode: ERROR in setting CE name from OSG_JOB_CONTACT" \n'
191     txt += ' echo "JOB_EXIT_STATUS = 10099" \n'
192     txt += ' echo "JobExitCode=10099" | tee -a $RUNTIME_AREA/$repo \n'
193     txt += ' dumpStatus $RUNTIME_AREA/$repo \n'
194     txt += ' exit 1 \n'
195     txt += ' fi \n'
196 ewv 1.28 txt += 'fi \n'
197 spiga 1.2
198     return txt
199 ewv 1.28
200 spiga 1.2 def loggingInfo(self, id):
201     """
202     retrieve the logging info from logging and bookkeeping and return it
203     """
204     self.checkProxy()
205 slacapra 1.8 cmd = 'glite-job-logging-info -v 3 ' + id
206 spiga 1.2 cmd_out = runCommand(cmd)
207     return cmd_out
208    
209     def queryDetailedStatus(self, id):
210     """ Query a detailed status of the job with id """
211     cmd = 'glite-job-status '+id
212     cmd_out = runCommand(cmd)
213     return cmd_out
214    
215     def findSites_(self, n):
216 slacapra 1.31 itr4 =[]
217 spiga 1.2 sites = common.jobDB.destination(n)
218 slacapra 1.3 if len(sites)>0 and sites[0]=="":
219 spiga 1.15 return itr4
220 ewv 1.28 if sites != [""]:
221 spiga 1.15 ##Addedd Daniele
222 gutsche 1.16 replicas = self.blackWhiteListParser.checkBlackList(sites,n)
223 spiga 1.15 if len(replicas)!=0:
224 gutsche 1.16 replicas = self.blackWhiteListParser.checkWhiteList(replicas,n)
225 ewv 1.28
226     itr4 = replicas
227     #####
228 spiga 1.15 return itr4
229 spiga 1.14
230 mcinquil 1.27 def tOut(self, list):
231 mcinquil 1.18 return 180