Partial fix for Bug 1408 97/10397/1
authorsousaedu <eduardo.sousa@canonical.com>
Wed, 3 Feb 2021 14:03:44 +0000 (15:03 +0100)
committersousaedu <eduardo.sousa@canonical.com>
Fri, 26 Feb 2021 12:22:50 +0000 (13:22 +0100)
This fixes the access to a non-exisiting key.
There is another bug that is causing this in LCM (bug 1431).

Change-Id: Ied80beb56657ead95eefa9ed967eca84e623f9c3
Signed-off-by: sousaedu <eduardo.sousa@canonical.com>
NG-RO/osm_ng_ro/ns.py

index f621051..1c2e960 100644 (file)
@@ -510,10 +510,11 @@ class Ns(object):
                     "ip_version": "IPv4" if "v4" in ip_profile.get("ip-version", "ipv4") else "IPv6",
                     "subnet_address": ip_profile.get("subnet-address"),
                     "gateway_address": ip_profile.get("gateway-address"),
-                    "dhcp_enabled": ip_profile["dhcp-params"].get("enabled", True),
-                    "dhcp_start_address": ip_profile["dhcp-params"].get("start-address"),
-                    "dhcp_count": ip_profile["dhcp-params"].get("count"),
-
+                    "dhcp_enabled": ip_profile["dhcp-params"].get("enabled", True)
+                    if "dhcp_params" in ip_profile else False,
+                    "dhcp_start_address": ip_profile["dhcp-params"].get("start-address")
+                    if "dhcp_params" in ip_profile else None,
+                    "dhcp_count": ip_profile["dhcp-params"].get("count") if "dhcp_params" in ip_profile else None,
                 }
                 if ip_profile.get("dns-server"):
                     ro_ip_profile["dns_address"] = ";".join([v["address"] for v in ip_profile["dns-server"]])