Search in sources :

Example 1 with PolicyProfile

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.PolicyProfile 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 PolicyProfile

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.PolicyProfile 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 PolicyProfile

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.PolicyProfile 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)

Example 4 with PolicyProfile

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.PolicyProfile 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)4 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 TunnelInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)3 ArrayList (java.util.ArrayList)1 PolicyProfile (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.PolicyProfile)1