本文整理汇总了Python中WMCore.Credential.Proxy.Proxy.logonRenewMyProxy方法的典型用法代码示例。如果您正苦于以下问题:Python Proxy.logonRenewMyProxy方法的具体用法?Python Proxy.logonRenewMyProxy怎么用?Python Proxy.logonRenewMyProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Credential.Proxy.Proxy
的用法示例。
在下文中一共展示了Proxy.logonRenewMyProxy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_proxy
# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import logonRenewMyProxy [as 别名]
def get_proxy(self, ad):
result = None
vo = 'cms'
group = ''
role = ''
if 'CRAB_UserVO' in ad and ad['CRAB_UserVO']:
vo = ad['CRAB_UserVO']
if 'CRAB_UserGroup' in ad and ad['CRAB_UserGroup'] and ad['CRAB_UserGroup'] != classad.Value.Undefined:
group = ad['CRAB_UserGroup']
if 'CRAB_UserRole' in ad and ad['CRAB_UserRole'] and ad['CRAB_UserRole'] != classad.Value.Undefined:
role = ad['CRAB_UserRole']
proxycfg = {'vo': vo,
'logger': self.logger,
'myProxySvr': self.config.Services.MyProxy,
'myproxyAccount': self.config.TaskWorker.resturl,
'proxyValidity' : '144:0',
'min_time_left' : MINPROXYLENGTH, ## do we need this ? or should we use self.myproxylen?
'userDN' : ad['CRAB_UserDN'],
'group' : group,
'role' : role,
'server_key': self.config.MyProxy.serverhostkey,
'server_cert': self.config.MyProxy.serverhostcert,
'serverDN': self.config.MyProxy.serverdn,
'uisource': getattr(self.config.MyProxy, 'uisource', ''),
'credServerPath': self.config.MyProxy.credpath,
'cleanEnvironment' : getattr(self.config.MyProxy, 'cleanEnvironment', False)}
proxy = Proxy(proxycfg)
userproxy = proxy.getProxyFilename(serverRenewer=True)
proxy.logonRenewMyProxy()
timeleft = proxy.getTimeLeft(userproxy)
if timeleft is None or timeleft <= 0:
self.logger.error("Impossible to retrieve proxy from %s for %s." %(proxycfg['myProxySvr'], proxycfg['userDN']))
raise Exception("Failed to retrieve proxy.")
return userproxy
示例2: execute
# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import logonRenewMyProxy [as 别名]
def execute(self, *args, **kwargs):
result = None
proxycfg = {'vo': kwargs['task']['tm_user_vo'],
'logger': self.logger,
'myProxySvr': self.config.Services.MyProxy,
'proxyValidity' : '144:0',
'min_time_left' : 36000, ## do we need this ? or should we use self.myproxylen?
'userDN' : kwargs['task']['tm_user_dn'],
'group' : kwargs['task']['tm_user_group'] if kwargs['task']['tm_user_group'] else '',
'role' : kwargs['task']['tm_user_role'] if kwargs['task']['tm_user_role'] else '',
'server_key': self.config.MyProxy.serverhostkey,
'server_cert': self.config.MyProxy.serverhostcert,
'serverDN': self.config.MyProxy.serverdn,
'uisource': getattr(self.config.MyProxy, 'uisource', ''),
'credServerPath': self.config.MyProxy.credpath,
'myproxyAccount' : self.server['host'],
'cleanEnvironment' : getattr(self.config.MyProxy, 'cleanEnvironment', False)
}
proxy = Proxy(proxycfg)
userproxy = proxy.getProxyFilename(serverRenewer=True)
proxy.logonRenewMyProxy()
timeleft = proxy.getTimeLeft(userproxy)
if timeleft is None or timeleft <= 0:
msg = "Impossible to retrieve proxy from %s for %s." % (proxycfg['myProxySvr'], proxycfg['userDN'])
raise TaskWorkerException(msg)
else:
kwargs['task']['user_proxy'] = userproxy
result = Result(task=kwargs['task'], result='OK')
return result
示例3: execute
# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import logonRenewMyProxy [as 别名]
def execute(self, *args, **kwargs):
result = None
proxycfg = {'vo': kwargs['task']['tm_user_vo'],
'logger': self.logger,
'myProxySvr': self.config.Services.MyProxy,
'proxyValidity' : '144:0',
'min_time_left' : 36000, ## do we need this ? or should we use self.myproxylen?
'userDN' : kwargs['task']['tm_user_dn'],
'group' : kwargs['task']['tm_user_group'] if kwargs['task']['tm_user_group'] else '',
'role' : kwargs['task']['tm_user_role'] if kwargs['task']['tm_user_role'] else '',
'server_key': self.config.MyProxy.serverhostkey,
'server_cert': self.config.MyProxy.serverhostcert,
'serverDN': self.config.MyProxy.serverdn,
'uisource': getattr(self.config.MyProxy, 'uisource', ''),
'credServerPath': self.config.MyProxy.credpath,
'myproxyAccount' : self.server['host'],
'cleanEnvironment' : getattr(self.config.MyProxy, 'cleanEnvironment', False)
}
# WMCore proxy methods are awfully verbode, reduce logging level when using them
with tempSetLogLevel(logger=self.logger, level=logging.ERROR):
proxy = Proxy(proxycfg)
userproxy = proxy.getProxyFilename(serverRenewer=True)
proxy.logonRenewMyProxy()
timeleft = proxy.getTimeLeft(userproxy)
usergroups = set(proxy.getAllUserGroups(userproxy))
if timeleft is None or timeleft <= 0:
msg = "Impossible to retrieve proxy from %s for %s." % (proxycfg['myProxySvr'], proxycfg['userDN'])
self.logger.error(msg)
self.logger.error("\n Will try again in verbose mode")
self.logger.error("===========PROXY ERROR START ==========================")
with tempSetLogLevel(logger=self.logger, level=logging.DEBUG):
userproxy = proxy.getProxyFilename(serverRenewer=True)
proxy.logonRenewMyProxy()
timeleft = proxy.getTimeLeft(userproxy)
usergroups = set(proxy.getAllUserGroups(userproxy))
self.logger.error("===========PROXY ERROR END ==========================")
raise TaskWorkerException(msg)
else:
kwargs['task']['user_proxy'] = userproxy
kwargs['task']['user_groups'] = usergroups
self.logger.debug("Valid proxy for %s now in %s", proxycfg['userDN'], userproxy)
result = Result(task=kwargs['task'], result='OK')
return result
示例4: get_proxy
# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import logonRenewMyProxy [as 别名]
def get_proxy(self, ad):
result = None
vo = "cms"
group = ""
role = ""
if "CRAB_UserVO" in ad and ad["CRAB_UserVO"]:
vo = ad["CRAB_UserVO"]
if "CRAB_UserGroup" in ad and ad["CRAB_UserGroup"] and ad["CRAB_UserGroup"] != classad.Value.Undefined:
group = ad["CRAB_UserGroup"]
if "CRAB_UserRole" in ad and ad["CRAB_UserRole"] and ad["CRAB_UserRole"] != classad.Value.Undefined:
role = ad["CRAB_UserRole"]
print vo, group, role
proxycfg = {
"vo": vo,
"logger": self.logger,
"myProxySvr": self.config.Services.MyProxy,
"myproxyAccount": self.config.TaskWorker.resturl,
"proxyValidity": "144:0",
"min_time_left": MINPROXYLENGTH, ## do we need this ? or should we use self.myproxylen?
"userDN": ad["CRAB_UserDN"],
"group": group,
"role": role,
"server_key": self.config.MyProxy.serverhostkey,
"server_cert": self.config.MyProxy.serverhostcert,
"serverDN": self.config.MyProxy.serverdn,
"uisource": getattr(self.config.MyProxy, "uisource", ""),
"credServerPath": self.config.MyProxy.credpath,
"cleanEnvironment": getattr(self.config.MyProxy, "cleanEnvironment", False),
}
proxy = Proxy(proxycfg)
userproxy = proxy.getProxyFilename(serverRenewer=True)
proxy.logonRenewMyProxy()
timeleft = proxy.getTimeLeft(userproxy)
if timeleft is None or timeleft <= 0:
self.logger.error(
"Impossible to retrieve proxy from %s for %s." % (proxycfg["myProxySvr"], proxycfg["userDN"])
)
raise Exception("Failed to retrieve proxy.")
return userproxy
示例5: execute
# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import logonRenewMyProxy [as 别名]
def execute(self, *args, **kwargs):
result = None
proxycfg = {
"vo": kwargs["task"]["tm_user_vo"],
"logger": self.logger,
"myProxySvr": self.config.Services.MyProxy,
"proxyValidity": "24:0",
"min_time_left": 36000, ## do we need this ? or should we use self.myproxylen?
"userDN": kwargs["task"]["tm_user_dn"],
"group": kwargs["task"]["tm_user_group"] if kwargs["task"]["tm_user_group"] else "",
"role": kwargs["task"]["tm_user_role"] if kwargs["task"]["tm_user_role"] else "",
"server_key": self.config.MyProxy.serverhostkey,
"server_cert": self.config.MyProxy.serverhostcert,
"serverDN": self.config.MyProxy.serverdn,
"uisource": self.config.MyProxy.uisource,
"credServerPath": self.config.MyProxy.credpath,
}
proxy = Proxy(proxycfg)
userproxy = proxy.getProxyFilename(serverRenewer=True)
proxy.logonRenewMyProxy()
timeleft = proxy.getTimeLeft(userproxy)
if timeleft is None or timeleft <= 0:
msg = "Impossible to retrieve proxy from %s for %s." % (proxycfg["myProxySvr"], proxycfg["userDN"])
self.logger.error("Setting %s as failed" % str(kwargs["task"]["tm_taskname"]))
configreq = {
"workflow": kwargs["task"]["tm_taskname"],
"status": "FAILED",
"subresource": "failure",
"failure": b64encode(msg),
}
self.logger.error(str(configreq))
self.server.post(self.resturl, data=urllib.urlencode(configreq))
raise StopHandler(msg)
else:
kwargs["task"]["user_proxy"] = userproxy
result = Result(task=kwargs["task"], result="OK")
return result
示例6: getProxy
# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import logonRenewMyProxy [as 别名]
def getProxy(userdn, group, role, defaultDelegation, logger):
"""
_getProxy_
"""
log.debug("Retrieving proxy for %s" % userdn)
proxy = Proxy(defaultDelegation)
proxyPath = proxy.getProxyFilename( True )
timeleft = proxy.getTimeLeft( proxyPath )
if timeleft is not None and timeleft > 3600:
return (True, proxyPath)
proxyPath = proxy.logonRenewMyProxy()
timeleft = proxy.getTimeLeft( proxyPath )
if timeleft is not None and timeleft > 0:
return (True, proxyPath)
return (False, None)
示例7: execute
# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import logonRenewMyProxy [as 别名]
def execute(self, *args, **kwargs):
result = None
proxycfg = {'vo': kwargs['task']['tm_user_vo'],
'logger': self.logger,
'myProxySvr': self.config.Services.MyProxy,
'proxyValidity' : '144:0',
'min_time_left' : 36000, ## do we need this ? or should we use self.myproxylen?
'userDN' : kwargs['task']['tm_user_dn'],
'group' : kwargs['task']['tm_user_group'] if kwargs['task']['tm_user_group'] else '',
'role' : kwargs['task']['tm_user_role'] if kwargs['task']['tm_user_role'] else '',
'server_key': self.config.MyProxy.serverhostkey,
'server_cert': self.config.MyProxy.serverhostcert,
'serverDN': self.config.MyProxy.serverdn,
'uisource': getattr(self.config.MyProxy, 'uisource', ''),
'credServerPath': self.config.MyProxy.credpath,
'myproxyAccount' : self.server['host'],
'cleanEnvironment' : getattr(self.config.MyProxy, 'cleanEnvironment', False)
}
proxy = Proxy(proxycfg)
userproxy = proxy.getProxyFilename(serverRenewer=True)
proxy.logonRenewMyProxy()
timeleft = proxy.getTimeLeft(userproxy)
if timeleft is None or timeleft <= 0:
msg = "Impossible to retrieve proxy from %s for %s." %(proxycfg['myProxySvr'], proxycfg['userDN'])
self.logger.error("Setting %s as failed" % str(kwargs['task']['tm_taskname']))
configreq = {'workflow': kwargs['task']['tm_taskname'],
'status': "FAILED",
'subresource': 'failure',
'failure': b64encode(msg)}
self.logger.error(str(configreq))
self.server.post(self.resturi, data = urllib.urlencode(configreq))
raise StopHandler(msg)
else:
kwargs['task']['user_proxy'] = userproxy
result = Result(task=kwargs['task'], result='OK')
return result
示例8: getProxy
# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import logonRenewMyProxy [as 别名]
def getProxy(config, userdn, group, role):
"""
_getProxy_
"""
defaultDelegation = getDefaultDelegation(config, "cms", "myproxy.cern.ch", threading.currentThread().logger)
defaultDelegation['userDN'] = userdn
defaultDelegation['group'] = group
defaultDelegation['role'] = role
logging.debug("Retrieving proxy for %s" % userdn)
proxy = Proxy(defaultDelegation)
proxyPath = proxy.getProxyFilename( True )
timeleft = proxy.getTimeLeft( proxyPath )
if timeleft is not None and timeleft > 3600:
return (True, proxyPath)
proxyPath = proxy.logonRenewMyProxy()
timeleft = proxy.getTimeLeft( proxyPath )
if timeleft is not None and timeleft > 0:
return (True, proxyPath)
return (False, None)