Skip to content

Commit

Permalink
Merge pull request #4063 from chloerh/ip-options
Browse files Browse the repository at this point in the history
utils_net:Add ip_options to function get_net_if
  • Loading branch information
dzhengfy authored Feb 13, 2025
2 parents 77f030f + 654f52a commit 0a76f2f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions virttest/utils_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -1426,15 +1426,18 @@ def local_runner_status(cmd, timeout=None, shell=False):
return process.run(cmd, verbose=False, timeout=timeout, shell=shell).exit_status


def get_net_if(runner=local_runner, state=".*", qdisc=".*", optional=".*"):
def get_net_if(
runner=local_runner, state=".*", qdisc=".*", optional=".*", ip_options=""
):
"""
:param runner: command runner.
:param state: interface state get from ip link
:param qdisc: interface qdisc get from ip link
:param optional: optional match for interface find
:param ip_options: ip command options
:return: List of network interfaces.
"""
cmd = "ip link"
cmd = f"ip {ip_options} link"
# As the runner converts stdout to unicode on Python2,
# it has to be converted to string for struct.pack().
result = str(runner(cmd))
Expand Down

0 comments on commit 0a76f2f

Please sign in to comment.