Merge "NSX|P: Fix subnet gw validation" into stable/victoria
This commit is contained in:
commit
9bd2662398
|
@ -1375,17 +1375,16 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
||||||
|
|
||||||
def _validate_subnet_gw_ip(self, context, subnet, orig_subnet=None):
|
def _validate_subnet_gw_ip(self, context, subnet, orig_subnet=None):
|
||||||
# Make sure the gw ip is legal and belongs to the subnet
|
# 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:
|
if orig_subnet and raw_gw_ip == const.ATTR_NOT_SPECIFIED:
|
||||||
# No change in GW ip
|
# No change in GW ip
|
||||||
raw_gw_ip = orig_subnet.get('gateway_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
|
if (orig_subnet and
|
||||||
(not raw_cidr or raw_cidr == const.ATTR_NOT_SPECIFIED)):
|
(not raw_cidr or raw_cidr == const.ATTR_NOT_SPECIFIED)):
|
||||||
raw_cidr = orig_subnet.get('cidr')
|
raw_cidr = orig_subnet.get('cidr')
|
||||||
if (not raw_gw_ip or raw_gw_ip == const.ATTR_NOT_SPECIFIED or
|
if (not raw_gw_ip or raw_gw_ip == const.ATTR_NOT_SPECIFIED or
|
||||||
not raw_cidr or raw_cidr == const.ATTR_NOT_SPECIFIED):
|
not raw_cidr or raw_cidr == const.ATTR_NOT_SPECIFIED):
|
||||||
|
|
||||||
if orig_subnet and raw_gw_ip is None:
|
if orig_subnet and raw_gw_ip is None:
|
||||||
# in update case, if the subnet is attached to a router the gw
|
# in update case, if the subnet is attached to a router the gw
|
||||||
# cannot be removes
|
# cannot be removes
|
||||||
|
@ -1397,6 +1396,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
||||||
if orig_subnet['id'] == interface_sub:
|
if orig_subnet['id'] == interface_sub:
|
||||||
msg = _('Subnet for router interface must have a '
|
msg = _('Subnet for router interface must have a '
|
||||||
'gateway IP')
|
'gateway IP')
|
||||||
|
LOG.error(msg)
|
||||||
raise n_exc.BadRequest(resource='router', msg=msg)
|
raise n_exc.BadRequest(resource='router', msg=msg)
|
||||||
# Nothing else to check here
|
# Nothing else to check here
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue