Best Python code snippet using tempest_python
test_network_v6.py
Source:test_network_v6.py
...137 # NOTE(slaweq): on RHEL based OS ifcfg file for new interface is138 # needed to make IPv6 working on it, so if139 # /etc/sysconfig/network-scripts directory exists ifcfg-%(nic)s file140 # should be added in it141 if self._sysconfig_network_scripts_dir_exists(ssh):142 try:143 ssh.exec_command(144 'echo -e "DEVICE=%(nic)s\\nNAME=%(nic)s\\nIPV6INIT=yes" | '145 'sudo tee /etc/sysconfig/network-scripts/ifcfg-%(nic)s; '146 'sudo nmcli connection reload' % {'nic': nic})147 ssh.exec_command('sudo nmcli connection up %s' % nic)148 except exceptions.SSHExecCommandFailed as e:149 # NOTE(slaweq): Sometimes it can happen that this SSH command150 # will fail because of some error from network manager in151 # guest os.152 # But even then doing ip link set up below is fine and153 # IP address should be configured properly.154 LOG.debug("Error during restarting %(nic)s interface on "155 "instance. Error message: %(error)s",156 {'nic': nic, 'error': e})157 ssh.exec_command("sudo ip link set %s up" % nic)158 def _sysconfig_network_scripts_dir_exists(self, ssh):159 return "False" not in ssh.exec_command(160 'test -d /etc/sysconfig/network-scripts/ || echo "False"')161 def _prepare_and_test(self, address6_mode, n_subnets6=1, dualnet=False):162 net_list = self.prepare_network(address6_mode=address6_mode,163 n_subnets6=n_subnets6,164 dualnet=dualnet)165 sshv4_1, ips_from_api_1, srv1 = self.prepare_server(networks=net_list)166 sshv4_2, ips_from_api_2, srv2 = self.prepare_server(networks=net_list)167 def guest_has_address(ssh, addr):168 return addr in ssh.exec_command("ip address")169 # Turn on 2nd NIC for Cirros when dualnet170 if dualnet:171 _, network_v6 = net_list172 self.turn_nic6_on(sshv4_1, srv1['id'], network_v6['id'])...
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!!