NSX|P: Fix dhcp subnets validation
Change-Id: Icfb92c64e6046a7b10eeaabbc1c31496cc52d596
This commit is contained in:
parent
871d2a918c
commit
43f1444717
@ -1312,12 +1312,16 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
|||||||
|
|
||||||
interface_ports = self._get_network_interface_ports(
|
interface_ports = self._get_network_interface_ports(
|
||||||
context, net_id)
|
context, net_id)
|
||||||
if interface_ports:
|
for if_port in interface_ports:
|
||||||
# Should have max 1 router interface per network
|
|
||||||
if_port = interface_ports[0]
|
|
||||||
if if_port['fixed_ips']:
|
if if_port['fixed_ips']:
|
||||||
if_subnet = interface_ports[0]['fixed_ips'][0]['subnet_id']
|
# skip subnets of the wrong version
|
||||||
if subnet_data.get('id') != if_subnet:
|
interface_ip = if_port['fixed_ips'][0].get('ip_address', '')
|
||||||
|
if ip_ver == 4 and ':' in interface_ip:
|
||||||
|
continue
|
||||||
|
if ip_ver == 6 and ':' not in interface_ip:
|
||||||
|
continue
|
||||||
|
interface_sub = if_port['fixed_ips'][0]['subnet_id']
|
||||||
|
if subnet_data.get('id') != interface_sub:
|
||||||
msg = (_("Can not create a DHCP subnet on network %(net)s "
|
msg = (_("Can not create a DHCP subnet on network %(net)s "
|
||||||
"as another IPv%(ver)s subnet is attached to a "
|
"as another IPv%(ver)s subnet is attached to a "
|
||||||
"router") % {'net': net_id, 'ver': ip_ver})
|
"router") % {'net': net_id, 'ver': ip_ver})
|
||||||
@ -2913,7 +2917,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
|||||||
for subnet in network.subnets:
|
for subnet in network.subnets:
|
||||||
if subnet.enable_dhcp and subnet.ip_version == 4:
|
if subnet.enable_dhcp and subnet.ip_version == 4:
|
||||||
msg = (_("Can not add router interface on network %(net)s "
|
msg = (_("Can not add router interface on network %(net)s "
|
||||||
"as another %(ver)s subnet has enabled DHCP") %
|
"as another IPv%(ver)s subnet has enabled DHCP") %
|
||||||
{'net': network_id, 'ver': subnet.ip_version})
|
{'net': network_id, 'ver': subnet.ip_version})
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise n_exc.InvalidInput(error_message=msg)
|
raise n_exc.InvalidInput(error_message=msg)
|
||||||
|
Loading…
Reference in New Issue
Block a user