From: berlin Date: Thu, 20 Feb 2014 03:07:03 +0000 (+0800) Subject: Fix NVP FWaaS errors when creating firewall without policy X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=eb1051b042e32f26882cb955508b9e263b0ddb4d;p=openstack-build%2Fneutron-build.git Fix NVP FWaaS errors when creating firewall without policy Change-Id: I7ced6fe91a2d27c3739c54aa90489976532b3ecc Closes-Bug: #1282366 --- diff --git a/neutron/plugins/vmware/plugins/service.py b/neutron/plugins/vmware/plugins/service.py index 00b92a707..d4e07a613 100644 --- a/neutron/plugins/vmware/plugins/service.py +++ b/neutron/plugins/vmware/plugins/service.py @@ -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")) diff --git a/neutron/plugins/vmware/vshield/edge_firewall_driver.py b/neutron/plugins/vmware/vshield/edge_firewall_driver.py index 6b030c523..582ce95f3 100644 --- a/neutron/plugins/vmware/vshield/edge_firewall_driver.py +++ b/neutron/plugins/vmware/vshield/edge_firewall_driver.py @@ -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) diff --git a/neutron/tests/unit/vmware/vshield/test_fwaas_plugin.py b/neutron/tests/unit/vmware/vshield/test_fwaas_plugin.py index db9263af1..4b02c4d6a 100644 --- a/neutron/tests/unit/vmware/vshield/test_fwaas_plugin.py +++ b/neutron/tests/unit/vmware/vshield/test_fwaas_plugin.py @@ -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)