Fixes KubevirtRoutingSnatHandler not to disassociate procedure when the gateway node is dead.
Change-Id: I31d196013513670b5356069867d646e289780462
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtRoutingSnatHandler.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtRoutingSnatHandler.java
index 8cdf435..9380e43 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtRoutingSnatHandler.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtRoutingSnatHandler.java
@@ -44,6 +44,7 @@
import org.onosproject.kubevirtnode.api.KubevirtNode;
import org.onosproject.kubevirtnode.api.KubevirtNodeService;
import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceAdminService;
import org.onosproject.net.driver.DriverService;
@@ -725,7 +726,13 @@
}
if (router.enableSnat() && !router.external().isEmpty() && router.peerRouter() != null) {
- initGatewayNodeSnatForRouter(router, disAssociatedGateway, false);
+ DeviceId disAssociatedGatewayIntDeviceId = kubevirtNodeService.node(disAssociatedGateway).intgBridge();
+
+ //Only do this in case disassociated gateway device is still alive.
+ if (disAssociatedGatewayIntDeviceId != null &&
+ deviceService.isAvailable(disAssociatedGatewayIntDeviceId)) {
+ initGatewayNodeSnatForRouter(router, disAssociatedGateway, false);
+ }
initGatewayNodeSnatForRouter(router, router.electedGateway(), true);
processRouterGatewayNodeDetached(router, disAssociatedGateway);