Ejemplo n.º 1
0
 def lockJob(self,dn,jobID):
     # make token
     tmpProxy = DBProxy()
     self.token = "%s:%s:" % (tmpProxy.cleanUserID(dn),jobID)
     _logger.debug("%s lockJob" % self.token)        
     # lock
     resST,resVal = self.taskBuffer.lockJobForReBrokerage(dn,jobID,self.simulation,self.forceOpt,
                                                          forFailed=self.forFailed)
     # failed
     if not resST:
         _logger.debug("%s lockJob failed since %s" % (self.token,resVal['err']))
         return False,resVal['err']
     # keep jobID
     self.jobID = jobID
     # set PandaID,buildStatus,userName
     self.rPandaID    = resVal['rPandaID']        
     self.bPandaID    = resVal['bPandaID']
     self.userName    = resVal['userName']
     self.buildStatus = resVal['bStatus']
     self.buildJobID  = resVal['bJobID']
     self.minPandaIDlibDS = resVal['minPandaIDlibDS']
     self.maxPandaIDlibDS = resVal['maxPandaIDlibDS']
     # use JobID as rev num
     self.revNum = self.taskBuffer.getJobIdUser(dn)
     _logger.debug("%s run PandaID=%s / build PandaID=%s Status=%s JobID=%s rev=%s" % \
                   (self.token,self.rPandaID,self.bPandaID,self.buildStatus,
                    self.buildJobID,self.revNum))
     # return
     return True,''
Ejemplo n.º 2
0
 def getEmail(self,dn):
     # get DN
     _logger.debug("getDN for %s" % dn)
     dbProxy = DBProxy()
     distinguishedName = dbProxy.cleanUserID(dn)
     _logger.debug("DN = %s" % distinguishedName)
     if distinguishedName == "":
         _logger.error("cannot get DN for %s" % dn)
         return ""
     # get email from MetaDB
     mailAddrInDB,dbUptime = self.taskBuffer.getEmailAddr(distinguishedName,withUpTime=True)
     _logger.debug("email in MetaDB : '%s'" % mailAddrInDB)
     notSendMail = False
     if not mailAddrInDB in [None,'']:
         # email mortification is suppressed
         if mailAddrInDB.split(':')[0] == 'notsend':
             notSendMail = True
     # avoid too frequently lookup
     if dbUptime != None and datetime.datetime.utcnow()-dbUptime < datetime.timedelta(hours=1):
         _logger.debug("no lookup")
         if notSendMail or mailAddrInDB in [None,'']:
             return 'notsend'
         else:
             return mailAddrInDB.split(':')[-1]
     # get email from DQ2
     realDN = re.sub('/CN=limited proxy','',dn)
     realDN = re.sub('(/CN=proxy)+','',realDN)
     try:
         _logger.debug("dq2Info.finger(%s)" % realDN)
         for iDDMTry in range(3):
             status,out = dq2Info.finger(realDN)
             if status != 0 or out.find("DQ2 internal server exception") != -1 \
                    or out.find("An error occurred on the central catalogs") != -1 \
                    or out.find("MySQL server has gone away") != -1:
                 time.sleep(10)
             else:
                 break
         _logger.debug(out)
         exec "userInfo=%s" % out
         mailAddr = userInfo['email']
         _logger.debug("email from DQ2 : '%s'" % mailAddr)
         if mailAddr == None:
             mailAddr = ''
         # make email field to update DB
         mailAddrToDB = ''
         if notSendMail:
             mailAddrToDB += 'notsend:'
         mailAddrToDB += mailAddr
         # update database
         _logger.debug("update email for %s to %s" % (distinguishedName,mailAddrToDB))
         self.taskBuffer.setEmailAddr(distinguishedName,mailAddrToDB)
         if notSendMail:
             return 'notsend'
         return mailAddr
     except:
         errType,errValue = sys.exc_info()[:2]
         _logger.error("%s %s" % (errType,errValue))
         return ""
     return ""
