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


Python VDC.get_vapp方法代码示例

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


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

示例1: test_11_change_owner

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [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

示例2: test_0002_add_vm

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [as 别名]
 def test_0002_add_vm(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, href=vdc_resource.get('href'))
     assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
     vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
     assert vapp_resource.get('name') == self.config['vcd']['vapp']
     vapp = VApp(self.client, resource=vapp_resource)
     catalog_item = org.get_catalog_item(self.config['vcd']['catalog'],
                                         self.config['vcd']['template'])
     source_vapp_resource = self.client.get_resource(
         catalog_item.Entity.get('href'))
     spec = {'source_vm_name': self.config['vcd']['vm'],
             'vapp': source_vapp_resource}
     spec['target_vm_name'] = self.config['vcd']['hostname']
     spec['hostname'] = self.config['vcd']['hostname']
     spec['network'] = self.config['vcd']['network']
     spec['ip_allocation_mode'] = self.config['vcd']['ip_allocation_mode']
     spec['storage_profile'] = vdc.get_storage_profile(
         self.config['vcd']['storage_profile'])
     vms = [spec]
     result = vapp.add_vms(vms)
     task = self.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)
     assert task.get('status') == TaskStatus.SUCCESS.value
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:37,代码来源:vcd_vapp_vm.py

