本文整理汇总了Python中pyvcloud.vcd.vdc.VDC.enable_vdc方法的典型用法代码示例。如果您正苦于以下问题:Python VDC.enable_vdc方法的具体用法?Python VDC.enable_vdc怎么用?Python VDC.enable_vdc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.vdc.VDC
的用法示例。
在下文中一共展示了VDC.enable_vdc方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_disable_vdc
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import enable_vdc [as 别名]
def test_disable_vdc(self):
org_to_use = self.client.get_org_by_name(
self.config['vcd']['org_to_use'])
org = Org(self.client, href=org_to_use.get('href'))
resource = org.get_vdc(self.config['vcd']['new_vdc'])
vdc = VDC(self.client, resource=resource)
vdc.enable_vdc(False)
vdc.reload()
assert vdc.resource.IsEnabled.text == 'false'
示例2: disable
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import enable_vdc [as 别名]
def disable(ctx, name):
try:
restore_session(ctx)
client = ctx.obj['client']
in_use_org_href = ctx.obj['profiles'].get('org_href')
org = Org(client, in_use_org_href)
vdc_resource = org.get_vdc(name)
vdc = VDC(client, resource=vdc_resource)
vdc.enable_vdc(False)
except Exception as e:
stderr(e, ctx)
示例3: test_0098_teardown
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import enable_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()
示例4: update
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import enable_vdc [as 别名]
def update(self):
vdc_name = self.params.get('vdc_name')
is_enabled = self.params.get('is_enabled')
response = dict()
response['changed'] = False
vdc_resource = self.org.get_vdc(vdc_name)
vdc = VDC(self.client, name=vdc_name, resource=vdc_resource)
vdc.enable_vdc(enable=is_enabled)
response['msg'] = 'VDC {} has been updated.'.format(vdc_name)
response['changed'] = True
return response
示例5: test_0040_enable_disable_vdc
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import enable_vdc [as 别名]
def test_0040_enable_disable_vdc(self):
"""Test the method VDC.enable_vdc().
First disable the vdc, try to re-disable it (which should fail). Next,
enable the vdc back, and then try to re-enable the vdc (which should
fail).
This test passes if the state of vdc matches our expectation after each
operation.
"""
logger = Environment.get_default_logger()
vdc = VDC(TestOrgVDC._client, href=TestOrgVDC._new_vdc_href)
# vdc should be in enabled state after the previous tests.
vdc.enable_vdc(enable=False)
logger.debug('Disabled vdc ' + TestOrgVDC._new_vdc_name + '.')
try:
logger.debug('Trying to again disable vdc ' +
TestOrgVDC._new_vdc_name + '.')
vdc.enable_vdc(enable=False)
self.fail('Should not be able to disable vdc ' +
TestOrgVDC._new_vdc_href)
except OperationNotSupportedException as e:
pass
vdc.enable_vdc(enable=True)
logger.debug('Enabled vdc ' + TestOrgVDC._new_vdc_name + '.')
try:
logger.debug('Trying to again enable vdc ' +
TestOrgVDC._new_vdc_name + '.')
vdc.enable_vdc(enable=True)
self.fail('Should not be able to enable vdc ' +
TestOrgVDC._new_vdc_href)
except OperationNotSupportedException as e:
pass
示例6: update
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import enable_vdc [as 别名]
def update(self):
logging.info("__INIT__update[Vdc]")
res = vdc_pb2.UpdateVdcResult()
res.updated = False
context = self.context
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
#Vdc details
name = self.name
is_enabled = self.is_enabled
try:
vdc_resource = org.get_vdc(name)
vdc = VDC(self.client, name=name, resource=vdc_resource)
result = vdc.enable_vdc(is_enabled)
res.updated = True
except Exception as e:
error_message = '__ERROR_update[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__update[Vdc]")
return res
示例7: delete
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import enable_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
示例8: test_9998_teardown
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import enable_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 + '.')
示例9: update_vdc
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import enable_vdc [as 别名]
def update_vdc(client):
print("================= Vdc update request ===================")
vdc_name = "pcp_vdc_02"
is_enabled = False
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)
update_vdc_resp = vdc.enable_vdc(is_enabled)
print("================= Vdc updated ===================")