本文整理汇总了Python中service.accounts.openstack.AccountDriver.create_user方法的典型用法代码示例。如果您正苦于以下问题:Python AccountDriver.create_user方法的具体用法?Python AccountDriver.create_user怎么用?Python AccountDriver.create_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类service.accounts.openstack.AccountDriver
的用法示例。
在下文中一共展示了AccountDriver.create_user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from service.accounts.openstack import AccountDriver [as 别名]
# 或者: from service.accounts.openstack.AccountDriver import create_user [as 别名]
def main():
"""
Generate openstack users then add them to the DB
"""
driver = AccountDriver(secrets.OPENSTACK_ARGS)
#Build the admin driver for openstack first.
driver.create_identity(secrets.OPENSTACK_ADMIN_KEY,
secrets.OPENSTACK_ADMIN_SECRET, secrets.OPENSTACK_ADMIN_TENANT,
True)
success = 1
#Add the others
core_services = ['atmo_test']#'sgregory', 'jmatt', 'edwins', 'cjlarose','mlent']
for username in core_services:
try:
password = driver.hashpass(username)
user = driver.get_user(username)
if not user:
user = driver.create_user(username, usergroup=True)
print 'New OStack User - %s Pass - %s' % (user.name,password)
else:
print 'Found OStack User - %s Pass - %s' % (user.name,password)
#ASSERT: User exists on openstack, create an identity for them.
ident = driver.create_identity(user.name, password, project_name=username)
success += 1
print 'New OStack Identity - %s:%s' % (ident.id, ident)
except Exception as e:
print "Problem adding username: %s" % username
print e
raise
print "Total users created:%s/%s" % (success,len(core_services))