Search in sources :

Example 36 with ParentRefs

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

the class OvsInterfaceConfigAddHelper method addTunnelConfiguration.

private void addTunnelConfiguration(ParentRefs parentRefs, Interface interfaceNew, IfTunnel ifTunnel, WriteTransaction defaultConfigShardTransaction, WriteTransaction defaultOperShardTransaction, List<ListenableFuture<Void>> futures) {
    if (parentRefs == null) {
        LOG.warn("ParentRefs for interface: {} Not Found. " + "Creation of Tunnel OF-Port not supported when dpid not provided.", interfaceNew.getName());
        return;
    }
    BigInteger dpId = parentRefs.getDatapathNodeIdentifier();
    if (dpId == null) {
        LOG.warn("dpid for interface: {} Not Found. No DPID provided. " + "Creation of OF-Port not supported.", interfaceNew.getName());
        return;
    }
    LOG.info("adding tunnel configuration for interface {}", interfaceNew.getName());
    if (ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeLogicalGroup.class)) {
        futures.add(addLogicalTunnelGroup(interfaceNew, defaultOperShardTransaction));
        return;
    }
    boolean createTunnelPort = true;
    final String tunnelName;
    if (SouthboundUtils.isOfTunnel(ifTunnel)) {
        BridgeEntry bridgeEntry = interfaceMetaUtils.getBridgeEntryFromConfigDS(dpId);
        createTunnelPort = bridgeEntry == null || bridgeEntry.getBridgeInterfaceEntry() == null || bridgeEntry.getBridgeInterfaceEntry().isEmpty();
        tunnelName = SouthboundUtils.generateOfTunnelName(dpId, ifTunnel);
        interfaceManagerCommonUtils.createInterfaceChildEntry(tunnelName, interfaceNew.getName(), defaultConfigShardTransaction);
        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState = interfaceManagerCommonUtils.getInterfaceState(tunnelName);
        if (interfaceState != null) {
            coordinator.enqueueJob(tunnelName, () -> ovsInterfaceStateAddHelper.addState(interfaceNew.getName(), interfaceState));
        }
    } else {
        tunnelName = interfaceNew.getName();
    }
    String parentInterface = parentRefs.getParentInterface();
    if (ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class) && !Strings.isNullOrEmpty(parentInterface)) {
        LOG.debug("MULTIPLE_VxLAN_TUNNELS: createInterfaceChildEntry for {} in logical group {}", tunnelName, parentInterface);
        interfaceManagerCommonUtils.createInterfaceChildEntry(parentInterface, tunnelName, defaultConfigShardTransaction);
    }
    LOG.debug("creating bridge interfaceEntry in ConfigDS {}", dpId);
    interfaceMetaUtils.createBridgeInterfaceEntryInConfigDS(dpId, interfaceNew.getName());
    // create bridge on switch, if switch is connected
    BridgeRefEntry bridgeRefEntry = interfaceMetaUtils.getBridgeRefEntryFromOperDS(dpId);
    if (bridgeRefEntry != null && bridgeRefEntry.getBridgeReference() != null) {
        LOG.debug("creating bridge interface on dpn {}", dpId);
        InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid = (InstanceIdentifier<OvsdbBridgeAugmentation>) bridgeRefEntry.getBridgeReference().getValue();
        if (createTunnelPort) {
            southboundUtils.addPortToBridge(bridgeIid, interfaceNew, tunnelName);
        }
        // if TEP is already configured on switch, start LLDP monitoring and
        // program tunnel ingress flow
        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(interfaceNew.getName());
        if (ifState != null) {
            NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
            if (ncId != null) {
                long portNo = IfmUtil.getPortNumberFromNodeConnectorId(ncId);
                interfaceManagerCommonUtils.addTunnelIngressFlow(ifTunnel, dpId, portNo, interfaceNew.getName(), ifState.getIfIndex());
                ListenableFuture<Void> future = FlowBasedServicesUtils.bindDefaultEgressDispatcherService(txRunner, interfaceNew, Long.toString(portNo), interfaceNew.getName(), ifState.getIfIndex());
                futures.add(future);
                Futures.addCallback(future, new FutureCallback<Void>() {

                    @Override
                    public void onSuccess(@Nullable Void result) {
                        // start LLDP monitoring for the tunnel interface
                        alivenessMonitorUtils.startLLDPMonitoring(ifTunnel, interfaceNew.getName());
                    }

                    @Override
                    public void onFailure(@Nonnull Throwable throwable) {
                        LOG.error("Unable to add tunnel monitoring", throwable);
                    }
                }, MoreExecutors.directExecutor());
            }
        }
    }
}
Also used : Collections(java.util.Collections) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) BridgeRefEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry) BridgeEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.BridgeEntry) OvsdbBridgeAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation) BigInteger(java.math.BigInteger)

