Skip to content

Commit

Permalink
Merge pull request avocado-framework#3807 from smitterl/fix_get_defau…
Browse files Browse the repository at this point in the history
…lt_gw

utils_net: use unified method for command invocation
  • Loading branch information
chloerh authored Nov 30, 2023
2 parents 1fb23f1 + 05abed4 commit 92b558f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions virttest/utils_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -3916,16 +3916,15 @@ def get_default_gateway(iface_name=False, session=None, ip_ver='ipv4',
else:
cmd = "%s | awk '/default/ { print $3 }'" % ip_cmd
try:
_, output = utils_misc.cmd_status_output(cmd, shell=True)
if session:
output = session.cmd_output(cmd).strip()
LOG.debug("Guest default gateway is %s", output)
else:
output = process.run(cmd, shell=True).stdout_text.rstrip()
LOG.debug("Host default gateway is %s", output)
except (aexpect.ShellError, aexpect.ShellTimeoutError, process.CmdError):
LOG.error("Failed to get the default GateWay")
return None
return output
return output.strip()


def check_listening_port_by_service(service, port, listen_addr='0.0.0.0',
Expand Down

0 comments on commit 92b558f

Please sign in to comment.