Search in sources :

Example 31 with ParentRefs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs 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)

Example 32 with ParentRefs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs 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 33 with ParentRefs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs in project genius by opendaylight.

the class OvsVlanMemberConfigUpdateHelper method updateConfiguration.

public List<ListenableFuture<Void>> updateConfiguration(ParentRefs parentRefsNew, Interface interfaceOld, IfL2vlan ifL2vlanNew, Interface interfaceNew) {
    LOG.info("updating interface configuration for vlan memeber {} with parent-interface {}", interfaceNew.getName(), parentRefsNew.getParentInterface());
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    ParentRefs parentRefsOld = interfaceOld.getAugmentation(ParentRefs.class);
    InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentRefsOld.getParentInterface());
    InterfaceChildEntryKey interfaceChildEntryKey = new InterfaceChildEntryKey(interfaceOld.getName());
    InterfaceChildEntry interfaceChildEntry = interfaceMetaUtils.getInterfaceChildEntryFromConfigDS(interfaceParentEntryKey, interfaceChildEntryKey);
    if (interfaceChildEntry == null) {
        futures.addAll(ovsVlanMemberConfigAddHelper.addConfiguration(interfaceNew.getAugmentation(ParentRefs.class), interfaceNew));
        return futures;
    }
    IfL2vlan ifL2vlanOld = interfaceOld.getAugmentation(IfL2vlan.class);
    if (ifL2vlanOld == null || ifL2vlanNew.getL2vlanMode() != ifL2vlanOld.getL2vlanMode()) {
        LOG.error("Configuration Error. Vlan Mode Change of Vlan Trunk Member {} as new trunk member: {} is " + "not allowed.", interfaceOld, interfaceNew);
        return futures;
    }
    if (vlanIdModified(ifL2vlanOld.getVlanId(), ifL2vlanNew.getVlanId()) || !parentRefsOld.getParentInterface().equals(parentRefsNew.getParentInterface())) {
        LOG.info("vlan-id modified for interface {}", interfaceNew.getName());
        futures.addAll(ovsVlanMemberConfigRemoveHelper.removeConfiguration(parentRefsOld, interfaceOld));
        futures.addAll(ovsVlanMemberConfigAddHelper.addConfiguration(parentRefsNew, interfaceNew));
        return futures;
    }
    if (Objects.equals(interfaceNew.isEnabled(), interfaceOld.isEnabled())) {
        return futures;
    }
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface pifState = interfaceManagerCommonUtils.getInterfaceState(parentRefsNew.getParentInterface());
    if (pifState != null) {
        OperStatus operStatus = interfaceNew.isEnabled() ? pifState.getOperStatus() : OperStatus.Down;
        LOG.info("admin-state modified for interface {}", interfaceNew.getName());
        futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
            InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceNew.getName());
            InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
            ifaceBuilder.setOperStatus(operStatus);
            ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceNew.getName()));
            tx.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
        }));
    }
    return futures;
}
Also used : InterfaceChildEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InterfaceParentEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntryKey) LoggerFactory(org.slf4j.LoggerFactory) Singleton(javax.inject.Singleton) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) ArrayList(java.util.ArrayList) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) Inject(javax.inject.Inject) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) IfmUtil(org.opendaylight.genius.interfacemanager.IfmUtil) Logger(org.slf4j.Logger) OperStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) InterfaceManagerCommonUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Objects(java.util.Objects) List(java.util.List) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) InterfaceChildEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntryKey) InterfaceMetaUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceMetaUtils) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) InterfaceChildEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntryKey) ArrayList(java.util.ArrayList) OperStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) InterfaceParentEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntryKey) InterfaceChildEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 34 with ParentRefs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs 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)

Example 35 with ParentRefs

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs in project genius by opendaylight.

the class IfmCLIUtil method showVxlanOutput.

static void showVxlanOutput(Interface iface, InterfaceInfo interfaceInfo, CommandSession session) {
    StringBuilder sb = new StringBuilder();
    Formatter fmt = new Formatter(sb);
    session.getConsole().println(fmt.format(VXLAN_OUTPUT_FORMAT_LINE1, iface.getName(), iface.getDescription() == null ? UNSET : iface.getDescription()));
    sb.setLength(0);
    IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
    session.getConsole().println(fmt.format(VXLAN_OUTPUT_FORMAT, new String(ifTunnel.getTunnelSource().getValue()), new String(ifTunnel.getTunnelDestination().getValue()), ifTunnel.getTunnelGateway() == null ? UNSET : new String(ifTunnel.getTunnelGateway().getValue()), interfaceInfo == null ? InterfaceInfo.InterfaceAdminState.DISABLED : interfaceInfo.getAdminState()));
    sb.setLength(0);
    ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
    session.getConsole().println(fmt.format(VXLAN_OUTPUT_FORMAT + "\n", interfaceInfo == null ? InterfaceOpState.DOWN : interfaceInfo.getOpState(), String.format("%s/%s", parentRefs.getDatapathNodeIdentifier(), iface.getName()), interfaceInfo == null ? UNSET : interfaceInfo.getInterfaceTag(), ""));
    fmt.close();
}
Also used : ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) Formatter(java.util.Formatter) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)

Aggregations

ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)39 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)20 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)16 IfL2vlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)13 BigInteger (java.math.BigInteger)12 ParentRefsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder)12 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)10 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)10 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder)9 ArrayList (java.util.ArrayList)8 Collections (java.util.Collections)7 InterfaceChildEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info._interface.parent.entry.InterfaceChildEntry)6 IfTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder)6 VlanId (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)5 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)5 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)5 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)5 Logger (org.slf4j.Logger)5