示例3: test_100_instantiate_vapp_identical

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [as 别名]
 def test_100_instantiate_vapp_identical(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.instantiate_vapp(
         self.config['vcd']['vapp'],
         self.config['vcd']['catalog'],
         self.config['vcd']['template'],
         network=self.config['vcd']['network'],
         fence_mode='bridged',
         deploy=True,
         power_on=False,
         identical=True)
     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
     vdc.reload()
     vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
     vm = vapp_resource.xpath(
         '//vcloud:VApp/vcloud:Children/vcloud:Vm', namespaces=NSMAP)
     assert len(vm) > 0
     assert vm[0].get('name') == self.config['vcd']['vm']
开发者ID:vmware,项目名称:pyvcloud,代码行数:34,代码来源:vcd_vapp.py

示例4: capture

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [as 别名]
def capture(ctx, name, catalog, template, customizable, description):
    try:
        restore_session(ctx, vdc_required=True)
        client = ctx.obj['client']
        in_use_org_href = ctx.obj['profiles'].get('org_href')
        org = Org(client, in_use_org_href)
        catalog_resource = org.get_catalog(catalog)
        vdc_href = ctx.obj['profiles'].get('vdc_href')
        vdc = VDC(client, href=vdc_href)
        vapp_resource = vdc.get_vapp(name)
        overwrite = False
        if template is None:
            template = vapp_resource.get('name')
        else:
            overwrite = True
        task = org.capture_vapp(
            catalog_resource,
            vapp_href=vapp_resource.get('href'),
            catalog_item_name=template,
            description=description,
            customize_on_instantiate=customizable == 'customizable',
            overwrite=overwrite)
        stdout(task, ctx)
    except Exception as e:
        stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:27,代码来源:vapp.py

示例5: delete_vm

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [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

示例6: test_1006_snapshot_create

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [as 别名]
 def test_1006_snapshot_create(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)
     assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
     vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
     assert vapp_resource.get('name') == self.config['vcd']['vapp']
     vapp = VApp(self.client, resource=vapp_resource)
     vm_resource = vapp.get_vm(self.config['vcd']['vm'])
     assert vm_resource.get('name') == self.config['vcd']['vm']
     vm = VM(self.client, resource=vm_resource)
     task = vm.snapshot_create(memory=False, quiesce=False)
     task = self.client.get_task_monitor().wait_for_status(
                         task=task,
                         timeout=120,
                         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,代码行数:27,代码来源:vcd_vm.py

示例7: test_1002_deploy_vm

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [as 别名]
 def test_1002_deploy_vm(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')
     vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
     assert vapp_resource.get('name') == self.config['vcd']['vapp']
     vapp = VApp(self.client, resource=vapp_resource)
     vm_resource = vapp.get_vm(self.config['vcd']['vm'])
     vm = VM(self.client, resource=vm_resource)
     result = vm.deploy()
     # result = vm.shutdown()
     task = self.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)
     assert task.get('status') == TaskStatus.SUCCESS.value
开发者ID:vmware,项目名称:pyvcloud,代码行数:27,代码来源:vcd_vm.py

示例8: test_060_attach_disk_to_vm_in_vapp

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [as 别名]
    def test_060_attach_disk_to_vm_in_vapp(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)
        assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')

        vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
        assert self.config['vcd']['vapp'] == vapp_resource.get('name')
        vapp = VApp(self.client, resource=vapp_resource)

        disk = vdc.get_disk(self.config['vcd']['idisk_name'])

        result = vapp.attach_disk_to_vm(disk_href=disk.get('href'),
                                        vm_name=self.config['vcd']['vm'])
        task = self.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)
        assert task.get('status') == TaskStatus.SUCCESS.value
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:29,代码来源:vcd_disk.py

示例9: test_0002_modify_memory

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [as 别名]
 def test_0002_modify_memory(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)
     assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
     vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
     vapp = VApp(self.client, resource=vapp_resource)
     vm_resource = vapp.get_vm(self.config['vcd']['vm'])
     vm = VM(self.client, resource=vm_resource)
     task = vm.modify_memory(self.config['vcd']['memory'])
     task = self.client.get_task_monitor().wait_for_status(
                         task=task,
                         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
     vm.reload()
     assert vm.get_memory() == self.config['vcd']['memory']
开发者ID:vmware,项目名称:pyvcloud,代码行数:27,代码来源:vcd_vm.py

示例10: capture_vapp

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [as 别名]
    def capture_vapp(self):
        params = self.params
        vapp_name = params.get('vapp_name')
        vdc_name = params.get('vdc_name')
        catalog_name = params.get('catalog_name')
        item_name = params.get('item_name')
        desc = params.get('description')
        customize_on_instantiate = params.get('customize_on_instantiate')
        overwrite = params.get('overwrite')
        client = self.client
        response = dict()
        response['changed'] = False

        v = self.org.get_vdc(vdc_name)
        vdc = VDC(client, href=v.get('href'))
        vapp = vdc.get_vapp(vapp_name)
        catalog = self.org.get_catalog(catalog_name)
        self.org.capture_vapp(
            catalog_resource=catalog,
            vapp_href=vapp.get('href'),
            catalog_item_name=item_name,
            description=desc,
            customize_on_instantiate=customize_on_instantiate,
            overwrite=overwrite)
        self.ova_check_resolved()
        response['msg'] = "Catalog Item {} has been captured".format(item_name)
        response['changed'] = True

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

示例11: read

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [as 别名]
    def read(self, request):
        logging.info("__INIT__read[VappVm]")
        res = vapp_vm_pb2.ReadVappVmResult()
        res.present = False
        org_resource = self.client.get_org()
        org = Org(self.client, resource=org_resource)
        try:
            vdc_resource = org.get_vdc(request.target_vdc)
            vdc = VDC(
                self.client, name=request.target_vdc, resource=vdc_resource)

            vapp_resource = vdc.get_vapp(request.target_vapp)
            vapp = VApp(
                self.client, name=request.target_vapp, resource=vapp_resource)
            read_vapp_vm_resp = vapp.get_vm(request.target_vm_name)
            vm = VM(client=self.client, href=None, resource=read_vapp_vm_resp)

            res.present = True
        except Exception as e:
            errmsg = '__ERROR_read[VappVm] failed for VappVm {0}. __ErrorMessage__ {1}'
            logging.warn(errmsg.format(request.target_vm_name, str(e)))

            return res

        logging.info("__DONE__read[VappVm]")

        return res
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:29,代码来源:vapp_vm.py

示例12: test_1006_unshare_vapp_access

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [as 别名]
 def test_1006_unshare_vapp_access(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)
     vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
     vapp = VApp(self.client, resource=vapp_resource)
     control_access = vapp.unshare_from_org_members()
     assert control_access.IsSharedToEveryone.text == 'false'
开发者ID:vmware,项目名称:pyvcloud,代码行数:11,代码来源:vcd_vapp.py

示例13: test_1003_get_vapp_access

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [as 别名]
 def test_1003_get_vapp_access(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)
     vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
     vapp = VApp(self.client, resource=vapp_resource)
     control_access = vapp.get_access_settings()
     assert len(control_access.AccessSettings.AccessSetting) == 2
开发者ID:vmware,项目名称:pyvcloud,代码行数:11,代码来源:vcd_vapp.py

示例14: test_1001_remove_all_vapp_access

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [as 别名]
 def test_1001_remove_all_vapp_access(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)
     vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
     vapp = VApp(self.client, resource=vapp_resource)
     control_access = vapp.remove_access_settings(remove_all=True)
     self.assertFalse(hasattr(control_access, 'AccessSettings'))
开发者ID:vmware,项目名称:pyvcloud,代码行数:11,代码来源:vcd_vapp.py

示例15: delete

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_vapp [as 别名]
    def delete(self, request):
        logging.info("__INIT__delete[VappVm]")
        res = vapp_vm_pb2.DeleteVappVmResult()
        res.deleted = False
        org_resource = self.client.get_org()
        org = Org(self.client, resource=org_resource)
        try:
            vdc_resource = org.get_vdc(request.target_vdc)
            vdc = VDC(
                self.client, name=request.target_vdc, resource=vdc_resource)

            vapp_resource = vdc.get_vapp(request.target_vapp)
            vapp = VApp(
                self.client, name=request.target_vapp, resource=vapp_resource)

            # Before deleting power_off vm
            # self.power_off(request.target_vdc, request.target_vapp)

            # Before deleting undeploy vm
            self.undeploy(request)

            vms = [request.target_vm_name]
            delete_vapp_vm_resp = vapp.delete_vms(vms)
            task = self.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:
                raise errors.VappVmDeleteError(
                    etree.tostring(task, pretty_print=True))

            message = 'delete vapp_vm status : {0} '.format(st)
            logging.info(message)
            res.deleted = True

        except Exception as e:
            res.deleted = False
            errmsg = '__ERROR_delete[VappVm] failed for VappVm {0}. __ErrorMessage__ {1}'
            logging.warn(errmsg.format(request.target_vm_name, str(e)))
            self.context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
            self.context.set_details(errmsg)

            return res

        logging.info("__DONE__delete[VappVm]")

        return res
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:57,代码来源:vapp_vm.py


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