diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-03-05 02:59:45 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-03-05 02:59:45 +0000 |
| commit | 87b8e04abbdee83e251f8e38d31cdd559ee791e0 (patch) | |
| tree | 4f78cb35164bfb8c11b875c4b79482ac8b5d665f | |
| parent | 1ba9da7ef9f3eed45137295006e69e1cdb3c9c7f (diff) | |
| parent | 5b38c5c6fe57f7b0d3e36a5d0206488fa01106c0 (diff) | |
| download | nova-87b8e04abbdee83e251f8e38d31cdd559ee791e0.tar.gz nova-87b8e04abbdee83e251f8e38d31cdd559ee791e0.tar.xz nova-87b8e04abbdee83e251f8e38d31cdd559ee791e0.zip | |
Merge "Return proper error messages while disassociating floating IP"
| -rw-r--r-- | nova/api/openstack/compute/contrib/floating_ips.py | 4 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_floating_ips.py | 15 |
2 files changed, 12 insertions, 7 deletions
diff --git a/nova/api/openstack/compute/contrib/floating_ips.py b/nova/api/openstack/compute/contrib/floating_ips.py index 2f3c56199..bf1246ccb 100644 --- a/nova/api/openstack/compute/contrib/floating_ips.py +++ b/nova/api/openstack/compute/contrib/floating_ips.py @@ -294,7 +294,9 @@ class FloatingIPActionController(wsgi.Controller): disassociate_floating_ip(self, context, instance, address) return webob.Response(status_int=202) else: - return webob.Response(status_int=404) + msg = _("Floating ip %(address)s is not associated with instance " + "%(id)s.") % locals() + raise webob.exc.HTTPUnprocessableEntity(explanation=msg) class Floating_ips(extensions.ExtensionDescriptor): diff --git a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py index 864ab7a9f..00759a7ef 100644 --- a/nova/tests/api/openstack/compute/contrib/test_floating_ips.py +++ b/nova/tests/api/openstack/compute/contrib/test_floating_ips.py @@ -364,8 +364,9 @@ class FloatingIpTest(test.TestCase): body = dict(removeFloatingIp=dict(address='10.10.10.10')) req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action') - rsp = self.manager._remove_floating_ip(req, 'test_inst', body) - self.assertTrue(rsp.status_int == 404) + self.assertRaises(webob.exc.HTTPUnprocessableEntity, + self.manager._remove_floating_ip, + req, 'test_inst', body) def test_floating_ip_associate_non_existent_ip(self): def fake_network_api_associate(self, context, instance, @@ -414,8 +415,9 @@ class FloatingIpTest(test.TestCase): body = dict(removeFloatingIp=dict(address='10.10.10.10')) req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action') - rsp = self.manager._remove_floating_ip(req, wrong_uuid, body) - self.assertTrue(rsp.status_int == 404) + self.assertRaises(webob.exc.HTTPUnprocessableEntity, + self.manager._remove_floating_ip, + req, wrong_uuid, body) def test_floating_ip_disassociate_wrong_instance_id(self): def get_instance_by_floating_ip_addr(self, context, address): @@ -428,8 +430,9 @@ class FloatingIpTest(test.TestCase): body = dict(removeFloatingIp=dict(address='10.10.10.10')) req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action') - rsp = self.manager._remove_floating_ip(req, 'test_inst', body) - self.assertTrue(rsp.status_int == 404) + self.assertRaises(webob.exc.HTTPUnprocessableEntity, + self.manager._remove_floating_ip, + req, 'test_inst', body) def test_floating_ip_disassociate_auto_assigned(self): def fake_get_floating_ip_addr_auto_assigned(self, context, address): |
