]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Return 409 for second firewall creation
authorAkihiro Motoki <motoki@da.jp.nec.com>
Wed, 2 Apr 2014 02:34:01 +0000 (11:34 +0900)
committerMark McClain <mmcclain@yahoo-inc.com>
Fri, 4 Apr 2014 22:57:35 +0000 (18:57 -0400)
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)

neutron/services/firewall/fwaas_plugin.py
neutron/tests/unit/services/firewall/test_fwaas_plugin.py

index f52902bcc70ca635bd60143bcc988e611cdb490a..793eb870bf620d1046e4865ddf3c8b3e73e00a81 100644 (file)
@@ -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.
 
index 840ac9c22dd80fead010409736a8b6da2738dcd4..9fc0aa47ffdcd5d3004bf74a71feed36869dca9e 100644 (file)
@@ -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)