Browse Source

NSX|P: Fix subnet gw validation

Change-Id: I0db5206663057dbdacdf6debfb980eeec6168fcf
changes/51/778251/1
asarfaty 2 months ago
committed by Adit Sarfaty
parent
commit
3dcac3f8e1
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      vmware_nsx/plugins/nsx_p/plugin.py

+ 3
- 3
vmware_nsx/plugins/nsx_p/plugin.py View File

@ -1386,17 +1386,16 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
def _validate_subnet_gw_ip(self, context, subnet, orig_subnet=None):
# Make sure the gw ip is legal and belongs to the subnet
raw_gw_ip = subnet.get('gateway_ip')
raw_gw_ip = subnet.get('gateway_ip', const.ATTR_NOT_SPECIFIED)
if orig_subnet and raw_gw_ip == const.ATTR_NOT_SPECIFIED:
# No change in GW ip
raw_gw_ip = orig_subnet.get('gateway_ip')
raw_cidr = subnet.get('cidr')
raw_cidr = subnet.get('cidr', const.ATTR_NOT_SPECIFIED)
if (orig_subnet and
(not raw_cidr or raw_cidr == const.ATTR_NOT_SPECIFIED)):
raw_cidr = orig_subnet.get('cidr')
if (not raw_gw_ip or raw_gw_ip == const.ATTR_NOT_SPECIFIED or
not raw_cidr or raw_cidr == const.ATTR_NOT_SPECIFIED):
if orig_subnet and raw_gw_ip is None:
# in update case, if the subnet is attached to a router the gw
# cannot be removes
@ -1408,6 +1407,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
if orig_subnet['id'] == interface_sub:
msg = _('Subnet for router interface must have a '
'gateway IP')
LOG.error(msg)
raise n_exc.BadRequest(resource='router', msg=msg)
# Nothing else to check here
return


Loading…
Cancel
Save