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


Python Org.get_user方法代码示例

本文整理汇总了Python中pyvcloud.vcd.org.Org.get_user方法的典型用法代码示例。如果您正苦于以下问题:Python Org.get_user方法的具体用法?Python Org.get_user怎么用?Python Org.get_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyvcloud.vcd.org.Org的用法示例。


在下文中一共展示了Org.get_user方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_user [as 别名]
    def read(self):
        logging.info("__INIT__read[User]")
        res = user_pb2.ReadUserResult()
        res.present = False
        context = self.context

        logged_in_org = self.client.get_org()
        org = Org(self.client, resource=logged_in_org)
        try:
            result = org.get_user(self.name)

            res.present = True
            res.is_enabled = result.IsEnabled
            res.name = str(result.NameInSource)
            res.role_name = str(result.Role.get('name'))

            res.full_name = str(result.FullName)

            #description not available
            #res.description = result.DESCRIPTION

            res.email = str(result.EmailAddress)
            res.telephone = str(result.Telephone)
            res.im = str(result.IM)

            #alert_email not available
            #res.alert_email = result.Role.ALERT_EMAIL

            #alert_email_prefix not available
            #res.alert_email_prefix = result.ALERT_EMAIL_PREFIX

            res.stored_vm_quota = result.StoredVmQuota
            res.deployed_vm_quota = result.DeployedVmQuota
            res.is_group_role = result.IsGroupRole

            #is_default_cached not available
            #res.is_default_cached = result.Role.get('name')

            res.is_external = result.IsExternal

            #is_alert_enabled not available
            #res.is_alert_enabled = result.Role.get('name')

            res.is_enabled = result.IsEnabled
        except Exception as e:
            error_message = '__ERROR_read[user] failed for user {0}. __ErrorMessage__ {1}'.format(
                self.name, str(e))
            logging.warn(error_message)
            #context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
            #context.set_details(error_message)
            return res
        logging.info("__DONE__read[User]")
        return res
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:55,代码来源:user.py

示例2: test_11_change_owner

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_user [as 别名]
    def test_11_change_owner(self):
        logged_in_org = self.client.get_org()
        org = Org(self.client, resource=logged_in_org)
        vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
        user_resource = org.get_user(self.config['vcd']['new_vapp_user'])
        vdc = VDC(self.client, href=vdc_resource.get('href'))
        vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
        vapp = VApp(self.client, resource=vapp_resource)
        vapp.change_owner(user_resource.get('href'))

        vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
        assert self.config['vcd']['new_vapp_user'] == \
            vapp_resource.Owner.User.get('name')
开发者ID:vmware,项目名称:pyvcloud,代码行数:15,代码来源:vcd_vapp.py

示例3: change_owner

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_user [as 别名]
def change_owner(ctx, vapp_name, user_name):
    try:
        restore_session(ctx, vdc_required=True)
        client = ctx.obj['client']
        vdc_href = ctx.obj['profiles'].get('vdc_href')
        vdc = VDC(client, href=vdc_href)
        in_use_org_href = ctx.obj['profiles'].get('org_href')
        org = Org(client, in_use_org_href)
        user_resource = org.get_user(user_name)
        vapp_resource = vdc.get_vapp(vapp_name)
        vapp = VApp(client, resource=vapp_resource)
        vapp.change_owner(user_resource.get('href'))
        stdout('vapp owner changed', ctx)
    except Exception as e:
        stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:17,代码来源:vapp.py

示例4: test_050_change_idisk_owner

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_user [as 别名]
    def test_050_change_idisk_owner(self):
        logged_in_org = self.client.get_org()
        org = Org(self.client, resource=logged_in_org)
        vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
        vdc = VDC(self.client, resource=vdc_resource)

        user_resource = org.get_user(
            self.config['vcd']['idisk_new_owner_name'])

        vdc.change_disk_owner(name=self.config['vcd']['idisk_name'],
                              user_href=user_resource.get('href'))

        disk_resource = vdc.get_disk(self.config['vcd']['idisk_name'])
        new_user = disk_resource.Owner.User.get('name')

        assert self.config['vcd']['idisk_new_owner_name'] == new_user
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:18,代码来源:vcd_disk.py

