diff --git a/neutron/services/portforwarding/pf_plugin.py b/neutron/services/portforwarding/pf_plugin.py index b3ecdd10707..684bc47971a 100644 --- a/neutron/services/portforwarding/pf_plugin.py +++ b/neutron/services/portforwarding/pf_plugin.py @@ -471,7 +471,7 @@ class PortForwardingPlugin(fip_pf.PortForwardingPluginBase): msg=message) def _check_port_forwarding_update(self, context, pf_obj): - def _check_port_forwarding_update_failed(conflict): + def _raise_port_forwarding_update_failed(conflict): message = _("Another port forwarding entry with the same " "attributes already exists, conflicting " "values are %s") % conflict @@ -499,7 +499,7 @@ class PortForwardingPlugin(fip_pf.PortForwardingPluginBase): # Ensure there are no conflicts on the outside if (obj.floating_ip_address == pf_obj.floating_ip_address and obj.external_port == pf_obj.external_port): - _check_port_forwarding_update_failed( + _raise_port_forwarding_update_failed( {'floating_ip_address': str(obj.floating_ip_address), 'external_port': obj.external_port}) # Ensure there are no conflicts in the inside @@ -507,7 +507,7 @@ class PortForwardingPlugin(fip_pf.PortForwardingPluginBase): if (obj.internal_port_id == pf_obj.internal_port_id and obj.internal_ip_address == pf_obj.internal_ip_address and obj.internal_port == pf_obj.internal_port): - _check_port_forwarding_update_failed( + _raise_port_forwarding_update_failed( {'internal_port_id': obj.internal_port_id, 'internal_ip_address': str(obj.internal_ip_address), 'internal_port': obj.internal_port}) diff --git a/neutron/tests/unit/services/portforwarding/test_pf_plugin.py b/neutron/tests/unit/services/portforwarding/test_pf_plugin.py index 8b40641e65d..a866e7f2e55 100644 --- a/neutron/tests/unit/services/portforwarding/test_pf_plugin.py +++ b/neutron/tests/unit/services/portforwarding/test_pf_plugin.py @@ -246,7 +246,7 @@ class TestPortForwardingPlugin(testlib_api.SqlTestCase): mock_pf_get_objects.return_value = [pf_obj, other_pf_obj] self.assertRaisesRegex( lib_exc.BadRequest, - "already exist.*same_fip_addr.*same_ext_port", + "already exist.*same_fip_addr", self.pf_plugin._check_port_forwarding_update, self.ctxt, pf_obj) mock_get_port.assert_called_once_with(self.ctxt, mock.ANY) @@ -269,8 +269,7 @@ class TestPortForwardingPlugin(testlib_api.SqlTestCase): mock_pf_get_objects.return_value = [pf_obj, other_pf_obj] self.assertRaisesRegex( lib_exc.BadRequest, - "already exist.*same_int_port_id.*{}.*same_int_port".format( - same_internal_ip), + "already exist.*{}".format(same_internal_ip), self.pf_plugin._check_port_forwarding_update, self.ctxt, pf_obj) mock_get_port.assert_called_once_with(self.ctxt, 'same_int_port_id')