当前位置: 首页>>代码示例>>Python>>正文


Python Org.list_users方法代码示例

本文整理汇总了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')
开发者ID:vmware,项目名称:pyvcloud,代码行数:34,代码来源:environment.py

示例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)
开发者ID:vmware,项目名称:vca-cli,代码行数:24,代码来源:user.py

示例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
开发者ID:vmware,项目名称:pyvcloud,代码行数:7,代码来源:vcd_user.py


注:本文中的pyvcloud.vcd.org.Org.list_users方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。