Skip to content
Open
Show file tree
Hide file tree
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: 10 additions & 0 deletions libvirt/tests/src/virtual_network/iface_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ def modify_iface_xml(sync=True):
if not source:
source = {"network": "default"}
net_ifs = utils_net.get_net_if(state="UP")
# if no interfaces are available in UP state,
# iterate through all interfaces with UNKNOWN
# state and check if they can be pinged to the
# internet through.
if len(net_ifs) == 0:
unknown_net_ifs = utils_net.get_net_if(state="UNKNOWN")
for interface in unknown_net_ifs:
if utils_net.ping(dest="google.com", interface=interface, count=5, timeout=120)[0] == 0:
net_ifs.append(interface)
break
# Check source device is valid or not,
# if it's not in host interface list, try to set
# source device to first active interface of host
Expand Down
10 changes: 10 additions & 0 deletions libvirt/tests/src/virtual_network/iface_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ def modify_iface_xml(update, status_error=False):
source = iface_source
if source:
net_ifs = utils_net.get_net_if(state="UP")
# if no interfaces are available in UP state,
# iterate through all interfaces with UNKNOWN
# state and check if they can be pinged to the
# internet through.
if len(net_ifs) == 0:
unknown_net_ifs = utils_net.get_net_if(state="UNKNOWN")
for interface in unknown_net_ifs:
if utils_net.ping(dest="google.com", interface=interface, count=5, timeout=120)[0] == 0:
net_ifs.append(interface)
break
# Check source device is valid or not,
# if it's not in host interface list, try to set
# source device to first active interface of host
Expand Down