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/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