Bug 4818 dnsNameservers not stored in subnet MDSAL 80/31580/3
authorVishal Thapar <vishal.thapar@ericsson.com>
Fri, 18 Dec 2015 08:37:30 +0000 (14:07 +0530)
committerVishal Thapar <vishal.thapar@ericsson.com>
Wed, 23 Dec 2015 08:15:33 +0000 (13:45 +0530)
NeutronSubnet.initDefaults() wrongly initializes dnsNameservers even if
user passed a value. There should be a null check and initialization should
be done only if user didn't pass anything.

This adds check for dnsNameservers and improves the test cases in NeutronSubnetTests

Change-Id: Ibade65f18a65b9c8e6c0a26de02bbbbbe5cac0b7
Signed-off-by: Vishal Thapar <vishal.thapar@ericsson.com>
integration/test/src/test/java/org/opendaylight/neutron/e2etest/NeutronSubnetTests.java
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronSubnet.java

index 5c6b2c593284be67b61f6b44ce58fcb8054f198b..bb4b559f978d21b84ee97529a5eb1895f95294cc 100644 (file)
@@ -42,9 +42,9 @@ public class NeutronSubnetTests {
                 "\"start\": \"10.0.0.2\", "+
                 "\"end\": \"10.0.0.254\" } ], "+
             "\"host_routes\":[ { \"destination\":\"0.0.0.0/0\", " +
-               " \"nexthop\":\"123.156.78.9\" }, " +
+               " \"nexthop\":\"10.0.0.1\" }, " +
             " { \"destination\":\"192.168.0.0/24\", " +
-               " \"nexthop\":\"192.168.0.1\" } ], " +
+               " \"nexthop\":\"10.0.0.2\" } ], " +
             "\"ip_version\": 4, "+
             "\"gateway_ip\": \"10.0.0.1\", "+
             "\"cidr\": \"10.0.0.0/24\", "+
@@ -78,10 +78,13 @@ public class NeutronSubnetTests {
             + " { \"allocation_pools\": [ "
             + " { \"end\": \"192.168.199.254\", \"start\": \"192.168.199.2\" } ], "
             + " \"cidr\": \"192.168.199.0/24\", "
-            + " \"dns_nameservers\": [], "
+            + " \"dns_nameservers\": [\"8.8.8.8\"], "
             + " \"enable_dhcp\": true, "
             + " \"gateway_ip\": \"192.168.199.1\", "
-            + " \"host_routes\": [], "
+            + " \"host_routes\":[ { \"destination\":\"0.0.0.0/0\", "
+            + " \"nexthop\":\"192.168.199.3\" }, "
+            + " { \"destination\":\"192.168.0.0/24\", "
+            + " \"nexthop\":\"192.168.199.4\" } ], "
             + " \"id\": \"0468a7a7-290d-4127-aedd-6c9449775a24\", "
             + " \"ip_version\": 4, "
             + " \"name\": \"\", "
@@ -89,10 +92,13 @@ public class NeutronSubnetTests {
             + " \"tenant_id\": \"4fd44f30292945e481c7b8a0c8908869\" }, { "
             + " \"allocation_pools\": [ { \"end\": \"10.56.7.254\", \"start\": \"10.56.4.2\" } ], "
             + " \"cidr\": \"10.56.4.0/22\", "
-            + " \"dns_nameservers\": [], "
+            + " \"dns_nameservers\": [\"8.8.8.8\", \"8.8.8.4\"], "
             + " \"enable_dhcp\": true, "
             + " \"gateway_ip\": \"10.56.4.1\", "
-            + " \"host_routes\": [], "
+            + " \"host_routes\":[ { \"destination\":\"0.0.0.0/0\", "
+            + " \"nexthop\":\"10.56.4.3\" }, "
+            + " { \"destination\":\"192.168.0.0/24\", "
+            + " \"nexthop\":\"10.56.4.4\" } ], "
             + " \"id\": \"b0e7435c-1512-45fb-aa9e-9a7c5932fb30\", "
             + " \"ip_version\": 4, "
             + " \"name\": \"\", "
@@ -108,9 +114,10 @@ public class NeutronSubnetTests {
             + " \"enable_dhcp\": true, "
             + " \"network_id\": \"af374017-c9ae-4a1d-b799-ab73111476e2\", "
             + " \"tenant_id\": \"4fd44f30292945e481c7b8a0c8908869\", "
-            + " \"dns_nameservers\": [], "
+            + " \"dns_nameservers\": [\"8.8.8.8\", \"8.8.8.4\"], "
             + " \"allocation_pools\": [ { \"start\": \"10.0.0.2\", \"end\": \"10.0.0.254\" } ], "
-            + " \"host_routes\": [], "
+            + " \"host_routes\": [{ \"destination\":\"192.168.0.0/24\", "
+            + " \"nexthop\":\"10.0.0.11\" } ], "
             + " \"ip_version\": 4, "
             + " \"gateway_ip\": \"10.0.0.1\", "
             + " \"cidr\": \"10.0.0.0/24\", "
index 9248259231646baf377323505c9bc07bb616caff..e095bc061320c118e42ac44ff71b76273191f76d 100644 (file)
@@ -345,7 +345,9 @@ public class NeutronSubnet extends NeutronObject implements Serializable, INeutr
         if (ipVersion == null) {
             ipVersion = IPV4_VERSION;
         }
-        dnsNameservers = new ArrayList<String>();
+        if (dnsNameservers == null) {
+            dnsNameservers = new ArrayList<String>();
+        }
         if (hostRoutes == null) {
             hostRoutes = new ArrayList<NeutronSubnet_HostRoute>();
         }