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


Python Org.get_name方法代码示例

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


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

示例1: share_catalog

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_name [as 别名]
    def share_catalog(cls):
        """Shares the test catalog with all members in the test organization.

        :raises: Exception: if the class variable _org_href is not populated.
        :raises: EntityNotFoundException: if the catalog in question is
            missing.
        """
        cls._basic_check()
        if cls._org_href is None:
            raise Exception('Org ' + cls._config['vcd']['default_org_name'] +
                            ' doesn\'t exist.')

        try:
            catalog_author_client = Environment.get_client_in_default_org(
                CommonRoles.CATALOG_AUTHOR)
            org = Org(catalog_author_client, href=cls._org_href)
            catalog_name = cls._config['vcd']['default_catalog_name']
            catalog_records = org.list_catalogs()
            for catalog_record in catalog_records:
                if catalog_record.get('name') == catalog_name:
                    cls._logger.debug('Sharing catalog ' + catalog_name + ' to'
                                      ' all members of org ' + org.get_name())
                    org.share_catalog_with_org_members(
                        catalog_name=catalog_name)
                    return
            raise EntityNotFoundException('Catalog ' + catalog_name +
                                          'doesn\'t exist.')
        finally:
            catalog_author_client.logout()
开发者ID:vmware,项目名称:pyvcloud,代码行数:31,代码来源:environment.py

示例2: delete_vm

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_name [as 别名]
def delete_vm(client):
    print("================= Vdc delete request ===================")
    vdc_name = "pcp_vdc_02"
    target_vm_name = "pcp_vm"
    org_resource = client.get_org()
    org = Org(client, resource=org_resource)
    print("Org name: ", org.get_name())
    print("Vdc name: ", vdc_name)

    vdc_resource = org.get_vdc(vdc_name)
    vdc = VDC(client, name=vdc_name, resource=vdc_resource)

    vapp_resource = vdc.get_vapp(vapp_name)
    vapp = VApp(client, name=vapp_name, resource=vapp_resource)

    delete_vapp_vm_resp = vapp.delete_vms(target_vm_name)
    task = client.get_task_monitor().wait_for_status(
        task=delete_vapp_vm_resp,
        timeout=60,
        poll_frequency=2,
        fail_on_statuses=None,
        expected_target_statuses=[
            TaskStatus.SUCCESS, TaskStatus.ABORTED, TaskStatus.ERROR,
            TaskStatus.CANCELED
        ],
        callback=None)

    st = task.get('status')
    if st == TaskStatus.SUCCESS.value:
        message = 'delete vdc status : {0} '.format(st)
        logging.info(message)
    else:
        raise errors.VCDVdcDeleteError(etree.tostring(task, pretty_print=True))
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:35,代码来源:test_vapp_vm.py

示例3: update_vdc

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_name [as 别名]
def update_vdc(client):
    print("================= Vdc update request ===================")
    vdc_name = "pcp_vdc_02"
    is_enabled = False

    org_resource = client.get_org()
    org = Org(client, resource=org_resource)
    print("Org name: ", org.get_name())
    print("Vdc name: ", vdc_name)

    vdc_resource = org.get_vdc(vdc_name)
    vdc = VDC(client, name=vdc_name, resource=vdc_resource)
    update_vdc_resp = vdc.enable_vdc(is_enabled)

    print("================= Vdc updated ===================")
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:17,代码来源:test_vapp_vm.py

示例4: Client

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_name [as 别名]
client = Client(cfg.vcd_host, verify_ssl_certs=False,
                log_file='pyvcloud.log',
                log_requests=True,
                log_headers=True,
                log_bodies=True)
client.set_highest_supported_version()
client.set_credentials(BasicLoginCredentials(cfg.vcd_admin_user,
                       "System", cfg.vcd_admin_password))

# Ensure the org exists.
print("Fetching org...")
try:
    # 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']))
开发者ID:vmware,项目名称:pyvcloud,代码行数:33,代码来源:tenant-onboard.py

