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


Python VDC.create_vapp方法代码示例

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


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

示例1: create

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import create_vapp [as 别名]
def create(ctx, name, description, catalog, template, network, memory, cpu,
           disk_size, ip_allocation_mode, vm_name, hostname, storage_profile,
           accept_all_eulas):
    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)
        if catalog is None and template is None:
            vapp_resource = vdc.create_vapp(
                name,
                description=description,
                network=network,
                accept_all_eulas=accept_all_eulas)
        else:
            vapp_resource = vdc.instantiate_vapp(
                name,
                catalog,
                template,
                description=description,
                network=network,
                memory=memory,
                cpu=cpu,
                disk_size=disk_size,
                deploy=True,
                power_on=True,
                accept_all_eulas=accept_all_eulas,
                cust_script=None,
                ip_allocation_mode=ip_allocation_mode,
                vm_name=vm_name,
                hostname=hostname,
                storage_profile=storage_profile)
        stdout(vapp_resource.Tasks.Task[0], ctx)
    except Exception as e:
        stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:37,代码来源:vapp.py

示例2: test_0001_create_vapp

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import create_vapp [as 别名]
 def test_0001_create_vapp(self):
     logged_in_org = self.client.get_org()
     org = Org(self.client, resource=logged_in_org)
     v = org.get_vdc(self.config['vcd']['vdc'])
     vdc = VDC(self.client, href=v.get('href'))
     assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
     result = vdc.create_vapp(self.config['vcd']['vapp'],
                              network=self.config['vcd']['network'],
                              fence_mode=self.config['vcd']['fence_mode'])
     task = self.client.get_task_monitor().wait_for_status(
                         task=result.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)
     assert task.get('status') == TaskStatus.SUCCESS.value
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:23,代码来源:vcd_vapp_vm.py

示例3: Vapp

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import create_vapp [as 别名]
class Vapp(VcdAnsibleModule):
    def __init__(self, **kwargs):
        super(Vapp, self).__init__(**kwargs)
        logged_in_org = self.client.get_org()
        self.org = Org(self.client, resource=logged_in_org)
        vdc_resource = self.org.get_vdc(self.params.get('vdc'))
        self.vdc = VDC(self.client, href=vdc_resource.get('href'))

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

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

    def manage_operations(self):
        state = self.params.get('operation')
        if state == "poweron":
            return self.power_on()

        if state == "poweroff":
            return self.power_off()

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

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

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

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

    def instantiate(self):
        params = self.params
        vapp_name = params.get('vapp_name')
        catalog_name = params.get('catalog_name')
        template_name = params.get('template_name')
        description = params.get('description')
        network = params.get('network')
        fence_mode = params.get('fence_mode')
        ip_allocation_mode = params.get('ip_allocation_mode')
        deploy = params.get('deploy')
        power_on = params.get('power_on')
        accept_all_eulas = params.get('accept_all_eulas')
        memory = params.get('memory')
        cpu = params.get('cpu')
        disk_size = params.get('disk_size')
        vmpassword = params.get('vmpassword')
        cust_script = params.get('cust_script')
        vm_name = params.get('vm_name')
        hostname = params.get('hostname')
        ip_address = params.get('ip_address')
        storage_profile = params.get('storage_profile')
        network_adapter_type = params.get('network_adapter_type')
        response = dict()
        response['changed'] = False

        try:
            self.vdc.get_vapp(vapp_name)
        except EntityNotFoundException:
            create_vapp_task = self.vdc.instantiate_vapp(
                name=vapp_name,
                catalog=catalog_name,
                template=template_name,
                description=description,
                network=network,
                fence_mode=fence_mode,
                ip_allocation_mode=ip_allocation_mode,
                deploy=deploy,
                power_on=power_on,
                accept_all_eulas=accept_all_eulas,
                memory=memory,
                cpu=cpu,
                disk_size=disk_size,
                password=vmpassword,
                cust_script=cust_script,
                vm_name=vm_name,
                hostname=hostname,
                ip_address=ip_address,
                storage_profile=storage_profile,
                network_adapter_type=network_adapter_type)
            self.execute_task(create_vapp_task.Tasks.Task[0])
            response['msg'] = 'Vapp {} has been created.'.format(vapp_name)
            response['changed'] = True
        else:
            response['warnings'] = "Vapp {} is already present.".format(vapp_name)

        return response

    def create(self):
        params = self.params
        vapp_name = params.get('vapp_name')
#.........这里部分代码省略.........
开发者ID:equinix-ms,项目名称:ansible-module-vcloud-director,代码行数:103,代码来源:vcd_vapp.py


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