Search in sources :

Example 11 with TunnelInterface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface in project netvirt by opendaylight.

the class PolicyServiceUtil method updateTunnelInterfacesForUnderlayNetwork.

public void updateTunnelInterfacesForUnderlayNetwork(String underlayNetwork, BigInteger srcDpId, List<TunnelInterface> tunnelInterfaces, boolean isAdded) {
    coordinator.enqueueJob(underlayNetwork, () -> {
        InstanceIdentifier<DpnToInterface> identifier = getUnderlayNetworkDpnIdentifier(underlayNetwork, srcDpId);
        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
        if (isAdded) {
            DpnToInterface dpnToInterface = new DpnToInterfaceBuilder().setDpId(srcDpId).setTunnelInterface(tunnelInterfaces).build();
            tx.merge(LogicalDatastoreType.OPERATIONAL, identifier, dpnToInterface, true);
            LOG.info("Add tunnel interfaces {} on DPN {} to underlay network {}", tunnelInterfaces, srcDpId, underlayNetwork);
        } else {
            tx.delete(LogicalDatastoreType.OPERATIONAL, identifier);
            LOG.info("Remove tunnel interfaces {} from DPN {} on underlay network {}", tunnelInterfaces, srcDpId, underlayNetwork);
        }
        return Collections.singletonList(tx.submit());
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.DpnToInterface) DpnToInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.DpnToInterfaceBuilder)

Example 12 with TunnelInterface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface in project netvirt by opendaylight.

the class PolicyServiceUtil method updateTunnelInterfaceForUnderlayNetwork.

public void updateTunnelInterfaceForUnderlayNetwork(String underlayNetwork, BigInteger srcDpId, BigInteger dstDpId, String tunnelInterfaceName, boolean isAdded) {
    coordinator.enqueueJob(underlayNetwork, () -> {
        InstanceIdentifier<TunnelInterface> identifier = getUnderlayNetworkTunnelIdentifier(underlayNetwork, srcDpId, tunnelInterfaceName);
        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
        if (isAdded) {
            TunnelInterface tunnelInterface = new TunnelInterfaceBuilder().setInterfaceName(tunnelInterfaceName).setRemoteDpId(dstDpId).build();
            tx.merge(LogicalDatastoreType.OPERATIONAL, identifier, tunnelInterface, true);
            LOG.info("Add tunnel {} on DPN {} to underlay network {}", tunnelInterfaceName, srcDpId, underlayNetwork);
        } else {
            tx.delete(LogicalDatastoreType.OPERATIONAL, identifier);
            LOG.info("Remove tunnel {} from DPN {} on underlay network {}", tunnelInterfaceName, srcDpId, underlayNetwork);
        }
        return Collections.singletonList(tx.submit());
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) TunnelInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterfaceBuilder) TunnelInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)

Example 13 with TunnelInterface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface in project netvirt by opendaylight.

the class ElanItmUtils method getSourceDpnTepIp.

/**
 * Gets the source dpn tep ip.
 *
 * @param srcDpnId
 *            the src dpn id
 * @param dstHwVtepNodeId
 *            the dst hw vtep node id
 * @return the dpn tep ip
 */
public IpAddress getSourceDpnTepIp(BigInteger srcDpnId, org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId dstHwVtepNodeId) {
    IpAddress dpnTepIp = null;
    String tunnelInterfaceName = getExternalTunnelInterfaceName(String.valueOf(srcDpnId), dstHwVtepNodeId.getValue());
    if (tunnelInterfaceName != null) {
        Interface tunnelInterface = ElanL2GatewayUtils.getInterfaceFromConfigDS(new InterfaceKey(tunnelInterfaceName), broker);
        if (tunnelInterface != null) {
            dpnTepIp = tunnelInterface.getAugmentation(IfTunnel.class).getTunnelSource();
        } else {
            LOG.warn("Tunnel interface not found for tunnelInterfaceName {}", tunnelInterfaceName);
        }
    } else {
        LOG.warn("Tunnel interface name not found for srcDpnId {} and dstHwVtepNodeId {}", srcDpnId, dstHwVtepNodeId);
    }
    return dpnTepIp;
}
Also used : IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) 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)

Example 14 with TunnelInterface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface in project netvirt by opendaylight.

the class TunnelUnderlayNetworkChangeListener method handleTepIpChangeEvent.

