本文整理匯總了Python中WMCore.Credential.Proxy.Proxy.getUserCertTimeLeft方法的典型用法代碼示例。如果您正苦於以下問題:Python Proxy.getUserCertTimeLeft方法的具體用法?Python Proxy.getUserCertTimeLeft怎麽用?Python Proxy.getUserCertTimeLeft使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WMCore.Credential.Proxy.Proxy
的用法示例。
在下文中一共展示了Proxy.getUserCertTimeLeft方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: AgentStatusPoller
# 需要導入模塊: from WMCore.Credential.Proxy import Proxy [as 別名]
# 或者: from WMCore.Credential.Proxy.Proxy import getUserCertTimeLeft [as 別名]
#.........這裏部分代碼省略.........
results['thresholds'] = self.wmagentDB.getJobSlotInfo()
logging.debug("Running and pending site thresholds: %s", results['thresholds'])
# now fetch the amount of jobs in each state and the amount of created
# jobs grouped by task
results.update(self.wmagentDB.getAgentMonitoring())
logging.debug("Total number of jobs in WMBS sorted by status: %s", results['wmbsCountByState'])
logging.debug("Total number of 'created' jobs in WMBS sorted by type: %s", results['wmbsCreatedTypeCount'])
logging.debug("Total number of 'executing' jobs in WMBS sorted by type: %s", results['wmbsExecutingTypeCount'])
logging.debug("Total number of active jobs in BossAir sorted by status: %s", results['activeRunJobByStatus'])
logging.debug("Total number of complete jobs in BossAir sorted by status: %s",
results['completeRunJobByStatus'])
logging.debug("Available slots thresholds to pull work from GQ to LQ: %s", results['thresholdsGQ2LQ'])
logging.debug("List of jobs pending for each site, sorted by priority: %s", results['sitePendCountByPrio'])
return results
def checkCredLifetime(self, agInfo, credType):
"""
Check the credential lifetime. Usually X509_USER_PROXY or X509_USER_CERT
and raise either a warning or an error if the proxy validity is about to expire.
:param agInfo: dictionary with plenty of agent monitoring information in place.
:param credType: credential type, can be: "proxy" or "certificate"
:return: same dictionary object plus additional keys/values if needed.
"""
if credType == "proxy":
credFile = self.proxyFile
secsLeft = self.proxy.getTimeLeft(proxy=credFile)
elif credType == "certificate":
credFile = self.userCertFile
secsLeft = self.proxy.getUserCertTimeLeft(openSSL=True)
else:
logging.error("Unknown credential type. Available options are: [proxy, certificate]")
return
logging.debug("%s '%s' lifetime is %d seconds", credType, credFile, secsLeft)
daysLeft = secsLeft / (60. * 60 * 24)
if daysLeft <= self.credThresholds[credType]['error']:
credWarning = True
agInfo['status'] = "error"
elif daysLeft <= self.credThresholds[credType]['warning']:
credWarning = True
if agInfo['status'] == "ok":
agInfo['status'] = "warning"
else:
credWarning = False
if credWarning:
warnMsg = "Agent %s '%s' must be renewed ASAP. " % (credType, credFile)
warnMsg += "Its time left is: %.2f hours;" % (secsLeft / 3600.)
agInfo['proxy_warning'] = agInfo.get('proxy_warning', "") + warnMsg
logging.warning(warnMsg)
return
def buildMonITDocs(self, dataStats):
"""
Convert agent statistics into MonIT-friendly documents to be posted
to AMQ/ES. It creates 5 different type of documents:
* priority information
* site information