Best Python code snippet using tempest_python
test_network_v6.py
Source:test_network_v6.py
...105 ssh = self.get_remote_client(106 server_or_ip=fip.floating_ip_address,107 username=username)108 return ssh, ips, srv["id"]109 def turn_nic6_on(self, ssh, sid):110 """Turns the IPv6 vNIC on111 Required because guest images usually set only the first vNIC on boot.112 Searches for the IPv6 vNIC's MAC and brings it up.113 @param ssh: RemoteClient ssh instance to server114 @param sid: server uuid115 """116 ports = [p["mac_address"] for p in117 self._list_ports(device_id=sid,118 network_id=self.network_v6.id)]119 self.assertEqual(1, len(ports),120 message=("Multiple IPv6 ports found on network %s. "121 "ports: %s")122 % (self.network_v6, ports))123 mac6 = ports[0]124 ssh.set_nic_state(ssh.get_nic_name(mac6))125 def _prepare_and_test(self, address6_mode, n_subnets6=1, dualnet=False):126 net_list = self.prepare_network(address6_mode=address6_mode,127 n_subnets6=n_subnets6,128 dualnet=dualnet)129 sshv4_1, ips_from_api_1, sid1 = self.prepare_server(networks=net_list)130 sshv4_2, ips_from_api_2, sid2 = self.prepare_server(networks=net_list)131 def guest_has_address(ssh, addr):132 return addr in ssh.get_ip_list()133 # Turn on 2nd NIC for Cirros when dualnet134 if dualnet:135 self.turn_nic6_on(sshv4_1, sid1)136 self.turn_nic6_on(sshv4_2, sid2)137 # get addresses assigned to vNIC as reported by 'ip address' utility138 ips_from_ip_1 = sshv4_1.get_ip_list()139 ips_from_ip_2 = sshv4_2.get_ip_list()140 self.assertIn(ips_from_api_1['4'], ips_from_ip_1)141 self.assertIn(ips_from_api_2['4'], ips_from_ip_2)142 for i in range(n_subnets6):143 # v6 should be configured since the image supports it144 # It can take time for ipv6 automatic address to get assigned145 srv1_v6_addr_assigned = functools.partial(146 guest_has_address, sshv4_1, ips_from_api_1['6'][i])147 srv2_v6_addr_assigned = functools.partial(148 guest_has_address, sshv4_2, ips_from_api_2['6'][i])149 self.assertTrue(test.call_until_true(srv1_v6_addr_assigned,150 CONF.validation.ping_timeout, 1))...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!