Search in sources :

Example 31 with InterfaceKey

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

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

the class InterfaceManagerCommonUtils method getInterfaceFromConfigDS.

@Nullable
public Interface getInterfaceFromConfigDS(ReadTransaction tx, String interfaceName) throws ReadFailedException {
    Interface iface = interfaceConfigMap.get(interfaceName);
    if (iface != null) {
        return iface;
    }
    InstanceIdentifier<Interface> interfaceId = getInterfaceIdentifier(new InterfaceKey(interfaceName));
    Optional<Interface> interfaceOptional = tx.read(LogicalDatastoreType.CONFIGURATION, interfaceId).checkedGet();
    if (interfaceOptional.isPresent()) {
        iface = interfaceOptional.get();
        interfaceConfigMap.put(iface.getName(), iface);
    }
    return iface;
}
Also used : DpnToInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) 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) Nullable(javax.annotation.Nullable)

Example 33 with InterfaceKey

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

the class OvsInterfaceStateAddHelper method addState.

private List<ListenableFuture<Void>> addState(NodeConnectorId nodeConnectorId, String interfaceName, long portNo, PhysAddress physAddress) {
    LOG.info("Adding Interface State to Oper DS for interface: {}", interfaceName);
    if (portNo == IfmConstants.INVALID_PORT_NO) {
        LOG.trace("Cannot derive port number, not proceeding with Interface State " + "addition for interface: {}", interfaceName);
        return null;
    }
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    Interface.OperStatus operStatus = Interface.OperStatus.Up;
    Interface.AdminStatus adminStatus = Interface.AdminStatus.Up;
    // Fetch the interface from config DS if exists
    InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
    if (InterfaceManagerCommonUtils.isTunnelPort(interfaceName) && !validateTunnelPortAttributes(nodeConnectorId, iface)) {
        return futures;
    }
    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
        Interface ifState = interfaceManagerCommonUtils.addStateEntry(iface, interfaceName, tx, physAddress, operStatus, adminStatus, nodeConnectorId);
        // flow,and start tunnel monitoring
        if (InterfaceManagerCommonUtils.isTunnelInterface(iface)) {
            handleTunnelMonitoringAddition(futures, nodeConnectorId, ifState.getIfIndex(), iface, interfaceName, portNo);
            return;
        }
        // install ingress flow if this is an l2vlan interface
        if (InterfaceManagerCommonUtils.isVlanInterface(iface) && iface.isEnabled() && ifState.getOperStatus() == org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up) {
            BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
            FlowBasedServicesUtils.installLportIngressFlow(dpId, portNo, iface, futures, txRunner, ifState.getIfIndex());
            futures.add(FlowBasedServicesUtils.bindDefaultEgressDispatcherService(txRunner, iface, Long.toString(portNo), interfaceName, ifState.getIfIndex()));
        }
    }));
    return futures;
}
Also used : IfmConstants(org.opendaylight.genius.interfacemanager.IfmConstants) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) LoggerFactory(org.slf4j.LoggerFactory) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) BigInteger(java.math.BigInteger) Nonnull(javax.annotation.Nonnull) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) Nullable(javax.annotation.Nullable) IfmUtil(org.opendaylight.genius.interfacemanager.IfmUtil) AlivenessMonitorUtils(org.opendaylight.genius.interfacemanager.commons.AlivenessMonitorUtils) Logger(org.slf4j.Logger) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) InterfaceManagerCommonUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) FutureCallback(com.google.common.util.concurrent.FutureCallback) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) FlowBasedServicesUtils(org.opendaylight.genius.interfacemanager.servicebindings.flowbased.utilities.FlowBasedServicesUtils) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) BigInteger(java.math.BigInteger) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)

Example 34 with InterfaceKey

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

the class OvsInterfaceStateUpdateHelper method handleInterfaceStateUpdates.

private void handleInterfaceStateUpdates(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface, WriteTransaction transaction, InterfaceBuilder ifaceBuilder, boolean opStateModified, String interfaceName, String portName, Interface.OperStatus opState) {
    // which have no corresponding config entries
    if (iface == null && !interfaceName.equals(portName)) {
        return;
    }
    final Interface interfaceState = interfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName);
    if (interfaceState == null || (interfaceState.getOperStatus() == opState)) {
        LOG.warn("Ignoring: updating interface state for interface {}", interfaceName);
        return;
    }
    LOG.debug("updating interface state entry for {}", interfaceName);
    InstanceIdentifier<Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceName);
    ifaceBuilder.setKey(new InterfaceKey(interfaceName));
    if (modifyOpState(iface, opStateModified)) {
        LOG.debug("updating interface oper status as {} for {}", opState.name(), interfaceName);
        ifaceBuilder.setOperStatus(opState);
    }
    transaction.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), false);
}
Also used : InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)

Example 35 with InterfaceKey

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

the class InterfaceManagerTestUtil method buildTunnelInterface.

static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled, Class<? extends TunnelTypeBase> tunType, String remoteIpStr, String localIpStr) {
    InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
    ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).build();
    builder.addAugmentation(ParentRefs.class, parentRefs);
    IpAddress remoteIp = new IpAddress(Ipv4Address.getDefaultInstance(remoteIpStr));
    IpAddress localIp = new IpAddress(Ipv4Address.getDefaultInstance(localIpStr));
    IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(localIp).setTunnelSource(localIp).setTunnelInterfaceType(tunType).setInternal(true).setMonitorEnabled(false).build();
    builder.addAugmentation(IfTunnel.class, tunnel);
    return builder.build();
}
Also used : ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) IfTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder)

Aggregations

InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)34 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)20 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)11 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)11 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder)9 ParentRefsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder)8 IfTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)6 BigInteger (java.math.BigInteger)5 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 DpnToInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface)5 DpnToInterfaceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey)5 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey)4 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)4 IfIndexInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterface)4 IfIndexInterfaceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterfaceKey)4 Collections (java.util.Collections)3 List (java.util.List)3