From 09784cc96bacf5b586cbfd08b1dd5f509b6eb46e Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Mon, 25 Dec 2017 09:07:39 +0200 Subject: [PATCH] NSX|v+v3: Prevent adding default route to router Both NSX backend does not support adding a static route with destination 0.0.0.0/0. The prefered way to change the default gw is to change the gw-ip of the external subnet. Change-Id: Ibb4f81a484de48f7ea65cb2bb6968e55eae087ad --- vmware_nsx/plugins/common/plugin.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vmware_nsx/plugins/common/plugin.py b/vmware_nsx/plugins/common/plugin.py index 78192a0f5d..73f3549ea7 100644 --- a/vmware_nsx/plugins/common/plugin.py +++ b/vmware_nsx/plugins/common/plugin.py @@ -320,6 +320,15 @@ class NsxPluginBase(db_base_plugin_v2.NeutronDbPluginV2, return [self._make_subnet_dict(subnet_obj) for subnet_obj in self._get_subnets_by_network(context.elevated(), network_id)] + def _validate_routes(self, context, router_id, routes): + super(NsxPluginBase, self)._validate_routes( + context, router_id, routes) + # do not allow adding a default route. NSX-v/v3 don't support it + for route in routes: + if route.get('destination') == '0.0.0.0/0': + msg = _("Cannot set a default route using static routes") + raise n_exc.BadRequest(resource='router', msg=msg) + # Register the callback def _validate_network_has_subnet(resource, event, trigger, **kwargs):