Merge pull request #84 from nix-community/robust_json_parse
kexec-installer: don't die on missing json keys
This commit is contained in:
commit
b3d848599d
1 changed files with 4 additions and 4 deletions
|
@ -14,7 +14,7 @@ def filter_interfaces(network: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||||
continue
|
continue
|
||||||
addr_info = []
|
addr_info = []
|
||||||
has_dynamic_address = False
|
has_dynamic_address = False
|
||||||
for addr in net["addr_info"]:
|
for addr in net.get("addr_info", []):
|
||||||
# no link-local ipv4/ipv6
|
# no link-local ipv4/ipv6
|
||||||
if addr.get("scope") == "link":
|
if addr.get("scope") == "link":
|
||||||
continue
|
continue
|
||||||
|
@ -50,16 +50,16 @@ def generate_networkd_units(
|
||||||
name = f"{interface['ifname']}.network"
|
name = f"{interface['ifname']}.network"
|
||||||
addresses = [
|
addresses = [
|
||||||
f"Address = {addr['local']}/{addr['prefixlen']}"
|
f"Address = {addr['local']}/{addr['prefixlen']}"
|
||||||
for addr in interface["addr_info"]
|
for addr in interface.get("addr_info", [])
|
||||||
]
|
]
|
||||||
|
|
||||||
route_sections = []
|
route_sections = []
|
||||||
for route in routes:
|
for route in routes:
|
||||||
if route["dev"] != interface["ifname"]:
|
if route.get("dev", "nodev") != interface.get("ifname", "noif"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
route_section = "[Route]\n"
|
route_section = "[Route]\n"
|
||||||
if route["dst"] != "default":
|
if route.get("dst") != "default":
|
||||||
# can be skipped for default routes
|
# can be skipped for default routes
|
||||||
route_section += f"Destination = {route['dst']}\n"
|
route_section += f"Destination = {route['dst']}\n"
|
||||||
gateway = route.get("gateway")
|
gateway = route.get("gateway")
|
||||||
|
|
Loading…
Reference in a new issue