How to use _get_server_nics method in tempest

Best Python code snippet using tempest_python

test_network_basic_ops.py

Source:test_network_basic_ops.py Github

copy

Full Screen

...181 ip_address = old_floating_ip.floating_ip_address182 private_key = self._get_server_key(server)183 ssh_client = self.get_remote_client(ip_address,184 private_key=private_key)185 old_nic_list = self._get_server_nics(ssh_client)186 # get a port from a list of one item187 port_list = self._list_ports(device_id=server['id'])188 self.assertEqual(1, len(port_list))189 old_port = port_list[0]190 _, interface = self.interface_client.create_interface(191 server=server['id'],192 network_id=self.new_net.id)193 self.addCleanup(self.network_client.wait_for_resource_deletion,194 'port',195 interface['port_id'])196 self.addCleanup(self.delete_wrapper,197 self.interface_client.delete_interface,198 server['id'], interface['port_id'])199 def check_ports():200 self.new_port_list = [port for port in201 self._list_ports(device_id=server['id'])202 if port != old_port]203 return len(self.new_port_list) == 1204 if not test.call_until_true(check_ports, CONF.network.build_timeout,205 CONF.network.build_interval):206 raise exceptions.TimeoutException("No new port attached to the "207 "server in time (%s sec) !"208 % CONF.network.build_timeout)209 new_port = net_resources.DeletablePort(client=self.network_client,210 **self.new_port_list[0])211 def check_new_nic():212 new_nic_list = self._get_server_nics(ssh_client)213 self.diff_list = [n for n in new_nic_list if n not in old_nic_list]214 return len(self.diff_list) == 1215 if not test.call_until_true(check_new_nic, CONF.network.build_timeout,216 CONF.network.build_interval):217 raise exceptions.TimeoutException("Interface not visible on the "218 "guest after %s sec"219 % CONF.network.build_timeout)220 num, new_nic = self.diff_list[0]221 ssh_client.assign_static_ip(nic=new_nic,222 addr=new_port.fixed_ips[0]['ip_address'])223 ssh_client.turn_nic_on(nic=new_nic)224 def _get_server_nics(self, ssh_client):225 reg = re.compile(r'(?P<num>\d+): (?P<nic_name>\w+):')226 ipatxt = ssh_client.get_ip_list()227 return reg.findall(ipatxt)228 def _check_network_internal_connectivity(self, network):229 """230 via ssh check VM internal connectivity:231 - ping internal gateway and DHCP port, implying in-tenant connectivity232 pinging both, because L3 and DHCP agents might be on different nodes233 """234 floating_ip, server = self.floating_ip_tuple235 # get internal ports' ips:236 # get all network ports in the new network237 internal_ips = (p['fixed_ips'][0]['ip_address'] for p in238 self._list_ports(tenant_id=server['tenant_id'],...

Full Screen

Full Screen

manager_congress.py

Source:manager_congress.py Github

copy

Full Screen

...160 ip_address = old_floating_ip.floating_ip_address161 private_key = self._get_server_key(server)162 ssh_client = self.get_remote_client(ip_address,163 private_key=private_key)164 old_nic_list = self._get_server_nics(ssh_client)165 # get a port from a list of one item166 port_list = self._list_ports(device_id=server['id'])167 self.assertEqual(1, len(port_list))168 old_port = port_list[0]169 _, interface = self.interface_client.create_interface(170 server=server['id'],171 network_id=self.new_net.id)172 self.addCleanup(self.ports_client.wait_for_resource_deletion,173 interface['port_id'])174 self.addCleanup(self.delete_wrapper,175 self.interface_client.delete_interface,176 server['id'], interface['port_id'])177 def check_ports():178 self.new_port_list = [port for port in179 self._list_ports(device_id=server['id'])180 if port != old_port]181 return len(self.new_port_list) == 1182 if not test.call_until_true(check_ports, CONF.network.build_timeout,183 CONF.network.build_interval):184 raise exceptions.TimeoutException("No new port attached to the "185 "server in time (%s sec) !"186 % CONF.network.build_timeout)187 new_port = self.ports_client.delete_port(self.new_port_list[0])188 def check_new_nic():189 new_nic_list = self._get_server_nics(ssh_client)190 self.diff_list = [n for n in new_nic_list if n not in old_nic_list]191 return len(self.diff_list) == 1192 if not test.call_until_true(check_new_nic, CONF.network.build_timeout,193 CONF.network.build_interval):194 raise exceptions.TimeoutException("Interface not visible on the "195 "guest after %s sec"196 % CONF.network.build_timeout)197 num, new_nic = self.diff_list[0]198 ssh_client.assign_static_ip(nic=new_nic,199 addr=new_port.fixed_ips[0]['ip_address'])200 ssh_client.turn_nic_on(nic=new_nic)201 def _get_server_nics(self, ssh_client):202 reg = re.compile(r'(?P<num>\d+): (?P<nic_name>\w+):')203 ipatxt = ssh_client.get_ip_list()204 return reg.findall(ipatxt)205 def _check_network_internal_connectivity(self, network):206 """via ssh check VM internal connectivity:207 - ping internal gateway and DHCP port, implying in-tenant connectivity208 pinging both, because L3 and DHCP agents might be on different nodes.209 """210 floating_ip, server = self.floating_ip_tuple211 # get internal ports' ips:212 # get all network ports in the new network213 internal_ips = (p['fixed_ips'][0]['ip_address'] for p in214 self._list_ports(tenant_id=server['tenant_id'],215 network_id=network.id)...

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