本文整理汇总了Python中pyvcloud.vcd.vdc.VDC.delete_vdc方法的典型用法代码示例。如果您正苦于以下问题:Python VDC.delete_vdc方法的具体用法?Python VDC.delete_vdc怎么用?Python VDC.delete_vdc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.vdc.VDC
的用法示例。
在下文中一共展示了VDC.delete_vdc方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_0098_teardown
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import delete_vdc [as 别名]
def test_0098_teardown(self):
"""Removes the added vdc, gateway and routed networks.
"""
vdc = VDC(TestIpSecVpn._client, resource=TestIpSecVpn._vdc_resource)
task1 = vdc.delete_routed_orgvdc_network(
name=TestIpSecVpn._routed_network_name)
TestIpSecVpn._client.get_task_monitor().wait_for_success(task=task1)
task2 = vdc.delete_gateway(name=TestIpSecVpn._gateway_name)
TestIpSecVpn._client.get_task_monitor().wait_for_success(task=task2)
vdc.enable_vdc(enable=False)
vdc.delete_vdc()
示例2: delete
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import delete_vdc [as 别名]
def delete(self):
logging.info("__INIT__delete[Vdc]")
res = vdc_pb2.DeleteVdcResult()
res.deleted = False
context = self.context
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
#Vdc details
name = self.name
try:
vdc_resource = org.get_vdc(name)
vdc = VDC(self.client, name=name, resource=vdc_resource)
delete_vdc_resp = vdc.delete_vdc()
task = self.client.get_task_monitor().wait_for_status(
task=delete_vdc_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))
res.deleted = True
except Exception as e:
res.deleted = False
error_message = '__ERROR_delete[Vdc] failed for Vdc {0}. __ErrorMessage__ {1}'.format(
self.name, str(e))
logging.warn(error_message)
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
context.set_details(error_message)
return res
logging.info("__DONE__delete[Vdc]")
return res
示例3: delete
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import delete_vdc [as 别名]
def delete(self):
vdc_name = self.params.get('vdc_name')
response = dict()
response['changed'] = False
try:
vdc_resource = self.org.get_vdc(vdc_name)
except EntityNotFoundException:
response['warnings'] = 'VDC {} is not present.'.format(vdc_name)
else:
vdc = VDC(self.client, name=vdc_name, resource=vdc_resource)
vdc.enable_vdc(enable=False)
delete_vdc_task = vdc.delete_vdc()
self.execute_task(delete_vdc_task)
response['msg'] = 'VDC {} has been deleted.'.format(vdc_name)
response['changed'] = True
return response
示例4: delete
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import delete_vdc [as 别名]
def delete(ctx, name):
try:
restore_session(ctx)
client = ctx.obj['client']
in_use_org_href = ctx.obj['profiles'].get('org_href')
in_use_vdc = ctx.obj['profiles'].get('vdc_in_use')
org = Org(client, in_use_org_href)
vdc_resource = org.get_vdc(name)
vdc = VDC(client, resource=vdc_resource)
task = vdc.delete_vdc()
if name == in_use_vdc:
ctx.obj['profiles'].set('vdc_in_use', '')
ctx.obj['profiles'].set('vdc_href', '')
ctx.obj['profiles'].set('vapp_in_use', '')
ctx.obj['profiles'].set('vapp_href', '')
stdout(task, ctx)
except Exception as e:
stderr(e, ctx)
示例5: test_9998_teardown
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import delete_vdc [as 别名]
def test_9998_teardown(self):
"""Test the method VDC.delete_vdc().
Invoke the method for the vdc created by setup.
This test passes if the task for deleting the vdc succeeds.
"""
logger = Environment.get_default_logger()
vdc = VDC(TestOrgVDC._client, href=TestOrgVDC._new_vdc_href)
# Disable the org vdc before deleting it. In case the org vdc is
# already disabled, we don't want the exception to leak out.
try:
vdc.enable_vdc(enable=False)
logger.debug('Disabled vdc ' + TestOrgVDC._new_vdc_name + '.')
except OperationNotSupportedException as e:
logger.debug('vdc ' + TestOrgVDC._new_vdc_name +
' is already disabled.')
pass
task = vdc.delete_vdc()
TestOrgVDC._client.get_task_monitor().wait_for_success(task=task)
logger.debug('Deleted vdc ' + TestOrgVDC._new_vdc_name + '.')