/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
private Entity connectedEntity;
private EntityOwnershipCandidateRegistration deviceOwnershipCandidateRegistration;
private HwvtepGlobalAugmentation initialCreatedData = null;
+ private HwvtepDeviceInfo deviceInfo;
HwvtepConnectionInstance (ConnectionInfo key,OvsdbClient client,
this.client = client;
this.instanceIdentifier = iid;
this.txInvoker = txInvoker;
+ this.deviceInfo = new HwvtepDeviceInfo();
}
public void transact(TransactCommand command) {
public void setHwvtepGlobalAugmentation(HwvtepGlobalAugmentation hwvtepGlobalData) {
this.initialCreatedData = hwvtepGlobalData;
}
+
+ public HwvtepDeviceInfo getDeviceInfo() {
+ return this.deviceInfo;
+ }
+
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.ovsdb.hwvtepsouthbound;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.opendaylight.ovsdb.lib.notation.UUID;
+import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch;
+
+/*
+ * HwvtepDeviceInfo is used to store some of the table entries received
+ * in updates from a Hwvtep device. There will be one instance of this per
+ * Hwvtep device connected. Table entries are stored in a map keyed by
+ * uuids of respective rows.
+ *
+ * Purpose of this class is to provide data present in tables which
+ * were updated in a previous transaction and are not available in
+ * current updatedRows. This allows us to handle updates for Tables
+ * which reference other tables and need information in those tables
+ * to add data to Operational data store.
+ *
+ * e.g. Mac-entries in data store use logical-switch-ref as one of the
+ * keys. Mac-entry updates from switch rarely contain Logical_Switch
+ * table entries. To add mac-entries we need table entries from
+ * Logical_Switch table which were created in an earlier update.
+ *
+ */
+public class HwvtepDeviceInfo {
+ private Map<UUID, LogicalSwitch> logicalSwitches = null;
+
+ public HwvtepDeviceInfo() {
+ this.logicalSwitches = new HashMap<>();
+ }
+
+ public void putLogicalSwitch(UUID uuid, LogicalSwitch lSwitch) {
+ logicalSwitches.put(uuid, lSwitch);
+ }
+
+ public LogicalSwitch getLogicalSwitch(UUID uuid) {
+ return logicalSwitches.get(uuid);
+ }
+
+ public LogicalSwitch removeLogicalSwitch(UUID uuid) {
+ return logicalSwitches.remove(uuid);
+ }
+
+ public Map<UUID, LogicalSwitch> getLogicalSwitches() {
+ return logicalSwitches;
+ }
+}
for (LocalMcastMacs macBefore: macListBefore) {
int i = 0;
for(; i < macListUpdated.size(); i++) {
- if (macBefore.getMacEntryKey().equals(macListUpdated.get(i).getMacEntryKey())) {
+ if (macBefore.getKey().equals(macListUpdated.get(i).getKey())) {
break;
}
}
for (RemoteMcastMacs macBefore: macListBefore) {
int i = 0;
for(; i < macListUpdated.size(); i++) {
- if (macBefore.getMacEntryKey().equals(macListUpdated.get(i).getMacEntryKey())) {
+ if (macBefore.getKey().equals(macListUpdated.get(i).getKey())) {
break;
}
}
for (LocalUcastMacs macBefore: macListBefore) {
int i = 0;
for(; i < macListUpdated.size(); i++) {
- if (macBefore.getMacEntryKey().equals(macListUpdated.get(i).getMacEntryKey())) {
+ if (macBefore.getKey().equals(macListUpdated.get(i).getKey())) {
break;
}
}
for (RemoteUcastMacs macBefore: macListBefore) {
int i = 0;
for(; i < macListUpdated.size(); i++) {
- if (macBefore.getMacEntryKey().equals(macListUpdated.get(i).getMacEntryKey())) {
+ if (macBefore.getKey().equals(macListUpdated.get(i).getKey())) {
break;
}
}
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
.child(LogicalSwitches.class, new LogicalSwitchesKey(new HwvtepNodeName(lSwitch.getName())));
// TODO Delete any references
transaction.delete(LogicalDatastoreType.OPERATIONAL, switchIid);
+ getOvsdbConnectionInstance().getDeviceInfo().removeLogicalSwitch(lSwitch.getUuid());
}
}
if (connection.isPresent()) {
Node connectionNode = buildConnectionNode(lSwitch);
transaction.merge(LogicalDatastoreType.OPERATIONAL, connectionIId, connectionNode);
+ getOvsdbConnectionInstance().getDeviceInfo().putLogicalSwitch(lSwitch.getUuid(), lSwitch);
// TODO: Delete entries that are no longer needed
}
}
package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
import java.util.Collection;
-import java.util.Map;
-
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
public class MacEntriesRemoveCommand extends AbstractTransactionCommand {
private static final Logger LOG = LoggerFactory.getLogger(MacEntriesRemoveCommand.class);
- Map<UUID, LogicalSwitch> lSwitchUpdatedRows;
public MacEntriesRemoveCommand(HwvtepConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema) {
super(key, updates, dbSchema);
- lSwitchUpdatedRows = TyperUtils.extractRowsUpdated(LogicalSwitch.class, getUpdates(), getDbSchema());
}
}
private HwvtepLogicalSwitchRef getLogicalSwitchRef(UUID switchUUID) {
- LogicalSwitch logicalSwitch = lSwitchUpdatedRows.get(switchUUID);
+ LogicalSwitch logicalSwitch = getOvsdbConnectionInstance().getDeviceInfo().getLogicalSwitch(switchUUID);
if (logicalSwitch != null) {
InstanceIdentifier<LogicalSwitches> lSwitchIid =
HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(), logicalSwitch);
return new HwvtepLogicalSwitchRef(lSwitchIid);
}
+ LOG.debug("Failed to get LogicalSwitch {}", switchUUID);
+ LOG.trace("Available LogicalSwitches: {}",
+ getOvsdbConnectionInstance().getDeviceInfo().getLogicalSwitches().values());
return null;
}
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
-
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
private Map<UUID, McastMacsLocal> updatedMMacsLocalRows;
private Map<UUID, PhysicalLocatorSet> updatedPLocSetRows;
private Map<UUID, PhysicalLocator> updatedPLocRows;
- private Map<UUID, LogicalSwitch> updatedLSRows;
public McastMacsLocalUpdateCommand(HwvtepConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema) {
super(key, updates, dbSchema);
updatedMMacsLocalRows = TyperUtils.extractRowsUpdated(McastMacsLocal.class, getUpdates(), getDbSchema());
updatedPLocSetRows = TyperUtils.extractRowsUpdated(PhysicalLocatorSet.class, getUpdates(), getDbSchema());
updatedPLocRows = TyperUtils.extractRowsUpdated(PhysicalLocator.class, getUpdates(), getDbSchema());
- updatedLSRows = TyperUtils.extractRowsUpdated(LogicalSwitch.class, getUpdates(), getDbSchema());
}
@Override
private void setLogicalSwitch(LocalMcastMacsBuilder mMacLocalBuilder, McastMacsLocal mMacLocal) {
if (mMacLocal.getLogicalSwitchColumn() != null && mMacLocal.getLogicalSwitchColumn().getData() != null) {
UUID lsUUID = mMacLocal.getLogicalSwitchColumn().getData();
- LogicalSwitch lSwitch = updatedLSRows.get(lsUUID);
+ LogicalSwitch lSwitch = getOvsdbConnectionInstance().getDeviceInfo().getLogicalSwitch(lsUUID);
if (lSwitch != null) {
InstanceIdentifier<LogicalSwitches> lSwitchIid =
HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(), lSwitch);
private Map<UUID, McastMacsRemote> updatedMMacsRemoteRows;
private Map<UUID, PhysicalLocatorSet> updatedPLocSetRows;
private Map<UUID, PhysicalLocator> updatedPLocRows;
- private Map<UUID, LogicalSwitch> updatedLSRows;
public McastMacsRemoteUpdateCommand(HwvtepConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema) {
super(key, updates, dbSchema);
updatedMMacsRemoteRows = TyperUtils.extractRowsUpdated(McastMacsRemote.class, getUpdates(), getDbSchema());
updatedPLocSetRows = TyperUtils.extractRowsUpdated(PhysicalLocatorSet.class, getUpdates(), getDbSchema());
updatedPLocRows = TyperUtils.extractRowsUpdated(PhysicalLocator.class, getUpdates(), getDbSchema());
- updatedLSRows = TyperUtils.extractRowsUpdated(LogicalSwitch.class, getUpdates(), getDbSchema());
}
@Override
private void setLogicalSwitch(RemoteMcastMacsBuilder mMacRemoteBuilder, McastMacsRemote mMacRemote) {
if (mMacRemote.getLogicalSwitchColumn() != null && mMacRemote.getLogicalSwitchColumn().getData() != null) {
UUID lsUUID = mMacRemote.getLogicalSwitchColumn().getData();
- LogicalSwitch lSwitch = updatedLSRows.get(lsUUID);
+ LogicalSwitch lSwitch = getOvsdbConnectionInstance().getDeviceInfo().getLogicalSwitch(lsUUID);
if (lSwitch != null) {
InstanceIdentifier<LogicalSwitches> lSwitchIid =
HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(), lSwitch);
/*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
private Map<UUID, PhysicalPort> updatedPPRows;
private Map<UUID, PhysicalPort> oldPPRows;
private Map<UUID, PhysicalSwitch> switchUpdatedRows;
- private Map<UUID, LogicalSwitch> lSwitchUpdatedRows;
public PhysicalPortUpdateCommand(HwvtepConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema) {
super(key, updates, dbSchema);
updatedPPRows = TyperUtils.extractRowsUpdated(PhysicalPort.class, getUpdates(), getDbSchema());
oldPPRows = TyperUtils.extractRowsOld(PhysicalPort.class, getUpdates(), getDbSchema());
switchUpdatedRows = TyperUtils.extractRowsUpdated(PhysicalSwitch.class, getUpdates(), getDbSchema());
- lSwitchUpdatedRows = TyperUtils.extractRowsUpdated(LogicalSwitch.class, getUpdates(), getDbSchema());
}
@Override
}
private HwvtepLogicalSwitchRef getLogicalSwitchRef(UUID switchUUID) {
- LogicalSwitch logicalSwitch = lSwitchUpdatedRows.get(switchUUID);
+ LogicalSwitch logicalSwitch = getOvsdbConnectionInstance().getDeviceInfo().getLogicalSwitch(switchUUID);
if (logicalSwitch != null) {
InstanceIdentifier<LogicalSwitches> lSwitchIid =
HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(), logicalSwitch);
return new HwvtepLogicalSwitchRef(lSwitchIid);
}
+ LOG.debug("Failed to get LogicalSwitch {}", switchUUID);
+ LOG.trace("Available LogicalSwitches: {}",
+ getOvsdbConnectionInstance().getDeviceInfo().getLogicalSwitches().values());
return null;
}
private Map<UUID, UcastMacsLocal> updatedUMacsLocalRows;
private Map<UUID, PhysicalLocator> updatedPLocRows;
- private Map<UUID, LogicalSwitch> updatedLSRows;
public UcastMacsLocalUpdateCommand(HwvtepConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema) {
super(key, updates, dbSchema);
updatedUMacsLocalRows = TyperUtils.extractRowsUpdated(UcastMacsLocal.class, getUpdates(), getDbSchema());
updatedPLocRows = TyperUtils.extractRowsUpdated(PhysicalLocator.class, getUpdates(), getDbSchema());
- updatedLSRows = TyperUtils.extractRowsUpdated(LogicalSwitch.class, getUpdates(), getDbSchema());
}
@Override
}
if (ucml.getLogicalSwitchColumn() != null && ucml.getLogicalSwitchColumn().getData() != null) {
UUID lsUUID = ucml.getLogicalSwitchColumn().getData();
- LogicalSwitch logicalSwitch = updatedLSRows.get(lsUUID);
+ LogicalSwitch logicalSwitch = getOvsdbConnectionInstance().getDeviceInfo().getLogicalSwitch(lsUUID);
if (logicalSwitch != null) {
InstanceIdentifier<LogicalSwitches> lSwitchIid =
HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(), logicalSwitch);
private final Map<UUID, UcastMacsRemote> updatedUMacsRemoteRows;
private final Map<UUID, PhysicalLocator> updatedPLocRows;
- private final Map<UUID, LogicalSwitch> updatedLSRows;
public UcastMacsRemoteUpdateCommand(HwvtepConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema) {
super(key, updates, dbSchema);
updatedUMacsRemoteRows = TyperUtils.extractRowsUpdated(UcastMacsRemote.class, getUpdates(), getDbSchema());
updatedPLocRows = TyperUtils.extractRowsUpdated(PhysicalLocator.class, getUpdates(), getDbSchema());
- updatedLSRows = TyperUtils.extractRowsUpdated(LogicalSwitch.class, getUpdates(), getDbSchema());
}
@Override
if (uMacRemote.getLogicalSwitchColumn() != null
&& uMacRemote.getLogicalSwitchColumn().getData() != null) {
UUID lsUUID = uMacRemote.getLogicalSwitchColumn().getData();
- final LogicalSwitch logicalSwitch = updatedLSRows.get(lsUUID);
+ final LogicalSwitch logicalSwitch = getOvsdbConnectionInstance().getDeviceInfo().getLogicalSwitch(lsUUID);
if (logicalSwitch != null) {
InstanceIdentifier<LogicalSwitches> lSwitchIid =
HwvtepSouthboundMapper.createInstanceIdentifier(getOvsdbConnectionInstance(), logicalSwitch);