Disallow networks with first ip 0.0.0.0 with dhcp enabled
fixes dhcp-agent errors due to establishing 0.0.0.1 as default gw Change-Id: I9e64b4597896ffde6a2f4caff81c64ca7738e402 Closes-Bug: #1471957 Signed-off-by: Andrew Karpow <andrew.karpow@sap.com>
This commit is contained in:
parent
ca13e651c9
commit
c57fede20f
|
@ -587,6 +587,10 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||
error_message = _("Loopback IP subnet is not supported "
|
||||
"if enable_dhcp is True")
|
||||
raise exc.InvalidInput(error_message=error_message)
|
||||
elif ip_ver == constants.IP_VERSION_4 and net.first is 0:
|
||||
error_message = _("First IP '0.0.0.0' of network is not "
|
||||
"supported if enable_dhcp is True.")
|
||||
raise exc.InvalidInput(error_message=error_message)
|
||||
|
||||
if validators.is_attr_set(s.get('gateway_ip')):
|
||||
self._validate_ip_version(ip_ver, s['gateway_ip'], 'gateway_ip')
|
||||
|
|
|
@ -3195,6 +3195,16 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
res = subnet_req.get_response(self.api)
|
||||
self.assertEqual(webob.exc.HTTPClientError.code, res.status_int)
|
||||
|
||||
def test_create_subnet_invalid_gw_V4_cidr(self):
|
||||
with self.network() as network:
|
||||
data = {'subnet': {'network_id': network['network']['id'],
|
||||
'cidr': '10.0.0.0/4',
|
||||
'ip_version': '4',
|
||||
'tenant_id': network['network']['tenant_id']}}
|
||||
subnet_req = self.new_create_request('subnets', data)
|
||||
res = subnet_req.get_response(self.api)
|
||||
self.assertEqual(webob.exc.HTTPClientError.code, res.status_int)
|
||||
|
||||
def test_create_subnet_with_cidr_and_default_subnetpool(self):
|
||||
"""Expect subnet-create to keep semantic with default pools."""
|
||||
with self.network() as network:
|
||||
|
@ -4607,6 +4617,16 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase):
|
|||
res = req.get_response(self.api)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
|
||||
def test_update_subnet_invalid_gw_V4_cidr(self):
|
||||
with self.network() as network:
|
||||
with self.subnet(network=network) as subnet:
|
||||
data = {'subnet': {'cidr': '10.0.0.0/4'}}
|
||||
req = self.new_update_request('subnets', data,
|
||||
subnet['subnet']['id'])
|
||||
res = req.get_response(self.api)
|
||||
self.assertEqual(webob.exc.HTTPClientError.code,
|
||||
res.status_int)
|
||||
|
||||
def test_update_subnet_inconsistent_ipv4_gatewayv6(self):
|
||||
with self.network() as network:
|
||||
with self.subnet(network=network) as subnet:
|
||||
|
|
Loading…
Reference in New Issue