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


Python VApp.power_off方法代码示例

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


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

示例1: power_off

# 需要导入模块: from pyvcloud.vcd.vapp import VApp [as 别名]
# 或者: from pyvcloud.vcd.vapp.VApp import power_off [as 别名]
    def power_off(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)
            power_off_vapp_task = vapp.power_off()
            self.execute_task(power_off_vapp_task)
            response['msg'] = 'Vapp {} has been powered off.'.format(vapp_name)
            response['changed'] = True
        except OperationNotSupportedException:
            response['warnings'] = 'Vapp {} is already powered off.'.format(vapp_name)

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

示例2: power_off

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


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