Skip to content

Commit

Permalink
utils_net:Fix func get_default_gateway_json
Browse files Browse the repository at this point in the history
Fix KeyError

Signed-off-by: Haijiao Zhao <[email protected]>
  • Loading branch information
chloerh committed Nov 21, 2024
1 parent 02c3e87 commit 0b4ba16
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion virttest/utils_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -4089,7 +4089,9 @@ def get_default_gateway_json(

default_route_list = [x for x in ip_route if x["dst"] == "default"]
if force_dhcp:
default_route_list = [x for x in default_route_list if x["protocol"] == "dhcp"]
default_route_list = [
x for x in default_route_list if x.get("protocol") == "dhcp"
]
if target_iface:
LOG.debug(f"Get default gateway only for: {target_iface}")
non_multi = [x for x in default_route_list if x.get("dev") == target_iface]
Expand Down

0 comments on commit 0b4ba16

Please sign in to comment.