本文整理汇总了Python中pyvcloud.vcd.org.Org.list_users方法的典型用法代码示例。如果您正苦于以下问题:Python Org.list_users方法的具体用法?Python Org.list_users怎么用?Python Org.list_users使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.org.Org
的用法示例。
在下文中一共展示了Org.list_users方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_users
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import list_users [as 别名]
def create_users(cls):
"""Creates users for each of the roles in CommonRoles.
Skips creating users which are already present in the organization.
:raises: Exception: if the class variable _org_href is not populated.
"""
cls._basic_check()
if cls._org_href is None:
raise Exception('Org ' + cls._config['vcd']['default_org_name'] +
' doesn\'t exist.')
org = Org(cls._sys_admin_client, href=cls._org_href)
for role_enum in cls._user_name_for_roles.keys():
user_name = cls._user_name_for_roles[role_enum]
user_records = list(
org.list_users(name_filter=('name', user_name)))
if len(user_records) > 0:
cls._logger.debug('Reusing existing user ' + user_name + '.')
cls._user_href_for_user_names[user_name] = \
user_records[0].get('href')
continue
role = org.get_role_record(role_enum.value)
cls._logger.debug('Creating user ' + user_name + '.')
user_resource = org.create_user(
user_name=user_name,
password=cls._config['vcd']['default_org_user_password'],
role_href=role.get('href'),
is_enabled=True)
cls._user_href_for_user_names[user_name] = \
user_resource.get('href')
示例2: list_users
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import list_users [as 别名]
def list_users(ctx, org_name):
try:
restore_session(ctx)
client = ctx.obj['client']
if org_name is not None:
org_href = client.get_org_by_name(org_name).get('href')
else:
org_href = ctx.obj['profiles'].get('org_href')
org = Org(client, href=org_href)
users = org.list_users()
result = []
for record in list(users):
result.append(
to_dict(
record,
exclude=[
'org', 'orgName', 'deployedVMQuotaRank',
'storedVMQuotaRank'
]))
stdout(result, ctx)
except Exception as e:
stderr(e, ctx)
示例3: test_00_list_users
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import list_users [as 别名]
def test_00_list_users(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
users = org.list_users()
assert len(users) > 0