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);
}
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);
}
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());
});
}
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());
});
}
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);
}
});
});
}
Aggregations