本文整理汇总了Python中pyvcloud.vcd.platform.Platform类的典型用法代码示例。如果您正苦于以下问题:Python Platform类的具体用法?Python Platform怎么用?Python Platform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Platform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_0010_update
def test_0010_update(self):
"""Test the method Platform.update_external_network()
Update name and description of the external network created by setup.
Verifies name and description after update completes. Reset the name
and description to original.
This test passes if name and description are updated successfully.
"""
logger = Environment.get_default_logger()
platform = Platform(TestExtNet._sys_admin_client)
new_name = 'updated_' + TestExtNet._name
new_description = 'Updated ' + TestExtNet._description
ext_net = platform.update_external_network(TestExtNet._name, new_name,
new_description)
task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
task=task)
logger.debug('Updated external network ' + TestExtNet._name + '.')
ext_net = platform.get_external_network(new_name)
self.assertIsNotNone(ext_net)
self.assertEqual(new_description,
ext_net['{' + NSMAP['vcloud'] + '}Description'].text)
# Reset the name and description to original
ext_net = platform.update_external_network(new_name, self._name,
self._description)
task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
task=task)
示例2: test_0020_add_subnet
def test_0020_add_subnet(self):
"""Test the method externalNetwork.add_subnet()
Add subnet to the existing external network
This test passes if subnet is added successfully.
"""
logger = Environment.get_default_logger()
platform = Platform(TestExtNet._sys_admin_client)
ext_net_resource = platform.get_external_network(self._name)
extnet_obj = ExternalNetwork(TestExtNet._sys_admin_client,
resource=ext_net_resource)
ext_net = extnet_obj.add_subnet(self._name,
TestExtNet._gateway2,
TestExtNet._netmask,
[TestExtNet._ip_range2],
TestExtNet._dns1,
TestExtNet._dns2,
TestExtNet._dns_suffix)
task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
task=task)
logger.debug(
'Added subnet to external network ' + TestExtNet._name + '.')
ext_net = platform.get_external_network(self._name)
self.assertIsNotNone(ext_net)
config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
new_subnet = config.IpScopes.IpScope[-1]
self.assertEqual(TestExtNet._gateway2, new_subnet.Gateway.text)
self.assertEqual(TestExtNet._netmask, new_subnet.Netmask.text)
示例3: test_0060_attach_port_group
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)
示例4: test_0055_delete_ip_range
def test_0055_delete_ip_range(self):
"""Test the method externalNetwork.delete_ip_range()
Delete ip range of a subnet in external network
This test passes if the ip range for a subnet is
deleted successfully.
"""
logger = Environment.get_default_logger()
platform = Platform(TestExtNet._sys_admin_client)
ext_net = self._get_ext_net(platform).delete_ip_range(
TestExtNet._gateway2,
[TestExtNet._ip_range4])
task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
task=task)
logger.debug(
'Deleted ip-range of a subnet in external network'
+ TestExtNet._name + '.')
ext_net = platform.get_external_network(self._name)
self.assertIsNotNone(ext_net)
config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
ip_scope = config.IpScopes.IpScope
for scope in ip_scope:
if scope.Gateway == TestExtNet._gateway2:
ip_scope = scope
break
self.assertIsNotNone(ip_scope)
self.assertFalse(self.__validate_ip_range(ip_scope,
TestExtNet._ip_range4))
示例5: test_0030_enable_subnet
def test_0030_enable_subnet(self):
"""Test the method externalNetwork.enable_subnet()
Enable subnet of external network
This test passes if subnet is enabled successfully.
"""
logger = Environment.get_default_logger()
platform = Platform(TestExtNet._sys_admin_client)
ext_net = self._get_ext_net(platform).enable_subnet(
TestExtNet._gateway2, True)
task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
task=task)
logger.debug(
'Enabled subnet of external network ' + TestExtNet._name + '.')
ext_net = platform.get_external_network(self._name)
self.assertIsNotNone(ext_net)
config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
ip_scope = config.IpScopes.IpScope
for scope in ip_scope:
if scope.Gateway == TestExtNet._gateway2:
ip_scope = scope
break
self.assertIsNotNone(ip_scope)
self.assertEqual(ip_scope.IsEnabled, True)
示例6: test_0021_list_available_port_group_names
def test_0021_list_available_port_group_names(self):
"""Test the method Platform.list_port_group_names, this method fetches
list of portgroup name for a particular vCenter"""
platform = Platform(TestVC._client)
port_group_names = \
platform.list_available_port_group_names(TestVC._vcenter_host_name)
self.assertTrue(len(port_group_names) > 0)
示例7: test_0061_detach_port_group
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)
示例8: list_vcenters
def list_vcenters(ctx):
try:
restore_session(ctx)
platform = Platform(ctx.obj['client'])
stdout(platform.list_vcenters(), ctx)
except Exception as e:
stderr(e, ctx)
示例9: info
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)
示例10: create_external_network
def create_external_network(cls):
"""Creates an external network by the name specified in the config file.
Skips creating one, if such a network already exists. Also stores the
href and name of the network as class variables for future use.
"""
cls._basic_check()
net_name = cls._config['external_network']['name']
platform = Platform(cls._sys_admin_client)
net_refs = platform.list_external_networks()
if net_name is not '*':
for net_ref in net_refs:
if net_ref.get('name').lower() == net_name.lower():
cls._logger.debug('Reusing existing ' + net_name)
cls._external_network_href = net_ref.get('href')
cls._external_network_name = net_name
return
cls._logger.debug('Creating new external network' + net_name)
ext_nw = cls._create_external_network()
cls._external_network_href = ext_nw.get('href')
cls._external_network_name = net_name
cls._logger.debug('Created external network ' + net_name)
else:
if len(net_refs) > 0:
cls._logger.debug('Defaulting to first network : ' +
net_refs[0].get('name'))
cls._external_network_href = net_refs[0].get('href')
cls._external_network_name = net_refs[0].get('name')
else:
cls._logger.debug('No usable network found. Aborting test.')
raise Exception('Test Aborted. No usable external network.')
示例11: detach
def detach(ctx, name):
try:
restore_session(ctx)
platform = Platform(ctx.obj['client'])
stdout(platform.detach_vcenter(vc_name=name), ctx)
except Exception as e:
stderr(e, ctx)
示例12: test_0020_get_vc
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)
示例13: test_0010_list_vc
def test_0010_list_vc(self):
"""Platform.list_vcenters prints a list of virtual center servers."""
logger = Environment.get_default_logger()
platform = Platform(TestVC._client)
vcenters = platform.list_vcenters()
for vcenter in vcenters:
logger.debug('vCenter found: %s' % vcenter.get('name'))
self.assertTrue(len(vcenters) > 0)
示例14: disable
def disable(ctx, name):
try:
restore_session(ctx)
platform = Platform(ctx.obj['client'])
stdout(platform.enable_disable_vcenter(
vc_name=name, enable_flag=False), ctx)
except Exception as e:
stderr(e, ctx)
示例15: test_0030_get_vc_negative
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