Search in sources :

Example 36 with InterfaceInfo

use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo 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 37 with InterfaceInfo

use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo 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 38 with InterfaceInfo

use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project genius by opendaylight.

the class IfmUtil method getEgressActionInfosForInterface.

/**
 * Returns a list of Actions to be taken when sending a packet over an
 * interface.
 *
 * @param interfaceName
 *            name of the interface
 * @param tunnelKey
 *            Optional.
 * @param actionKeyStart
 *            action key
 * @param interfaceUtils
 *            InterfaceManagerCommonUtils
 * @return list of actions
 */
public static List<ActionInfo> getEgressActionInfosForInterface(String interfaceName, Long tunnelKey, int actionKeyStart, InterfaceManagerCommonUtils interfaceUtils, Boolean isDefaultEgress) {
    Interface interfaceInfo = interfaceUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName));
    if (interfaceInfo == null) {
        throw new NullPointerException("Interface information not present in config DS for " + interfaceName);
    }
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceUtils.getInterfaceState(interfaceName);
    if (ifState == null) {
        throw new NullPointerException("Interface information not present in oper DS for " + interfaceName);
    }
    String lowerLayerIf = ifState.getLowerLayerIf().get(0);
    NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
    String portNo = IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId);
    InterfaceInfo.InterfaceType ifaceType = getInterfaceType(interfaceInfo);
    return getEgressActionInfosForInterface(interfaceInfo, portNo, ifaceType, tunnelKey, actionKeyStart, isDefaultEgress, ifState.getIfIndex(), 0);
}
Also used : Collections(java.util.Collections) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) VlanInterfaceInfo(org.opendaylight.genius.interfacemanager.globals.VlanInterfaceInfo) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Example 39 with InterfaceInfo

use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project genius by opendaylight.

the class InterfacemgrProvider method getInterfaceInfo.

@Override
public InterfaceInfo getInterfaceInfo(String interfaceName) {
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(interfaceName);
    if (ifState == null) {
        LOG.debug("Interface {} is not present", interfaceName);
        return null;
    }
    Interface intf = interfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName));
    if (intf == null) {
        LOG.error("Interface {} doesn't exist in config datastore", interfaceName);
        return null;
    }
    NodeConnectorId ncId = FlowBasedServicesUtils.getNodeConnectorIdFromInterface(intf.getName(), interfaceManagerCommonUtils);
    InterfaceInfo.InterfaceType interfaceType = IfmUtil.getInterfaceType(intf);
    InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
    BigInteger dpId = org.opendaylight.genius.interfacemanager.globals.IfmConstants.INVALID_DPID;
    Integer portNo = org.opendaylight.genius.interfacemanager.globals.IfmConstants.INVALID_PORT_NO;
    if (ncId != null) {
        dpId = IfmUtil.getDpnFromNodeConnectorId(ncId);
        portNo = Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId));
    }
    if (interfaceType == InterfaceInfo.InterfaceType.VLAN_INTERFACE) {
        interfaceInfo = IfmUtil.getVlanInterfaceInfo(intf, dpId);
    } else if (interfaceType == InterfaceInfo.InterfaceType.UNKNOWN_INTERFACE) {
        LOG.error("Type of Interface {} is unknown", interfaceName);
        return null;
    }
    interfaceInfo.setDpId(dpId);
    interfaceInfo.setPortNo(portNo);
    interfaceInfo.setAdminState(intf.isEnabled() ? InterfaceAdminState.ENABLED : InterfaceAdminState.DISABLED);
    interfaceInfo.setInterfaceName(interfaceName);
    Integer lportTag = ifState.getIfIndex();
    interfaceInfo.setInterfaceTag(lportTag);
    interfaceInfo.setInterfaceType(interfaceType);
    interfaceInfo.setGroupId(IfmUtil.getGroupId(lportTag, interfaceType));
    interfaceInfo.setOpState(InterfaceInfo.InterfaceOpState.fromModel(ifState.getOperStatus()));
    PhysAddress phyAddress = ifState.getPhysAddress();
    if (phyAddress != null) {
        interfaceInfo.setMacAddress(ifState.getPhysAddress().getValue());
    }
    return interfaceInfo;
}
Also used : Collections(java.util.Collections) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger) BigInteger(java.math.BigInteger) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 40 with InterfaceInfo

use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project genius by opendaylight.

the class InterfacemgrProvider method populateInterfaceInfo.

public InterfaceInfo populateInterfaceInfo(String interfaceName, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
    InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
    NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
    if (ncId != null) {
        if (Tunnel.class.equals(ifState.getType())) {
            interfaceInfo.setPortName(interfaceName);
        } else {
            Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceName);
            if (iface != null) {
                ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
                interfaceInfo.setPortName(parentRefs.getParentInterface());
            }
        }
        interfaceInfo.setDpId(IfmUtil.getDpnFromNodeConnectorId(ncId));
        interfaceInfo.setPortNo(Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId)));
    }
    interfaceInfo.setAdminState(ifState.getAdminStatus() == AdminStatus.Up ? InterfaceAdminState.ENABLED : InterfaceAdminState.DISABLED);
    interfaceInfo.setInterfaceName(interfaceName);
    Integer lportTag = ifState.getIfIndex();
    if (lportTag != null) {
        interfaceInfo.setInterfaceTag(lportTag);
    }
    interfaceInfo.setOpState(InterfaceInfo.InterfaceOpState.fromModel(ifState.getOperStatus()));
    PhysAddress phyAddress = ifState.getPhysAddress();
    if (phyAddress != null) {
        interfaceInfo.setMacAddress(ifState.getPhysAddress().getValue());
    }
    return interfaceInfo;
}
Also used : BigInteger(java.math.BigInteger) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Aggregations

InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)40 BigInteger (java.math.BigInteger)16 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)12 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)8 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)8 ArrayList (java.util.ArrayList)7 Collections (java.util.Collections)7 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)6 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)5 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)5 ElanInterfaceMac (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac)5 ElanInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)5 MacEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder)5 MacEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryKey)5 Optional (com.google.common.base.Optional)4 Inject (javax.inject.Inject)4 Singleton (javax.inject.Singleton)4 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)4 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)4