summaryrefslogtreecommitdiff
path: root/nova/tests/unit/api
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem.os@gmail.com>2017-05-25 15:00:24 -0400
committerMatt Riedemann <mriedem.os@gmail.com>2017-05-25 15:11:01 -0400
commit452f21183f2f80cc5673ebd3fd3e5daf039caacc (patch)
tree7d9c64443c4a0ce24bc7a98640e16ce6299694c3 /nova/tests/unit/api
parent65402e1aeb770d077620f2935a0cb305474aa7a1 (diff)
downloadnova-452f21183f2f80cc5673ebd3fd3e5daf039caacc.tar.gz
Handle conflict from neutron when addFloatingIP fails
Neutron can raise a Conflict exception when attempting to associate a floating IP to a server when the fixed address is already associated to another floating IP. This has always resulted in a 400 response, however, it would also trace an ERROR in the nova-api logs, which is something we shouldn't be doing for an expected type of failure. This handles the Conflict in the neutronv2 API client code and re-raises an exception that the REST API controller code can handle and return as a 400 without the stacktrace in the logs. Change-Id: I27d3241300f75e2aa79a32348a3843e09123cb10 Closes-Bug: #1693576
Diffstat (limited to 'nova/tests/unit/api')
-rw-r--r--nova/tests/unit/api/openstack/compute/test_floating_ips.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/nova/tests/unit/api/openstack/compute/test_floating_ips.py b/nova/tests/unit/api/openstack/compute/test_floating_ips.py
index 1cb214142d..0fc45b6f72 100644
--- a/nova/tests/unit/api/openstack/compute/test_floating_ips.py
+++ b/nova/tests/unit/api/openstack/compute/test_floating_ips.py
@@ -634,6 +634,15 @@ class FloatingIpTestV21(test.TestCase):
self.manager._add_floating_ip, self.fake_req,
TEST_INST, body=body)
+ @mock.patch.object(network.api.API, 'associate_floating_ip',
+ side_effect=exception.FloatingIpAssociateFailed(
+ address='10.10.10.11'))
+ def test_associate_floating_ip_failed(self, associate_mock):
+ body = dict(addFloatingIp=dict(address='10.10.10.11'))
+ self.assertRaises(webob.exc.HTTPBadRequest,
+ self.manager._add_floating_ip, self.fake_req,
+ TEST_INST, body=body)
+
def test_associate_floating_ip_bad_address_key(self):
body = dict(addFloatingIp=dict(bad_address='10.10.10.11'))
req = fakes.HTTPRequest.blank('/v2/fake/servers/test_inst/action')