Merge "Error code for creating duplicate floating_ip_bulk"

This commit is contained in:
Jenkins
2014-11-27 14:21:31 +00:00
committed by Gerrit Code Review
3 changed files with 4 additions and 4 deletions

View File

@@ -103,7 +103,7 @@ class FloatingIPBulkController(object):
try:
objects.FloatingIPList.create(context, ips)
except exception.FloatingIpExists as exc:
raise webob.exc.HTTPBadRequest(explanation=exc.format_message())
raise webob.exc.HTTPConflict(explanation=exc.format_message())
return {"floating_ips_bulk_create": {"ip_range": ip_range,
"pool": pool,

View File

@@ -84,7 +84,7 @@ class FloatingIPBulkController(wsgi.Controller):
return floating_ip_info
@extensions.expected_errors(400)
@extensions.expected_errors((400, 409))
@validation.schema(floating_ips_bulk.create)
def create(self, req, body):
"""Bulk create floating ips."""
@@ -106,7 +106,7 @@ class FloatingIPBulkController(wsgi.Controller):
try:
objects.FloatingIPList.create(context, ips)
except exception.FloatingIpExists as exc:
raise webob.exc.HTTPBadRequest(explanation=exc.format_message())
raise webob.exc.HTTPConflict(explanation=exc.format_message())
return {"floating_ips_bulk_create": {"ip_range": ip_range,
"pool": pool,

View File

@@ -146,7 +146,7 @@ class FloatingIPBulkV21(test.TestCase):
ip_range = '192.168.1.0/29'
body = {'floating_ips_bulk_create': {'ip_range': ip_range}}
req = fakes.HTTPRequest.blank(self.url)
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create,
self.assertRaises(webob.exc.HTTPConflict, self.controller.create,
req, body=body)
def test_create_bad_cidr_fail(self):