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()