本文整理汇总了Python中pyvcloud.vcd.vdc.VDC.delete_vapp方法的典型用法代码示例。如果您正苦于以下问题:Python VDC.delete_vapp方法的具体用法?Python VDC.delete_vapp怎么用?Python VDC.delete_vapp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.vdc.VDC
的用法示例。
在下文中一共展示了VDC.delete_vapp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import delete_vapp [as 别名]
def delete(ctx, name, vm_names, force):
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 len(vm_names) == 0:
task = vdc.delete_vapp(name, force)
else:
vapp_resource = vdc.get_vapp(name)
vapp = VApp(client, resource=vapp_resource)
task = vapp.delete_vms(vm_names)
stdout(task, ctx)
except Exception as e:
stderr(e, ctx)
示例2: test_1000_delete_vapp
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import delete_vapp [as 别名]
def test_1000_delete_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.delete_vapp(self.config['vcd']['vapp'], force=True)
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
示例3: delete
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import delete_vapp [as 别名]
def delete(client, vappInfo):
logging.debug("===INIT delete vapp called === \n")
try:
logged_in_org = client.get_org()
org = Org(client, resource=logged_in_org)
v = org.get_vdc(vappInfo.vdc)
vdc = VDC(client, href=v.get('href'))
cresult = vapp_pb2.DeleteVAppResult()
cresult.deleted = False
try:
logging.info(" calling delete_vapp............")
result = vdc.delete_vapp(name=vappInfo.name, force=True)
logging.info(" delete proceeding............")
task = 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=task_callback)
if task.get('status') == TaskStatus.SUCCESS.value:
cresult.deleted = True
except Exception as e:
logging.exception("\n Not Deleted VApp [" + vappInfo.name + "]")
return cresult
except Exception as e:
logging.exception("error occured create vapp ", e)
示例4: Vapp
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import delete_vapp [as 别名]
#.........这里部分代码省略.........
fence_mode = params.get('fence_mode')
accept_all_eulas = params.get('accept_all_eulas')
response = dict()
response['changed'] = False
try:
self.vdc.get_vapp(vapp_name)
except EntityNotFoundException:
create_vapp_task = self.vdc.create_vapp(
name=vapp_name,
description=description,
network=network,
fence_mode=fence_mode,
accept_all_eulas=accept_all_eulas)
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 delete(self):
vapp_name = self.params.get('vapp_name')
force = self.params.get('force')
response = dict()
response['changed'] = False
try:
self.vdc.get_vapp(vapp_name)
except EntityNotFoundException:
response['warnings'] = "Vapp {} is not present.".format(vapp_name)
else:
delete_vapp_task = self.vdc.delete_vapp(name=vapp_name, force=force)
self.execute_task(delete_vapp_task)
response['msg'] = 'Vapp {} has been deleted.'.format(vapp_name)
response['changed'] = True
return response
def power_on(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_on_vapp_task = vapp.power_on()
self.execute_task(power_on_vapp_task)
response['msg'] = 'Vapp {} has been powered on.'.format(vapp_name)
response['changed'] = True
except OperationNotSupportedException:
response['warnings'] = 'Vapp {} is already powered on.'.format(vapp_name)
return response
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()