Make SubnetMismatchForPort extend BadRequest rather than Conflict

Nova is trying to do a better job of mapping Neutron exceptions and
change I4c087684ef77988e5f463d7f2f50fc2a04f37db0 is trying to map 409 to
the proper nova exception. In looking at what raises a 409 exception in
Neutron, the SubnetMismatchForPort exception seemed like a candidate for
changing from Conflict (409) to BadRequest (400) to ease that mapping.

Note that the only thing currently using this exception is the L3 router
extension when removing a router interface and the 400 response code is
already listed in the API docs as a possible response code:

http://docs.openstack.org/api/openstack-network/2.0/content/router_remove_interface.html

Also note that it's generally OK to change APIs for a more accurate
response code:

https://wiki.openstack.org/wiki/APIChangeGuidelines#Generally_Considered_OK

Related-Bug: #1209446

Change-Id: I4507e1db69d738ec0f943f1b8b1209f269d5aebf
This commit is contained in:
Matt Riedemann 2013-08-08 12:33:10 -07:00 committed by Mark McClain
parent fd1c78a815
commit 6cd3e190c6
4 changed files with 9 additions and 9 deletions

View File

@ -178,7 +178,7 @@ class NoNetworkAvailable(ResourceExhausted):
"No tenant network is available for allocation.")
class SubnetMismatchForPort(Conflict):
class SubnetMismatchForPort(BadRequest):
message = _("Subnet on port %(port_id)s does not match "
"the requested subnet %(subnet_id)s")

View File

@ -112,7 +112,7 @@ class RouterDBTestCase(test_l3_plugin.L3NatDBTestCase):
cfg.CONF.reset()
test_l3_plugin.L3NatDBTestCase.setUp = origSetUp
def test_router_remove_router_interface_wrong_subnet_returns_409(self):
def test_router_remove_router_interface_wrong_subnet_returns_400(self):
with self.router() as r:
with self.subnet() as s:
with self.subnet(cidr='10.0.10.0/24') as s1:
@ -125,7 +125,7 @@ class RouterDBTestCase(test_l3_plugin.L3NatDBTestCase):
r['router']['id'],
s['subnet']['id'],
p['port']['id'],
exc.HTTPConflict.code)
exc.HTTPBadRequest.code)
#remove properly to clean-up
self._router_interface_action('remove',
r['router']['id'],
@ -213,7 +213,7 @@ class RouterDBTestCase(test_l3_plugin.L3NatDBTestCase):
subnet['subnet']['network_id'],
expected_code=exc.HTTPConflict.code)
def test_router_remove_interface_wrong_subnet_returns_409(self):
def test_router_remove_interface_wrong_subnet_returns_400(self):
with self.router() as r:
with self.subnet(cidr='10.0.10.0/24') as s:
with self.port(no_delete=True) as p:
@ -225,7 +225,7 @@ class RouterDBTestCase(test_l3_plugin.L3NatDBTestCase):
r['router']['id'],
s['subnet']['id'],
p['port']['id'],
exc.HTTPConflict.code)
exc.HTTPBadRequest.code)
#remove properly to clean-up
self._router_interface_action('remove',
r['router']['id'],

View File

@ -514,9 +514,9 @@ class TestNiciraL3NatTestCase(test_l3_plugin.L3NatDBTestCase,
self.test_router_remove_interface_inuse_returns_409()
self._nvp_metadata_teardown()
def test_router_remove_iface_wrong_sub_returns_409_with_metadata(self):
def test_router_remove_iface_wrong_sub_returns_400_with_metadata(self):
self._nvp_metadata_setup()
self.test_router_remove_interface_wrong_subnet_returns_409()
self.test_router_remove_interface_wrong_subnet_returns_400()
self._nvp_metadata_teardown()
def test_router_delete_with_metadata_access(self):

View File

@ -989,7 +989,7 @@ class L3NatDBTestCase(L3NatTestCaseBase):
s['subnet']['id'],
None)
def test_router_remove_interface_wrong_subnet_returns_409(self):
def test_router_remove_interface_wrong_subnet_returns_400(self):
with self.router() as r:
with self.subnet() as s:
with self.port(no_delete=True) as p:
@ -1001,7 +1001,7 @@ class L3NatDBTestCase(L3NatTestCaseBase):
r['router']['id'],
s['subnet']['id'],
p['port']['id'],
exc.HTTPConflict.code)
exc.HTTPBadRequest.code)
#remove properly to clean-up
self._router_interface_action('remove',
r['router']['id'],