Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_0000_setup(self):
"""Setup the vApps required for the other tests in this module.
Create two vApps as per the configuration stated above.
This test passes if the two vApp hrefs are not None.
"""
logger = Environment.get_default_logger()
TestVApp._pvdc_name = Environment.get_test_pvdc_name()
TestVApp._config = Environment.get_config()
TestVApp._default_org_name = TestVApp._config['vcd'][
'default_org_name']
TestVApp._client = Environment.get_client_in_default_org(
TestVApp._test_runner_role)
TestVApp._sys_admin_client = Environment.get_sys_admin_client()
vdc = Environment.get_test_vdc(TestVApp._client)
logger.debug('Creating empty vApp.')
TestVApp._empty_vapp_href = \
create_empty_vapp(client=TestVApp._client,
vdc=vdc,
name=TestVApp._empty_vapp_name,
description=TestVApp._empty_vapp_description)
TestVApp._empty_vapp_owner_name = Environment.\
def test_0000_setup(self):
"""Add Static Route in the gateway.
It will trigger the cli command 'services static-route create'
"""
self._config = Environment.get_config()
TestStaticRoute._logger = Environment.get_default_logger()
TestStaticRoute._runner = CliRunner()
default_org = self._config['vcd']['default_org_name']
self._login()
TestStaticRoute._runner.invoke(org, ['use', default_org])
result = TestStaticRoute._runner.invoke(
gateway,
args=[
'services', 'static-route', 'create', TestStaticRoute._name,
'--type', TestStaticRoute._type, '--network',
TestStaticRoute._network, '--next-hop',
TestStaticRoute._next_hop, '--mtu', TestStaticRoute._mtu,
'--desc', TestStaticRoute._desc, '-v',
TestStaticRoute._vnic])
self.assertEqual(0, result.exit_code)
def wrapper(self):
if not Environment._config['global']['developer_mode']:
function(self)
else:
Environment.get_default_logger().debug(
'Skipping ' + function.__name__ +
' because developer mode is on.')
VmTest._client)
VmTest._test_old_vapp_href = VmTest._test_vapp.get_resource().get(
'href')
self.assertIsNotNone(VmTest._test_old_vapp_href)
logger.debug("Old vapp href is : " + VmTest._test_old_vapp_href)
VmTest._test_vm = VM(
VmTest._client,
href=VmTest._test_vapp.get_vm(VAppConstants.vm1_name).get('href'))
self.assertIsNotNone(
VmTest._test_vapp.get_vm(VAppConstants.vm1_name).get('href'))
logger.debug("Old vapp VM href is : " +
VmTest._test_vapp.get_vm(VAppConstants.vm1_name).get(
'href'))
vdc1 = Environment.get_test_vdc(VmTest._client)
logger.debug('Creating empty vApp.')
VmTest._empty_vapp_href = \
create_empty_vapp(client=VmTest._client,
vdc=vdc1,
name=VmTest._empty_vapp_name,
description=VmTest._empty_vapp_description)
self.assertIsNotNone(VmTest._empty_vapp_href)
logger.debug("Empty vapp href is: " + VmTest._empty_vapp_href)
# Create independent disk
VmTest._idisk_id = create_independent_disk(client=VmTest._client,
vdc=vdc1,
name=self._idisk_name,
size=self._idisk_size,
description=self._idisk_description)
self.assertIsNotNone(VmTest._idisk_id)
def test_0000_setup(self):
# TODO(): need more pipeline work before this test can actually be run
TestVC._client = Environment.get_sys_admin_client()
TestVC._config = Environment.get_config()
TestVC._vcenter_host_name = self._config['vc']['vcenter_host_name']
TestVC._vcenter_invalid = 'xyz'
TestVC._vcServerName = self._config['vc']['vcServerName']
TestVC._vcServerHost = self._config['vc']['vcServerHost']
TestVC._vcAdminUser = self._config['vc']['vcAdminUser']
TestVC._vcAdminPwd = self._config['vc']['vcAdminPwd']
TestVC._NSXServerName = self._config['vc']['NSXServerName']
TestVC._NSXHost = self._config['vc']['NSXHost']
TestVC._NSXAdminUser = self._config['vc']['NSXAdminUser']
TestVC._NSXAdminPwd = self._config['vc']['NSXAdminPwd']
TestVC._isEnabled = False
def setUp(self):
"""Load configuration and create a click runner to invoke CLI."""
self._config = Environment.get_config()
self._logger = Environment.get_default_logger()
self._runner = CliRunner()
def test_0000_setup(self):
"""Load configuration and create a click runner to invoke CLI."""
logger = Environment.get_default_logger()
VmTest._config = Environment.get_config()
VmTest._logger = logger
VmTest._client = Environment.get_client_in_default_org(
CommonRoles.ORGANIZATION_ADMINISTRATOR)
VmTest._media_resource = Environment.get_test_media_resource()
VmTest._runner = CliRunner()
default_org = VmTest._config['vcd']['default_org_name']
VmTest._login(self)
VmTest._runner.invoke(org, ['use', default_org])
default_ovdc = VmTest._config['vcd']['default_ovdc_name']
VmTest._default_ovdc = default_ovdc
VmTest._runner.invoke(vdc, ['use', VmTest._default_ovdc])
VmTest._test_vdc = Environment.get_test_vdc(VmTest._client)
def __add_sub_allocate_ip_pool(self):
gateway = Environment. \
get_test_gateway(TestExtNet._sys_admin_client)
gateway_obj = Gateway(TestExtNet._sys_admin_client,
href=gateway.get('href'))
ext_net = TestExtNet._config['external_network']['name']
task = gateway_obj.add_sub_allocated_ip_pools(
ext_net, [TestExtNet._gateway_sub_allocate_ip_pool_range])
TestExtNet._sys_admin_client.get_task_monitor(). \
wait_for_success(task=task)
def test_0000_setup(self):
"""Setup the gateway required for the other tests in this module.
Create a gateway as per the configuration stated
above.
This test passes if the gateway is created successfully.
"""
TestGateway._client = Environment.get_sys_admin_client()
TestGateway._vdc = Environment.get_test_vdc(TestGateway._client)
TestGateway._org_client = Environment.get_client_in_default_org(
CommonRoles.ORGANIZATION_ADMINISTRATOR)
TestGateway._config = Environment.get_config()
TestGateway._api_version = TestGateway._config['vcd']['api_version']
external_network = Environment.get_test_external_network(
TestGateway._client)
ext_net_resource = external_network.get_resource()
ip_scopes = ext_net_resource.xpath(
'vcloud:Configuration/vcloud:IpScopes/vcloud:IpScope',
namespaces=NSMAP)
first_ipscope = ip_scopes[0]
gateway_ip = first_ipscope.Gateway.text
def test_0000_setup(self):
self._config = Environment.get_config()
TestVappNat._logger = Environment.get_default_logger()
TestVappNat._client = Environment.get_sys_admin_client()
TestVappNat._runner = CliRunner()
default_org = self._config['vcd']['default_org_name']
self._login()
TestVappNat._runner.invoke(org, ['use', default_org])
vapp = Environment.get_test_vapp_with_network(TestVappNat._client)
vapp.reload()
task = vapp.connect_vapp_network_to_ovdc_network(
network_name=TestVappNat._vapp_network_name,
orgvdc_network_name=TestVappNat._org_vdc_network_name)
result = TestVappNat._client.get_task_monitor().wait_for_success(task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
vm_resource = vapp.get_vm(TestVappNat._vm_name)
vm = VM(TestVappNat._client, resource=vm_resource)
task = vm.add_nic(NetworkAdapterType.E1000.value, True, True,
TestVappNat._vapp_network_name,
IpAddressMode.MANUAL.value,
TestVappNat._allocate_ip_address)
result = TestVappNat._client.get_task_monitor().wait_for_success(task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
list_vm_interface = vapp.list_vm_interface(