Bug 5064 - Deletion of tunnel interfaces not removing the TEP from switch 50/33450/1
authorFaseela K <faseela.k@ericsson.com>
Sat, 23 Jan 2016 19:02:26 +0000 (00:32 +0530)
committerFaseela K <faseela.k@ericsson.com>
Mon, 25 Jan 2016 06:15:14 +0000 (06:15 +0000)
Change-Id: I8fae09299a257e47a924f37fc75e5424a878da4c
Signed-off-by: Faseela K <faseela.k@ericsson.com>
(cherry picked from commit 973f90816ea93d263c9369a94c9e5f590826337a)

interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/InterfaceMetaUtils.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigAddHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateAddHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceTopologyStateRemoveHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/utilities/SouthboundUtils.java

index a123fccc1e846bcfaa41de4bfe24705231e291cb..3ce243cde34db7a59ef4ef89ba134d25c9db7286 100644 (file)
@@ -8,12 +8,17 @@
 package org.opendaylight.vpnservice.interfacemgr.commons;
 
 import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.eclipse.xtend.lib.annotations.Data;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.idmanager.IdManager;
 import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
 import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
+import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.utilities.SouthboundUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.BridgeInterfaceInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.BridgeRefInfo;
@@ -32,10 +37,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.met
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntryKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntryKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
 public class InterfaceMetaUtils {
     public static InstanceIdentifier<BridgeRefEntry> getBridgeRefEntryIdentifier(BridgeRefEntryKey bridgeRefEntryKey) {
         InstanceIdentifier.InstanceIdentifierBuilder<BridgeRefEntry> bridgeRefEntryInstanceIdentifierBuilder =
@@ -168,4 +178,15 @@ public class InterfaceMetaUtils {
         }
         IfmUtil.releaseId(idManager, IfmConstants.IFM_IDPOOL_NAME, infName);
     }
+
+    public static void createBridgeRefEntry(BigInteger dpnId, InstanceIdentifier<?> bridgeIid,
+                                            WriteTransaction tx){
+        BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
+        InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
+                InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
+        BridgeRefEntryBuilder tunnelDpnBridgeEntryBuilder =
+                new BridgeRefEntryBuilder().setKey(bridgeRefEntryKey).setDpid(dpnId)
+                        .setBridgeReference(new OvsdbBridgeRef(bridgeIid));
+        tx.put(LogicalDatastoreType.OPERATIONAL, bridgeEntryId, tunnelDpnBridgeEntryBuilder.build(), true);
+    }
 }
\ No newline at end of file
index 70fca216c73d681aaf45ccbf55ffbca43826cd06..901604f837da1fcfb8393d156aaa6f984fc8f003 100644 (file)
@@ -140,8 +140,6 @@ public class OvsInterfaceConfigAddHelper {
             return;
         }
 
-        //createBridgeEntryIfNotPresent(dpId, dataBroker, t);
-
         BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpId);
         BridgeInterfaceEntryKey bridgeInterfaceEntryKey = new BridgeInterfaceEntryKey(interfaceNew.getName());
 
