OVSDB-445 Port creation not reflected in OperDS 62/66862/2
authorVishal Thapar <vishal.thapar@ericsson.com>
Thu, 4 Jan 2018 05:34:48 +0000 (11:04 +0530)
committerVishal Thapar <vishal.thapar@ericsson.com>
Thu, 4 Jan 2018 10:35:56 +0000 (16:05 +0530)
When a port is deleted and added in same ovs-vsctl command
it doesn't show up in OperDS. This is because
OvsdbOperationalCommandAggregator always processes removes
after Updates. Since delete is being done for same port right
after update, it ends up not adding it to datastore.

Fix is to check if same port is present in updates or not
before deleting it.

Note: This may impact other such configuration too, though
not sure of any valid use cases for bridges etc.

Change-Id: I596ceaf579c4342a3e6bc282ce140cf15a295d60
Signed-off-by: Vishal Thapar <vishal.thapar@ericsson.com>
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortRemoveCommand.java

index 09bf8b1a59d315efcfe9bea05fb1089de4eaff7a..bf26be4132bac740d9292343815442f123b88504 100644 (file)
@@ -42,14 +42,22 @@ public class OvsdbPortRemoveCommand extends AbstractTransactionCommand {
 
     @Override
     public void execute(ReadWriteTransaction transaction) {
-        String portName = null;
         Collection<Port> portRemovedRows = TyperUtils.extractRowsRemoved(
                 Port.class, getUpdates(), getDbSchema()).values();
+        Map<UUID, Port> portUpdatedRows = TyperUtils.extractRowsUpdated(
+                Port.class, getUpdates(), getDbSchema());
         Map<UUID,Bridge> bridgeUpdatedRows = TyperUtils.extractRowsUpdated(
                 Bridge.class, getUpdates(), getDbSchema());
         Map<UUID,Bridge> bridgeUpdatedOldRows = TyperUtils.extractRowsOld(
                 Bridge.class, getUpdates(), getDbSchema());
         for (Port port : portRemovedRows) {
+            final String portName = port.getName();
+            boolean isPortInUpdatedRows = portUpdatedRows.values()
+                .stream().anyMatch(updatedPort -> portName.equals(updatedPort.getName()));
+            if (isPortInUpdatedRows) {
+                LOG.debug("port {} present in updated rows, skipping delete", portName);
+                continue;
+            }
             Bridge updatedBridgeData = null;
             for (UUID bridgeUuid : bridgeUpdatedOldRows.keySet()) {
                 Bridge oldBridgeData = bridgeUpdatedOldRows.get(bridgeUuid);
@@ -64,7 +72,6 @@ public class OvsdbPortRemoveCommand extends AbstractTransactionCommand {
                 LOG.warn("Bridge not found for port {}",port);
                 continue;
             }
-            portName = port.getName();
             final InstanceIdentifier<TerminationPoint> nodePath = SouthboundMapper
                     .createInstanceIdentifier(instanceIdentifierCodec, getOvsdbConnectionInstance(),
                             updatedBridgeData).child(