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