示例5: create

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_name [as 别名]
def create(client):
    print("=============== __LOG__Create_VDC  =======================\n\n")

    vdc_name = "ACME_PAYG"
    vapp_name = "test2"

    org_resource = client.get_org()
    org = Org(client, resource=org_resource)
    print("Org name: ", org.get_name())
    print("Vdc name: ", vdc_name)

    try:
        vdc_resource = org.get_vdc(vdc_name)
        vdc = VDC(client, name=vdc_name, resource=vdc_resource)

        vapp_resource = vdc.get_vapp(vapp_name)
        vapp = VApp(client, name=vapp_name, resource=vapp_resource)
        print("vapp : ", vapp)

        catalog_item = org.get_catalog_item('ACME', 'tinyova')

        source_vapp_resource = client.get_resource(
            catalog_item.Entity.get('href'))

        print("source_vapp_resource: ", source_vapp_resource)

        spec = {
            'source_vm_name': 'Tiny Linux template',
            'vapp': source_vapp_resource
        }

        storage_profiles = [{
            'name': 'Performance',
            'enabled': True,
            'units': 'MB',
            'limit': 0,
            'default': True
        }]

        spec['target_vm_name'] = 'ubuntu_pcp_11'
        spec['hostname'] = 'ubuntu'
        spec['network'] = 'global'
        spec['ip_allocation_mode'] = 'dhcp'
        #spec['storage_profile'] = storage_profiles

        vms = [spec]
        result = vapp.add_vms(vms)

        print("result: ", result)
        #task = client.get_task_monitor().wait_for_status(
        #                    task=result,
        #                    timeout=60,
        #                    poll_frequency=2,
        #                    fail_on_statuses=None,
        #                    expected_target_statuses=[
        #                        TaskStatus.SUCCESS,
        #                        TaskStatus.ABORTED,
        #                        TaskStatus.ERROR,
        #                        TaskStatus.CANCELED],
        #                    callback=None)

        #st = task.get('status')
        #if st == TaskStatus.SUCCESS.value:
        #    message = 'status : {0} '.format(st)
        #    logging.info(message)
        #else:
        #    print("st : ", st)
        #    raise Exception(task)
        print("=============================================\n\n")
        return True
    except Exception as e:
        error_message = '__ERROR_ [create_vdc] failed for vdc {0} '.format(
            vdc_name)
        logging.warn(error_message, e)
        return False
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:77,代码来源:test_vapp_vm.py

示例6: read_vdc

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_name [as 别名]
def read_vdc(client):
    print("================= Vdc read request ===================")
    vdc_name = "pcp_vdc_03"
    org_resource = client.get_org()
    org = Org(client, resource=org_resource)
    print("Org name: ", org.get_name())
    print("Vdc name: ", vdc_name)

    vdc_resource = org.get_vdc(vdc_name)
    vdc = VDC(client, name=vdc_name, resource=vdc_resource)

    print("name = ", vdc_resource.get('name'))
    # res.provider_vdc = str(vdc_resource.provider_vdc)
    description = str(vdc_resource.Description)
    print("description = ", description)

    allocation_model = str(vdc_resource.AllocationModel)
    print("allocation_model = ", allocation_model)

    cpu_units = str(vdc_resource.ComputeCapacity.Cpu.Units)
    print("cpu_units = ", cpu_units)

    cpu_allocated = vdc_resource.ComputeCapacity.Cpu.Allocated
    print("cpu_allocated = ", cpu_allocated)

    cpu_limit = vdc_resource.ComputeCapacity.Cpu.Limit
    print("cpu_limit = ", cpu_limit)

    mem_units = vdc_resource.ComputeCapacity.Memory.Units
    print("mem_units = ", mem_units)

    mem_allocated = vdc_resource.ComputeCapacity.Memory.Allocated
    print("mem_allocated = ", mem_allocated)

    mem_limit = vdc_resource.ComputeCapacity.Memory.Limit
    print("mem_limit = ", mem_limit)

    nic_quota = vdc_resource.NicQuota
    print("nic_quota = ", nic_quota)

    network_quota = vdc_resource.NetworkQuota
    print("network_quota = ", network_quota)

    vm_quota = vdc_resource.VmQuota
    print("vm_quota = ", vm_quota)

    storage_profiles = str(
        vdc_resource.VdcStorageProfiles.VdcStorageProfile.get('name'))
    print("storage_profiles = ", storage_profiles)

    # res.resource_guaranteed_memory = str(vdc_resource.resource_guaranteed_memory)
    # res.resource_guaranteed_cpu = str(vdc_resource.resource_guaranteed_cpu)

    vcpu_in_mhz = vdc_resource.VCpuInMhz2
    print("vcpu_in_mhz = ", vcpu_in_mhz)

    # res.is_thin_provision = str(vdc_resource.is_thin_provision)
    # res.network_pool_name = str(vdc_resource.network_pool_name)
    # res.uses_fast_provisioning = str(vdc_resource.uses_fast_provisioning)
    # res.over_commit_allowed = str(vdc_resource.over_commit_allowed)
    # res.vm_discovery_enabled = str(vdc_resource.vm_discovery_enabled)

    is_enabled = vdc_resource.IsEnabled
    print("is_enabled = ", is_enabled)
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:66,代码来源:test_vapp_vm.py


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