]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix NVP FWaaS errors when creating firewall without policy
authorberlin <linb@vmware.com>
Thu, 20 Feb 2014 03:07:03 +0000 (11:07 +0800)
committerThomas Goirand <thomas@goirand.fr>
Thu, 13 Mar 2014 07:20:39 +0000 (15:20 +0800)
Change-Id: I7ced6fe91a2d27c3739c54aa90489976532b3ecc
Closes-Bug: #1282366

neutron/plugins/vmware/plugins/service.py
neutron/plugins/vmware/vshield/edge_firewall_driver.py
neutron/tests/unit/vmware/vshield/test_fwaas_plugin.py

index 00b92a707ea3363eada1f9b2b90a3352954b5590..d4e07a61387ac4b56cdb2a1149d37ce9e35d4ae8 100644 (file)
@@ -852,7 +852,7 @@ class NsxAdvancedPlugin(sr_db.ServiceRouter_mixin,
             LOG.exception(msg)
             raise e
 
-        except exceptions.BadRequest as e:
+        except exceptions.VcnsBadRequest as e:
             self._firewall_set_status(
                 context, fw['id'], service_constants.ERROR)
             LOG.exception(_("Bad Firewall request Input"))
index 6b030c5231276d1c2f645ea8b8c3622b744752f3..582ce95f3cd8b88e66764ba91156241bb4ce9486 100644 (file)
@@ -41,7 +41,7 @@ class EdgeFirewallDriver(db_base_plugin_v2.NeutronDbPluginV2):
             return VSE_FWAAS_DENY
         else:
             msg = _("Invalid action value %s in a firewall rule") % action
-            raise vcns_exc.BadRequest(resource='firewall_rule', msg=msg)
+            raise vcns_exc.VcnsBadRequest(resource='firewall_rule', msg=msg)
 
     def _restore_firewall_action(self, action):
         if action == VSE_FWAAS_ALLOW:
@@ -51,7 +51,7 @@ class EdgeFirewallDriver(db_base_plugin_v2.NeutronDbPluginV2):
         else:
             msg = (_("Invalid action value %s in "
                      "a vshield firewall rule") % action)
-            raise vcns_exc.BadRequest(resource='firewall_rule', msg=msg)
+            raise vcns_exc.VcnsBadRequest(resource='firewall_rule', msg=msg)
 
     def _get_port_range_from_min_max_ports(self, min_port, max_port):
         if not min_port:
@@ -351,4 +351,4 @@ class EdgeFirewallDriver(db_base_plugin_v2.NeutronDbPluginV2):
         else:
             msg = _("Can't execute insert rule operation "
                     "without reference rule_id")
-            raise vcns_exc.BadRequest(resource='firewall_rule', msg=msg)
+            raise vcns_exc.VcnsBadRequest(resource='firewall_rule', msg=msg)
index db9263af1bffd6897a85fa1865ef766617661267..4b02c4d6a02a8cd5f59eb63296ea556fefc16df8 100644 (file)
@@ -141,6 +141,21 @@ class FirewallPluginTestCase(test_db_firewall.FirewallPluginDbTestCase,
                 for k, v in attrs.iteritems():
                     self.assertEqual(fw['firewall'][k], v)
 
+    def test_create_firewall_without_policy(self):
+        name = "new_fw"
+        attrs = self._get_test_firewall_attrs(name)
+        attrs['router_id'] = self._create_and_get_router()
+
+        with self.firewall(name=name,
+                           router_id=attrs['router_id'],
+                           admin_state_up=
+                           test_db_firewall.ADMIN_STATE_UP,
+                           expected_res_status=201) as fw:
+            attrs = self._replace_firewall_status(
+                attrs, const.PENDING_CREATE, const.ACTIVE)
+            for k, v in attrs.iteritems():
+                self.assertEqual(fw['firewall'][k], v)
+
     def test_update_firewall(self):
         name = "new_fw"
         attrs = self._get_test_firewall_attrs(name)