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

utils_net: also check ip for host up nic #3982

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
15 changes: 14 additions & 1 deletion virttest/utils_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,11 +1439,24 @@ def get_net_if(runner=local_runner, state=".*", qdisc=".*", optional=".*"):
# As the runner converts stdout to unicode on Python2,
# it has to be converted to string for struct.pack().
result = str(runner(cmd))
return re.findall(
ifaces_up = re.findall(
r"^\d+: (\S+?)[@:].*%s.*%s.*state %s.*$" % (optional, qdisc, state),
result,
re.MULTILINE,
)
LOG.debug("The ifaces up on host: %s" % ifaces_up)
ifaces_with_ip = []
for iface in ifaces_up:
cmd = "ip -c=never addr show %s" % iface
ret = runner(cmd)
ipv4_addr = re.findall("inet (.+?)/..?", ret, re.MULTILINE)
if ipv4_addr:
ifaces_with_ip.append(iface)
LOG.debug("The ifaces up with ip on host: %s" % ifaces_with_ip)
if not ifaces_with_ip:
LOG.error("No up ifaces with ip on host!")
else:
return ifaces_with_ip


def get_sorted_net_if():
Expand Down
Loading