Search in sources :

Example 1 with UnderlayNetwork

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.UnderlayNetwork in project netvirt by opendaylight.

the class UnderlayNetworkDpnListener method remove.

@Override
protected void remove(InstanceIdentifier<DpnToInterface> key, DpnToInterface dpnToInterface) {
    String underlayNetwork = key.firstKeyOf(UnderlayNetwork.class).getNetworkName();
    BigInteger dpId = dpnToInterface.getDpId();
    List<TunnelInterface> tunnelInterfaces = dpnToInterface.getTunnelInterface();
    LOG.info("DPN {} removed from underlay network {} with tunnels {}", dpId, underlayNetwork, tunnelInterfaces);
    List<PolicyProfile> profiles = policyServiceUtil.getUnderlayNetworkPolicyProfiles(underlayNetwork);
    if (profiles == null || profiles.isEmpty()) {
        LOG.debug("No policy profiles found for underlay network {}", underlayNetwork);
        return;
    }
    populatePolicyGroupBucketsToDpn(underlayNetwork, profiles, tunnelInterfaces, dpId, NwConstants.DEL_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) BigInteger(java.math.BigInteger) TunnelInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)

Example 2 with UnderlayNetwork

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.UnderlayNetwork in project netvirt by opendaylight.

the class UnderlayNetworkDpnListener method add.

@Override
protected void add(InstanceIdentifier<DpnToInterface> key, DpnToInterface dpnToInterface) {
    String underlayNetwork = key.firstKeyOf(UnderlayNetwork.class).getNetworkName();
    BigInteger dpId = dpnToInterface.getDpId();
    List<TunnelInterface> tunnelInterfaces = dpnToInterface.getTunnelInterface();
    LOG.info("DPN {} added to underlay network {} with tunnels {}", dpId, underlayNetwork, tunnelInterfaces);
    List<PolicyProfile> profiles = policyServiceUtil.getUnderlayNetworkPolicyProfiles(underlayNetwork);
    if (profiles == null || profiles.isEmpty()) {
        LOG.debug("No policy profiles found for underlay network {}", underlayNetwork);
        return;
    }
    populatePolicyGroupsToDpn(profiles, tunnelInterfaces, dpId, NwConstants.ADD_FLOW);
    populatePolicyGroupBucketsToDpn(underlayNetwork, profiles, tunnelInterfaces, dpId, NwConstants.ADD_FLOW);
    populatePolicyAclRulesToDpn(dpId, profiles, NwConstants.ADD_FLOW);
    populatePolicyRoutesToDpn(profiles, tunnelInterfaces, 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) BigInteger(java.math.BigInteger) TunnelInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)

Example 3 with UnderlayNetwork

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.UnderlayNetwork 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 4 with UnderlayNetwork

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.UnderlayNetwork 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 5 with UnderlayNetwork

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.UnderlayNetwork in project netvirt by opendaylight.

the class TunnelStateChangeListener method populatePolicyRoutesToDpn.

private void populatePolicyRoutesToDpn(StateTunnelList tunnelState, int addOrRemove) {
    BigInteger srcDpId = getTepDpnId(tunnelState.getSrcInfo());
    BigInteger dstDpId = getTepDpnId(tunnelState.getDstInfo());
    String tunnelInterfaceName = tunnelState.getTunnelInterfaceName();
    if (BigInteger.ZERO.equals(srcDpId) || BigInteger.ZERO.equals(dstDpId)) {
        LOG.warn("No valid DPN found for logical tunnel {}", tunnelInterfaceName);
        return;
    }
    List<PolicyProfile> policyProfiles = policyServiceUtil.getAllPolicyProfiles();
    if (policyProfiles == null || policyProfiles.isEmpty()) {
        LOG.debug("No policy profiles found on addition of {}", tunnelInterfaceName);
        return;
    }
    policyProfiles.forEach(policyProfile -> {
        String policyClassifier = policyProfile.getPolicyClassifier();
        List<String> underlayNetworks = PolicyServiceUtil.getUnderlayNetworksFromPolicyRoutes(policyProfile.getPolicyRoute());
        underlayNetworks.forEach(underlayNetwork -> {
            if (policyServiceUtil.underlayNetworkContainsDpn(underlayNetwork, srcDpId) && policyServiceUtil.underlayNetworkContainsRemoteDpn(underlayNetwork, dstDpId)) {
                routeFlowProgrammer.programPolicyClassifierFlow(policyClassifier, srcDpId, dstDpId, addOrRemove, true);
            } else {
                LOG.trace("logical tunnel {} source DPN {} dest DPN {} not associated to policy classifier {}", tunnelInterfaceName, srcDpId, dstDpId, policyClassifier);
            }
        });
    });
}
Also used : PolicyProfile(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.PolicyProfile) BigInteger(java.math.BigInteger)

Aggregations

BigInteger (java.math.BigInteger)6 TunnelInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 UnderlayNetwork (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.UnderlayNetwork)3 PolicyProfile (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.PolicyProfile)3 DpnToInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.DpnToInterface)2 ArrayList (java.util.ArrayList)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 PolicyProfile (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.PolicyProfile)1 DpnToInterfaceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.DpnToInterfaceBuilder)1 TunnelInterfaceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterfaceBuilder)1