Example 37 with ParentRefs

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

the class OvsInterfaceConfigAddHelper method addVlanConfiguration.

private void addVlanConfiguration(Interface interfaceNew, ParentRefs parentRefs, WriteTransaction defaultConfigShardTransaction, WriteTransaction defaultOperShardTransaction, List<ListenableFuture<Void>> futures) {
    IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
    if (ifL2vlan == null || IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode() && IfL2vlan.L2vlanMode.Transparent != ifL2vlan.getL2vlanMode()) {
        return;
    }
    if (!interfaceManagerCommonUtils.createInterfaceChildEntryIfNotPresent(defaultConfigShardTransaction, parentRefs.getParentInterface(), interfaceNew.getName(), ifL2vlan.getL2vlanMode())) {
        return;
    }
    LOG.info("adding vlan configuration for interface {}", interfaceNew.getName());
    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(), defaultOperShardTransaction, futures, ifState);
    VlanMemberStateAddWorker vlanMemberStateAddWorker = new VlanMemberStateAddWorker(txRunner, interfaceManagerCommonUtils, interfaceMetaUtils, interfaceNew.getName(), ifState);
    coordinator.enqueueJob(interfaceNew.getName(), vlanMemberStateAddWorker, IfmConstants.JOB_MAX_RETRIES);
}
Also used : Collections(java.util.Collections) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 38 with ParentRefs

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

the class OvsInterfaceConfigRemoveHelper method removeTunnelConfiguration.

private void removeTunnelConfiguration(ParentRefs parentRefs, String interfaceName, IfTunnel ifTunnel, WriteTransaction defaultOperationalShardTransaction) {
    LOG.info("removing tunnel configuration for interface {}", interfaceName);
    BigInteger dpId = null;
    if (parentRefs != null) {
        dpId = parentRefs.getDatapathNodeIdentifier();
    }
    if (dpId == null) {
        return;
    }
    OvsdbBridgeRef ovsdbBridgeRef = interfaceMetaUtils.getOvsdbBridgeRef(dpId);
    BridgeEntryKey bridgeEntryKey = new BridgeEntryKey(dpId);
    InstanceIdentifier<BridgeEntry> bridgeEntryIid = InterfaceMetaUtils.getBridgeEntryIdentifier(bridgeEntryKey);
    BridgeEntry bridgeEntry = interfaceMetaUtils.getBridgeEntryFromConfigDS(bridgeEntryIid);
    if (bridgeEntry == null) {
        LOG.debug("Bridge Entry not present for dpn: {}", dpId);
        return;
    }
    List<BridgeInterfaceEntry> bridgeInterfaceEntries = bridgeEntry.getBridgeInterfaceEntry();
    if (bridgeInterfaceEntries == null) {
        LOG.debug("Bridge Interface Entries not present for dpn : {}", dpId);
        return;
    }
    String tunnelName = SouthboundUtils.isOfTunnel(ifTunnel) ? SouthboundUtils.generateOfTunnelName(dpId, ifTunnel) : interfaceName;
    boolean deleteTunnel = canDeleteTunnelPort(bridgeInterfaceEntries, ifTunnel);
    if (ovsdbBridgeRef != null && deleteTunnel) {
        southboundUtils.removeTerminationEndPoint(ovsdbBridgeRef.getValue(), tunnelName);
    }
    if (SouthboundUtils.isOfTunnel(ifTunnel)) {
        if (deleteTunnel) {
            interfaceManagerCommonUtils.deleteParentInterfaceEntry(tunnelName);
        } else {
            interfaceManagerCommonUtils.deleteInterfaceChildEntry(tunnelName, interfaceName);
        }
    }
    // delete tunnel ingress flow
    removeTunnelIngressFlow(interfaceName, ifTunnel, dpId);
    // delete bridge to tunnel interface mappings
    interfaceMetaUtils.deleteBridgeInterfaceEntry(bridgeEntryKey, bridgeInterfaceEntries, bridgeEntryIid, interfaceName);
    int lportTag = interfaceMetaUtils.removeLportTagInterfaceMap(defaultOperationalShardTransaction, interfaceName);
    cleanUpInterfaceWithUnknownState(interfaceName, parentRefs, ifTunnel, defaultOperationalShardTransaction);
    // stop LLDP monitoring for the tunnel interface
    alivenessMonitorUtils.stopLLDPMonitoring(ifTunnel, interfaceName);
    if (ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
        removeMultipleVxlanTunnelsConfiguration(interfaceName, parentRefs);
    } else if (ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeLogicalGroup.class)) {
        removeLogicalTunnelGroup(dpId, interfaceName, lportTag, defaultOperationalShardTransaction);
    }
}
Also used : BridgeEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.BridgeEntryKey) TunnelTypeLogicalGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup) BridgeEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.BridgeEntry) BigInteger(java.math.BigInteger) OvsdbBridgeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeRef) BridgeInterfaceEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge._interface.info.bridge.entry.BridgeInterfaceEntry)

