Raise GatewayConflict as BadRequest
neutron GatewayConflictWithAllocationPools exception is raised as a 500, but it is actually user error, so it should be a 400. Catch the GatewayConflictWithAllocationPools exception and raise as a BadRequest with the relevant info. Change-Id: Id94590c2c8637a64a90f06834c7e3400ea2b6330 JIRA:NCP-1993 Closes-Bug: #1599980
This commit is contained in:
parent
7a906e1406
commit
203412773d
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import netaddr
|
||||
from neutron.common import exceptions as neutron_exc
|
||||
from neutron import quota
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from oslo_config import cfg
|
||||
@ -71,7 +72,11 @@ def create_route(context, route):
|
||||
|
||||
alloc_pools = allocation_pool.AllocationPools(subnet["cidr"],
|
||||
policies=policies)
|
||||
try:
|
||||
alloc_pools.validate_gateway_excluded(route["gateway"])
|
||||
except neutron_exc.GatewayConflictWithAllocationPools as e:
|
||||
LOG.exception(str(e))
|
||||
raise n_exc.BadRequest(resource="routes", msg=str(e))
|
||||
|
||||
# TODO(anyone): May want to denormalize the cidr values into columns
|
||||
# to achieve single db lookup on conflict check
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
import contextlib
|
||||
import mock
|
||||
from neutron.common import exceptions as n_exc_ext
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from oslo_config import cfg
|
||||
from quark import exceptions as q_exc
|
||||
@ -102,8 +101,7 @@ class QuarkCreateRoutes(BaseFunctionalTest):
|
||||
self.assertIsNotNone(sub)
|
||||
self.assertIsNotNone(ipp)
|
||||
create_route["subnet_id"] = sub["id"]
|
||||
with self.assertRaises(
|
||||
n_exc_ext.GatewayConflictWithAllocationPools):
|
||||
with self.assertRaises(n_exc.BadRequest):
|
||||
routes_api.create_route(self.context,
|
||||
dict(route=create_route))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user