2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.vpnservice.neutronvpn.api.l2gw;
11 import java.util.ArrayList;
12 import java.util.Collections;
13 import java.util.List;
14 import java.util.concurrent.atomic.AtomicBoolean;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LocalUcastMacs;
21 * The Class L2GatewayDevice.
23 public class L2GatewayDevice {
25 /** The device name. */
28 /** The hwvtep node id. */
31 /** The tunnel ips. */
32 List<IpAddress> tunnelIps = new ArrayList<IpAddress>();
34 /** The l2 gateway ids. */
35 List<Uuid> l2GatewayIds = new ArrayList<Uuid>();
37 /** The ucast local macs. */
38 List<LocalUcastMacs> ucastLocalMacs = Collections.synchronizedList(new ArrayList<LocalUcastMacs>());
40 /** the status of this device connectin */
41 AtomicBoolean connected = new AtomicBoolean(true);
44 * VTEP device name mentioned with L2 Gateway.
46 * @return the device name
48 public String getDeviceName() {
53 * Sets the device name.
58 public void setDeviceName(String deviceName) {
59 this.deviceName = deviceName;
63 * VTEP Node id for the device mentioned with L2 Gateway.
65 * @return the hwvtep node id
67 public String getHwvtepNodeId() {
72 * Sets the hwvtep node id.
75 * the new hwvtep node id
77 public void setHwvtepNodeId(String nodeId) {
78 this.hwvtepNodeId = nodeId;
82 * Tunnel IP created with in the device mentioned with L2 Gateway.
84 * @return the tunnel ips
86 public List<IpAddress> getTunnelIps() {
93 * @return the tunnel ip
95 public IpAddress getTunnelIp() {
96 if (tunnelIps.size() > 0) {
97 return tunnelIps.get(0);
103 * Adds the tunnel ip.
108 public void addTunnelIp(IpAddress tunnelIp) {
109 tunnelIps.add(tunnelIp);
113 * UUID representing L2Gateway.
115 * @return the l2 gateway ids
117 public List<Uuid> getL2GatewayIds() {
122 * Adds the l2 gateway id.
127 public void addL2GatewayId(Uuid l2GatewayId) {
128 l2GatewayIds.add(l2GatewayId);
132 * Removes the l2 gateway id.
137 public void removeL2GatewayId(Uuid l2GatewayId) {
138 l2GatewayIds.remove(l2GatewayId);
142 * Clear hwvtep node data.
144 public void clearHwvtepNodeData() {
150 * Sets the tunnel ips.
155 public void setTunnelIps(List<IpAddress> tunnelIps) {
156 this.tunnelIps = tunnelIps;
160 * Gets the ucast local macs.
162 * @return the ucast local macs
164 public List<LocalUcastMacs> getUcastLocalMacs() {
165 return new ArrayList<>(ucastLocalMacs);
169 * Adds the ucast local mac.
171 * @param localUcastMacs
172 * the local ucast macs
174 public void addUcastLocalMac(LocalUcastMacs localUcastMacs) {
175 ucastLocalMacs.add(localUcastMacs);
179 * Removes the ucast local mac.
181 * @param localUcastMacs
182 * the local ucast macs
184 public void removeUcastLocalMac(LocalUcastMacs localUcastMacs) {
185 ucastLocalMacs.remove(localUcastMacs);
188 public boolean isConnected() {
189 return connected.get();
192 public void setConnected(boolean connected) {
193 this.connected.set(connected);
199 * @see java.lang.Object#hashCode()
202 public int hashCode() {
203 final int prime = 31;
205 result = prime * result + ((deviceName == null) ? 0 : deviceName.hashCode());
206 result = prime * result + ((hwvtepNodeId == null) ? 0 : hwvtepNodeId.hashCode());
207 result = prime * result + ((l2GatewayIds == null) ? 0 : l2GatewayIds.hashCode());
208 result = prime * result + ((tunnelIps == null) ? 0 : tunnelIps.hashCode());
209 result = prime * result + ((ucastLocalMacs == null) ? 0 : ucastLocalMacs.hashCode());
216 * @see java.lang.Object#equals(java.lang.Object)
219 public boolean equals(Object obj) {
226 if (getClass() != obj.getClass()) {
229 L2GatewayDevice other = (L2GatewayDevice) obj;
230 if (deviceName == null) {
231 if (other.deviceName != null) {
234 } else if (!deviceName.equals(other.deviceName)) {
237 if (hwvtepNodeId == null) {
238 if (other.hwvtepNodeId != null) {
241 } else if (!hwvtepNodeId.equals(other.hwvtepNodeId)) {
244 if (l2GatewayIds == null) {
245 if (other.l2GatewayIds != null) {
248 } else if (!l2GatewayIds.equals(other.l2GatewayIds)) {
251 if (tunnelIps == null) {
252 if (other.tunnelIps != null) {
255 } else if (!tunnelIps.equals(other.tunnelIps)) {
258 if (ucastLocalMacs == null) {
259 if (other.ucastLocalMacs != null) {
262 } else if (!ucastLocalMacs.equals(other.ucastLocalMacs)) {
271 * @see java.lang.Object#toString()
274 public String toString() {
275 StringBuilder builder = new StringBuilder();
276 builder.append("L2GatewayDevice [deviceName=").append(deviceName).append(", hwvtepNodeId=").append(hwvtepNodeId)
277 .append(", tunnelIps=").append(tunnelIps).append(", l2GatewayIds=").append(l2GatewayIds)
278 .append(", ucastLocalMacs=").append(ucastLocalMacs).append("]");
279 return builder.toString();