Search in sources :

Example 11 with OperStatus

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus in project genius by opendaylight.

the class ItmTunnelAggregationHelper method getAggregatedOperStatus.

private OperStatus getAggregatedOperStatus(Interface ifaceState, InterfaceParentEntry parentEntry) {
    String logicalTunnelName = parentEntry.getParentInterface();
    if (!logicalTunnelName.equals(ifaceState.getName()) && ifaceState.getOperStatus() == OperStatus.Up) {
        return OperStatus.Up;
    }
    List<InterfaceChildEntry> interfaceChildEntries = parentEntry.getInterfaceChildEntry();
    if (interfaceChildEntries == null || interfaceChildEntries.isEmpty()) {
        LOG.debug("MULTIPLE_VxLAN_TUNNELS: OperStatus is Down, because of the empty child list in group {}", parentEntry.getParentInterface());
        return OperStatus.Down;
    }
    for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
        String curChildInterface = interfaceChildEntry.getChildInterface();
        if (!curChildInterface.equals(ifaceState.getName())) {
            InterfaceInfo ifInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(curChildInterface);
            if (ifInfo != null && InterfaceInfo.InterfaceOpState.UP.equals(ifInfo.getOpState())) {
                return OperStatus.Up;
            }
        }
    }
    return OperStatus.Down;
}
Also used : InterfaceChildEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 12 with OperStatus

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus in project genius by opendaylight.

the class ItmTunnelAggregationHelper method updateInterfaceOperStatus.

private void updateInterfaceOperStatus(String ifaceName, Interface ifaceState, OperStatus st, WriteTransaction tx) {
    LOG.debug("MULTIPLE_VxLAN_TUNNELS: update OperStatus to be {} for {}", st.toString(), ifaceName);
    InstanceIdentifier<Interface> idLogicGroup = ItmUtils.buildStateInterfaceId(ifaceName);
    InterfaceBuilder ifaceBuilderChild = new InterfaceBuilder(ifaceState);
    ifaceBuilderChild.setOperStatus(st);
    tx.merge(LogicalDatastoreType.OPERATIONAL, idLogicGroup, ifaceBuilderChild.build(), true);
}
Also used : InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)

Example 13 with OperStatus

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus in project genius by opendaylight.

the class ItmTunnelAggregationHelper method updateLogicalTunnelGroupOperStatus.

private void updateLogicalTunnelGroupOperStatus(String logicalTunnelIfaceName, Interface ifaceState, InterfaceParentEntry parentEntry, ReadWriteTransaction tx) throws ReadFailedException {
    if (parentEntry == null) {
        LOG.debug("MULTIPLE_VxLAN_TUNNELS: uninitialized parent entry {}", logicalTunnelIfaceName);
        return;
    }
    OperStatus newOperStatus = getAggregatedOperStatus(ifaceState, parentEntry);
    if (logicalTunnelIfaceName.equals(ifaceState.getName())) {
        // the current interface is logical tunnel itself
        if (ifaceState.getOperStatus() != newOperStatus) {
            updateInterfaceOperStatus(logicalTunnelIfaceName, ifaceState, newOperStatus, tx);
        }
    } else {
        InterfaceInfo ifLogicInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(logicalTunnelIfaceName);
        if (isLogicalTunnelStateUpdateNeeded(newOperStatus, ifLogicInfo)) {
            InstanceIdentifier<Interface> id = ItmUtils.buildStateInterfaceId(logicalTunnelIfaceName);
            Optional<Interface> ifState = tx.read(LogicalDatastoreType.OPERATIONAL, id).checkedGet();
            if (ifState.isPresent()) {
                Interface ifStateLogicTunnel = ifState.get();
                updateInterfaceOperStatus(logicalTunnelIfaceName, ifStateLogicTunnel, newOperStatus, tx);
            }
        }
    }
}
Also used : OperStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)

Example 14 with OperStatus

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus in project genius by opendaylight.

the class InterfaceManagerCommonUtils method updateOperStatus.

