Add config context function

Usage: go to Netbox > Device > Edit > Config Context

- input the dictionary structure you want to have in generated config
- the code will compare if the key exists in current generated config
- if not, write the data into output configuration

Change-Id: I79584001d20c71443ef22f54e7d8d5b902134bf3
diff --git a/scripts/edgeconfig.py b/scripts/edgeconfig.py
index 8131335..5a809fb 100644
--- a/scripts/edgeconfig.py
+++ b/scripts/edgeconfig.py
@@ -62,7 +62,17 @@
             output_yaml["dhcpd_subnets"] = dhcpd_subnets
             output_yaml["dhcpd_interfaces"] = list(device.internal_interfaces.keys())
             output_yaml["netprep_nftables"] = device.generate_nftables()
-            output_yaml.update(device.generate_extra_config())
+
+            # If the key exists in generated config, warning with the key name
+            extra_config = device.generate_extra_config()
+            for key in extra_config.keys():
+                if key in output_yaml:
+                    nbhelper.utils.logger.warning(
+                        "Output YAML Key %s was overwritten", key
+                    )
+
+            output_yaml.update(extra_config)
+
             output_yaml = nbhelper.utils.apply_as_router(output_yaml)
 
         output_yaml["netprep_netplan"] = device.generate_netplan()
diff --git a/scripts/nbhelper/device.py b/scripts/nbhelper/device.py
index 32a2075..05f7ee0 100644
--- a/scripts/nbhelper/device.py
+++ b/scripts/nbhelper/device.py
@@ -310,7 +310,7 @@
 
             ret["interface_subnets"] = dict()
             ret["ue_routing"] = dict()
-            ret["ue_routing"]["ue_subnets"] = self.data.config_context["ue_subnets"]
+            ret["ue_routing"]["ue_subnets"] = self.data.config_context.pop("ue_subnets")
 
             # Create the interface_subnets in the configuration
             # It's using the interface as the key to list IP addresses
@@ -368,6 +368,8 @@
         """
         Generate the extra configs which need in management server configuration
         This function should only be called when the device role is "Router"
+
+        Extra config includes: service configuring parameters, additional config context
         """
 
         if self.extra_config:
@@ -404,6 +406,13 @@
             if ntp_client_allow:
                 self.extra_config["ntp_client_allow"] = ntp_client_allow
 
+        # If the key exists in generated config, warning with the key name
+        for key in self.data.config_context.keys():
+            if key in self.extra_config:
+                logger.warning("Extra config Key %s was overwritten", key)
+
+        self.extra_config.update(self.data.config_context)
+
         return self.extra_config