Ejemplo n.º 3
0
 def getEmail(self,dn):
     # get DN
     _logger.debug("getDN for %s" % dn)
     dbProxy = DBProxy()
     distinguishedName = dbProxy.cleanUserID(dn)
     _logger.debug("DN = %s" % distinguishedName)
     if distinguishedName == "":
         _logger.error("cannot get DN for %s" % dn)
         return ""
     # get email from MetaDB
     mailAddrInDB,dbUptime = self.taskBuffer.getEmailAddr(distinguishedName,withUpTime=True)
     _logger.debug("email in MetaDB : '%s'" % mailAddrInDB)
     notSendMail = False
     if not mailAddrInDB in [None,'']:
         # email mortification is suppressed
         if mailAddrInDB.split(':')[0] == 'notsend':
             notSendMail = True
     # avoid too frequently lookup
     if dbUptime != None and datetime.datetime.utcnow()-dbUptime < datetime.timedelta(hours=1):
         _logger.debug("no lookup")
         if notSendMail or mailAddrInDB in [None,'']:
             return 'notsend'
         else:
             return mailAddrInDB.split(':')[-1]
     # get email from DQ2
     realDN = re.sub('/CN=limited proxy','',dn)
     realDN = re.sub('(/CN=proxy)+','',realDN)
     try:
         _logger.debug("dq2Info.finger(%s)" % realDN)
         for iDDMTry in range(3):
             status,out = dq2Info.finger(realDN)
             if status != 0 or out.find("DQ2 internal server exception") != -1 \
                    or out.find("An error occurred on the central catalogs") != -1 \
                    or out.find("MySQL server has gone away") != -1:
                 time.sleep(10)
             else:
                 break
         _logger.debug(out)
         exec "userInfo=%s" % out
         mailAddr = userInfo['email']
         _logger.debug("email from DQ2 : '%s'" % mailAddr)
         if mailAddr == None:
             mailAddr = ''
         # make email field to update DB
         mailAddrToDB = ''
         if notSendMail:
             mailAddrToDB += 'notsend:'
         mailAddrToDB += mailAddr
         # update database
         _logger.debug("update email for %s to %s" % (distinguishedName,mailAddrToDB))
         self.taskBuffer.setEmailAddr(distinguishedName,mailAddrToDB)
         if notSendMail:
             return 'notsend'
         return mailAddr
     except:
         errType,errValue = sys.exc_info()[:2]
         _logger.error("%s %s" % (errType,errValue))
         return ""
     return ""
Ejemplo n.º 4
0
 def getEmail(self,dn):
     # get DN
     _logger.debug("getDN for %s" % dn)
     dbProxy = DBProxy()
     distinguishedName = dbProxy.cleanUserID(dn)
     _logger.debug("DN = %s" % distinguishedName)
     if distinguishedName == "":
         _logger.error("cannot get DN for %s" % dn)
         return ""
     # get email from MetaDB
     mailAddrInDB,dbUptime = self.taskBuffer.getEmailAddr(distinguishedName,withUpTime=True)
     _logger.debug("email in MetaDB : '%s'" % mailAddrInDB)
     notSendMail = False
     if not mailAddrInDB in [None,'']:
         # email mortification is suppressed
         if mailAddrInDB.split(':')[0] == 'notsend':
             notSendMail = True
     # avoid too frequently lookup
     if dbUptime != None and datetime.datetime.utcnow()-dbUptime < datetime.timedelta(hours=1):
         _logger.debug("no lookup")
         if notSendMail or mailAddrInDB in [None,'']:
             return 'notsend'
         else:
             return mailAddrInDB.split(':')[-1]
     # get email from DQ2
     realDN = re.sub('/CN=limited proxy','',dn)
     realDN = re.sub('(/CN=proxy)+','',realDN)
     try:
         tmpStatus,userInfo = rucioAPI.finger(realDN)
         mailAddr = userInfo['email']
         _logger.debug("email from DDM : '%s'" % mailAddr)
         if mailAddr == None:
             mailAddr = ''
         # make email field to update DB
         mailAddrToDB = ''
         if notSendMail:
             mailAddrToDB += 'notsend:'
         mailAddrToDB += mailAddr
         # update database
         _logger.debug("update email for %s to %s" % (distinguishedName,mailAddrToDB))
         self.taskBuffer.setEmailAddr(distinguishedName,mailAddrToDB)
         if notSendMail:
             return 'notsend'
         return mailAddr
     except:
         errType,errValue = sys.exc_info()[:2]
         _logger.error("%s %s" % (errType,errValue))
         return ""
     return ""
Ejemplo n.º 5
0
def cleanName(dn):
    # extract First Last from DN
    dbProxy = DBProxy()
    extractedDN = dbProxy.cleanUserID(dn)
    # replace -.
    extractedDN = re.sub('-|\.',' ',extractedDN)
    # change to lower
    extractedDN = extractedDN.lower()
    # remove ATLAS
    extractedDN = re.sub('\(*atlas\)*','',extractedDN)
    # remove numbers
    extractedDN = re.sub('\d*','',extractedDN)
    # remove Jr
    extractedDN = re.sub(' jr( |$)',' ',extractedDN)    
    # remove whitespaces
    extractedDN = re.sub(' +',' ',extractedDN)
    extractedDN = extractedDN.strip()
    # return
    return extractedDN