public static void updateOperStatus(String interfaceName, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus, WriteTransaction transaction) {
    LOG.info("updating operational status {} for interface {}", interfaceName, operStatus);
    InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId = IfmUtil.buildStateInterfaceId(interfaceName);
    InterfaceBuilder ifaceBuilderChild = new InterfaceBuilder();
    ifaceBuilderChild.setOperStatus(operStatus);
    ifaceBuilderChild.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
    transaction.merge(LogicalDatastoreType.OPERATIONAL, ifChildStateId, ifaceBuilderChild.build());
}
Also used : InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface)

Example 15 with OperStatus

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus in project genius by opendaylight.

the class InterfaceManagerCommonUtils method addStateEntry.

public org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface addStateEntry(Interface interfaceInfo, String interfaceName, WriteTransaction transaction, PhysAddress physAddress, OperStatus operStatus, AdminStatus adminStatus, NodeConnectorId nodeConnectorId) {
    LOG.debug("adding interface state for {}", interfaceName);
    InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setType(Other.class).setIfIndex(IfmConstants.DEFAULT_IFINDEX);
    Integer ifIndex;
    Class<? extends InterfaceType> interfaceType = null;
    if (interfaceInfo != null) {
        if (!interfaceInfo.isEnabled()) {
            operStatus = OperStatus.Down;
        }
        interfaceType = interfaceInfo.getType();
        ifaceBuilder.setType(interfaceType);
        // retrieve if-index only for northbound configured interfaces
        ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceName);
        ifaceBuilder.setIfIndex(ifIndex);
        interfaceMetaUtils.createLportTagInterfaceMap(interfaceName, ifIndex);
    }
    InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceName);
    List<String> childLowerLayerIfList = new ArrayList<>();
    if (nodeConnectorId != null) {
        childLowerLayerIfList.add(0, nodeConnectorId.getValue());
    } else {
        // logical tunnel group doesn't have OF port
        ParentRefs parentRefs = interfaceInfo.getAugmentation(ParentRefs.class);
        if (parentRefs != null) {
            BigInteger dpId = parentRefs.getDatapathNodeIdentifier();
            String lowref = MDSALUtil.NODE_PREFIX + MDSALUtil.SEPARATOR + dpId + MDSALUtil.SEPARATOR + 0;
            childLowerLayerIfList.add(0, lowref);
        }
    }
    ifaceBuilder.setAdminStatus(adminStatus).setOperStatus(operStatus).setLowerLayerIf(childLowerLayerIfList);
    if (physAddress != null) {
        ifaceBuilder.setPhysAddress(physAddress);
    }
    ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
    ifaceBuilder.setStatistics(new StatisticsBuilder().setDiscontinuityTime(DateAndTime.getDefaultInstance(ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT))).build());
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = ifaceBuilder.build();
    boolean isTunnelInterface = InterfaceManagerCommonUtils.isTunnelInterface(interfaceInfo);
    boolean isOfTunnelInterface = InterfaceManagerCommonUtils.isOfTunnelInterface(interfaceInfo);
    if (isTunnelInterface && !isOfTunnelInterface) {
        batchingUtils.write(ifStateId, ifState, BatchingUtils.EntityType.DEFAULT_OPERATIONAL);
    } else {
        transaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifState, true);
    }
    if (nodeConnectorId != null) {
        BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
        // Update the DpnToInterfaceList OpDS
        createOrUpdateDpnToInterface(dpId, interfaceName, interfaceType);
    }
    return ifState;
}
Also used : Collections(java.util.Collections) ArrayList(java.util.ArrayList) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) StatisticsBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state._interface.StatisticsBuilder) BigInteger(java.math.BigInteger) BigInteger(java.math.BigInteger) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface) Other(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other)

Aggregations

OperStatus (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus)8 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder)7 BigInteger (java.math.BigInteger)6 ArrayList (java.util.ArrayList)6 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)6 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)4 DpnToInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 List (java.util.List)3 Inject (javax.inject.Inject)3 Singleton (javax.inject.Singleton)3 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)3 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)3 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)3 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)3 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)3 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 Futures (com.google.common.util.concurrent.Futures)2 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)2 IfmUtil (org.opendaylight.genius.interfacemanager.IfmUtil)2