X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=interfacemanager%2Finterfacemanager-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fgenius%2Finterfacemanager%2Frenderer%2Fovs%2Fstatehelpers%2FOvsInterfaceStateUpdateHelper.java;h=a70f7038dde0a3bc800c3bc5d6080547c7b115f3;hb=9cf3f1b8989ff0ffb08326c382814254a36f671e;hp=a4e9a75220bbef0efc0ed303c2cfddba1d78a446;hpb=38681f481fd73013fbefefd6072732591b67390a;p=genius.git diff --git a/interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/renderer/ovs/statehelpers/OvsInterfaceStateUpdateHelper.java b/interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/renderer/ovs/statehelpers/OvsInterfaceStateUpdateHelper.java index a4e9a7522..a70f7038d 100644 --- a/interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/renderer/ovs/statehelpers/OvsInterfaceStateUpdateHelper.java +++ b/interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/renderer/ovs/statehelpers/OvsInterfaceStateUpdateHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. + * Copyright (c) 2016, 2017 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, @@ -8,6 +8,8 @@ package org.opendaylight.genius.interfacemanager.renderer.ovs.statehelpers; import com.google.common.util.concurrent.ListenableFuture; +import java.util.ArrayList; +import java.util.List; 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; @@ -26,25 +28,20 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.List; - public class OvsInterfaceStateUpdateHelper { private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceStateUpdateHelper.class); public static List> updateState(InstanceIdentifier key, - AlivenessMonitorService alivenessMonitorService, - DataBroker dataBroker, String interfaceName, - FlowCapableNodeConnector flowCapableNodeConnectorNew, - FlowCapableNodeConnector flowCapableNodeConnectorOld) { + AlivenessMonitorService alivenessMonitorService, DataBroker dataBroker, String interfaceName, + FlowCapableNodeConnector flowCapableNodeConnectorNew, + FlowCapableNodeConnector flowCapableNodeConnectorOld) { LOG.debug("Update of Interface State for port: {}", interfaceName); List> futures = new ArrayList<>(); - WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); - Interface.OperStatus operStatusNew = getOpState(flowCapableNodeConnectorNew); + Interface.OperStatus operStatusNew = InterfaceManagerCommonUtils.getOpState(flowCapableNodeConnectorNew); MacAddress macAddressNew = flowCapableNodeConnectorNew.getHardwareAddress(); - Interface.OperStatus operStatusOld = getOpState(flowCapableNodeConnectorOld); + Interface.OperStatus operStatusOld = InterfaceManagerCommonUtils.getOpState(flowCapableNodeConnectorOld); MacAddress macAddressOld = flowCapableNodeConnectorOld.getHardwareAddress(); boolean opstateModified = false; @@ -61,14 +58,14 @@ public class OvsInterfaceStateUpdateHelper { return futures; } - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = - InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceName, dataBroker); + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf + .interfaces.rev140508.interfaces.Interface iface = InterfaceManagerCommonUtils + .getInterfaceFromConfigDS(interfaceName, dataBroker); - // For tunnels, derive the final opstate based on the bfd tunnel monitoring status - if (modifyTunnel(iface, opstateModified) - && InterfaceManagerCommonUtils.checkIfBfdStateIsDown(iface.getName())) { - operStatusNew = Interface.OperStatus.Down; - opstateModified = operStatusNew.equals(operStatusOld); + // For monitoring enabled tunnels, skip opstate update + if (isTunnelInterface(iface) && !modifyTunnelOpState(iface, opstateModified)) { + LOG.debug("skip interface-state updation for monitoring enabled tunnel interface {}", interfaceName); + opstateModified = false; } if (!opstateModified && !hardwareAddressModified) { @@ -82,11 +79,12 @@ public class OvsInterfaceStateUpdateHelper { ifaceBuilder.setPhysAddress(physAddress); } // modify the attributes in interface operational DS + WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); handleInterfaceStateUpdates(iface, transaction, dataBroker, ifaceBuilder, opstateModified, interfaceName, flowCapableNodeConnectorNew.getName(), operStatusNew); // start/stop monitoring based on opState - if (modifyTunnel(iface, opstateModified)) { + if (isTunnelInterface(iface) && opstateModified) { handleTunnelMonitoringUpdates(alivenessMonitorService, dataBroker, iface.getAugmentation(IfTunnel.class), iface.getName(), operStatusNew); } @@ -101,29 +99,24 @@ public class OvsInterfaceStateUpdateHelper { LOG.debug("Updating interface oper-status to UNKNOWN for : {}", interfaceName); InterfaceBuilder ifaceBuilder = new InterfaceBuilder(); - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = - InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceName, dataBroker); - handleInterfaceStateUpdates(iface,transaction, dataBroker, - ifaceBuilder, true, interfaceName, flowCapableNodeConnector.getName(), - Interface.OperStatus.Unknown); + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang + .ietf.interfaces.rev140508.interfaces.Interface iface = InterfaceManagerCommonUtils + .getInterfaceFromConfigDS(interfaceName, dataBroker); + handleInterfaceStateUpdates(iface, transaction, dataBroker, ifaceBuilder, true, interfaceName, + flowCapableNodeConnector.getName(), Interface.OperStatus.Unknown); if (InterfaceManagerCommonUtils.isTunnelInterface(iface)) { handleTunnelMonitoringUpdates(alivenessMonitorService, dataBroker, iface.getAugmentation(IfTunnel.class), interfaceName, Interface.OperStatus.Unknown); } } - public static Interface.OperStatus getOpState(FlowCapableNodeConnector flowCapableNodeConnector) { - Interface.OperStatus operStatus = flowCapableNodeConnector.getState().isLive() - && !flowCapableNodeConnector.getConfiguration().isPORTDOWN() - ? Interface.OperStatus.Up : Interface.OperStatus.Down; - return operStatus; - } - public static void handleInterfaceStateUpdates( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface, + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang + .ietf.interfaces.rev140508.interfaces.Interface iface, WriteTransaction transaction, DataBroker dataBroker, InterfaceBuilder ifaceBuilder, boolean opStateModified, String interfaceName, String portName, Interface.OperStatus opState) { - // if interface config DS is null, do the update only for the lower-layer-interfaces + // if interface config DS is null, do the update only for the + // lower-layer-interfaces // which have no corresponding config entries if (iface == null && !interfaceName.equals(portName)) { return; @@ -149,14 +142,25 @@ public class OvsInterfaceStateUpdateHelper { } public static boolean modifyOpState( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface, + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf + .interfaces.rev140508.interfaces.Interface iface, boolean opStateModified) { return opStateModified && (iface == null || iface != null && iface.isEnabled()); } - public static boolean modifyTunnel( - org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface, + public static boolean isTunnelInterface( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang + .ietf.interfaces.rev140508.interfaces.Interface iface) { + return iface != null && iface.getAugmentation(IfTunnel.class) != null; + } + + public static boolean modifyTunnelOpState( + org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang + .ietf.interfaces.rev140508.interfaces.Interface iface, boolean opStateModified) { - return modifyOpState(iface, opStateModified) && iface != null && iface.getAugmentation(IfTunnel.class) != null; + if (!iface.getAugmentation(IfTunnel.class).isMonitorEnabled()) { + return modifyOpState(iface, opStateModified); + } + return false; } }