diff --git a/neutron/extensions/l3_ext_gw_mode.py b/neutron/extensions/l3_ext_gw_mode.py index a9726a18c29..530279d0119 100644 --- a/neutron/extensions/l3_ext_gw_mode.py +++ b/neutron/extensions/l3_ext_gw_mode.py @@ -32,7 +32,7 @@ EXTENDED_ATTRIBUTES_2_0 = { 'convert_to': attrs.convert_to_boolean}, 'external_fixed_ips': { 'convert_list_to': attrs.convert_kvp_list_to_dict, - 'validate': {'type:fixed_ips': None}, + 'type:fixed_ips': None, 'default': None, 'required': False} } diff --git a/neutron/tests/unit/extensions/test_l3_ext_gw_mode.py b/neutron/tests/unit/extensions/test_l3_ext_gw_mode.py index 28577f57112..e2229f86537 100644 --- a/neutron/tests/unit/extensions/test_l3_ext_gw_mode.py +++ b/neutron/tests/unit/extensions/test_l3_ext_gw_mode.py @@ -16,6 +16,7 @@ import mock from oslo_config import cfg +from oslo_serialization import jsonutils from oslo_utils import uuidutils import testscenarios from webob import exc @@ -388,6 +389,24 @@ class ExtGwModeIntTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase, expected_code=expected_code, neutron_context=neutron_context) + def test_router_create_with_gwinfo_invalid_ext_ip(self): + with self.subnet() as s: + self._set_net_external(s['subnet']['network_id']) + ext_info = { + 'network_id': s['subnet']['network_id'], + 'external_fixed_ips': [{'ip_address': '10.0.0.'}] + } + error_code = exc.HTTPBadRequest.code + res = self._create_router( + self.fmt, _uuid(), arg_list=('external_gateway_info',), + external_gateway_info=ext_info, + expected_code=error_code + ) + msg = ("Invalid input for external_gateway_info. " + "Reason: '10.0.0.' is not a valid IP address.") + body = jsonutils.loads(res.body) + self.assertEqual(msg, body['NeutronError']['message']) + def test_router_create_show_no_ext_gwinfo(self): name = 'router1' tenant_id = _uuid()