Fixing issue with ovsdb datapath id conversion 72/31972/2
authorFaseela K <faseela.k@ericsson.com>
Thu, 31 Dec 2015 13:08:17 +0000 (18:38 +0530)
committerFaseela K <faseela.k@ericsson.com>
Fri, 1 Jan 2016 11:14:21 +0000 (16:44 +0530)
Change-Id: If1f45a46aead6f2369873bdea1ece6ff287a0686
Signed-off-by: Faseela K <faseela.k@ericsson.com>
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/IfmUtil.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceStateRemoveHelper.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

index 26366286c9ed9581b7105fdb705ad52d98664a81..44f754e86fa54b0f30f14a558384ae91afa4f5d3 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdOutput;
@@ -191,4 +192,12 @@ public class IfmUtil {
             LOG.warn("Exception when releasing Id for key {}", idKey, e);
         }
     }
+
+    public static BigInteger getDpnId(DatapathId datapathId){
+        if (datapathId != null) {
+            String dpIdStr = datapathId.getValue().replace(":", "");
+            return new BigInteger(dpIdStr, 16);
+        }
+        return null;
+    }
 }
index fb3ac13a575233771c20d07bcd26bcc8f6c1b533..2aa85d2675e39037ea11347926485c4564510f6f 100644 (file)
@@ -51,7 +51,9 @@ public class OvsInterfaceStateRemoveHelper {
         /* Remove entry from if-index-interface-name map and deallocate Id from Idmanager. */
         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState =
                 InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(portName, dataBroker);
-        InterfaceMetaUtils.removeLportTagInterfaceMap(transaction, idManager, dataBroker, interfaceState.getName(), interfaceState.getIfIndex());
+        if(interfaceState != null) {
+            InterfaceMetaUtils.removeLportTagInterfaceMap(transaction, idManager, dataBroker, interfaceState.getName(), interfaceState.getIfIndex());
+        }
 
         transaction.delete(LogicalDatastoreType.OPERATIONAL, ifStateId);
 
index 4b426a09f7a9282a582cf37350649fa05ae9fb17..4fa4c1bf0b4c951c2af6fcecb2594158c372535c 100644 (file)
@@ -28,8 +28,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.met
 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.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
-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.node.TerminationPoint;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -56,29 +54,23 @@ public class OvsInterfaceTopologyStateAddHelper {
                 return futures;
             }
         }
-
-        String dpId = bridgeNew.getDatapathId().getValue();
         String bridgeName = bridgeNew.getBridgeName().getValue();
-        LOG.info("adding dpId {} to bridge reference {}", dpId, bridgeNew);
+        BigInteger dpnId = IfmUtil.getDpnId(bridgeNew.getDatapathId());
 
-        if (dpId == null) {
-            LOG.error("Optained null dpid for bridge: {}", bridgeNew);
+        if (dpnId == null) {
+            LOG.warn("Got Null DPID for Bridge: {}", bridgeNew);
             return futures;
         }
 
-        String datapathId = dpId.replaceAll("[^\\d.]", "");
-        BigInteger ovsdbDpId = new BigInteger(datapathId, 16);
-
-        LOG.info("adding dpId {} to bridge reference {}", datapathId, bridgeName);
-        BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(ovsdbDpId);
+        BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
         InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
                 InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
         BridgeRefEntryBuilder tunnelDpnBridgeEntryBuilder =
-                new BridgeRefEntryBuilder().setKey(bridgeRefEntryKey).setDpid(ovsdbDpId)
+                new BridgeRefEntryBuilder().setKey(bridgeRefEntryKey).setDpid(dpnId)
                         .setBridgeReference(new OvsdbBridgeRef(bridgeIid));
         t.put(LogicalDatastoreType.OPERATIONAL, bridgeEntryId, tunnelDpnBridgeEntryBuilder.build(), true);
 
-        BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(ovsdbDpId);
+        BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpnId);
         InstanceIdentifier<BridgeEntry> bridgeEntryInstanceIdentifier =
                 InterfaceMetaUtils.getBridgeEntryIdentifier(bridgeEntryKey);
         BridgeEntry bridgeEntry =
index b38708a041a15a580c6b3e58035a26b97c9f6c4d..90fcf3607777ff943e13d563e7b7cf7af222b37f 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.util.concurrent.ListenableFuture;
 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.vpnservice.interfacemgr.IfmUtil;
 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
 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;
@@ -30,16 +31,13 @@ public class OvsInterfaceTopologyStateRemoveHelper {
                                                                OvsdbBridgeAugmentation bridgeOld, DataBroker dataBroker) {
         List<ListenableFuture<Void>> futures = new ArrayList<>();
         WriteTransaction t = dataBroker.newWriteOnlyTransaction();;
+        BigInteger dpnId = IfmUtil.getDpnId(bridgeOld.getDatapathId());
 
-        String dpId = bridgeOld.getDatapathId().getValue().replaceAll("[^\\d.]", "");
-        if (dpId == null) {
+        if (dpnId == null) {
             LOG.warn("Got Null DPID for Bridge: {}", bridgeOld);
             return futures;
         }
-
-        dpId = dpId.replaceAll("[^\\d.]", "");
-        BigInteger ovsdbDpId = new BigInteger(dpId,16);
-        BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(ovsdbDpId);
+        BridgeRefEntryKey bridgeRefEntryKey = new BridgeRefEntryKey(dpnId);
         InstanceIdentifier<BridgeRefEntry> bridgeEntryId =
                 InterfaceMetaUtils.getBridgeRefEntryIdentifier(bridgeRefEntryKey);
         t.delete(LogicalDatastoreType.OPERATIONAL, bridgeEntryId);