Example 39 with ParentRefs

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

the class OvsInterfaceConfigRemoveHelper method removeVlanConfiguration.

private void removeVlanConfiguration(ParentRefs parentRefs, String interfaceName, IfL2vlan ifL2vlan, WriteTransaction tx, List<ListenableFuture<Void>> futures) {
    if (parentRefs == null || ifL2vlan == null || IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode() && IfL2vlan.L2vlanMode.Transparent != ifL2vlan.getL2vlanMode()) {
        return;
    }
    LOG.info("removing vlan configuration for interface {}", interfaceName);
    interfaceManagerCommonUtils.deleteInterfaceStateInformation(interfaceName, tx);
    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("could not fetch interface state corresponding to {}, probably already removed as part of port " + "removal event, proceeding with remaining config cleanups", interfaceName);
    }
    cleanUpInterfaceWithUnknownState(interfaceName, parentRefs, null, tx);
    BigInteger dpId = IfmUtil.getDpnFromInterface(ifState);
    FlowBasedServicesUtils.removeIngressFlow(interfaceName, dpId, txRunner, futures);
    interfaceManagerCommonUtils.deleteParentInterfaceEntry(parentRefs.getParentInterface());
    // For Vlan-Trunk Interface, remove the trunk-member operstates as
    // well...
    InterfaceParentEntry interfaceParentEntry = interfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceName);
    if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
        return;
    }
    VlanMemberStateRemoveWorker vlanMemberStateRemoveWorker = new VlanMemberStateRemoveWorker(txRunner, interfaceManagerCommonUtils, dpId, interfaceName, interfaceParentEntry);
    coordinator.enqueueJob(interfaceName, vlanMemberStateRemoveWorker, IfmConstants.JOB_MAX_RETRIES);
}
Also used : Collections(java.util.Collections) BigInteger(java.math.BigInteger) InterfaceParentEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._interface.child.info.InterfaceParentEntry)

Example 40 with ParentRefs

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

the class OvsInterfaceConfigUpdateHelper method portAttributesModified.

private static boolean portAttributesModified(Interface interfaceOld, Interface interfaceNew) {
    ParentRefs parentRefsOld = interfaceOld.getAugmentation(ParentRefs.class);
    ParentRefs parentRefsNew = interfaceNew.getAugmentation(ParentRefs.class);
    if (checkAugmentations(parentRefsOld, parentRefsNew)) {
        return true;
    }
    IfL2vlan ifL2vlanOld = interfaceOld.getAugmentation(IfL2vlan.class);
    IfL2vlan ifL2vlanNew = interfaceNew.getAugmentation(IfL2vlan.class);
    if (checkAugmentations(ifL2vlanOld, ifL2vlanNew)) {
        return true;
    }
    IfTunnel ifTunnelOld = interfaceOld.getAugmentation(IfTunnel.class);
    IfTunnel ifTunnelNew = interfaceNew.getAugmentation(IfTunnel.class);
    if (checkAugmentations(ifTunnelOld, ifTunnelNew)) {
        if (!ifTunnelNew.getTunnelDestination().equals(ifTunnelOld.getTunnelDestination()) || !ifTunnelNew.getTunnelSource().equals(ifTunnelOld.getTunnelSource()) || ifTunnelNew.getTunnelGateway() != null && ifTunnelOld.getTunnelGateway() != null && !ifTunnelNew.getTunnelGateway().equals(ifTunnelOld.getTunnelGateway())) {
            return true;
        }
    }
    return false;
}
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) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

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