- handleDisableSnat(original, networkUuid, externalIps, false, null, dpnId, routerId,
- removeFlowInvTx);
- } else {
- LOG.info("update : SNAT enabled for Router {}", original.getRouterName());
- addOrDelDefFibRouteToSNAT(routerName, routerId, finalBgpVpnId, bgpVpnUuid,
- true, writeFlowInvTx);
- handleEnableSnat(update, routerId, dpnId, finalBgpVpnId, writeFlowInvTx);
+ final String vpnName = NatUtil.getAssociatedVPN(dataBroker, networkId);
+ handleDisableSnat(original, networkUuid, externalIps, false, vpnName,
+ dpnId, routerId, removeFlowInvTx);
+ } else if (updatedSNATEnabled) {
+ LOG.info("update : SNAT enabled for Router {}", routerName);
+ addOrDelDefFibRouteToSNAT(routerName, routerId, bgpVpnId, bgpVpnUuid,
+ true, writeFlowInvTx);
+ if (isPrimaryNaptSwitchNotSelected) {
+ dpnId = selectNewNAPTSwitch(routerName);
+ if (dpnId != null && !dpnId.equals(Uint64.valueOf(BigInteger.ZERO))) {
+ handleEnableSnat(update, routerId, dpnId, bgpVpnId, removeFlowInvTx);
+ } else {
+ LOG.error("update : Failed to elect Napt Switch During update event"
+ + " of router {}", routerName);
+ }
+ }