Fix a few bugs introduced in recent changes

Change-Id: Ic939cc65208c4e3eb90f547ffac09ce40924641e
diff --git a/scripts/edgeconfig.py b/scripts/edgeconfig.py
index 2baa9a3..c8a31c2 100644
--- a/scripts/edgeconfig.py
+++ b/scripts/edgeconfig.py
@@ -61,4 +61,7 @@
     yaml_out["dhcpd_subnets"] = dhcpd_subnets
     yaml_out["dhcpd_interfaces"] = dhcpd_interfaces
 
+    if tenant.generate_extra_config():
+        yaml_out.update(tenant.generate_extra_config())
+
     print(yaml.safe_dump(yaml_out, indent=2))
diff --git a/scripts/nbhelper.py b/scripts/nbhelper.py
index c8309ab..2138889 100644
--- a/scripts/nbhelper.py
+++ b/scripts/nbhelper.py
@@ -186,6 +186,27 @@
 
         return target.generate_netplan()
 
+    def generate_extra_config(self, name=""):
+        """
+        Get the extra config of specific server belongs to this tenant,
+        If the name wasn't specified, return the management device config by default
+        """
+
+        target = None
+
+        if not name:
+            for machine in self.devices + self.vms:
+                if machine.data["device_role"]["name"] == "Router":
+                    target = machine
+                    break
+        else:
+            for machine in self.devices + self.vms:
+                if machine.name == name:
+                    target = machine
+                    break
+
+        return target.generate_extra_config()
+
 
 @yaml.yaml_object(ydump)
 class NBPrefix:
@@ -213,8 +234,6 @@
         self.build_prefix()
         self.prefixes[self.data.prefix] = self
 
-        self.prefixes[self.data.prefix] = self
-
     @classmethod
     def all_prefixes(cls):
         return cls.prefixes
@@ -398,6 +417,7 @@
         )
 
         self.netplan_config = dict()
+        self.extra_config = dict()
 
     def __repr__(self):
         return str(dict(self.data))
@@ -615,6 +635,15 @@
             if routes:
                 self.netplan_config["vlans"][virtual_if.name]["routes"] = routes
 
+        return self.netplan_config
+
+    def generate_extra_config(self):
+
+        if self.extra_config:
+            return self.extra_config
+
+        primary_ip = self.data.primary_ip.address if self.data.primary_ip else None
+
         # If the object is mgmtserver, it needs to have DNS/NTP server configs
         if self.data["device_role"]["name"] == "Router":
             services = list(netboxapi.ipam.services.filter(device_id=self.id))
@@ -631,13 +660,12 @@
                 for prefix in NBPrefix.all_prefixes().values():
                     if prefix.data.description:
                         unbound_allow_ips.append(prefix.data.prefix)
-                        ntp_client_allow.append(prefix.data.prefix)
 
                 if unbound_listen_ips:
-                    self.netplan_config["unbound_listen_ips"] = unbound_listen_ips
+                    self.extra_config["unbound_listen_ips"] = unbound_listen_ips
 
                 if unbound_allow_ips:
-                    self.netplan_config["unbound_allow_ips"] = unbound_allow_ips
+                    self.extra_config["unbound_allow_ips"] = unbound_allow_ips
 
             if "ntp" in service_names:
                 ntp_client_allow = []
@@ -647,9 +675,9 @@
                         ntp_client_allow.append(prefix.data.prefix)
 
                 if ntp_client_allow:
-                    self.netplan_config["ntp_client_allow"] = ntp_client_allow
+                    self.extra_config["ntp_client_allow"] = ntp_client_allow
 
-        return self.netplan_config
+        return self.extra_config
 
 
 @yaml.yaml_object(ydump)
diff --git a/scripts/tenant_validator.py b/scripts/tenant_validator.py
index 86c9702..0ce504e 100644
--- a/scripts/tenant_validator.py
+++ b/scripts/tenant_validator.py
@@ -386,7 +386,7 @@
         netbox_config["api_endpoint"], token=netbox_config["token"], threading=True
     )
 
-    if not netbox_config.get("validate_certs", False):
+    if not netbox_config.get("validate_certs", True):
         session = requests.Session()
         session.verify = False
         netboxapi.http_session = session