Search in sources :

Example 6 with IfL2vlan

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

the class NeutronTrunkChangeListener method createSubPortInterface.

private void createSubPortInterface(Trunk trunk, SubPorts subPort) {
    if (!NetworkTypeVlan.class.equals(subPort.getSegmentationType())) {
        LOG.warn("SegmentationType other than VLAN not supported for Trunk:SubPorts");
        return;
    }
    String portName = subPort.getPortId().getValue();
    String parentName = trunk.getPortId().getValue();
    InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(portName);
    // Should we use parentName?
    jobCoordinator.enqueueJob("PORT- " + portName, () -> {
        Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
        List<ListenableFuture<Void>> futures = new ArrayList<>();
        if (iface == null) {
            /*
                 * Trunk creation requires NeutronPort to be present, by this time interface
                 * should've been created. In controller restart use case Interface would already be present.
                 * Clustering consideration:
                 *      This being same shard as NeutronPort, interface creation will be triggered on the same
                 *      node as this one. Use of DSJC helps ensure the order.
                 */
            LOG.warn("Interface not present for Trunk SubPort: {}", subPort);
            return futures;
        }
        InterfaceBuilder interfaceBuilder = new InterfaceBuilder();
        IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.TrunkMember).setVlanId(new VlanId(subPort.getSegmentationId().intValue())).build();
        ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(parentName).build();
        SplitHorizon splitHorizon = new SplitHorizonBuilder().setOverrideSplitHorizonProtection(true).build();
        interfaceBuilder.setName(portName).setType(L2vlan.class).addAugmentation(IfL2vlan.class, ifL2vlan).addAugmentation(ParentRefs.class, parentRefs).addAugmentation(SplitHorizon.class, splitHorizon);
        iface = interfaceBuilder.build();
        /*
             * Interface is already created for parent NeutronPort. We're updating parent refs
             * and VLAN Information
             */
        WriteTransaction txn = dataBroker.newWriteOnlyTransaction();
        txn.merge(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, iface);
        LOG.trace("Creating trunk member interface {}", iface);
        futures.add(txn.submit());
        return futures;
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan) SplitHorizonBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizonBuilder) ArrayList(java.util.ArrayList) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) IfL2vlanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) NetworkTypeVlan(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVlan) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) VlanId(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId) SplitHorizon(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.SplitHorizon) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 7 with IfL2vlan

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

the class FlowBasedServicesUtils method getMatchInfoForVlanPortAtIngressTable.

public static List<MatchInfo> getMatchInfoForVlanPortAtIngressTable(BigInteger dpId, long portNo, Interface iface) {
    List<MatchInfo> matches = new ArrayList<>();
    matches.add(new MatchInPort(dpId, portNo));
    int vlanId = 0;
    IfL2vlan l2vlan = iface.getAugmentation(IfL2vlan.class);
    if (l2vlan != null) {
        vlanId = l2vlan.getVlanId() == null ? 0 : l2vlan.getVlanId().getValue();
    }
    if (vlanId >= 0 && l2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Transparent) {
        matches.add(new MatchVlanVid(vlanId));
    }
    return matches;
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) MatchVlanVid(org.opendaylight.genius.mdsalutil.matches.MatchVlanVid) ArrayList(java.util.ArrayList) MatchInPort(org.opendaylight.genius.mdsalutil.matches.MatchInPort) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 8 with IfL2vlan

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

the class IfmUtil method getVlanInterfaceInfo.

public static VlanInterfaceInfo getVlanInterfaceInfo(Interface iface, BigInteger dpId) {
    short vlanId = 0;
    String portName = null;
    IfL2vlan vlanIface = iface.getAugmentation(IfL2vlan.class);
    ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
    if (parentRefs != null && parentRefs.getParentInterface() != null) {
        portName = parentRefs.getParentInterface();
    } else {
        LOG.warn("Portname set to null since parentRef is Null");
    }
    VlanInterfaceInfo vlanInterfaceInfo = new VlanInterfaceInfo(dpId, portName, vlanId);
    if (vlanIface != null) {
        vlanId = vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue().shortValue();
        L2vlanMode l2VlanMode = vlanIface.getL2vlanMode();
        if (l2VlanMode == L2vlanMode.Transparent) {
            vlanInterfaceInfo.setVlanTransparent(true);
        }
        if (l2VlanMode == L2vlanMode.NativeUntagged) {
            vlanInterfaceInfo.setUntaggedVlan(true);
        }
        vlanInterfaceInfo.setVlanId(vlanId);
    }
    return vlanInterfaceInfo;
}
Also used : ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) VlanInterfaceInfo(org.opendaylight.genius.interfacemanager.globals.VlanInterfaceInfo) L2vlanMode(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan.L2vlanMode) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 9 with IfL2vlan

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

the class IfmUtil method getEgressActionInfosForInterface.

/**
 * Returns the list of egress actions for a given interface.
 *
 * @param interfaceInfo the interface to look up
 * @param portNo port number
 * @param ifaceType the type of the interface
 * @param tunnelKey the tunnel key
 * @param actionKeyStart the start for the first key assigned for the new actions
 * @param isDefaultEgress if it is the default egress
 * @param ifIndex interface index
 * @param groupId group Id
 * @return list of actions for the interface
 */
