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;
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
}
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;
}
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 + "]";
+ }
}