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%2Fconfighelpers%2FOvsInterfaceConfigRemoveHelper.java;h=97187870bde731fdff3b71b45781c9b6a48ae454;hb=HEAD;hp=bb55c4f7261ef361ef5583b84f39f3fe4fb6f903;hpb=4a61af2a3eb515be685d55c84c8a98794e1f2ee2;p=vpnservice.git diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigRemoveHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigRemoveHelper.java index bb55c4f7..97187870 100644 --- a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigRemoveHelper.java +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigRemoveHelper.java @@ -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, @@ -13,9 +13,13 @@ 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.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.renderer.ovs.utilities.SouthboundUtils; +import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils; +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.Interface; 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.OperStatus; @@ -23,6 +27,10 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces. 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; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.AlivenessMonitorService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.MonitorStopInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.MonitorStopInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService; 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; @@ -48,88 +56,66 @@ import java.util.List; public class OvsInterfaceConfigRemoveHelper { private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceConfigRemoveHelper.class); - public static List> removeConfiguration(DataBroker dataBroker, Interface interfaceOld, - IdManager idManager, ParentRefs parentRefs) { + public static List> removeConfiguration(DataBroker dataBroker, AlivenessMonitorService alivenessMonitorService, + Interface interfaceOld, + IdManagerService idManager, + IMdsalApiManager mdsalApiManager, + ParentRefs parentRefs) { List> futures = new ArrayList<>(); WriteTransaction t = dataBroker.newWriteOnlyTransaction(); IfTunnel ifTunnel = interfaceOld.getAugmentation(IfTunnel.class); if (ifTunnel != null) { - removeTunnelConfiguration(parentRefs, dataBroker, interfaceOld, idManager, t); + removeTunnelConfiguration(alivenessMonitorService, parentRefs, dataBroker, interfaceOld, + idManager, mdsalApiManager, futures); + }else { + removeVlanConfiguration(dataBroker, parentRefs, interfaceOld, t); futures.add(t.submit()); - return futures; } - - removeVlanConfiguration(dataBroker, interfaceOld, t); - - /* FIXME: Deallocate ID from Idmanager. */ - - futures.add(t.submit()); return futures; } - private static void removeVlanConfiguration(DataBroker dataBroker, Interface interfaceOld, WriteTransaction t) { + private static void removeVlanConfiguration(DataBroker dataBroker, ParentRefs parentRefs, Interface interfaceOld, WriteTransaction transaction) { + LOG.debug("removing vlan configuration for {}",interfaceOld.getName()); + IfL2vlan ifL2vlan = interfaceOld.getAugmentation(IfL2vlan.class); + if (ifL2vlan == null || (IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode() && IfL2vlan.L2vlanMode.Transparent != ifL2vlan.getL2vlanMode())) { + return; + } org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceOld.getName(), dataBroker); if (ifState == null) { + LOG.debug("could not fetch interface state corresponding to {}",interfaceOld.getName()); return; } - String ncStr = ifState.getLowerLayerIf().get(0); - NodeConnectorId nodeConnectorId = new NodeConnectorId(ncStr); - NodeConnector nodeConnector = - InterfaceManagerCommonUtils.getNodeConnectorFromInventoryOperDS(nodeConnectorId, dataBroker); - if(nodeConnector != null) { - FlowCapableNodeConnector flowCapableNodeConnector = - nodeConnector.getAugmentation(FlowCapableNodeConnector.class); - //State state = flowCapableNodeConnector.getState(); - OperStatus operStatus = flowCapableNodeConnector == null ? OperStatus.Down : OperStatus.Up; - - if (ifState.getOperStatus() != operStatus) { - InstanceIdentifier ifStateId = - IfmUtil.buildStateInterfaceId(interfaceOld.getName()); - InterfaceBuilder ifaceBuilder = new InterfaceBuilder(); - ifaceBuilder.setOperStatus(operStatus); - ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceOld.getName())); - t.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build()); - } - } - IfL2vlan ifL2vlan = interfaceOld.getAugmentation(IfL2vlan.class); - if (ifL2vlan == null || ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) { - return; - } + InterfaceManagerCommonUtils.deleteStateEntry(interfaceOld.getName(), transaction); + BigInteger dpId = IfmUtil.getDpnFromInterface(ifState); + FlowBasedServicesUtils.removeIngressFlow(interfaceOld.getName(), dpId, transaction); + InterfaceManagerCommonUtils.deleteParentInterfaceEntry(transaction, parentRefs.getParentInterface()); // For Vlan-Trunk Interface, remove the trunk-member operstates as well... - InterfaceKey interfaceKey = new InterfaceKey(interfaceOld.getName()); - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = - InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker); - if (iface == null) { - return; - } - InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(iface.getName()); + InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(interfaceOld.getName()); InterfaceParentEntry interfaceParentEntry = InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker); - if (interfaceParentEntry == null) { - return; - } - - List interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry(); - if (interfaceChildEntries == null) { + if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) { return; } //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()); - t.delete(LogicalDatastoreType.OPERATIONAL, ifChildStateId); + for (InterfaceChildEntry interfaceChildEntry : interfaceParentEntry.getInterfaceChildEntry()) { + LOG.debug("removing interface state for vlan trunk member {}",interfaceChildEntry.getChildInterface()); + InterfaceManagerCommonUtils.deleteStateEntry(interfaceChildEntry.getChildInterface(), transaction); + FlowBasedServicesUtils.removeIngressFlow(interfaceChildEntry.getChildInterface(), dpId, transaction); } } - private static void removeTunnelConfiguration(ParentRefs parentRefs, DataBroker dataBroker, Interface interfaceOld, - IdManager idManager, WriteTransaction t) { - + private static void removeTunnelConfiguration(AlivenessMonitorService alivenessMonitorService, ParentRefs parentRefs, + DataBroker dataBroker, Interface interfaceOld, + IdManagerService idManager, IMdsalApiManager mdsalApiManager, + List> futures) { + LOG.debug("removing tunnel configuration for {}",interfaceOld.getName()); + WriteTransaction t = dataBroker.newWriteOnlyTransaction(); BigInteger dpId = null; if (parentRefs != null) { dpId = parentRefs.getDatapathNodeIdentifier(); @@ -146,10 +132,20 @@ public class OvsInterfaceConfigRemoveHelper { InterfaceMetaUtils.getBridgeRefEntryFromOperDS(bridgeRefEntryIid, dataBroker); if (bridgeRefEntry != null) { + LOG.debug("removing termination point for {}",interfaceOld.getName()); InstanceIdentifier bridgeIid = bridgeRefEntry.getBridgeReference().getValue(); InstanceIdentifier tpIid = SouthboundUtils.createTerminationPointInstanceIdentifier( InstanceIdentifier.keyOf(bridgeIid.firstIdentifierOf(Node.class)), interfaceOld.getName()); t.delete(LogicalDatastoreType.CONFIGURATION, tpIid); + + // delete tunnel ingress flow + LOG.debug("removing tunnel ingress flow for {}",interfaceOld.getName()); + NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(interfaceOld, dataBroker); + long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(ncId)); + InterfaceManagerCommonUtils.makeTunnelIngressFlow(futures, mdsalApiManager, + interfaceOld.getAugmentation(IfTunnel.class), + dpId, portNo, interfaceOld, -1, + NwConstants.DEL_FLOW); } BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpId); @@ -174,5 +170,8 @@ public class OvsInterfaceConfigRemoveHelper { bridgeInterfaceEntryKey); t.delete(LogicalDatastoreType.CONFIGURATION, bridgeInterfaceEntryIid); } + futures.add(t.submit()); + // stop LLDP monitoring for the tunnel interface + AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, interfaceOld); } } \ No newline at end of file