private void handleTepIpChangeEvent(BigInteger dpId, String srcTepIp, String origUnderlayNetwork, String updatedUnderlayNetwork) {
    LOG.debug("Underlay network change for TEP ip {} from {} to {} DPN {}", srcTepIp, origUnderlayNetwork, updatedUnderlayNetwork, dpId);
    com.google.common.base.Optional<DpnToInterface> dpnToInterfaceOpt = policyServiceUtil.getUnderlayNetworkDpnToInterfaces(origUnderlayNetwork, dpId);
    if (!dpnToInterfaceOpt.isPresent()) {
        LOG.debug("No DpnToInterfaces found for underlay network {} DPN {}", origUnderlayNetwork, dpId);
        return;
    }
    DpnToInterface dpnToInterface = dpnToInterfaceOpt.get();
    List<TunnelInterface> tunnelInterfaces = dpnToInterface.getTunnelInterface();
    if (tunnelInterfaces == null || tunnelInterfaces.isEmpty()) {
        LOG.debug("No tunnel interfaces found for underlay network {} on DPN {}", origUnderlayNetwork, dpId);
        return;
    }
    policyServiceUtil.updateTunnelInterfacesForUnderlayNetwork(origUnderlayNetwork, dpId, tunnelInterfaces, false);
    policyServiceUtil.updateTunnelInterfacesForUnderlayNetwork(updatedUnderlayNetwork, dpId, tunnelInterfaces, true);
}
Also used : DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.DpnToInterface) TunnelInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)

Example 15 with TunnelInterface

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface in project netvirt by opendaylight.

the class UnderlayNetworkDpnListener method update.

@Override
protected void update(InstanceIdentifier<DpnToInterface> key, DpnToInterface origDpnToInterface, DpnToInterface updatedDpnToInterface) {
    String underlayNetwork = key.firstKeyOf(UnderlayNetwork.class).getNetworkName();
    BigInteger dpId = updatedDpnToInterface.getDpId();
    LOG.info("DPN {} updated to underlay network {} with tunnels {}", dpId, underlayNetwork, updatedDpnToInterface.getTunnelInterface());
    List<PolicyProfile> profiles = policyServiceUtil.getUnderlayNetworkPolicyProfiles(underlayNetwork);
    if (profiles == null || profiles.isEmpty()) {
        LOG.debug("No policy profiles found for underlay network {}", underlayNetwork);
        return;
    }
    List<TunnelInterface> origTunnelInterfaces = origDpnToInterface.getTunnelInterface();
    if (origTunnelInterfaces == null) {
        origTunnelInterfaces = Collections.emptyList();
    }
    List<TunnelInterface> updatedTunnelInterfaces = updatedDpnToInterface.getTunnelInterface();
    if (updatedTunnelInterfaces == null) {
        updatedTunnelInterfaces = Collections.emptyList();
    }
    List<TunnelInterface> removedTunnelInterfaces = new ArrayList<>(origTunnelInterfaces);
    removedTunnelInterfaces.removeAll(updatedTunnelInterfaces);
    List<TunnelInterface> addedTunnelInterfaces = new ArrayList<>(updatedTunnelInterfaces);
    addedTunnelInterfaces.removeAll(origTunnelInterfaces);
    populatePolicyGroupBucketsToDpn(underlayNetwork, profiles, removedTunnelInterfaces, dpId, NwConstants.DEL_FLOW);
    populatePolicyGroupsToDpn(profiles, addedTunnelInterfaces, dpId, NwConstants.ADD_FLOW);
    populatePolicyGroupBucketsToDpn(underlayNetwork, profiles, addedTunnelInterfaces, dpId, NwConstants.ADD_FLOW);
}
Also used : UnderlayNetwork(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.UnderlayNetwork) PolicyProfile(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.PolicyProfile) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) TunnelInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)

Aggregations

BigInteger (java.math.BigInteger)8 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 TunnelInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)6 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)5 ArrayList (java.util.ArrayList)4 Collections (java.util.Collections)4 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)4 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)4 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)4 Port (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 List (java.util.List)3 ExecutionException (java.util.concurrent.ExecutionException)3 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)3 IInterfaceManager (org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager)3 NwConstants (org.opendaylight.genius.mdsalutil.NwConstants)3