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
"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")
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:
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'],
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:
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'],
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):
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:
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'],