import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Singleton;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ModifiedNodeDoesNotExistException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
}
+ public void removeMipAdjacency(String vpnInterface, String ipAddress) {
+ String prefix = VpnUtil.getIpPrefix(ipAddress);
+ InstanceIdentifier<Adjacency> adjacencyIdentifier = getAdjacencyIdentifier(vpnInterface, prefix);
+ try {
+ SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, adjacencyIdentifier);
+ } catch (TransactionCommitFailedException e) {
+ if (e.getCause() instanceof ModifiedNodeDoesNotExistException) {
+ LOG.debug("vpnInterface {} is already deleted. prefix={}", vpnInterface, prefix);
+ } else {
+ LOG.error("Failed to delete adjacency for vpnInterface {}, prefix {}", vpnInterface, prefix, e);
+ }
+ }
+ }
+
static InstanceIdentifier<NetworkMap> buildNetworkMapIdentifier(Uuid networkId) {
return InstanceIdentifier.builder(NetworkMaps.class).child(NetworkMap.class, new
NetworkMapKey(networkId)).build();
alivenessMonitorUtils.stopIpMonitoring(monitorId);
});
+ String learntIp = macEntry.getIpAddress().getHostAddress();
if (this.isRemoveMipAdjAndLearntIp) {
String vpnName = macEntry.getVpnName();
- String learntIp = macEntry.getIpAddress().getHostAddress();
LearntVpnVipToPort vpnVipToPort = vpnUtil.getLearntVpnVipToPort(vpnName, learntIp);
if (vpnVipToPort != null && !vpnVipToPort.getCreationTime().equals(macEntry.getCreatedTime())) {
LOG.warn("The MIP {} over vpn {} has been learnt again and processed. "
+ "Ignoring this remove event.", learntIp, vpnName);
return futures;
}
-
- vpnUtil.removeMipAdjAndLearntIp(macEntry.getVpnName(), macEntry.getInterfaceName(),
- macEntry.getIpAddress().getHostAddress());
+ vpnUtil.removeMipAdjAndLearntIp(vpnName, macEntry.getInterfaceName(), learntIp);
+ } else {
+ // Delete only MIP adjacency
+ vpnUtil.removeMipAdjacency(macEntry.getInterfaceName(), learntIp);
}
return futures;
}