Fix for BUG 402: Subnet creation with NeutronAPIService sometimes fails 34/5134/2
authorRyan Moats <rmoats@us.ibm.com>
Wed, 5 Feb 2014 17:07:35 +0000 (11:07 -0600)
committerRyan Moats <rmoats@us.ibm.com>
Wed, 5 Feb 2014 18:00:52 +0000 (12:00 -0600)
with a 409 error

Correct typo and bring hostRoutes out as own init block

Change-Id: I7f6f83cb6a63aa81a057b40c377ac49132a9fcb9
Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet.java

index 11a1be21180db9f454cc1817ed55f762429d904d..6582d8c021d5f61de10ae6b221f1217fdd1d668f 100644 (file)
@@ -269,22 +269,26 @@ public class NeutronSubnet extends ConfigurationObject implements Serializable {
         }
         gatewayIPAssigned = false;
         dnsNameservers = new ArrayList<String>();
         }
         gatewayIPAssigned = false;
         dnsNameservers = new ArrayList<String>();
-        allocationPools = new ArrayList<NeutronSubnet_IPAllocationPool>();
-        hostRoutes = new ArrayList<NeutronSubnet_HostRoute>();
-        try {
-            SubnetUtils util = new SubnetUtils(cidr);
-            SubnetInfo info = util.getInfo();
-            if (gatewayIP == null) {
-                gatewayIP = info.getLowAddress();
-            }
-            if (allocationPools.size() < 1) {
-                NeutronSubnet_IPAllocationPool source =
-                    new NeutronSubnet_IPAllocationPool(info.getLowAddress(),
-                            info.getHighAddress());
-                allocationPools = source.splitPool(gatewayIP);
+        if (hostRoutes == null) {
+            hostRoutes = new ArrayList<NeutronSubnet_HostRoute>();
+        }
+        if (allocationPools == null) {
+            allocationPools = new ArrayList<NeutronSubnet_IPAllocationPool>();
+            try {
+                SubnetUtils util = new SubnetUtils(cidr);
+                SubnetInfo info = util.getInfo();
+                if (gatewayIP == null) {
+                    gatewayIP = info.getLowAddress();
+                }
+                if (allocationPools.size() < 1) {
+                    NeutronSubnet_IPAllocationPool source =
+                        new NeutronSubnet_IPAllocationPool(info.getLowAddress(),
+                                info.getHighAddress());
+                    allocationPools = source.splitPool(gatewayIP);
+                }
+            } catch (Exception e) {
+                return false;
             }
             }
-        } catch (Exception e) {
-            return false;
         }
         return true;
     }
         }
         return true;
     }