From: Akihiro Motoki Date: Wed, 2 Apr 2014 02:34:01 +0000 (+0900) Subject: Return 409 for second firewall creation X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=2436e3e543e572ac51e1d688089cb424da47e19d;p=openstack-build%2Fneutron-build.git Return 409 for second firewall creation Second firewall creation returns 500, but it is an expected behavior of firewall reference implementation and an internal server error should not be returned. Change-Id: I9f537b238007d35172e2504591d9d3568ba3a41a Closes-Bug: #1301105 (cherry picked from commit 9df867c672bfb3f80511086c889b744113c56604) --- diff --git a/neutron/services/firewall/fwaas_plugin.py b/neutron/services/firewall/fwaas_plugin.py index f52902bcc..793eb870b 100644 --- a/neutron/services/firewall/fwaas_plugin.py +++ b/neutron/services/firewall/fwaas_plugin.py @@ -130,7 +130,7 @@ class FirewallAgentApi(proxy.RpcProxy): ) -class FirewallCountExceeded(n_exception.NeutronException): +class FirewallCountExceeded(n_exception.Conflict): """Reference implementation specific exception for firewall count. diff --git a/neutron/tests/unit/services/firewall/test_fwaas_plugin.py b/neutron/tests/unit/services/firewall/test_fwaas_plugin.py index 840ac9c22..9fc0aa47f 100644 --- a/neutron/tests/unit/services/firewall/test_fwaas_plugin.py +++ b/neutron/tests/unit/services/firewall/test_fwaas_plugin.py @@ -21,6 +21,7 @@ import contextlib import mock +from webob import exc from neutron import context from neutron.extensions import firewall @@ -198,7 +199,7 @@ class TestFirewallPluginBase(test_db_firewall.TestFirewallDBPlugin): res = self._create_firewall( None, 'firewall2', description='test', firewall_policy_id=None, admin_state_up=True) - self.assertEqual(res.status_int, 500) + self.assertEqual(res.status_int, exc.HTTPConflict.code) def test_create_firewall_admin_not_affected_by_other_tenant(self): # Create fw with admin after creating fw with other tenant @@ -245,7 +246,7 @@ class TestFirewallPluginBase(test_db_firewall.TestFirewallDBPlugin): data = {'firewall': {'name': name}} req = self.new_update_request('firewalls', data, fw_id) res = req.get_response(self.ext_api) - self.assertEqual(res.status_int, 409) + self.assertEqual(res.status_int, exc.HTTPConflict.code) def test_update_firewall_policy_fails_when_firewall_pending(self): name = "new_firewall1" @@ -261,7 +262,7 @@ class TestFirewallPluginBase(test_db_firewall.TestFirewallDBPlugin): req = self.new_update_request('firewall_policies', data, fwp_id) res = req.get_response(self.ext_api) - self.assertEqual(res.status_int, 409) + self.assertEqual(res.status_int, exc.HTTPConflict.code) def test_update_firewall_rule_fails_when_firewall_pending(self): with self.firewall_rule(name='fwr1') as fr: @@ -281,7 +282,7 @@ class TestFirewallPluginBase(test_db_firewall.TestFirewallDBPlugin): req = self.new_update_request('firewall_rules', data, fr_id) res = req.get_response(self.ext_api) - self.assertEqual(res.status_int, 409) + self.assertEqual(res.status_int, exc.HTTPConflict.code) def test_delete_firewall(self): ctx = context.get_admin_context() @@ -315,7 +316,7 @@ class TestFirewallPluginBase(test_db_firewall.TestFirewallDBPlugin): fw_id = fw['firewall']['id'] req = self.new_delete_request('firewalls', fw_id) res = req.get_response(self.ext_api) - self.assertEqual(res.status_int, 204) + self.assertEqual(res.status_int, exc.HTTPNoContent.code) self.assertRaises(firewall.FirewallNotFound, self.plugin.get_firewall, ctx, fw_id)