diff --git a/vmware_nsx/services/lbaas/nsx_v/v2/loadbalancer_mgr.py b/vmware_nsx/services/lbaas/nsx_v/v2/loadbalancer_mgr.py index 360f0be0c2..7e846d48d7 100644 --- a/vmware_nsx/services/lbaas/nsx_v/v2/loadbalancer_mgr.py +++ b/vmware_nsx/services/lbaas/nsx_v/v2/loadbalancer_mgr.py @@ -13,11 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc from oslo_log import helpers as log_helpers from oslo_log import log as logging from oslo_utils import excutils -from vmware_nsx._i18n import _LE +from vmware_nsx._i18n import _, _LE from vmware_nsx.db import nsxv_db from vmware_nsx.plugins.nsx_v.vshield.common import exceptions as nsxv_exc from vmware_nsx.services.lbaas.nsx_v import lbaas_common as lb_common @@ -33,10 +34,15 @@ class EdgeLoadBalancerManager(base_mgr.EdgeLoadbalancerBaseManager): @log_helpers.log_method_call def create(self, context, lb): - try: - edge_id = lb_common.get_lbaas_edge_id_for_subnet( - context, self.core_plugin, lb.vip_subnet_id, lb.tenant_id) + edge_id = lb_common.get_lbaas_edge_id_for_subnet( + context, self.core_plugin, lb.vip_subnet_id, lb.tenant_id) + if not edge_id: + msg = _( + 'No suitable Edge found for subnet %s') % lb.vip_subnet_id + raise n_exc.BadRequest(resource='edge-lbaas', msg=msg) + + try: if not nsxv_db.get_nsxv_lbaas_loadbalancer_binding_by_edge( context.session, edge_id): lb_common.enable_edge_acceleration(self.vcns, edge_id)