Search in sources :

Example 11 with InterfaceType

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType in project netvirt by opendaylight.

the class NexthopManager method getRemoteNextHopPointer.

public AdjacencyResult getRemoteNextHopPointer(BigInteger remoteDpnId, long vpnId, String prefixIp, String nextHopIp) {
    String egressIfName = null;
    LOG.trace("getRemoteNextHopPointer: input [remoteDpnId {}, vpnId {}, prefixIp {}, nextHopIp {} ]", remoteDpnId, vpnId, prefixIp, nextHopIp);
    Class<? extends InterfaceType> egressIfType;
    ElanInstance elanInstance = getElanInstanceForPrefix(vpnId, prefixIp);
    if (elanInstance != null) {
        egressIfType = getInterfaceType(elanInstance);
    } else {
        LOG.warn("Failed to determine network type for prefixIp {} using tunnel", prefixIp);
        egressIfType = Tunnel.class;
    }
    if (Tunnel.class.equals(egressIfType)) {
        egressIfName = getTunnelRemoteNextHopPointer(remoteDpnId, nextHopIp);
    } else {
        egressIfName = getExtPortRemoteNextHopPointer(remoteDpnId, elanInstance);
    }
    LOG.trace("NextHop pointer for prefixIp {} vpnId {} dpnId {} is {}", prefixIp, vpnId, remoteDpnId, egressIfName);
    return egressIfName != null ? new AdjacencyResult(egressIfName, egressIfType, nextHopIp, prefixIp) : null;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)

Example 12 with InterfaceType

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

the class AlivenessProtocolHandlerLLDP method getInterfaceActions.

private List<ActionInfo> getInterfaceActions(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState, long portNum) throws InterruptedException, ExecutionException {
    Class<? extends InterfaceType> intfType;
    if (interfaceState != null) {
        intfType = interfaceState.getType();
    } else {
        LOG.error("Could not retrieve port type for interface to construct actions");
        return Collections.emptyList();
    }
    List<ActionInfo> actionInfos = new ArrayList<>();
    // Set the LLDP service Id which is 0
    if (Tunnel.class.equals(intfType)) {
        actionInfos.add(new ActionSetFieldTunnelId(BigInteger.ZERO));
    }
    actionInfos.add(new ActionOutput(new Uri(Long.toString(portNum))));
    return actionInfos;
}
Also used : ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) ActionOutput(org.opendaylight.genius.mdsalutil.actions.ActionOutput) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)

Example 13 with InterfaceType

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType 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 14 with InterfaceType

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType 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)

Example 15 with InterfaceType

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

the class InterfaceManagerTestUtil method createFlowCapableNodeConnector.

static void createFlowCapableNodeConnector(DataBroker dataBroker, String interfaceName, Class<? extends InterfaceType> ifType) throws TransactionCommitFailedException {
    WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
    BigInteger dpnId = Tunnel.class.equals(ifType) ? DPN_ID_2 : DPN_ID_1;
    long portNo = Tunnel.class.equals(ifType) ? PORT_NO_1 : PORT_NO_1;
    NodeConnector nodeConnector = InterfaceManagerTestUtil.buildFlowCapableNodeConnector(buildNodeConnectorId(dpnId, portNo), interfaceName, true);
    tx.put(OPERATIONAL, buildNodeConnectorInstanceIdentifier(dpnId, portNo), nodeConnector, true);
    tx.submit().checkedGet();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) Tunnel(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) BigInteger(java.math.BigInteger)

Aggregations

BigInteger (java.math.BigInteger)8 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)6 Tunnel (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel)5 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)5 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)5 ArrayList (java.util.ArrayList)4 Collections (java.util.Collections)4 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)4 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)4 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)4 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)3 DpnToInterfaceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey)3 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)3 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder)2 AdminStatus (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus)2 OperStatus (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus)2 FlowCapableNodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)2 DpnToInterfaceList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.DpnToInterfaceList)2 InterfaceNameEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntry)2 InterfaceNameEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.dpn.to._interface.InterfaceNameEntryBuilder)2