X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetworkconfiguration%2Fneutron%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetworkconfig%2Fneutron%2FNeutronSubnet.java;h=6582d8c021d5f61de10ae6b221f1217fdd1d668f;hb=fc4e18f55f96fe9a361069769a3e3a49a6782ee5;hp=e53c3d4b1a9ddee674c231bdf400f0beed22a162;hpb=350dbdeb0a3d942ba532ada1d1931baf591bec5b;p=controller.git diff --git a/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet.java b/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet.java index e53c3d4b1a..6582d8c021 100644 --- a/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet.java +++ b/opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet.java @@ -8,9 +8,11 @@ package org.opendaylight.controller.networkconfig.neutron; +import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import java.util.List; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -18,11 +20,14 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.commons.net.util.SubnetUtils; import org.apache.commons.net.util.SubnetUtils.SubnetInfo; +import org.opendaylight.controller.configuration.ConfigurationObject; @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) -public class NeutronSubnet { +public class NeutronSubnet extends ConfigurationObject implements Serializable { + private static final long serialVersionUID = 1L; + // See OpenStack Network API v2.0 Reference for description of // annotated attributes @@ -264,22 +269,26 @@ public class NeutronSubnet { } gatewayIPAssigned = false; dnsNameservers = new ArrayList(); - allocationPools = new ArrayList(); - hostRoutes = new ArrayList(); - 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(); + } + if (allocationPools == null) { + allocationPools = new ArrayList(); + 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; } @@ -428,4 +437,13 @@ public class NeutronSubnet { public void resetGatewayIPAllocated() { gatewayIPAssigned = false; } + + @Override + public String toString() { + return "NeutronSubnet [subnetUUID=" + subnetUUID + ", networkUUID=" + networkUUID + ", name=" + name + + ", ipVersion=" + ipVersion + ", cidr=" + cidr + ", gatewayIP=" + gatewayIP + ", dnsNameservers=" + + dnsNameservers + ", allocationPools=" + allocationPools + ", hostRoutes=" + hostRoutes + + ", enableDHCP=" + enableDHCP + ", tenantID=" + tenantID + ", myPorts=" + myPorts + + ", gatewayIPAssigned=" + gatewayIPAssigned + "]"; + } }