本文整理汇总了Python中DIRAC.Interfaces.API.DiracAdmin.DiracAdmin.csModifyUser方法的典型用法代码示例。如果您正苦于以下问题:Python DiracAdmin.csModifyUser方法的具体用法?Python DiracAdmin.csModifyUser怎么用?Python DiracAdmin.csModifyUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.Interfaces.API.DiracAdmin.DiracAdmin
的用法示例。
在下文中一共展示了DiracAdmin.csModifyUser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addUserToCS
# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import csModifyUser [as 别名]
def addUserToCS(clip, userProps):
"""Add the user to the CS, return list of errors"""
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
diracAdmin = DiracAdmin()
exitCode = 0
errorList = []
if not diracAdmin.csModifyUser( clip.uname, userProps, createIfNonExistant = True )['OK']:
errorList.append( ( "add user", "Cannot register user: '%s'" % clip.uname ) )
exitCode = 255
else:
result = diracAdmin.csCommitChanges()
if not result[ 'OK' ]:
errorList.append( ( "commit", result[ 'Message' ] ) )
exitCode = 255
for error in errorList:
gLogger.error( "%s: %s" % error )
if exitCode:
dexit(exitCode)
示例2: in
# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import csModifyUser [as 别名]
forceCreation = True
elif unprocSw[0] in ( "p", "property" ):
prop = unprocSw[1]
pl = prop.split( "=" )
if len( pl ) < 2:
errorList.append( ( "in arguments", "Property %s has to include a '=' to separate name from value" % prop ) )
exitCode = 255
else:
pName = pl[0]
pValue = "=".join( pl[1:] )
print "Setting property %s to %s" % ( pName, pValue )
userProps[ pName ] = pValue
userName = args[0]
userProps[ 'DN' ] = args[1]
userProps[ 'Groups' ] = args[2:]
if not diracAdmin.csModifyUser( userName, userProps, createIfNonExistant = forceCreation ):
errorList.append( ( "modify user", "Cannot modify user %s" % userName ) )
exitCode = 255
else:
result = diracAdmin.csCommitChanges()
if not result[ 'OK' ]:
errorList.append( ( "commit", result[ 'Message' ] ) )
exitCode = 255
for error in errorList:
print "ERROR %s: %s" % error
DIRAC.exit( exitCode )
示例3: len
# 需要导入模块: from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin [as 别名]
# 或者: from DIRAC.Interfaces.API.DiracAdmin.DiracAdmin import csModifyUser [as 别名]
exitCode = 0
errorList = []
userProps = {"DN": userDN, "Email": userMail}
if userGroups:
userProps["Groups"] = userGroups
for prop in args:
pl = prop.split("=")
if len(pl) < 2:
errorList.append(("in arguments", "Property %s has to include a '=' to separate name from value" % prop))
exitCode = 255
else:
pName = pl[0]
pValue = "=".join(pl[1:])
Script.gLogger.info("Setting property %s to %s" % (pName, pValue))
userProps[pName] = pValue
if not diracAdmin.csModifyUser(userName, userProps, createIfNonExistant=True)["Value"]:
errorList.append(("add user", "Cannot register user %s" % userName))
exitCode = 255
else:
result = diracAdmin.csCommitChanges()
if not result["OK"]:
errorList.append(("commit", result["Message"]))
exitCode = 255
for error in errorList:
Script.gLogger.error("%s: %s" % error)
DIRAC.exit(exitCode)