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.ovsdb.hwvtepsouthbound;
11 import java.util.HashMap;
14 import org.opendaylight.ovsdb.lib.notation.UUID;
15 import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch;
16 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocator;
17 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalSwitch;
20 * HwvtepDeviceInfo is used to store some of the table entries received
21 * in updates from a Hwvtep device. There will be one instance of this per
22 * Hwvtep device connected. Table entries are stored in a map keyed by
23 * uuids of respective rows.
25 * Purpose of this class is to provide data present in tables which
26 * were updated in a previous transaction and are not available in
27 * current updatedRows. This allows us to handle updates for Tables
28 * which reference other tables and need information in those tables
29 * to add data to Operational data store.
31 * e.g. Mac-entries in data store use logical-switch-ref as one of the
32 * keys. Mac-entry updates from switch rarely contain Logical_Switch
33 * table entries. To add mac-entries we need table entries from
34 * Logical_Switch table which were created in an earlier update.
37 public class HwvtepDeviceInfo {
38 private Map<UUID, LogicalSwitch> logicalSwitches = null;
39 private Map<UUID, PhysicalSwitch> physicalSwitches = null;
40 private Map<UUID, PhysicalLocator> physicalLocators = null;
41 private Map<UUID, UUID> mapTunnelToPhysicalSwitch = null;
43 public HwvtepDeviceInfo() {
44 this.logicalSwitches = new HashMap<>();
45 this.physicalSwitches = new HashMap<>();
46 this.physicalLocators = new HashMap<>();
47 this.mapTunnelToPhysicalSwitch = new HashMap<>();
50 public void putLogicalSwitch(UUID uuid, LogicalSwitch lSwitch) {
51 logicalSwitches.put(uuid, lSwitch);
54 public LogicalSwitch getLogicalSwitch(UUID uuid) {
55 return logicalSwitches.get(uuid);
58 public LogicalSwitch removeLogicalSwitch(UUID uuid) {
59 return logicalSwitches.remove(uuid);
62 public Map<UUID, LogicalSwitch> getLogicalSwitches() {
63 return logicalSwitches;
66 public void putPhysicalSwitch(UUID uuid, PhysicalSwitch pSwitch) {
67 physicalSwitches.put(uuid, pSwitch);
70 public PhysicalSwitch getPhysicalSwitch(UUID uuid) {
71 return physicalSwitches.get(uuid);
74 public PhysicalSwitch removePhysicalSwitch(UUID uuid) {
75 return physicalSwitches.remove(uuid);
78 public Map<UUID, PhysicalSwitch> getPhysicalSwitches() {
79 return physicalSwitches;
82 public void putPhysicalLocator(UUID uuid, PhysicalLocator pLocator) {
83 physicalLocators.put(uuid, pLocator);
86 public PhysicalLocator getPhysicalLocator(UUID uuid) {
87 return physicalLocators.get(uuid);
90 public PhysicalLocator removePhysicalLocator(UUID uuid) {
91 return physicalLocators.remove(uuid);
94 public Map<UUID, PhysicalLocator> getPhysicalLocators() {
95 return physicalLocators;
98 public void putPhysicalSwitchForTunnel(UUID uuid, UUID psUUID) {
99 mapTunnelToPhysicalSwitch.put(uuid, psUUID);
102 public PhysicalSwitch getPhysicalSwitchForTunnel(UUID uuid) {
103 return physicalSwitches.get(mapTunnelToPhysicalSwitch.get(uuid));
106 public void removePhysicalSwitchForTunnel(UUID uuid) {
107 mapTunnelToPhysicalSwitch.remove(uuid);
110 public Map<UUID, UUID> getPhysicalSwitchesForTunnels() {
111 return mapTunnelToPhysicalSwitch;