if not ip_range:
raise n_exc.IpAddressGenerationFailure(
net_id=cur_subnet.network_id)
+ net = netaddr.IPNetwork(s['cidr'])
+ if net.is_multicast():
+ error_message = _("Multicast IP subnet is not supported "
+ "if enable_dhcp is True.")
+ raise n_exc.InvalidInput(error_message=error_message)
+ elif net.is_loopback():
+ error_message = _("Loopback IP subnet is not supported "
+ "if enable_dhcp is True.")
+ raise n_exc.InvalidInput(error_message=error_message)
if attributes.is_attr_set(s.get('gateway_ip')):
self._validate_ip_version(ip_ver, s['gateway_ip'], 'gateway_ip')
res = subnet_req.get_response(self.api)
self.assertEqual(res.status_int, webob.exc.HTTPClientError.code)
+ def _test_unsupported_subnet_cidr(self, subnet_cidr):
+ with self.network() as network:
+ subnet = {'network_id': network['network']['id'],
+ 'cidr': subnet_cidr,
+ 'ip_version': 4,
+ 'enable_dhcp': True,
+ 'tenant_id': network['network']['tenant_id']}
+ plugin = manager.NeutronManager.get_plugin()
+ if hasattr(plugin, '_validate_subnet'):
+ self.assertRaises(n_exc.InvalidInput,
+ plugin._validate_subnet,
+ context.get_admin_context(),
+ subnet)
+
+ def test_unsupported_subnet_cidr_multicast(self):
+ self._test_unsupported_subnet_cidr("224.0.0.1/16")
+
+ def test_unsupported_subnet_cidr_loopback(self):
+ self._test_unsupported_subnet_cidr("127.0.0.1/8")
+
def test_invalid_ip_address(self):
with self.network() as network:
data = {'subnet': {'network_id': network['network']['id'],