From ce92804eadd5ec253ef6123b8551fa47c73aad80 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Thu, 26 Apr 2018 13:31:49 +0300 Subject: [PATCH] NSX|V Do not allow router with lbaas migration In case a loadbalancer is on an exclusive router edge, do not allow changing the router type to shared. Change-Id: Idc36a0bb096302274ea182dd9f0535627bc28cfa --- vmware_nsx/plugins/nsx_v/plugin.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index bc1cb10927..61c674da2a 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -3263,6 +3263,16 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, len(router['routes']) > 0): raise n_exc.InvalidInput(error_message=err_msg) + # shared router cannot be attached to a loadbalancer + edge_id = self._get_edge_id_by_rtr_id(context, router_id) + if edge_id: + lb_bind = nsxv_db.get_nsxv_lbaas_loadbalancer_binding_by_edge( + context.session, edge_id) + if lb_bind: + err_msg = _('Unable to create a shared router with a load ' + 'balancer') + raise n_exc.InvalidInput(error_message=err_msg) + def update_router(self, context, router_id, router): with locking.LockManager.get_lock('router-%s' % router_id): return self._safe_update_router(context, router_id, router)