Support the custom field for rfc3442 static routes to the edgeconfig script
Run netprep role on compute servers, with a suitable netplan
Change-Id: I3406d39cbdf733d3a0c1c1e8470f30471a278e60
diff --git a/scripts/base_edgeconfig.yaml b/scripts/base_edgeconfig.yaml
index fcd1a23..e98a648 100644
--- a/scripts/base_edgeconfig.yaml
+++ b/scripts/base_edgeconfig.yaml
@@ -3,6 +3,8 @@
netprep_nat_if: "eno1"
netprep_internal_if: "eno2"
+netprep_router: true
+netprep_netplan_file: "02-pronto"
tftpd_files:
- "undionly.kpxe"
diff --git a/scripts/netbox_edgeconfig.py b/scripts/netbox_edgeconfig.py
index 1ba9dc5..9f4e9d6 100644
--- a/scripts/netbox_edgeconfig.py
+++ b/scripts/netbox_edgeconfig.py
@@ -242,7 +242,7 @@
# inner function to iterate over a dev list
ihosts = []
idyn_range = None
- irouter = None
+ irouter = []
idns_servers = []
itftpd_server = None
@@ -255,7 +255,16 @@
# handle a router reservation
if name == "router":
- irouter = value["ip4"]
+ ir = {"ip": value["ip4"]}
+ if (
+ "rfc3442routes" in value["custom_fields"]
+ and value["custom_fields"]["rfc3442routes"]
+ ):
+ ir["rfc3442routes"] = value["custom_fields"]["rfc3442routes"].split(
+ ","
+ )
+
+ irouter.append(ir)
continue
# has a MAC address, and it's not null
@@ -456,12 +465,19 @@
res["ip4"] = str(netaddr.IPNetwork(ip["address"]).ip)
res["dns_name"] = ip["dns_name"] if "dns_name" in ip else "None"
res["services"] = {}
+ res["custom_fields"] = ip["custom_fields"]
resname = res["description"].lower().split(" ")[0]
devs[resname] = res
continue
+ aotype = ip["assigned_object_type"]
+
+ # don't handle VM's yet
+ if aotype == "virtualization.vminterface":
+ continue
+
dev = {}
dev["type"] = "device"