5 |
|
|
6 |
|
import os, errno, time, sys, re |
7 |
|
import commands, traceback |
8 |
< |
import zlib |
8 |
> |
import zlib, base64 |
9 |
|
|
10 |
|
from Submitter import Submitter |
11 |
|
from ServerCommunicator import ServerCommunicator |
230 |
|
return |
231 |
|
|
232 |
|
|
233 |
+ |
def checkIfDrained(self, csCommunicator): |
234 |
+ |
isDrained = False |
235 |
+ |
|
236 |
+ |
try: |
237 |
+ |
drainStatus = csCommunicator.checkDrainMode(self.taskuuid) |
238 |
+ |
drainStatus += "="*( len(drainStatus)%8 ) |
239 |
+ |
drainStatus = zlib.decompress( base64.urlsafe_b64decode(drainStatus) ) |
240 |
+ |
isDrained = ( drainStatus == "true") |
241 |
+ |
except Exception, e: |
242 |
+ |
common.logger.debug("Problem while checking server drain mode. The server will be assumed as available.") |
243 |
+ |
common.logger.debug( traceback.format_exc() ) |
244 |
+ |
isDrained = False |
245 |
+ |
|
246 |
+ |
if isDrained == True: |
247 |
+ |
msg = "Server is in Drain mode. Unable to submit new tasks." |
248 |
+ |
raise CrabException(msg) |
249 |
+ |
|
250 |
+ |
return isDrained |
251 |
+ |
|
252 |
|
def manageCredential(self): |
253 |
|
""" |
254 |
|
Prepare configuration and Call credential API |
310 |
|
self.cfg_params['CRAB.se_remote_dir'] = self.remotedir |
311 |
|
|
312 |
|
if firstSubmission==True: |
313 |
+ |
# check if the server is in drain mode |
314 |
+ |
if self.checkIfDrained(csCommunicator)==True: |
315 |
+ |
return |
316 |
|
|
317 |
|
TotJob = common._db.nJobs() |
318 |
|
# move the sandbox |