index 4fa4c1bf0b4c951c2af6fcecb2594158c372535c..ae9dccf33575c3886974a88a126d30514564157c 100644 (file)
@@ -41,7 +41,7 @@ public class OvsInterfaceTopologyStateAddHelper {
     public static List<ListenableFuture<Void>> addPortToBridge(InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
                                                                OvsdbBridgeAugmentation bridgeNew, DataBroker dataBroker) {
         List<ListenableFuture<Void>> futures = new ArrayList<>();
-        WriteTransaction t = dataBroker.newWriteOnlyTransaction();
+        WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
 
         if (bridgeNew.getDatapathId() == null) {
             LOG.warn("DataPathId found as null for Bridge Augmentation: {}... retrying...", bridgeNew);
@@ -62,13 +62,11 @@ public class OvsInterfaceTopologyStateAddHelper {
             return futures;
         }
 
-        BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
-        InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
-                InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
-        BridgeRefEntryBuilder tunnelDpnBridgeEntryBuilder =
-                new BridgeRefEntryBuilder().setKey(bridgeRefEntryKey).setDpid(dpnId)
-                        .setBridgeReference(new OvsdbBridgeRef(bridgeIid));
-        t.put(LogicalDatastoreType.OPERATIONAL, bridgeEntryId, tunnelDpnBridgeEntryBuilder.build(), true);
+        // create bridge reference entry in interface meta operational DS
+        InterfaceMetaUtils.createBridgeRefEntry(dpnId, bridgeIid, writeTransaction);
+
+        // FIX for OVSDB Bug - manually copying the bridge info from topology operational DS to config DS
+        SouthboundUtils.addBridge(bridgeIid, bridgeNew, dataBroker, futures);
 
         BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpnId);
         InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier =
@@ -77,7 +75,7 @@ public class OvsInterfaceTopologyStateAddHelper {
                 InterfaceMetaUtils.getBridgeEntryFromConfigDS(bridgeEntryInstanceIdentifier,
                         dataBroker);
         if (bridgeEntry == null) {
-            futures.add(t.submit());
+            futures.add(writeTransaction.submit());
             return futures;
         }
 
@@ -88,12 +86,10 @@ public class OvsInterfaceTopologyStateAddHelper {
             Interface iface = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
             if (iface.getAugmentation(IfTunnel.class) != null) {
                 SouthboundUtils.addPortToBridge(bridgeIid, iface, bridgeNew, bridgeName, portName, dataBroker, futures);
-                InterfaceMetaUtils.createBridgeInterfaceEntryInConfigDS(bridgeEntryKey,
-                        new BridgeInterfaceEntryKey(portName), portName, t);
             }
         }
 
-        futures.add(t.submit());
+        futures.add(writeTransaction.submit());
         return futures;
     }
 }
\ No newline at end of file
index 90fcf3607777ff943e13d563e7b7cf7af222b37f..dd4f25db0712bd1c118d37175d63a1bd7f21e866 100644 (file)
@@ -13,6 +13,7 @@ import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
+import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.utilities.SouthboundUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntryKey;
@@ -42,6 +43,9 @@ public class OvsInterfaceTopologyStateRemoveHelper {
                 InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
         t.delete(LogicalDatastoreType.OPERATIONAL, bridgeEntryId);
 
+        // FIX for ovsdb bug for delete TEP
+        SouthboundUtils.deleteBridge(bridgeIid, dataBroker, futures);
+
         futures.add(t.submit());
         return futures;
     }
index 690a5eee73508dfe808fac812ae94caec4e3eff1..4bf4d42f30ca91a8003280e7e032c8a931ad773b 100644 (file)
@@ -20,11 +20,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.re
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.*;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.*;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointBuilder;
@@ -57,6 +59,26 @@ public class SouthboundUtils {
         futures.add(tx.submit());
     }
 
+    public static void addBridge(InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
+                                 OvsdbBridgeAugmentation bridgeAugmentation,
+                                 DataBroker dataBroker, List<ListenableFuture<Void>> futures){
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+        NodeId nodeId = InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)).getNodeId();
+        NodeBuilder bridgeNodeBuilder = new NodeBuilder();
+        bridgeNodeBuilder.setNodeId(nodeId);
+        bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, bridgeAugmentation);
+        tx.put(LogicalDatastoreType.CONFIGURATION, createNodeInstanceIdentifier(nodeId), bridgeNodeBuilder.build(), true);
+        futures.add(tx.submit());
+    }
+
+    public static void deleteBridge(InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid,
+                                 DataBroker dataBroker, List<ListenableFuture<Void>> futures){
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+        NodeId nodeId = InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)).getNodeId();
+        tx.delete(LogicalDatastoreType.CONFIGURATION, createNodeInstanceIdentifier(nodeId));
+        futures.add(tx.submit());
+    }
+
     private static void addVlanPortToBridge(InstanceIdentifier<?> bridgeIid, IfL2vlan ifL2vlan,
                                               OvsdbBridgeAugmentation bridgeAugmentation, String bridgeName,
                                               String portName, DataBroker dataBroker, WriteTransaction t) {
@@ -160,4 +182,11 @@ public class SouthboundUtils {
         LOG.debug("Termination point InstanceIdentifier generated : {}",terminationPointPath);
         return terminationPointPath;
     }
+
+    public static InstanceIdentifier<Node> createNodeInstanceIdentifier(NodeId nodeId) {
+        return InstanceIdentifier
+                .create(NetworkTopology.class)
+                .child(Topology.class, new TopologyKey(OVSDB_TOPOLOGY_ID))
+                .child(Node.class,new NodeKey(nodeId));
+    }
 }
\ No newline at end of file