Partial Fix for Bug 3428 46/21846/1
authorVishal Thapar <vishal.thapar@ericsson.com>
Wed, 3 Jun 2015 19:24:18 +0000 (00:54 +0530)
committerVishal Thapar <vishal.thapar@ericsson.com>
Thu, 4 Jun 2015 06:12:04 +0000 (06:12 +0000)
This fixes flow delete for tunnel interfaces
When interface is deleted we can't read Config DS to get NodeConnector
as it is already deleted.
This fix adds a new API.

Pending:
Group entries still not deleted, needs fix in MDSAL Util.

Change-Id: Ib82c68518f312b2c169455d85c5afacc82f38cbe
Signed-off-by: Vishal Thapar <vishal.thapar@ericsson.com>
(cherry picked from commit dba7df67fcbe1c7aae2b2503b1811c07c24ad42f)

interfacemgr/interfacemgr-api/src/main/java/org/opendaylight/vpnservice/interfacemgr/interfaces/IInterfaceManager.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/InterfaceManager.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/InterfacemgrProvider.java
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/OdlInterfaceChangeListener.java

index a0a26d66c99ad18762d1decd29e495a078f31f9c..0923c9345aa4f1cddb3a040277585927cd8f2a93 100644 (file)
@@ -8,8 +8,9 @@
 
 package org.opendaylight.vpnservice.interfacemgr.interfaces;
 
-import java.math.BigInteger;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
 
+import java.math.BigInteger;
 import java.util.List;
 import org.opendaylight.vpnservice.mdsalutil.ActionInfo;
 import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
@@ -18,6 +19,7 @@ public interface IInterfaceManager {
 
     public Long getPortForInterface(String ifName);
     public BigInteger getDpnForInterface(String ifName);
+    public BigInteger getDpnForInterface(Interface intrf);
     public String getEndpointIpForDpn(BigInteger dpnId);
     public List<MatchInfo> getInterfaceIngressRule(String ifName);
     public List<ActionInfo> getInterfaceEgressActions(String ifName);
index d8f77f4297bcb37482be2d848ee709aecba3065f..1543b57a621d66ef426ca1a543a41206f2317bf7 100644 (file)
@@ -434,15 +434,24 @@ public class InterfaceManager extends AbstractDataChangeListener<Interface> impl
         return getPortNumForInterface(iface);
     }
 
-    BigInteger getDpnForInterface(String ifName) {
-        Interface iface = getInterfaceByIfName(ifName);
+
+    public BigInteger getDpnForInterface(Interface intrf) {
         try {
-            NodeConnector port = getNodeConnectorFromDataStore(iface);
+            NodeConnector port = getNodeConnectorFromDataStore(intrf);
             //TODO: This should be an MDSAL Util method
             return new BigInteger(IfmUtil.getDpnFromNodeConnectorId(port.getId()));
         } catch (NullPointerException e) {
-            LOG.error("dpn for Interface {} not found", ifName);
+            LOG.error("dpn for Interface {} not found", intrf.getName(), e);
+        }
+        return BigInteger.ZERO;
+    }
+
+    BigInteger getDpnForInterface(String ifName) {
+        Interface iface = getInterfaceByIfName(ifName);
+        if(iface != null) {
+            return getDpnForInterface(iface);
         }
+        LOG.error("Interface {} doesn't exist", ifName);
         return BigInteger.ZERO;
     }
 
index b1b65b7258c7bf2975e6c74a62f57423fabce02e..c8166a7a2774fc721066e501d80939b50a1fb84c 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.vpnservice.interfacemgr;
 
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+
 import java.math.BigInteger;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
@@ -94,4 +96,10 @@ public class InterfacemgrProvider implements BindingAwareProvider, AutoCloseable
     public List<ActionInfo> getInterfaceEgressActions(String ifName) {
         return interfaceManager.getInterfaceEgressActions(ifName);
     }
+
+    @Override
+    public BigInteger getDpnForInterface(Interface intrf) {
+        // TODO Auto-generated method stub
+        return interfaceManager.getDpnForInterface(intrf);
+    }
 }
index bdfd046b00c052f91dabf8113e6fbcdc029c3831..49a7bdbbf43fd81b6ad60680709680f374b2dcb9 100644 (file)
@@ -91,7 +91,7 @@ public class OdlInterfaceChangeListener extends AbstractDataChangeListener<Inter
             Interface intrf) {
         LOG.trace("Removing interface : key: " + identifier + ", value=" + intrf );
         if (intrf.getType().equals(L3tunnel.class)) {
-            BigInteger dpnId = interfaceManager.getDpnForInterface(intrf.getName());
+            BigInteger dpnId = interfaceManager.getDpnForInterface(intrf);
             IfL3tunnel intfData = intrf.getAugmentation(IfL3tunnel.class);
             IpAddress gatewayIp = intfData.getGatewayIp();
             IpAddress remoteIp = (gatewayIp == null) ? intfData.getRemoteIp() : gatewayIp;