X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=interfacemgr%2Finterfacemgr-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Finterfacemgr%2Frenderer%2Fovs%2Fstatehelpers%2FOvsInterfaceStateRemoveHelper.java;h=e44694eae42deea6e85e664fac7ea7c0f1352baa;hb=d27dda6e70f5fa31d518aced0010aa48fe5884a7;hp=88af8f816baab55a01b1493aba82fb53dda93906;hpb=3b8ac2ae2430fb66f91303dd9e69070f8450eb7a;p=vpnservice.git diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceStateRemoveHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceStateRemoveHelper.java index 88af8f81..e44694ea 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceStateRemoveHelper.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceStateRemoveHelper.java @@ -8,6 +8,7 @@ package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers; 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; @@ -15,11 +16,14 @@ import org.opendaylight.vpnservice.interfacemgr.IfmUtil; import org.opendaylight.vpnservice.interfacemgr.commons.AlivenessMonitorUtils; import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils; import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils; +import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils; import org.opendaylight.vpnservice.mdsalutil.MDSALUtil; +import org.opendaylight.vpnservice.mdsalutil.MatchInfo; import org.opendaylight.vpnservice.mdsalutil.NwConstants; import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId; import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; @@ -30,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; @@ -60,49 +65,66 @@ public class OvsInterfaceStateRemoveHelper { transaction.delete(LogicalDatastoreType.OPERATIONAL, ifStateId); - // For Vlan-Trunk Interface, remove the trunk-member operstates as well... InterfaceKey interfaceKey = new InterfaceKey(portName); org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker); - if (iface == null) { - futures.add(transaction.submit()); - return futures; - } + NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId(); + BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId)); // If this interface is a tunnel interface, remove the tunnel ingress flow and stop lldp monitoring - IfTunnel tunnel = iface.getAugmentation(IfTunnel.class); - if(tunnel != null){ - NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId(); - BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId)); - long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId)); - InterfaceManagerCommonUtils.makeTunnelIngressFlow(futures, mdsalApiManager, tunnel, dpId, portNo, iface, - NwConstants.DEL_FLOW); - futures.add(transaction.submit()); - AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, iface); - return futures; + if(iface != null) { + IfTunnel tunnel = iface.getAugmentation(IfTunnel.class); + if (tunnel != null) { + long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId)); + InterfaceManagerCommonUtils.makeTunnelIngressFlow(futures, mdsalApiManager, tunnel, dpId, portNo, iface, -1, + NwConstants.DEL_FLOW); + futures.add(transaction.submit()); + AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, iface); + return futures; + } } - InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(iface.getName()); + InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(portName); InterfaceParentEntry interfaceParentEntry = InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker); - if (interfaceParentEntry == null) { + if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) { futures.add(transaction.submit()); return futures; } - List interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry(); - if (interfaceChildEntries == null) { - futures.add(transaction.submit()); - return futures; + //FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100. + InterfaceChildEntry higherlayerChild = interfaceParentEntry.getInterfaceChildEntry().get(0); + InstanceIdentifier + higerLayerChildIfStateId = IfmUtil.buildStateInterfaceId(higherlayerChild.getChildInterface()); + /* Remove entry from if-index-interface-name map and deallocate Id from Idmanager. */ + Interface higherLayerIfChildState = InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(higherlayerChild.getChildInterface(), dataBroker); + if (interfaceState != null) { + InterfaceMetaUtils.removeLportTagInterfaceMap(transaction, idManager, dataBroker, higherLayerIfChildState.getName(), + higherLayerIfChildState.getIfIndex()); + transaction.delete(LogicalDatastoreType.OPERATIONAL, higerLayerChildIfStateId); + FlowBasedServicesUtils.removeIngressFlow(higherLayerIfChildState.getName(), dpId, transaction); } + // If this interface maps to a Vlan trunk entity, operational states of all the vlan-trunk-members + // should also be created here. + InterfaceParentEntryKey higherLayerParentEntryKey = new InterfaceParentEntryKey(higherlayerChild.getChildInterface()); + InterfaceParentEntry higherLayerParent = + InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(higherLayerParentEntryKey, dataBroker); - //FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100. - for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) { - InstanceIdentifier ifChildStateId = - IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface()); - transaction.delete(LogicalDatastoreType.OPERATIONAL, ifChildStateId); + if(higherLayerParent != null && higherLayerParent.getInterfaceChildEntry() != null) { + for (InterfaceChildEntry interfaceChildEntry : higherLayerParent.getInterfaceChildEntry()) { + InstanceIdentifier ifChildStateId = + IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface()); + /* Remove entry from if-index-interface-name map and deallocate Id from Idmanager. */ + Interface childInterfaceState = InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceChildEntry.getChildInterface(), dataBroker); + if (childInterfaceState != null) { + InterfaceMetaUtils.removeLportTagInterfaceMap(transaction, idManager, dataBroker, childInterfaceState.getName(), childInterfaceState.getIfIndex()); + transaction.delete(LogicalDatastoreType.OPERATIONAL, ifChildStateId); + FlowBasedServicesUtils.removeIngressFlow(childInterfaceState.getName(), dpId, transaction); + } + } } + /* Below code will be needed if we want to update the vlan-trunk in the of-port. NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId(); BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));