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


Python Org.create_org_vdc方法代码示例

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


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

示例1: create

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import create_org_vdc [as 别名]
def create(ctx, name, pvdc_name, network_pool_name, allocation_model, sp_name,
           sp_limit, description, cpu_allocated, cpu_limit):
    try:
        restore_session(ctx)
        client = ctx.obj['client']
        in_use_org_href = ctx.obj['profiles'].get('org_href')
        org = Org(client, in_use_org_href)
        storage_profiles = [{
            'name': sp_name,
            'enabled': True,
            'units': 'MB',
            'limit': sp_limit,
            'default': True
        }]
        vdc_resource = org.create_org_vdc(
            name,
            pvdc_name,
            network_pool_name=network_pool_name,
            description=description,
            allocation_model=allocation_model,
            cpu_allocated=cpu_allocated,
            cpu_limit=cpu_limit,
            storage_profiles=storage_profiles,
            uses_fast_provisioning=True,
            is_thin_provision=True)
        stdout(vdc_resource.Tasks.Task[0], ctx)
    except Exception as e:
        stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:30,代码来源:vdc.py

示例2: test_create_vdc

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import create_org_vdc [as 别名]
 def test_create_vdc(self):
     org_to_use = self.client.get_org_by_name(
         self.config['vcd']['org_to_use'])
     org = Org(self.client, href=org_to_use.get('href'))
     storage_profiles = [{
         'name': self.config['vcd']['storage_profile'],
         'enabled': True,
         'units': 'MB',
         'limit': 0,
         'default': True
     }]
     vdc_resource = org.create_org_vdc(
         self.config['vcd']['new_vdc'],
         self.config['vcd']['provider_vdc'],
         network_pool_name=self.config['vcd']['network_pool'],
         description='description',
         allocation_model='AllocationVApp',
         cpu_allocated=0,
         cpu_limit=0,
         storage_profiles=storage_profiles,
         uses_fast_provisioning=True,
         is_thin_provision=True)
     task = self.client.get_task_monitor().wait_for_status(
         task=vdc_resource.Tasks.Task[0],
         timeout=30,
         poll_frequency=2,
         fail_on_statuses=None,
         expected_target_statuses=[
             TaskStatus.SUCCESS, TaskStatus.ABORTED, TaskStatus.ERROR,
             TaskStatus.CANCELED
         ],
         callback=None)
     assert task.get('status') == TaskStatus.SUCCESS.value
开发者ID:vmware,项目名称:pyvcloud,代码行数:35,代码来源:vcd_vdc.py

