Revert "Revert "GENIUS-116: Efficient Handling of DPN disconnect"" 27/69527/8
authorFaseela K <faseela.k@ericsson.com>
Tue, 10 Apr 2018 17:41:55 +0000 (23:11 +0530)
committerFaseela K <faseela.k@ericsson.com>
Thu, 12 Apr 2018 04:45:17 +0000 (04:45 +0000)
This reverts commit 1c26ba35a1c6e03534151bbddeed8ec4d460c109.

Change-Id: Ie09689a0d1596c09e0a18d4e4ed462cbca46106e
Signed-off-by: Faseela K <faseela.k@ericsson.com>
interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/listeners/InterfaceInventoryStateListener.java

index 39dd5ff119998cf57280a036681dc3c844e54653..a678f223249cd497e80a9198eec6a4956b7bf1ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2016, 2018 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,
@@ -171,7 +171,8 @@ public class InterfaceInventoryStateListener
             return;
         }
 
-        if (!entityOwnershipUtils.isEntityOwner(IfmConstants.INTERFACE_CONFIG_ENTITY,
+        if (fcNodeConnectorNew.getReason() == PortReason.Delete
+                || !entityOwnershipUtils.isEntityOwner(IfmConstants.INTERFACE_CONFIG_ENTITY,
                 IfmConstants.INTERFACE_CONFIG_ENTITY)) {
             return;
         }
@@ -375,10 +376,12 @@ public class InterfaceInventoryStateListener
             BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
 
             futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
-                //VM Migration: Update the interface state to unknown only if remove event received for same switch
-                boolean nodePresent = interfaceManagerCommonUtils.isNodePresent(tx, nodeConnectorIdNew);
-                LOG.debug("Removing interface state information for interface: {} {}", interfaceName, nodePresent);
-                if (!nodePresent && nodeConnectorIdNew.equals(nodeConnectorIdOld)) {
+                // In a genuine port delete scenario, the reason will be there in the incoming event, for all remaining
+                // cases treat the event as DPN disconnect, if old and new ports are same. Else, this is a VM migration
+                // scenario, and should be treated as port removal.
+                LOG.debug("Removing interface state information for interface: {}", interfaceName);
+                if (fcNodeConnectorOld.getReason() != PortReason.Delete
+                        && nodeConnectorIdNew.equals(nodeConnectorIdOld)) {
                     //Remove event is because of connection lost between controller and switch, or switch shutdown.
                     // Hence, don't remove the interface but set the status as "unknown"
                     ovsInterfaceStateUpdateHelper.updateInterfaceStateOnNodeRemove(interfaceName, fcNodeConnectorOld,