LBaaSv2: Fail when no router found for subnet

LBaaSv2 uses an excusive router as a platform for the loadbalancer
object. When a suitable router wasn't found, the code should throw an
appropriate exception.

Change-Id: I4b85526de90e8f189c5fbf4cf14088d06a0dff1f
This commit is contained in:
Kobi Samoray 2016-04-06 12:21:40 +03:00
parent 42cc581c01
commit 84ea909232

View File

@ -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)
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)