Bug 5463 : Fixing datapath-id changing behaviour seen while testing with mininet
[vpnservice.git] / interfacemgr / interfacemgr-impl / src / main / java / org / opendaylight / vpnservice / interfacemgr / commons / InterfaceMetaUtils.java
index 797e5597c73e737e9f1bd36b8b61af0a3781727a..396a470bbeed6be1babe8d119d2e7cc8ee3e99e6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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,
@@ -57,6 +57,7 @@ public class InterfaceMetaUtils {
         return bridgeRefEntryInstanceIdentifierBuilder.build();
     }
 
+
     public static BridgeRefEntry getBridgeRefEntryFromOperDS(InstanceIdentifier<BridgeRefEntry> dpnBridgeEntryIid,
                                                              DataBroker dataBroker) {
         Optional<BridgeRefEntry> bridgeRefEntryOptional =
@@ -73,6 +74,15 @@ public class InterfaceMetaUtils {
         return bridgeEntryIdBuilder.build();
     }
 
+    public static BridgeEntry getBridgeEntryFromConfigDS(BigInteger dpnId,
+                                                         DataBroker dataBroker) {
+        BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpnId);
+        InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier =
+                InterfaceMetaUtils.getBridgeEntryIdentifier(bridgeEntryKey);
+        return getBridgeEntryFromConfigDS(bridgeEntryInstanceIdentifier,
+                        dataBroker);
+    }
+
     public static BridgeEntry getBridgeEntryFromConfigDS(InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier,
                                                          DataBroker dataBroker) {
         Optional<BridgeEntry> bridgeEntryOptional =
@@ -186,6 +196,8 @@ public class InterfaceMetaUtils {
 
     public static void createBridgeRefEntry(BigInteger dpnId, InstanceIdentifier<?> bridgeIid,
                                             WriteTransaction tx){
+        LOG.debug("Creating bridge ref entry for dpn: {} bridge: {}",
+                dpnId, bridgeIid);
         BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
         InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
                 InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
@@ -194,4 +206,14 @@ public class InterfaceMetaUtils {
                         .setBridgeReference(new OvsdbBridgeRef(bridgeIid));
         tx.put(LogicalDatastoreType.OPERATIONAL, bridgeEntryId, tunnelDpnBridgeEntryBuilder.build(), true);
     }
+
+    public static void deleteBridgeRefEntry(BigInteger dpnId,
+                                            WriteTransaction tx) {
+        LOG.debug("Deleting bridge ref entry for dpn: {}",
+                dpnId);
+        BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
+        InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
+                InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
+        tx.delete(LogicalDatastoreType.OPERATIONAL, bridgeEntryId);
+    }
 }
\ No newline at end of file