示例5: change_disk_owner

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_user [as 别名]
def change_disk_owner(ctx, disk_name, user_name):
    try:
        restore_session(ctx, vdc_required=True)
        client = ctx.obj['client']
        vdc_href = ctx.obj['profiles'].get('vdc_href')
        vdc = VDC(client, href=vdc_href)
        in_use_org_href = ctx.obj['profiles'].get('org_href')
        org = Org(client, in_use_org_href)
        user_resource = org.get_user(user_name)
        disk_name, disk_id = extract_name_and_id(disk_name)
        vdc.change_disk_owner(
            user_href=user_resource.get('href'),
            name=disk_name,
            disk_id=disk_id)
        stdout('Owner of disk \'%s\' changed to \'%s\'' % (disk_name,
                                                           user_name), ctx)
    except Exception as e:
        stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:20,代码来源:disk.py

示例6: Org

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_user [as 别名]
    # This call gets a record that we can turn into an Org class.
    org_record = client.get_org_by_name(cfg.org)
    org = Org(client, href=org_record.get('href'))
    print("Org already exists: {0}".format(org.get_name()))
except Exception:
    print("Org does not exist, creating: {0}".format(cfg.org))
    sys_admin_resource = client.get_admin()
    system = System(client, admin_resource=sys_admin_resource)
    admin_org_resource = system.create_org(cfg.org, "Test Org", True)
    org_record = client.get_org_by_name(cfg.org)
    org = Org(client, href=org_record.get('href'))
    print("Org now exists: {0}".format(org.get_name()))

# Ensure user exists on the org.
try:
    user_resource = org.get_user(cfg.user['name'])
    print("User already exists: {0}".format(cfg.user['name']))
except Exception:
    print("User does not exist, creating: {0}".format(cfg.user['name']))
    role_record = org.get_role_record(cfg.user['role'])
    user_resource = org.create_user(user_name=cfg.user['name'],
                                    password=cfg.user['password'],
                                    role_href=role_record.get('href'))
    print("User now exists: {0}".format(user_resource.get('name')))

# Ensure the user is enabled.  We could also do so when creating the user
# but this approach will also fix an existing user who is disabled.
user_dict = to_dict(user_resource)
if user_dict.get('IsEnabled') == 'true':
    print("User is enabled: {0}".format(user_dict.get('name')))
else:
开发者ID:vmware,项目名称:pyvcloud,代码行数:33,代码来源:tenant-onboard.py

示例7: User

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_user [as 别名]
class User(VcdAnsibleModule):
    def __init__(self, **kwargs):
        super(User, self).__init__(**kwargs)
        logged_in_org = self.client.get_org()
        self.org = Org(self.client, resource=logged_in_org)

    def manage_states(self):
        state = self.params.get('state')
        if state == "present":
            return self.create()

        if state == "absent":
            return self.delete()

        if state == "update":
            return self.update()

    def create(self):
        params = self.params
        role = self.org.get_role_record(params.get('role_name'))
        role_href = role.get('href')
        username = params.get('username')
        userpassword = params.get('userpassword')
        full_username = params.get('full_username')
        description = params.get('description')
        email = params.get('email')
        telephone = params.get('telephone')
        im = params.get('im')
        alert_email = params.get('alert_email')
        alert_email_prefix = params.get('alert_email_prefix')
        stored_vm_quota = params.get('stored_vm_quota')
        deployed_vm_quota = params.get('deployed_vm_quota')
        is_group_role = params.get('is_group_role')
        is_default_cached = params.get('is_default_cached')
        is_external = params.get('is_external')
        is_alert_enabled = params.get('is_alert_enabled')
        is_enabled = params.get('is_enabled')
        response = dict()
        response['changed'] = False

        try:
            self.org.get_user(username)
        except EntityNotFoundException:
            self.org.create_user(
                username, userpassword, role_href, full_username, description,
                email, telephone, im, alert_email, alert_email_prefix,
                stored_vm_quota, deployed_vm_quota, is_group_role,
                is_default_cached, is_external, is_alert_enabled,
                is_enabled)
            response['msg'] = "User {} has been created.".format(username)
            response['changed'] = True
        else:
            response['warnings'] = "User {} is already present.".format(username)

        return response

    def delete(self):
        username = self.params.get('username')
        response = dict()
        response['changed'] = False

        try:
            self.org.get_user(username)
        except EntityNotFoundException:
            response['warnings'] = "User {} is not present.".format(username)
        else:
            self.org.delete_user(username)
            response['msg'] = "User {} has been deleted.".format(username)
            response['changed'] = True

        return response

    def update(self):
        username = self.params.get('username')
        enabled = self.params.get('is_enabled')
        response = dict()
        response['changed'] = False

        self.org.get_user(username)
        self.org.update_user(username, enabled)
        response['msg'] = "User {} has been updated".format(username)
        response['changed'] = True

        return response
开发者ID:equinix-ms,项目名称:ansible-module-vcloud-director,代码行数:86,代码来源:vcd_user.py


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