X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openstack%2Fnet-virt%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fovsdb%2Fopenstack%2Fnetvirt%2Fapi%2FLoadBalancerConfiguration.java;h=ccb8655222fbe51f0d7b8a9c1a847558fcfac608;hb=c6efe31a199b6aba3c346da19c3fb4c2e70709af;hp=7965a9e96318bad5979a498bef4ded1ac283910b;hpb=ad8b8cfbfdd4f3bf996a32b865485a8622d5782c;p=netvirt.git diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/api/LoadBalancerConfiguration.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/api/LoadBalancerConfiguration.java index 7965a9e963..ccb8655222 100755 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/api/LoadBalancerConfiguration.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/api/LoadBalancerConfiguration.java @@ -19,10 +19,9 @@ import java.util.Map; */ public class LoadBalancerConfiguration { + public static final String PROTOCOL_TCP = "TCP"; public static final String PROTOCOL_HTTP = "HTTP"; public static final String PROTOCOL_HTTPS = "HTTPS"; - public static final Integer PROTOCOL_HTTP_PORT = 80; - public static final Integer PROTOCOL_HTTPS_PORT = 443; public class LoadBalancerPoolMember { String ipAddr; @@ -63,16 +62,50 @@ public class LoadBalancerConfiguration { public void setIndex(int index) { this.index = index; } - public boolean equals(LoadBalancerPoolMember other) { - if (other.ipAddr != ipAddr) + + /** + * Overridden equals() where index is not checked. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { return false; - else if (other.macAddr != macAddr) + } + LoadBalancerPoolMember other = (LoadBalancerPoolMember) obj; + if (ipAddr == null) { + if (other.ipAddr != null) { + return false; + } + } else if (!ipAddr.equals(other.ipAddr)) { return false; - else if (other.protocol != protocol) + } + if (macAddr == null) { + if (other.macAddr != null) { + return false; + } + } else if (!macAddr.equals(other.macAddr)) { return false; - else if (other.port != port) + } + if (port == null) { + if (other.port != null) { + return false; + } + } else if (!port.equals(other.port)) { return false; - //Ignore Index + } + if (protocol == null) { + if (other.protocol != null) { + return false; + } + } else if (!protocol.equals(other.protocol)) { + return false; + } return true; } @@ -85,18 +118,20 @@ public class LoadBalancerConfiguration { @Override public int hashCode() { final int prime = 31; - int result = super.hashCode(); + int result = 1; result = prime * result + ((ipAddr == null) ? 0 : ipAddr.hashCode()); result = prime * result + ((macAddr == null) ? 0 : macAddr.hashCode()); result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); result = prime * result + ((port == null) ? 0 : port.hashCode()); - result = prime * result + index; return result; } } private String name; private String vip; + private String vmac; //Used when a dummy neutron port is created for the VIP + private String providerNetworkType; + private String providerSegmentationId; private Map members; public LoadBalancerConfiguration() { @@ -107,12 +142,23 @@ public class LoadBalancerConfiguration { this.members = Maps.newHashMap(); this.name = name; this.vip = vip; + this.vmac = null; + } + + public LoadBalancerConfiguration(String name, String vip, String vmac) { + this.members = Maps.newHashMap(); + this.name = name; + this.vip = vip; + this.vmac = vmac; } public LoadBalancerConfiguration(LoadBalancerConfiguration lbConfig) { this.members = Maps.newHashMap(lbConfig.getMembers()); this.name = lbConfig.getName(); this.vip = lbConfig.getVip(); + this.vmac = lbConfig.getVmac(); + this.providerNetworkType = lbConfig.getProviderNetworkType(); + this.providerSegmentationId = lbConfig.getProviderSegmentationId(); } public Map getMembers() { @@ -121,8 +167,9 @@ public class LoadBalancerConfiguration { public Map addMember(String uuid, LoadBalancerPoolMember member) { //If index is not set for this object, update it before inserting - if (member.getIndex() == -1) + if (member.getIndex() == -1) { member.setIndex(members.size()); + } this.members.put(uuid, member); return this.members; } @@ -136,16 +183,21 @@ public class LoadBalancerConfiguration { /* Update indices of all other members */ int index = 0; - for(Map.Entry entry : this.getMembers().entrySet()) + for(Map.Entry entry : this.getMembers().entrySet()) { ((LoadBalancerPoolMember) entry.getValue()).setIndex(index++); + } return this.members; } public boolean isValid() { - if (members.size() == 0) + if (members.size() == 0) { + return false; + } else if (providerNetworkType == null) { return false; + } return true; } + public void setVip(String vip) { this.vip = vip; } @@ -154,6 +206,14 @@ public class LoadBalancerConfiguration { return this.vip; } + public void setVmac(String vmac) { + this.vmac = vmac; + } + + public String getVmac() { + return this.vmac; + } + public void setName(String name) { this.name = name; } @@ -162,9 +222,27 @@ public class LoadBalancerConfiguration { return this.name; } + public void setProviderSegmentationId(String providerSegmentationId) { + this.providerSegmentationId = providerSegmentationId; + } + + public String getProviderSegmentationId() { + return this.providerSegmentationId; + } + public void setProviderNetworkType(String providerNetworkType) { + this.providerNetworkType = providerNetworkType; + } + + public String getProviderNetworkType() { + return this.providerNetworkType; + } + @Override public String toString() { - return "LoadBalancerConfiguration [name=" + name + ", vip=" + vip + + return "LoadBalancerConfiguration [name=" + name + + ", vip=" + vip + ", vmac=" + vmac + + ", networkType=" + providerNetworkType + + ", segmentationId=" + providerSegmentationId + ", members=" + members + "]"; } }