本文整理汇总了Python中pyvcloud.vcd.platform.Platform.get_vcenter方法的典型用法代码示例。如果您正苦于以下问题:Python Platform.get_vcenter方法的具体用法?Python Platform.get_vcenter怎么用?Python Platform.get_vcenter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.platform.Platform
的用法示例。
在下文中一共展示了Platform.get_vcenter方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_0030_get_vc_negative
# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_vcenter [as 别名]
def test_0030_get_vc_negative(self):
"""Platform.get_vcenter does not find a non-existent vcenter."""
try:
platform = Platform(TestVC._client)
platform.get_vcenter(TestVC._vcenter_invalid)
self.fail('Should not be able to find VC that does not exist ' +
TestVC._vcenter_invalid)
except EntityNotFoundException as e:
return
示例2: test_0080_detach_vc
# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_vcenter [as 别名]
def test_0080_detach_vc(self):
"""Platform.detach_vcenter unregisters (detaches) a vcenter.
Wait for async command to complete before checking result.
"""
platform = Platform(TestVC._client)
task = platform.detach_vcenter(vc_name=TestVC._vcServerName)
TestVC._client.get_task_monitor().wait_for_success(task=task)
try:
platform.get_vcenter(name=TestVC._vcServerName)
self.fail('Should not be able to find detached VC ' +
TestVC._vcServerName)
except EntityNotFoundException as e:
return
示例3: test_0061_detach_port_group
# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_vcenter [as 别名]
def test_0061_detach_port_group(self):
"""Detach a portgroup from an external network
This test passes if the portgroup from another vCenter is removed
from external network successfully.
"""
if TestExtNet._vc2_host_ip is None or TestExtNet._vc2_host_ip == '':
return
logger = Environment.get_default_logger()
platform = Platform(TestExtNet._sys_admin_client)
vc_name = TestExtNet._config['vc2']['vcenter_host_name']
port_group_helper = PortgroupHelper(TestExtNet._sys_admin_client)
pg_name = port_group_helper.get_ext_net_portgroup_name(vc_name,
self._name)
ext_net = self._get_ext_net(platform).detach_port_group(vc_name,
pg_name)
task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
task=task)
logger.debug(
'Detach a portgroup from an external network' + TestExtNet._name)
ext_net = platform.get_external_network(self._name)
self.assertIsNotNone(ext_net)
vc_record = platform.get_vcenter(vc_name)
vc_href = vc_record.get('href')
vim_port_group_ref = ext_net.VimPortGroupRef
vc_href_found = False
if vim_port_group_ref.VimServerRef.get('href') == vc_href:
vc_href_found = True
self.assertFalse(vc_href_found)
示例4: test_0060_attach_port_group
# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_vcenter [as 别名]
def test_0060_attach_port_group(self):
"""Attach a portgroup to an external network
This test passes if the portgroup from another vCenter is added
to external network successfully.
"""
if TestExtNet._vc2_host_ip is None or TestExtNet._vc2_host_ip == '':
return
logger = Environment.get_default_logger()
platform = Platform(TestExtNet._sys_admin_client)
vc_name = TestExtNet._config['vc2']['vcenter_host_name']
portgrouphelper = PortgroupHelper(TestExtNet._sys_admin_client)
pg_name = portgrouphelper.get_available_portgroup_name(
vc_name, TestExtNet._portgroupType)
ext_net = self._get_ext_net(platform).attach_port_group(
vc_name,
pg_name)
task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
task=task)
logger.debug(
'Attach a portgroup to an external network'
+ TestExtNet._name + '.')
ext_net = platform.get_external_network(self._name)
self.assertIsNotNone(ext_net)
vc_record = platform.get_vcenter(vc_name)
vc_href = vc_record.get('href')
vim_port_group_refs = \
ext_net['{' + NSMAP['vmext'] + '}VimPortGroupRefs']
vc_href_found = False
for vim_obj_ref in vim_port_group_refs.VimObjectRef:
if vim_obj_ref.VimServerRef.get('href') == vc_href:
vc_href_found = True
break
self.assertTrue(vc_href_found)
示例5: info
# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_vcenter [as 别名]
def info(ctx, name):
try:
restore_session(ctx)
platform = Platform(ctx.obj['client'])
stdout(platform.get_vcenter(name=name), ctx)
except Exception as e:
stderr(e, ctx)
示例6: test_0020_get_vc
# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_vcenter [as 别名]
def test_0020_get_vc(self):
"""Platform.get_vcenter finds a known vcenter."""
logger = Environment.get_default_logger()
platform = Platform(TestVC._client)
vcenter = platform.get_vcenter(TestVC._vcenter_host_name)
logger.debug('vCenter: name=%s, url=%s' %
(vcenter.get('name'), vcenter.Url.text))
self.assertIsNotNone(vcenter)
示例7: attach_port_group
# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_vcenter [as 别名]
def attach_port_group(self, vim_server_name, port_group_name):
"""Attach a portgroup to an external network.
:param str vc_name: name of vc where portgroup is present.
:param str pg_name: name of the portgroup to be attached to
external network.
return: object containing vmext:VMWExternalNetwork XML element that
representing the external network.
:rtype: lxml.objectify.ObjectifiedElement
"""
ext_net = self.get_resource()
platform = Platform(self.client)
if not vim_server_name or not port_group_name:
raise InvalidParameterException(
"Either vCenter Server name is none or portgroup name is none")
vc_record = platform.get_vcenter(vim_server_name)
vc_href = vc_record.get('href')
pg_moref_types = \
platform.get_port_group_moref_types(vim_server_name,
port_group_name)
if hasattr(ext_net, '{' + NSMAP['vmext'] + '}VimPortGroupRef'):
vim_port_group_refs = E_VMEXT.VimPortGroupRefs()
vim_object_ref1 = self.__create_vimobj_ref(
vc_href, pg_moref_types[0], pg_moref_types[1])
# Create a new VimObjectRef using vc href, portgroup moref and type
# from existing VimPortGroupRef. Add the VimObjectRef to
# VimPortGroupRefs and then delete VimPortGroupRef
# from external network.
vim_pg_ref = ext_net['{' + NSMAP['vmext'] + '}VimPortGroupRef']
vc2_href = vim_pg_ref.VimServerRef.get('href')
vim_object_ref2 = self.__create_vimobj_ref(
vc2_href, vim_pg_ref.MoRef.text, vim_pg_ref.VimObjectType.text)
vim_port_group_refs.append(vim_object_ref1)
vim_port_group_refs.append(vim_object_ref2)
ext_net.remove(vim_pg_ref)
ext_net.append(vim_port_group_refs)
else:
vim_port_group_refs = \
ext_net['{' + NSMAP['vmext'] + '}VimPortGroupRefs']
vim_object_ref1 = self.__create_vimobj_ref(
vc_href, pg_moref_types[0], pg_moref_types[1])
vim_port_group_refs.append(vim_object_ref1)
return self.client. \
put_linked_resource(ext_net, rel=RelationType.EDIT,
media_type=EntityType.
EXTERNAL_NETWORK.value,
contents=ext_net)
示例8: test_0050_enable_vc
# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_vcenter [as 别名]
def test_0050_enable_vc(self):
"""Platform.enable_vcenter enables a vcenter.
Wait for async command to complete before checking result.
"""
platform = Platform(TestVC._client)
task = platform.enable_disable_vcenter(
vc_name=TestVC._vcServerName, enable_flag=True)
TestVC._client.get_task_monitor().wait_for_success(task=task)
vc = platform.get_vcenter(name=TestVC._vcServerName)
self.assertTrue(vc.IsEnabled)
示例9: detach_port_group
# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_vcenter [as 别名]
def detach_port_group(self, vim_server_name, port_group_name):
"""Detach a portgroup from an external network.
:param str vim_server_name: name of vim server where
portgroup is present.
:param str port_group_name: name of the portgroup to be detached from
external network.
return: object containing vmext:VMWExternalNetwork XML element that
representing the external network.
:rtype: lxml.objectify.ObjectifiedElement
"""
ext_net = self.get_resource()
platform = Platform(self.client)
if not vim_server_name or not port_group_name:
raise InvalidParameterException(
"Either vCenter Server name is none or portgroup name is none")
vc_record = platform.get_vcenter(vim_server_name)
vc_href = vc_record.get('href')
if hasattr(ext_net, 'VimPortGroupRefs'):
pg_moref_types = \
platform.get_port_group_moref_types(vim_server_name,
port_group_name)
else:
raise \
InvalidParameterException("External network"
" has only one port group")
vim_port_group_refs = ext_net.VimPortGroupRefs
vim_obj_refs = vim_port_group_refs.VimObjectRef
for vim_obj_ref in vim_obj_refs:
if vim_obj_ref.VimServerRef.get('href') == vc_href \
and vim_obj_ref.MoRef == pg_moref_types[0] \
and vim_obj_ref.VimObjectType == pg_moref_types[1]:
vim_port_group_refs.remove(vim_obj_ref)
return self.client. \
put_linked_resource(ext_net, rel=RelationType.EDIT,
media_type=EntityType.
EXTERNAL_NETWORK.value,
contents=ext_net)
示例10: test_0002_get_vc
# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_vcenter [as 别名]
def test_0002_get_vc(self):
platform = Platform(self.client)
vcenter = platform.get_vcenter(self.config['vcd']['vcenter'])
self.logger.debug('vCenter: name=%s, url=%s' %
(vcenter.get('name'), vcenter.Url.text))
assert vcenter is not None