Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize the format. Added exception detection. #5982

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions avocado/utils/network/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,10 @@ def set_mtu(self, mtu, timeout=30):
up again. Default is 30.
"""
cmd = f"ip link set {self.name} mtu {mtu}"
run_command(cmd, self.host, sudo=True)
try:
run_command(cmd, self.host, sudo=True)
except Exception as ex:
raise NWException(f"Failed to set MTU. {ex}")
wait_for(self.is_link_up, timeout=timeout)
if int(mtu) != self.get_mtu():
raise NWException("Failed to set MTU.")
Expand Down Expand Up @@ -694,8 +697,7 @@ def are_packets_lost(self, peer_ip, options=None, sudo=False):
:param options: Type is List. Options such as -c, -f. Default is None
:param sudo: If sudo permissions are needed. Default is False
"""
cmd = f"ping -I {self.name} {peer_ip}"
cmd = f"{cmd} "
cmd = f"ping -I {self.name} {peer_ip} "
if options is not None:
for elem in options:
cmd += f"{elem} "
Expand Down Expand Up @@ -772,7 +774,7 @@ def validate_ipv4_netmask_format(self, netmask):
if not 0 <= num <= 255:
return False
octet_bin = [format(int(i), "08b") for i in netmask_list]
binary_netmask = ("").join(octet_bin)
binary_netmask = "".join(octet_bin)
accept_zero_only = False
first_bit = True
for symbol in binary_netmask:
Expand Down
Loading