How to use _create_subnet_with_last_subnet_block method in tempest

Best Python code snippet using tempest_python

test_subnets.py

Source: test_subnets.py Github

copy

Full Screen

...58 body = cls.create_network(client=cls.admin_networks_client,59 **cls._provider_network_body)60 cls.network = body['network']61 cls.name = cls.network['name']62 cls.subnet = cls._create_subnet_with_last_subnet_block(cls.network)63 cls.cidr = cls.subnet['cidr']64 cls._subnet_data = {6: {'gateway':65 str(cls._get_gateway_from_tempest_conf(6)),66 'allocation_pools':67 cls._get_allocation_pools_from_gateway(6),68 'dns_nameservers': ['2001:4860:4860::8844',69 '2001:4860:4860::8888'],70 'host_routes': [{'destination': '2001::/​64',71 'nexthop': '2003::1'}],72 'new_host_routes': [{'destination':73 '2001::/​64',74 'nexthop': '2005::1'}],75 'new_dns_nameservers':76 ['2001:4860:4860::7744',77 '2001:4860:4860::7888']},78 4: {'gateway':79 str(cls._get_gateway_from_tempest_conf(4)),80 'allocation_pools':81 cls._get_allocation_pools_from_gateway(4),82 'dns_nameservers': ['8.8.4.4', '8.8.8.8'],83 'host_routes': [{'destination': '10.20.0.0/​32',84 'nexthop': '10.100.1.1'}],85 'new_host_routes': [{'destination':86 '10.20.0.0/​32',87 'nexthop':88 '10.100.1.2'}],89 'new_dns_nameservers': ['7.8.8.8', '7.8.4.4']}}90 @classmethod91 def _create_subnet_with_last_subnet_block(cls, network, ip_version=4):92 """Derive last subnet CIDR block from tenant CIDR and93 create the subnet with that derived CIDR94 """95 if ip_version == 4:96 cidr = netaddr.IPNetwork(CONF.network.project_network_cidr)97 mask_bits = CONF.network.project_network_mask_bits98 elif ip_version == 6:99 cidr = netaddr.IPNetwork(CONF.network.project_network_v6_cidr)100 mask_bits = CONF.network.project_network_v6_mask_bits101 subnet_cidr = list(cidr.subnet(mask_bits))[-1]102 gateway_ip = str(netaddr.IPAddress(subnet_cidr) + 1)103 body = cls.create_subnet(network, gateway=gateway_ip,104 cidr=subnet_cidr, mask_bits=mask_bits)105 return body['subnet']...

Full Screen

Full Screen

test_vlan_network_action.py

Source: test_vlan_network_action.py Github

copy

Full Screen

...18 def resource_setup(cls):19 super(DVSNetworksTest, cls).resource_setup()20 cls.network = cls.create_network()21 cls.name = cls.network['name']22 cls.subnet = cls._create_subnet_with_last_subnet_block(cls.network,23 cls._ip_version)24 cls._subnet_data = {6: {'gateway':25 str(cls._get_gateway_from_tempest_conf(6)),26 'allocation_pools':27 cls._get_allocation_pools_from_gateway(6),28 'dns_nameservers': ['2001:4860:4860::8844',29 '2001:4860:4860::8888'],30 'host_routes': [{'destination': '2001::/​64',31 'nexthop': '2003::1'}],32 'new_host_routes': [{'destination':33 '2001::/​64',34 'nexthop': '2005::1'}],35 'new_dns_nameservers':36 ['2001:4860:4860::7744',37 '2001:4860:4860::7888']},38 4: {'gateway':39 str(cls._get_gateway_from_tempest_conf(4)),40 'allocation_pools':41 cls._get_allocation_pools_from_gateway(4),42 'dns_nameservers': ['8.8.4.4', '8.8.8.8'],43 'host_routes': [{'destination': '10.20.0.0/​32',44 'nexthop': '10.100.1.1'}],45 'new_host_routes': [{'destination':46 '10.20.0.0/​32',47 'nexthop':48 '10.100.1.2'}],49 'new_dns_nameservers': ['7.8.8.8', '7.8.4.4']}}50# @classmethod51# def resource_cleanup(cls):52# " do not delete network "53# pass 54 def test_a_create_update_delete_network_subnet(self):55 " Create a network "56 name = data_utils.rand_name('network-') 57 network = self.create_network(network_name=name)58 self.addCleanup(self._delete_network, network)59 net_id = network['id']60 self.net_id = net_id61 self.assertEqual('ACTIVE', network['status'])62 "network update"63 new_name = data_utils.rand_name('new-network-')64 body = self.networks_client.update_network(net_id, name=new_name)65 updated_net = body['network']66 self.assertEqual(updated_net['name'], new_name)67 "Find a cidr that is not in use yet and create a subnet with it"68 subnet = self.create_subnet(network)69 subnet_id = subnet['id']70 "subnet update"71 new_name = "New_subnet"72 body = self.subnets_client.update_subnet(subnet_id, name=new_name)73 updated_subnet = body['subnet']74 self.assertEqual(updated_subnet['name'], new_name)75 76 def test_b_show_network(self):77 "show network"78 body = self.networks_client.show_network(self.network['id'])79 network = body['network']80 for key in ['id', 'name']:81 self.assertEqual(network[key], self.network[key])82 print network83 def test_c_show_network_fields(self):84 fields = ['id', 'name']85 body = self.networks_client.show_network(self.network['id'],86 fields=fields)87 network = body['network']88 self.assertEqual(sorted(network.keys()), sorted(fields))89 for field_name in fields:90 self.assertEqual(network[field_name], self.network[field_name])91 print ">>>>", network92 def test_d_list_networks(self):93 body = self.networks_client.list_networks()94 networks = [network['id'] for network in body['networks']95 if network['id'] == self.network['id']]96 self.assertNotEmpty(networks, "Created network not found in the list")97 98 def test_e_delete_network(self):99 "delete network"100 body = self.networks_client.delete_network(self.network['id'])101 self.assertEqual(204, body.response.status)102 @classmethod103 def _create_subnet_with_last_subnet_block(cls, network, ip_version):104 if ip_version == 4:105 cidr = netaddr.IPNetwork(CONF.network.project_network_cidr)106 mask_bits = CONF.network.project_network_mask_bits107 elif ip_version == 6:108 cidr = netaddr.IPNetwork(CONF.network.project_network_v6_cidr)109 mask_bits = CONF.network.project_network_v6_mask_bits110 subnet_cidr = list(cidr.subnet(mask_bits))[-1]111 gateway_ip = str(netaddr.IPAddress(subnet_cidr) + 1)112 return cls.create_subnet(network, gateway=gateway_ip,113 cidr=subnet_cidr, mask_bits=mask_bits)114 @classmethod115 def _get_gateway_from_tempest_conf(cls, ip_version):116 """Return first subnet gateway for configured CIDR """117 if ip_version == 4:...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Rebuild Confidence in Your Test Automation

These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.

What will come after “agile”?

I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

Do you possess the necessary characteristics to adopt an Agile testing mindset?

To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.

How To Refresh Page Using Selenium C# [Complete Tutorial]

When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.

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