Bug 5334 : Delete ELANport , ELAN instance VLAN and re-create
[vpnservice.git] / interfacemgr / interfacemgr-impl / src / main / java / org / opendaylight / vpnservice / interfacemgr / renderer / ovs / confighelpers / OvsVlanMemberConfigRemoveHelper.java
index 83c7c042b17a6ca76032d461c9fec05feba6bf64..83eab5a29cb19bb833d75ad24e78b0037fa7503f 100644 (file)
@@ -38,6 +38,7 @@ public class OvsVlanMemberConfigRemoveHelper {
     public static List<ListenableFuture<Void>> removeConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
                                                                 Interface interfaceOld, IfL2vlan ifL2vlan,
                                                                 IdManagerService idManager) {
+        LOG.debug("remove vlan member configuration {}",interfaceOld.getName());
         List<ListenableFuture<Void>> futures = new ArrayList<>();
         WriteTransaction t = dataBroker.newWriteOnlyTransaction();
 
@@ -47,14 +48,19 @@ public class OvsVlanMemberConfigRemoveHelper {
         InterfaceParentEntry interfaceParentEntry =
                 InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryIid, dataBroker);
 
+        if(interfaceParentEntry == null){
+            return futures;
+        }
+
+        //Delete the interface child information
         List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
+        InterfaceChildEntryKey interfaceChildEntryKey = new InterfaceChildEntryKey(interfaceOld.getName());
+        InstanceIdentifier<InterfaceChildEntry> interfaceChildEntryIid =
+                    InterfaceMetaUtils.getInterfaceChildEntryIdentifier(interfaceParentEntryKey, interfaceChildEntryKey);
+        t.delete(LogicalDatastoreType.CONFIGURATION, interfaceChildEntryIid);
+        //If this is the last child, remove the interface parent info as well.
         if (interfaceChildEntries.size() <= 1) {
             t.delete(LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIid);
-        } else {
-            InterfaceChildEntryKey interfaceChildEntryKey = new InterfaceChildEntryKey(interfaceOld.getName());
-            InstanceIdentifier<InterfaceChildEntry> interfaceChildEntryIid =
-                    InterfaceMetaUtils.getInterfaceChildEntryIdentifier(interfaceParentEntryKey, interfaceChildEntryKey);
-            t.delete(LogicalDatastoreType.CONFIGURATION, interfaceChildEntryIid);
         }
 
         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
@@ -84,13 +90,12 @@ public class OvsVlanMemberConfigRemoveHelper {
                 }
             } */
 
-            String ncStr = ifState.getLowerLayerIf().get(0);
-            NodeConnectorId nodeConnectorId = new NodeConnectorId(ncStr);
-            BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
+            LOG.debug("delete vlan member interface state {}",interfaceOld.getName());
+            BigInteger dpId = IfmUtil.getDpnFromInterface(ifState);
             InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
                     IfmUtil.buildStateInterfaceId(interfaceOld.getName());
             t.delete(LogicalDatastoreType.OPERATIONAL, ifStateId);
-            FlowBasedServicesUtils.removeIngressFlow(interfaceOld, dpId, t);
+            FlowBasedServicesUtils.removeIngressFlow(interfaceOld.getName(), dpId, t);
         }
 
         futures.add(t.submit());