Search in sources :

Example 21 with Trunk

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.

the class OvsVlanMemberConfigAddHelper method addConfiguration.

public List<ListenableFuture<Void>> addConfiguration(ParentRefs parentRefs, Interface interfaceNew) {
    LOG.info("adding vlan member configuration for interface {}", interfaceNew.getName());
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> interfaceManagerCommonUtils.createInterfaceChildEntry(parentRefs.getParentInterface(), interfaceNew.getName(), tx)));
    InterfaceKey interfaceKey = new InterfaceKey(parentRefs.getParentInterface());
    Interface ifaceParent = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
    if (ifaceParent == null) {
        LOG.info("Parent Interface: {} not found when adding child interface: {}", parentRefs.getParentInterface(), interfaceNew.getName());
        return futures;
    }
    IfL2vlan parentIfL2Vlan = ifaceParent.getAugmentation(IfL2vlan.class);
    if (parentIfL2Vlan == null || parentIfL2Vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
        LOG.error("Parent Interface: {} not of trunk Type when adding trunk-member: {}", ifaceParent, interfaceNew);
        return futures;
    }
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(parentRefs.getParentInterface());
    interfaceManagerCommonUtils.addStateEntry(interfaceNew.getName(), futures, ifState);
    return futures;
}
Also used : Logger(org.slf4j.Logger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LoggerFactory(org.slf4j.LoggerFactory) InterfaceManagerCommonUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils) Singleton(javax.inject.Singleton) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) 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) List(java.util.List) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) 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) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 22 with Trunk

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.

the class VlanMemberConfigListener method update.

@Override
public void update(@Nonnull Interface originalInterface, @Nonnull Interface updatedInterface) {
    IfL2vlan ifL2vlanNew = updatedInterface.getAugmentation(IfL2vlan.class);
    if (ifL2vlanNew == null) {
        return;
    }
    IfL2vlan ifL2vlanOld = originalInterface.getAugmentation(IfL2vlan.class);
    if (IfL2vlan.L2vlanMode.TrunkMember == ifL2vlanNew.getL2vlanMode() && IfL2vlan.L2vlanMode.Trunk == ifL2vlanOld.getL2vlanMode()) {
        // Trunk subport add use case
        addVlanMember(updatedInterface);
        return;
    } else if (IfL2vlan.L2vlanMode.Trunk == ifL2vlanNew.getL2vlanMode() && IfL2vlan.L2vlanMode.TrunkMember == ifL2vlanOld.getL2vlanMode()) {
        // Trunk subport remove use case
        removeVlanMember(originalInterface);
    } else if (IfL2vlan.L2vlanMode.TrunkMember != ifL2vlanNew.getL2vlanMode()) {
        return;
    }
    ParentRefs parentRefsNew = updatedInterface.getAugmentation(ParentRefs.class);
    if (parentRefsNew == null) {
        LOG.error("Configuration Error. Attempt to update Vlan Trunk-Member {} without a " + "parent interface", updatedInterface);
        return;
    }
    String lowerLayerIf = parentRefsNew.getParentInterface();
    if (lowerLayerIf.equals(updatedInterface.getName())) {
        LOG.error("Configuration Error. Attempt to update Vlan Trunk-Member {} with same parent " + "interface name.", updatedInterface);
        return;
    }
    coordinator.enqueueJob(lowerLayerIf, () -> ovsVlanMemberConfigUpdateHelper.updateConfiguration(parentRefsNew, originalInterface, ifL2vlanNew, updatedInterface), IfmConstants.JOB_MAX_RETRIES);
}
Also used : ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 23 with Trunk

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.

the class VlanMemberConfigListener method addVlanMember.

private void addVlanMember(Interface added) {
    ParentRefs parentRefs = added.getAugmentation(ParentRefs.class);
    if (parentRefs == null) {
        return;
    }
    String lowerLayerIf = parentRefs.getParentInterface();
    if (lowerLayerIf.equals(added.getName())) {
        LOG.error("Attempt to add Vlan Trunk-Member {} with same parent interface name.", added);
        return;
    }
    coordinator.enqueueJob(lowerLayerIf, () -> ovsVlanMemberConfigAddHelper.addConfiguration(parentRefs, added), IfmConstants.JOB_MAX_RETRIES);
}
Also used : ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)