示例3: create_ovdc

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import create_org_vdc [as 别名]
    def create_ovdc(cls):
        """Creates an org vdc with the name specified in the config file.

        Skips creating one, if such an org vdc already exists. Also stores the
        href of the org vdc as class variable for future use.

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

        if cls._pvdc_name is None:
            raise Exception('pVDC ' + cls._config['vcd']['default_pvdc_name'] +
                            ' doesn\'t exist.')

        org = Org(cls._sys_admin_client, href=cls._org_href)
        ovdc_name = cls._config['vcd']['default_ovdc_name']
        for vdc in org.list_vdcs():
            if vdc.get('name').lower() == ovdc_name.lower():
                cls._logger.debug('Reusing existing ovdc ' + ovdc_name + '.')
                cls._ovdc_href = vdc.get('href')
                return

        storage_profiles = [{
            'name':
            cls._config['vcd']['default_storage_profile_name'],
            'enabled':
            True,
            'units':
            'MB',
            'limit':
            0,
            'default':
            True
        }]

        system = System(
            cls._sys_admin_client,
            admin_resource=cls._sys_admin_client.get_admin())
        netpool_to_use = cls._get_netpool_name_to_use(system)

        cls._logger.debug('Creating ovdc ' + ovdc_name + '.')
        vdc_resource = org.create_org_vdc(
            ovdc_name,
            cls._pvdc_name,
            network_pool_name=netpool_to_use,
            network_quota=cls._config['vcd']['default_network_quota'],
            storage_profiles=storage_profiles,
            uses_fast_provisioning=True,
            is_thin_provision=True)

        cls._sys_admin_client.get_task_monitor().wait_for_success(
            task=vdc_resource.Tasks.Task[0])

        org.reload()
        # The following contraption is required to get the non admin href of
        # the ovdc. vdc_resource contains the admin version of the href since
        # we created the ovdc as a sys admin.
        for vdc in org.list_vdcs():
            if vdc.get('name').lower() == ovdc_name.lower():
                cls._ovdc_href = vdc.get('href')
开发者ID:vmware,项目名称:pyvcloud,代码行数:66,代码来源:environment.py

示例4: VDC

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import create_org_vdc [as 别名]
# Ensure VDC exists.  If we create it reload the org as it affects
# org resource contents and future calls might fail otherwise.
try:
    vdc_resource = org.get_vdc(cfg.vdc['vdc_name'])
    vdc = VDC(client, resource=vdc_resource)
    print("VDC already exists: {0}".format(vdc.name))
except Exception:
    print("VDC does not exist, creating: {0}".format(cfg.vdc['vdc_name']))
    vdc_kwargs = cfg.vdc
    # Vet the netpool and pvcd arguments as either can be '*' in which 
    # case we need to find default values. 
    _fill_in_pvdc_default(client, vdc_kwargs)
    _fill_in_netpool_default(client, vdc_kwargs)
    # Now create the VDC.  
    admin_vdc_resource = org.create_org_vdc(**vdc_kwargs)
    # The 'admin_vdc_resource' is not a task but an AdminVdc entity.  Tasks
    # are two levels down.
    handle_task(client, admin_vdc_resource.Tasks.Task[0])
    org.reload()
    vdc_resource = org.get_vdc(cfg.vdc['vdc_name'])
    vdc = VDC(client, resource=vdc_resource)
    print("VDC now exists: {0}".format(vdc.name))

# Ensure the catalog exists.  For now we don't do anything special with
# permissions.  As with VDC's we reload the org if we create a catalog
# so that it's visible in future calls.
try:
    catalog_resource = org.get_catalog_resource(cfg.catalog['name'])
    print("Catalog already exists: {0}".format(cfg.catalog['name']))
except Exception:
开发者ID:vmware,项目名称:pyvcloud,代码行数:32,代码来源:tenant-onboard.py

示例5: create

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import create_org_vdc [as 别名]
    def create(self, provider_vdc_name, description, allocation_model,
               storage_profiles, cpu_units, cpu_allocated, cpu_limit,
               mem_units, mem_allocated, mem_limit, nic_quota, network_quota,
               vm_quota, resource_guaranteed_memory, resource_guaranteed_cpu,
               vcpu_in_mhz, is_thin_provision, network_pool_name,
               uses_fast_provisioning, over_commit_allowed,
               vm_discovery_enabled):
        logging.info("__INIT__create[Vdc]")

        res = vdc_pb2.CreateVdcResult()
        res.created = False

        context = self.context
        logged_in_org = self.client.get_org()
        org = Org(self.client, resource=logged_in_org)

        #Vdc details
        name = self.name
        is_enabled = self.is_enabled

        try:
            storage_profiles = json.loads(storage_profiles)
            if not network_pool_name.strip():
                network_pool_name = None

            create_vdc_resp = org.create_org_vdc(
                vdc_name=name,
                provider_vdc_name=provider_vdc_name,
                description=description,
                allocation_model=allocation_model,
                storage_profiles=storage_profiles,
                cpu_units=cpu_units,
                cpu_allocated=cpu_allocated,
                cpu_limit=cpu_limit,
                mem_units=mem_units,
                mem_allocated=mem_allocated,
                mem_limit=mem_limit,
                nic_quota=nic_quota,
                network_quota=network_quota,
                vm_quota=vm_quota,
                resource_guaranteed_memory=resource_guaranteed_memory,
                resource_guaranteed_cpu=resource_guaranteed_cpu,
                vcpu_in_mhz=vcpu_in_mhz,
                is_thin_provision=is_thin_provision,
                network_pool_name=network_pool_name,
                uses_fast_provisioning=uses_fast_provisioning,
                over_commit_allowed=over_commit_allowed,
                vm_discovery_enabled=vm_discovery_enabled,
                is_enabled=is_enabled)

            task = self.client.get_task_monitor().wait_for_status(
                task=create_vdc_resp.Tasks.Task[0],
                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.VCDVdcCreateError(
                    etree.tostring(task, pretty_print=True))

            res.created = True
        except Exception as e:
            error_message = '__ERROR_create[Vdc] failed for Vdc {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__create[Vdc]")
        return res
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:82,代码来源:vdc.py

示例6: Vdc

# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import create_org_vdc [as 别名]
class Vdc(VcdAnsibleModule):
    def __init__(self, **kwargs):
        super(Vdc, 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):
        vdc_name = self.params.get('vdc_name')
        is_enabled = self.params.get('is_enabled')
        provider_vdc_name = self.params.get('provider_vdc_name')
        description = self.params.get('description')
        allocation_model = self.params.get('allocation_model')
        storage_profiles = json.loads(self.params.get('storage_profiles'))
        cpu_units = self.params.get('cpu_units')
        cpu_allocated = self.params.get('cpu_allocated')
        cpu_limit = self.params.get('cpu_limit')
        mem_units = self.params.get('mem_units')
        mem_allocated = self.params.get('mem_allocated')
        mem_limit = self.params.get('mem_limit')
        nic_quota = self.params.get('nic_quota')
        network_quota = self.params.get('network_quota')
        vm_quota = self.params.get('vm_quota')
        resource_guaranteed_memory = self.params.get('resource_guaranteed_memory')
        resource_guaranteed_cpu = self.params.get('resource_guaranteed_cpu')
        vcpu_in_mhz = self.params.get('vcpu_in_mhz')
        is_thin_provision = self.params.get('is_thin_provision')
        network_pool_name = self.params.get('network_pool_name')
        uses_fast_provisioning = self.params.get('uses_fast_provisioning')
        over_commit_allowed = self.params.get('over_commit_allowed')
        vm_discovery_enabled = self.params.get('vm_discovery_enabled')
        storage_profiles = storage_profiles if type(storage_profiles) is list else [storage_profiles]
        response = dict()
        response['changed'] = False

        try:
            self.org.get_vdc(vdc_name)
        except EntityNotFoundException:
            create_vdc_task = self.org.create_org_vdc(
                vdc_name=vdc_name,
                provider_vdc_name=provider_vdc_name,
                description=description,
                allocation_model=allocation_model,
                storage_profiles=storage_profiles,
                cpu_units=cpu_units,
                cpu_allocated=cpu_allocated,
                cpu_limit=cpu_limit,
                mem_units=mem_units,
                mem_allocated=mem_allocated,
                mem_limit=mem_limit,
                nic_quota=nic_quota,
                network_quota=network_quota,
                vm_quota=vm_quota,
                resource_guaranteed_memory=resource_guaranteed_memory,
                resource_guaranteed_cpu=resource_guaranteed_cpu,
                vcpu_in_mhz=vcpu_in_mhz,
                is_thin_provision=is_thin_provision,
                network_pool_name=network_pool_name,
                uses_fast_provisioning=uses_fast_provisioning,
                over_commit_allowed=over_commit_allowed,
                vm_discovery_enabled=vm_discovery_enabled,
                is_enabled=is_enabled)

            self.execute_task(create_vdc_task.Tasks.Task[0])
            response['msg'] = 'VDC {} has been created.'.format(vdc_name)
            response['changed'] = True
        else:
            response['warnings'] = 'VDC {} is already present.'.format(vdc_name)

        return response

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

        vdc_resource = self.org.get_vdc(vdc_name)
        vdc = VDC(self.client, name=vdc_name, resource=vdc_resource)
        vdc.enable_vdc(enable=is_enabled)
        response['msg'] = 'VDC {} has been updated.'.format(vdc_name)
        response['changed'] = True

        return response

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

#.........这里部分代码省略.........
开发者ID:equinix-ms,项目名称:ansible-module-vcloud-director,代码行数:103,代码来源:vcd_org_vdc.py


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