本文整理汇总了Python中WMCore.Credential.Proxy.Proxy.getAttributeFromProxy方法的典型用法代码示例。如果您正苦于以下问题:Python Proxy.getAttributeFromProxy方法的具体用法?Python Proxy.getAttributeFromProxy怎么用?Python Proxy.getAttributeFromProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMCore.Credential.Proxy.Proxy
的用法示例。
在下文中一共展示了Proxy.getAttributeFromProxy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getAttributeFromProxy [as 别名]
def __init__(self, config):
BasePlugin.__init__(self, config)
self.locationDict = {}
myThread = threading.currentThread()
daoFactory = DAOFactory(package="WMCore.WMBS", logger=myThread.logger,
dbinterface=myThread.dbi)
self.locationAction = daoFactory(classname="Locations.GetSiteInfo")
self.packageDir = None
if os.path.exists(os.path.join(getWMBASE(),
'src/python/WMCore/WMRuntime/Unpacker.py')):
self.unpacker = os.path.join(getWMBASE(),
'src/python/WMCore/WMRuntime/Unpacker.py')
else:
self.unpacker = os.path.join(getWMBASE(),
'WMCore/WMRuntime/Unpacker.py')
self.agent = getattr(config.Agent, 'agentName', 'WMAgent')
self.sandbox = None
self.scriptFile = config.JobSubmitter.submitScript
self.defaultTaskPriority = getattr(config.BossAir, 'defaultTaskPriority', 0)
self.maxTaskPriority = getattr(config.BossAir, 'maxTaskPriority', 1e7)
self.jobsPerSubmit = getattr(config.JobSubmitter, 'jobsPerSubmit', 200)
self.extraMem = getattr(config.JobSubmitter, 'extraMemoryPerCore', 500)
# Required for global pool accounting
self.acctGroup = getattr(config.BossAir, 'acctGroup', "production")
self.acctGroupUser = getattr(config.BossAir, 'acctGroupUser', "cmsdataops")
# Build a requirement string. All CMS resources match DESIRED_Sites on the START
# expression side; however, there are currently some resources (T2_CH_CERN_HLT)
# that are missing the REQUIRED_OS logic. Hence, we duplicate it here.
# TODO(bbockelm): Remove reqStr once HLT has upgraded.
self.reqStr = ('((REQUIRED_OS=?="any") || '
'(GLIDEIN_REQUIRED_OS =?= "any") || '
'stringListMember(GLIDEIN_REQUIRED_OS, REQUIRED_OS)) && '
'(AuthenticatedIdentity =!= "[email protected]")')
if hasattr(config.BossAir, 'condorRequirementsString'):
self.reqStr = config.BossAir.condorRequirementsString
# x509 proxy handling
proxy = Proxy({'logger': myThread.logger})
self.x509userproxy = proxy.getProxyFilename()
self.x509userproxysubject = proxy.getSubject()
self.x509userproxyfqan = proxy.getAttributeFromProxy(self.x509userproxy)
# Remove the x509 ads if the job is matching a volunteer resource
self.x509Expr = 'ifThenElse("$$(GLIDEIN_CMSSite)" =?= "T3_CH_Volunteer",undefined,"%s")'
return
示例2: ProxyTest
# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getAttributeFromProxy [as 别名]
#.........这里部分代码省略.........
Verify that the getSubject() method works correctly.
"""
subject = self.proxy.getSubject()
self.assertEqual(subject, self.getUserIdentity(), "Error: Wrong subject.")
return
@attr("integration")
def testGetUserName(self):
"""
_testGetUserName_
Verify that the getUserName() method correctly determines the user's
name.
"""
user = self.proxy.getUserName()
identity = self.getUserIdentity().split("/")[len(self.getUserIdentity().split("/")) - 1][3:]
self.assertEqual(user, identity, "Error: User name is wrong: |%s|\n|%s|" % (user, identity))
return
@attr("integration")
def testCheckAttribute(self):
"""
Test if the checkAttribute method checks correctly the attributes validity.
"""
valid = self.proxy.checkAttribute()
self.assertTrue(valid)
@attr("integration")
def testCheckTimeLeft(self):
"""
Test if the check method checks correctly the proxy validity.
"""
valid = self.proxy.check(self.proxyPath)
self.assertTrue(valid)
@attr("integration")
def testVomsRenewal(self):
"""
Test if vomsExtensionRenewal method renews correctly the voms-proxy.
"""
proxyPath = self.proxy.getProxyFilename()
time.sleep(70)
attribute = self.proxy.prepareAttForVomsRenewal(self.proxy.getAttributeFromProxy(proxyPath))
self.proxy.vomsExtensionRenewal(proxyPath, attribute)
vomsTimeLeft = self.proxy.getVomsLife(proxyPath)
self.assertEqual(int(vomsTimeLeft) / 3600, 191)
@attr("integration")
def testElevateAttribute(self):
"""
Test if the vomsExtensionRenewal method elevate last attributes given.
"""
proxyPath = self.proxy.getProxyFilename()
attribute = self.proxy.prepareAttForVomsRenewal("/cms/Role=NULL/Capability=NULL")
self.proxy.vomsExtensionRenewal(proxyPath, attribute)
self.assertEqual(self.proxy.getAttributeFromProxy(proxyPath), "/cms/Role=NULL/Capability=NULL")
# Restore the original configuration of the proxy
self.proxy.create()
@attr("integration")
def testUserGroupInProxy(self):
"""
Test if getUserAttributes method returns correctly the user group.
"""
self.assertTrue(self.proxy.group, "No group set. Testing incomplete.")
self.assertEqual(self.proxy.group, self.getUserAttributes().split("\n")[0].split("/")[2])
@attr("integration")
def testUserRoleInProxy(self):
"""
Test if getUserAttributes method returns correctly the user role.
"""
self.assertEqual(self.proxy.role, self.getUserAttributes().split("\n")[0].split("/")[3].split("=")[1])
@attr("integration")
def testGetAttributes(self):
"""
Test getAttributeFromProxy method.
"""
self.assertTrue(self.proxy.group, "No group set. Testing incomplete.")
if not self.dict["role"]:
role = "NULL"
else:
role = self.dict["role"]
proxyPath = self.proxy.getProxyFilename()
self.assertEqual(self.proxy.getAttributeFromProxy(proxyPath).split("/")[2], self.dict["group"])
self.assertEqual(self.proxy.getAttributeFromProxy(proxyPath).split("/")[3].split("=")[1], role)
@attr("integration")
def testGetUserGroupAndRole(self):
"""
Test GetUserGroupAndRoleFromProxy method.
"""
if not self.dict["role"]:
role = "NULL"
else:
role = self.dict["role"]
proxyPath = self.proxy.getProxyFilename()
if self.dict["group"] and self.dict["role"]:
self.assertEqual(self.proxy.getUserGroupAndRoleFromProxy(proxyPath)[0], self.dict["group"])
self.assertEqual(self.proxy.getUserGroupAndRoleFromProxy(proxyPath)[1], role)
示例3: ProxyTest
# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getAttributeFromProxy [as 别名]
#.........这里部分代码省略.........
_testGetUserName_
Verify that the getUserName() method correctly determines the user's
name.
"""
user = self.proxy.getUserName( )
identity = self.getUserIdentity().split("/")[ len(self.getUserIdentity().split("/")) - 1 ][3:]
self.assertEqual(user, identity,
"Error: User name is wrong: |%s|\n|%s|" % (user, identity))
return
@attr("integration")
def testCheckAttribute( self ):
"""
Test if the checkAttribute method checks correctly the attributes validity.
"""
valid = self.proxy.checkAttribute( )
self.assertTrue(valid)
@attr("integration")
def testCheckTimeLeft( self ):
"""
Test if the check method checks correctly the proxy validity.
"""
valid = self.proxy.check( self.proxyPath )
self.assertTrue(valid)
@attr("integration")
def testVomsRenewal( self ):
"""
Test if vomsExtensionRenewal method renews correctly the voms-proxy.
"""
proxyPath = self.proxy.getProxyFilename( )
time.sleep( 70 )
attribute = self.proxy.prepareAttForVomsRenewal( self.proxy.getAttributeFromProxy( proxyPath ) )
self.proxy.vomsExtensionRenewal( proxyPath, attribute )
vomsTimeLeft = self.proxy.getVomsLife( proxyPath )
self.assertEqual(int(vomsTimeLeft) / 3600, 191)
@attr("integration")
def testElevateAttribute( self ):
"""
Test if the vomsExtensionRenewal method elevate last attributes given.
"""
proxyPath = self.proxy.getProxyFilename( )
attribute = self.proxy.prepareAttForVomsRenewal( '/cms/Role=NULL/Capability=NULL' )
self.proxy.vomsExtensionRenewal( proxyPath, attribute )
self.assertEqual(self.proxy.getAttributeFromProxy(proxyPath), '/cms/Role=NULL/Capability=NULL')
# Restore the original configuration of the proxy
self.proxy.create()
@attr("integration")
def testUserGroupInProxy( self ):
"""
Test if getUserAttributes method returns correctly the user group.
"""
self.assertTrue(self.proxy.group, 'No group set. Testing incomplete.')
self.assertEqual(self.proxy.group, self.getUserAttributes().split('\n')[0].split('/')[2])
@attr("integration")
def testUserRoleInProxy( self ):
"""
Test if getUserAttributes method returns correctly the user role.
"""
self.assertEqual(self.proxy.role, self.getUserAttributes().split('\n')[0].split('/')[3].split('=')[1])
@attr("integration")