How to use _create_net_subnet_ret_net_from_cidr method in tempest

Best Python code snippet using tempest_python

test_create_server_multi_nic.py

Source:test_create_server_multi_nic.py Github

copy

Full Screen

...33 super(ServersTestMultiNic, cls).setup_clients()34 cls.client = cls.servers_client35 cls.networks_client = cls.os_primary.networks_client36 cls.subnets_client = cls.os_primary.subnets_client37 def _create_net_subnet_ret_net_from_cidr(self, cidr):38 name_net = data_utils.rand_name(self.__class__.__name__)39 net = self.networks_client.create_network(name=name_net)40 self.addCleanup(self.networks_client.delete_network,41 net['network']['id'])42 subnet = self.subnets_client.create_subnet(43 network_id=net['network']['id'],44 cidr=cidr,45 ip_version=4)46 self.addCleanup(self.subnets_client.delete_subnet,47 subnet['subnet']['id'])48 return net49 @decorators.idempotent_id('0578d144-ed74-43f8-8e57-ab10dbf9b3c2')50 def test_verify_multiple_nics_order(self):51 # Verify that the networks order given at the server creation is52 # preserved within the server.53 net1 = self._create_net_subnet_ret_net_from_cidr('19.80.0.0/24')54 net2 = self._create_net_subnet_ret_net_from_cidr('19.86.0.0/24')55 networks = [{'uuid': net1['network']['id']},56 {'uuid': net2['network']['id']}]57 server_multi_nics = self.create_test_server(58 networks=networks, wait_until='ACTIVE')59 # Cleanup server; this is needed in the test case because with the LIFO60 # nature of the cleanups, if we don't delete the server first, the port61 # will still be part of the subnet and we'll get a 409 from Neutron62 # when trying to delete the subnet. The tear down in the base class63 # will try to delete the server and get a 404 but it's ignored so64 # we're OK.65 self.addCleanup(self.delete_server, server_multi_nics['id'])66 addresses = (self.client.list_addresses(server_multi_nics['id'])67 ['addresses'])68 # We can't predict the ip addresses assigned to the server on networks.69 # Sometimes the assigned addresses are ['19.80.0.2', '19.86.0.2'], at70 # other times ['19.80.0.3', '19.86.0.3']. So we check if the first71 # address is in first network, similarly second address is in second72 # network.73 addr = [addresses[net1['network']['name']][0]['addr'],74 addresses[net2['network']['name']][0]['addr']]75 networks = [netaddr.IPNetwork('19.80.0.0/24'),76 netaddr.IPNetwork('19.86.0.0/24')]77 for address, network in zip(addr, networks):78 self.assertIn(address, network)79 @decorators.idempotent_id('1678d144-ed74-43f8-8e57-ab10dbf9b3c2')80 def test_verify_duplicate_network_nics(self):81 # Verify that server creation does not fail when more than one nic82 # is created on the same network.83 net1 = self._create_net_subnet_ret_net_from_cidr('19.80.0.0/24')84 net2 = self._create_net_subnet_ret_net_from_cidr('19.86.0.0/24')85 networks = [{'uuid': net1['network']['id']},86 {'uuid': net2['network']['id']},87 {'uuid': net1['network']['id']}]88 server_multi_nics = self.create_test_server(89 networks=networks, wait_until='ACTIVE')90 self.addCleanup(self.delete_server, server_multi_nics['id'])91 addresses = (self.client.list_addresses(server_multi_nics['id'])92 ['addresses'])93 addr = [addresses[net1['network']['name']][0]['addr'],94 addresses[net2['network']['name']][0]['addr'],95 addresses[net1['network']['name']][1]['addr']]96 networks = [netaddr.IPNetwork('19.80.0.0/24'),97 netaddr.IPNetwork('19.86.0.0/24'),98 netaddr.IPNetwork('19.80.0.0/24')]...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful