diff --git a/vmware_nsx/plugins/nsx_v/drivers/shared_router_driver.py b/vmware_nsx/plugins/nsx_v/drivers/shared_router_driver.py index 68e7799502..6638658c2f 100644 --- a/vmware_nsx/plugins/nsx_v/drivers/shared_router_driver.py +++ b/vmware_nsx/plugins/nsx_v/drivers/shared_router_driver.py @@ -691,8 +691,18 @@ class RouterSharedDriver(router_driver.RouterBaseDriver): self._unbind_router_on_edge(context, router_id) is_migrated = True else: + updated_routes = False # Update external vnic if addr or mask is changed if orgaddr != newaddr or orgmask != newmask: + # If external gateway is removed, the default + # gateway should be cleared before updating the + # interface, or else the backend will fail. + if (new_ext_net_id != org_ext_net_id and + new_ext_net_id is None): + self._update_routes_on_routers( + context, router_id, router_ids) + updated_routes = True + self._update_external_interface_on_routers( context, router_id, router_ids) @@ -711,9 +721,10 @@ class RouterSharedDriver(router_driver.RouterBaseDriver): context, router_id, router_ids, allow_external=True) - # Update static routes in all. - self._update_routes_on_routers( - context, router_id, router_ids) + # Update static routes in all (if not updated yet). + if not updated_routes: + self._update_routes_on_routers( + context, router_id, router_ids) if is_migrated: self._bind_router_on_available_edge( context, router_id, router.admin_state_up)