How to use get_nic_name_by_ip method in tempest

Best Python code snippet using tempest_python

remote_client.py

Source:remote_client.py Github

copy

Full Screen

...78 def get_nic_name_by_mac(self, address):79 cmd = "ip -o link | awk '/%s/ {print $2}'" % address80 nic = self.exec_command(cmd)81 return nic.strip().strip(":").split('@')[0].lower()82 def get_nic_name_by_ip(self, address):83 cmd = "ip -o addr | awk '/%s/ {print $2}'" % address84 nic = self.exec_command(cmd)85 LOG.debug('(get_nic_name_by_ip) Command result: %s', nic)86 return nic.strip().strip(":").split('@')[0].lower()87 def get_dns_servers(self):88 cmd = 'cat /etc/resolv.conf'89 resolve_file = self.exec_command(cmd).strip().split('\n')90 entries = (l.split() for l in resolve_file)91 dns_servers = [l[1] for l in entries92 if len(l) and l[0] == 'nameserver']93 return dns_servers94 def _renew_lease_udhcpc(self, fixed_ip=None):95 """Renews DHCP lease via udhcpc client. """96 file_path = '/var/run/udhcpc.'97 nic_name = self.get_nic_name_by_ip(fixed_ip)98 pid = self.exec_command('cat {path}{nic}.pid'.99 format(path=file_path, nic=nic_name))100 pid = pid.strip()101 cmd = 'sudo /bin/kill -{sig} {pid}'.format(pid=pid, sig='USR1')102 self.exec_command(cmd)103 def _renew_lease_dhclient(self, fixed_ip=None):104 """Renews DHCP lease via dhclient client. """105 cmd = "sudo /sbin/dhclient -r && sudo /sbin/dhclient"106 self.exec_command(cmd)107 def renew_lease(self, fixed_ip=None, dhcp_client='udhcpc'):108 """Wrapper method for renewing DHCP lease via given client109 Supporting:110 * udhcpc111 * dhclient...

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