// The following suppression is for javac, not for checkstyle
@SuppressWarnings("fallthrough")
@SuppressFBWarnings("SF_SWITCH_FALLTHROUGH")
public static List<ActionInfo> getEgressActionInfosForInterface(Interface interfaceInfo, String portNo, InterfaceInfo.InterfaceType ifaceType, Long tunnelKey, int actionKeyStart, boolean isDefaultEgress, int ifIndex, long groupId) {
    List<ActionInfo> result = new ArrayList<>();
    switch(ifaceType) {
        case MPLS_OVER_GRE:
        // fall through
        case GRE_TRUNK_INTERFACE:
            if (!isDefaultEgress) {
                // stores the value coming from a VXLAN tunnel
                if (tunnelKey == null) {
                    tunnelKey = 0L;
                }
            }
        // fall through
        case VXLAN_TRUNK_INTERFACE:
            if (!isDefaultEgress) {
                if (tunnelKey != null) {
                    result.add(new ActionSetFieldTunnelId(actionKeyStart++, BigInteger.valueOf(tunnelKey)));
                }
            } else {
                // For OF Tunnels default egress actions need to set tunnelIps
                IfTunnel ifTunnel = interfaceInfo.getAugmentation(IfTunnel.class);
                if (BooleanUtils.isTrue(ifTunnel.isTunnelRemoteIpFlow() && ifTunnel.getTunnelDestination() != null)) {
                    result.add(new ActionSetTunnelDestinationIp(actionKeyStart++, ifTunnel.getTunnelDestination()));
                }
                if (BooleanUtils.isTrue(ifTunnel.isTunnelSourceIpFlow() && ifTunnel.getTunnelSource() != null)) {
                    result.add(new ActionSetTunnelSourceIp(actionKeyStart++, ifTunnel.getTunnelSource()));
                }
            }
        // fall through
        case VLAN_INTERFACE:
            if (isDefaultEgress) {
                IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
                LOG.trace("get egress actions for l2vlan interface: {}", vlanIface);
                boolean isVlanTransparent = false;
                int vlanVid = 0;
                if (vlanIface != null) {
                    vlanVid = vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue();
                    isVlanTransparent = vlanIface.getL2vlanMode() == IfL2vlan.L2vlanMode.Transparent;
                }
                if (vlanVid != 0 && !isVlanTransparent) {
                    result.add(new ActionPushVlan(actionKeyStart++));
                    result.add(new ActionSetFieldVlanVid(actionKeyStart++, vlanVid));
                }
                result.add(new ActionOutput(actionKeyStart++, new Uri(portNo)));
            } else {
                addEgressActionInfosForInterface(ifIndex, actionKeyStart, result);
            }
            break;
        case LOGICAL_GROUP_INTERFACE:
            if (isDefaultEgress) {
                result.add(new ActionGroup(groupId));
            } else {
                addEgressActionInfosForInterface(ifIndex, actionKeyStart, result);
            }
            break;
        default:
            LOG.warn("Interface Type {} not handled yet", ifaceType);
            break;
    }
    return result;
}
Also used : ActionSetTunnelDestinationIp(org.opendaylight.genius.mdsalutil.actions.ActionSetTunnelDestinationIp) ArrayList(java.util.ArrayList) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) ActionSetFieldVlanVid(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) ActionPushVlan(org.opendaylight.genius.mdsalutil.actions.ActionPushVlan) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) ActionSetTunnelSourceIp(org.opendaylight.genius.mdsalutil.actions.ActionSetTunnelSourceIp) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) ActionOutput(org.opendaylight.genius.mdsalutil.actions.ActionOutput) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 10 with IfL2vlan

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

the class OvsInterfaceConfigUpdateHelper method handleInterfaceAdminStateUpdates.

private void handleInterfaceAdminStateUpdates(WriteTransaction transaction, Interface interfaceNew, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
    IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
    if (ifL2vlan == null || IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode() && IfL2vlan.L2vlanMode.Transparent != ifL2vlan.getL2vlanMode()) {
        return;
    }
    LOG.info("admin-state modified for interface {}", interfaceNew.getName());
    OperStatus operStatus = interfaceManagerCommonUtils.updateStateEntry(interfaceNew, transaction, ifState);
    InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(interfaceNew.getName());
    InterfaceParentEntry interfaceParentEntry = interfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey);
    if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
        return;
    }
    VlanMemberStateUpdateWorker vlanMemberStateUpdateWorker = new VlanMemberStateUpdateWorker(txRunner, operStatus, interfaceParentEntry.getInterfaceChildEntry());
    coordinator.enqueueJob(interfaceNew.getName(), vlanMemberStateUpdateWorker, IfmConstants.JOB_MAX_RETRIES);
}
Also used : InterfaceParentEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntryKey) OperStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus) InterfaceParentEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntry) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Aggregations

IfL2vlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)23 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)11 ArrayList (java.util.ArrayList)9 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)9 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 Collections (java.util.Collections)5 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)5 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 BigInteger (java.math.BigInteger)4 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)4 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)4 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)4 VlanId (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId)4 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)4 List (java.util.List)3 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 InterfaceManagerCommonUtils (org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils)3 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder)3