Example 24 with Trunk

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project genius by opendaylight.

the class InterfaceManagerCommonUtils method createInterfaceChildEntryIfNotPresent.

// For trunk interfaces, binding to a parent interface which is already
// bound to another trunk interface should not
// be allowed
public boolean createInterfaceChildEntryIfNotPresent(WriteTransaction tx, String parentInterface, String childInterface, IfL2vlan.L2vlanMode l2vlanMode) {
    InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentInterface);
    InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryIdentifier = InterfaceMetaUtils.getInterfaceParentEntryIdentifier(interfaceParentEntryKey);
    InterfaceParentEntry interfaceParentEntry = interfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryIdentifier);
    if (interfaceParentEntry != null) {
        List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
        if (interfaceChildEntries != null) {
            for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
                String curChildInterface = interfaceChildEntry.getChildInterface();
                if (childInterface.equals(curChildInterface)) {
                    LOG.trace("Child entry for interface {} already exists", childInterface);
                    return false;
                }
                Interface iface = getInterfaceFromConfigDS(curChildInterface);
                if (l2vlanMode == IfL2vlan.L2vlanMode.Trunk && isTrunkInterface(iface)) {
                    LOG.error("Trying to bind child interface {} of type Trunk to parent interface {}," + "but it is already bound to a trunk interface {}", childInterface, parentInterface, curChildInterface);
                    return false;
                }
            }
        }
    }
    LOG.info("Creating child interface {} of type {} bound on parent-interface {}", childInterface, l2vlanMode, parentInterface);
    createInterfaceChildEntry(parentInterface, childInterface, tx);
    return true;
}
Also used : 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) InterfaceParentEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntry) 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)

Example 25 with Trunk

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.trunks.rev170118.trunks.attributes.trunks.Trunk in project netvirt by opendaylight.

the class ElanServiceProvider method createIetfInterfaces.

/**
 * Create ietf-interfaces based on the ELAN segment type.<br>
 * For segment type flat - create transparent interface pointing to the
 * patch-port attached to the physnet port.<br>
 * For segment type vlan - create trunk interface pointing to the patch-port
 * attached to the physnet port + trunk-member interface pointing to the
 * trunk interface.
 *
 * @param elanInstance
 *            ELAN instance
 * @param parentRef
 *            parent interface name
 * @return the name of the interface to be added to the ELAN instance i.e.
 *         trunk-member name for vlan network and transparent for flat
 *         network or null otherwise
 */
private String createIetfInterfaces(ElanInstance elanInstance, String parentRef) {
    String interfaceName = null;
    try {
        String trunkName = getTrunkInterfaceName(parentRef);
        // trunk interface may have been created by other vlan network
        Interface trunkInterface = interfaceManager.getInterfaceInfoFromConfigDataStore(trunkName);
        if (trunkInterface == null) {
            interfaceManager.createVLANInterface(trunkName, parentRef, null, null, IfL2vlan.L2vlanMode.Trunk, true);
        }
        if (ElanUtils.isFlat(elanInstance)) {
            interfaceName = trunkName;
        } else if (ElanUtils.isVlan(elanInstance)) {
            Long segmentationId = elanInstance.getSegmentationId().toJava();
            interfaceName = parentRef + IfmConstants.OF_URI_SEPARATOR + segmentationId;
            interfaceManager.createVLANInterface(interfaceName, trunkName, segmentationId.intValue(), null, IfL2vlan.L2vlanMode.TrunkMember, true);
        }
    } catch (InterfaceAlreadyExistsException e) {
        LOG.trace("Interface {} was already created", interfaceName);
    }
    return interfaceName;
}
Also used : InterfaceAlreadyExistsException(org.opendaylight.genius.interfacemanager.exceptions.InterfaceAlreadyExistsException) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) EtreeInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInterface)

Aggregations

Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)14 IfL2vlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)7 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)7 ArrayList (java.util.ArrayList)6 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 BigInteger (java.math.BigInteger)4 List (java.util.List)4 Inject (javax.inject.Inject)4 Singleton (javax.inject.Singleton)4 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)4 ExternalTunnelKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey)4 Collections (java.util.Collections)3 Objects (java.util.Objects)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)3 ExternalTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)3 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)3 VlanId (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId)3 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)3 Preconditions (com.google.common.base.Preconditions)2