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


Python VApp.undeploy方法代码示例

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


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

示例1: update

# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import undeploy [as 别名]
def update(client, context, vappInfo):
    logging.info("__INIT__update[Vapp]")

    cresult = vapp_pb2.UpdateVAppResult()
    cresult.updated = False

    print("Vapp[ {0} ], Vdc[ {1} ]".format(vappInfo.name, vappInfo.vdc))

    org_resource = client.get_org()
    org = Org(client, resource=org_resource)
    try:
        vdc_resource = org.get_vdc(vappInfo.vdc)
        vdc = VDC(client, name=vappInfo.vdc, resource=vdc_resource)
        vapp_resource = vdc.get_vapp(vappInfo.name)
        vapp = VApp(client, name=vappInfo.name, resource=vapp_resource)
        resp = None
        if (vappInfo.power_on == True):
            logging.info("Powering on [Vapp %v]".format(vappInfo.name))
            resp = vapp.power_on()
        else:
            logging.info("Powering off [Vapp %v]".format(vappInfo.name))
            resp = vapp.undeploy()

        task = client.get_task_monitor().wait_for_status(
            task=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 = 'status : {0} '.format(st)
            logging.info(message)
            cresult.updated = True
        else:
            raise errors.VappUpdateError(
                etree.tostring(task, pretty_print=True))
    except Exception as e:
        error_message = '__ERROR_updating [Vapp] power_on={0} for Vapp {1} . __ErrorMessage__ {2}'.format(
            vappInfo.power_on, vappInfo.name, str(e))
        logging.warn(error_message)
        cresult.updated = False
        context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
        context.set_details(error_message)
    logging.info("__DONE__update[Vapp]")
    return cresult
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:53,代码来源:vapp.py

示例2: undeploy

# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import undeploy [as 别名]
    def undeploy(self):
        vapp_name = self.params.get('vapp_name')
        response = dict()
        response['changed'] = False

        try:
            vapp_resource = self.vdc.get_vapp(vapp_name)
            vapp = VApp(self.client, name=vapp_name, resource=vapp_resource)
            undeploy_vapp_task = vapp.undeploy()
            self.execute_task(undeploy_vapp_task)
            response['msg'] = 'Vapp {} has been undeployed.'.format(vapp_name)
            response['changed'] = True
        except OperationNotSupportedException:
            response['warnings'] = 'Vapp {} is already undeployed.'.format(vapp_name)

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

示例3: undeploy

# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import undeploy [as 别名]
def undeploy(ctx, name, vm_names, action):
    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)
        vapp_resource = vdc.get_vapp(name)
        vapp = VApp(client, resource=vapp_resource)
        if len(vm_names) == 0:
            task = vapp.undeploy(action)
            stdout(task, ctx)
        else:
            for vm_name in vm_names:
                vm = VM(client, href=vapp.get_vm(vm_name).get('href'))
                vm.reload()
                task = vm.undeploy(action)
                stdout(task, ctx)
    except Exception as e:
        stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:21,代码来源:vapp.py


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