From 3dcac3f8e1c8e902a0ce4590ab14e1b2a479b249 Mon Sep 17 00:00:00 2001 From: asarfaty Date: Wed, 3 Mar 2021 09:17:15 +0200 Subject: [PATCH] NSX|P: Fix subnet gw validation Change-Id: I0db5206663057dbdacdf6debfb980eeec6168fcf --- vmware_nsx/plugins/nsx_p/plugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vmware_nsx/plugins/nsx_p/plugin.py b/vmware_nsx/plugins/nsx_p/plugin.py index 65d8da849c..64e0916783 100644 --- a/vmware_nsx/plugins/nsx_p/plugin.py +++ b/vmware_nsx/plugins/nsx_p/plugin.py @@ -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