Fix some output format issues

Change-Id: I6eab9da1f0c4ff047b27c3d8c572d587a32d61ce
diff --git a/scripts/nbhelper/container.py b/scripts/nbhelper/container.py
index 2f3748a..397ee32 100644
--- a/scripts/nbhelper/container.py
+++ b/scripts/nbhelper/container.py
@@ -144,6 +144,11 @@
                 or ""
             )
 
+            # When prefix.routes is None, we will get the RouterIP from prefix instance
+            # And to output a normal format, we need to build as a list here.
+            if isinstance(routes, str):
+                routes = [{"ip": routes}]
+
             self.instances[prefix.data.description] = {
                 "domain": domain,
                 "subnet": prefix.subnet,
diff --git a/scripts/nbhelper/device.py b/scripts/nbhelper/device.py
index a88740b..94b03df 100644
--- a/scripts/nbhelper/device.py
+++ b/scripts/nbhelper/device.py
@@ -230,11 +230,12 @@
                     if not destination:
                         continue
 
-                    # If interface address is in destination subnet, we don't need this route
-                    if netaddr.IPNetwork(address).ip in netaddr.IPNetwork(destination):
-                        continue
+                    for dest_addr in destination.split(","):
 
-                    for dest_addr in destination.split():
+                        # If interface address is in destination subnet, we don't need this route
+                        if netaddr.IPNetwork(address).ip in netaddr.IPNetwork(dest_addr):
+                            continue
+
                         new_route = {
                             "to": dest_addr,
                             "via": str(netaddr.IPNetwork(reserved_ip["ip4"]).ip),
diff --git a/scripts/nbhelper/network.py b/scripts/nbhelper/network.py
index 5520d48..3a51219 100644
--- a/scripts/nbhelper/network.py
+++ b/scripts/nbhelper/network.py
@@ -94,9 +94,13 @@
                     "ip4": str(ip.address),
                     "custom_fields": ip.custom_fields,
                 }
+
+                rfc3442routes = ip.custom_fields.get("rfc3442routes")
+                rfc3442routes = rfc3442routes.split(",") if rfc3442routes else list()
+
                 self.routes.append(
                     {
-                        "ip": str(ip.address),
-                        "rfc3442routes": [ip.custom_fields.get("rfc3442routes")],
+                        "ip": str(netaddr.IPNetwork(ip.address).ip),
+                        "rfc3442routes": rfc3442routes,
                     }
                 )
diff --git a/scripts/nbhelper/service.py b/scripts/nbhelper/service.py
index d84f0cb..1ad992c 100644
--- a/scripts/nbhelper/service.py
+++ b/scripts/nbhelper/service.py
@@ -28,10 +28,10 @@
             "dns_search": [domainName],
             "dns_servers": [domain["dnsServer"]["address"]],
             "ntp_servers": [domain["ntpServer"]["address"]],
-            "tftp_servers": domain["dhcpServer"]["address"],
-            "range": domain["dhcprange"],
+            "tftpd_server": domain["dhcpServer"]["address"],
+            "range": domain["dhcprange"][0],
             "subnet": domain["subnet"],
-            "routers": [{"ip": domain["router"]}],
+            "routers": domain["router"],
             "hosts": list(),
         }
 
@@ -89,11 +89,11 @@
 
         # If service exists, set the FQDN to CNAME records
         if ntpServer:
-            forwardZoneConfig["cname"]["dns"] = getDomainNameByIP(ntpServer["address"])
+            forwardZoneConfig["cname"]["ntp"] = getDomainNameByIP(ntpServer["address"])
         if dhcpServer:
             forwardZoneConfig["cname"]["tftp"] = getDomainNameByIP(dhcpServer["address"])
         if dnsServer:
-            forwardZoneConfig["cname"]["dns"] = getDomainNameByIP(dnsServer["address"])
+            forwardZoneConfig["cname"]["ns"] = getDomainNameByIP(dnsServer["address"])
             forwardZoneConfig["ns"].append(getDomainNameByIP(dnsServer["address"]))
 
         for address, host in domain["hosts"].items():