Revising log with wrong network_id when create port failed

Log network_id passed from api rather than subnet['network_id']

Change-Id: I8151253be1ca42bbf4b49f904751565783723769
Closes-Bug: #1844607
This commit is contained in:
zhengyong 2020-04-28 14:05:23 +08:00
parent 4b02ed8225
commit e07b6d8108
2 changed files with 7 additions and 5 deletions

View File

@ -383,7 +383,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
if segment.is_dynamic:
raise segment_exc.SubnetCantAssociateToDynamicSegment()
def _get_subnet_for_fixed_ip(self, context, fixed, subnets):
def _get_subnet_for_fixed_ip(self, context, fixed, subnets, network_id):
# Subnets are all the subnets belonging to the same network.
if not subnets:
msg = _('IP allocation requires subnets for network')
@ -396,12 +396,13 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
return subnet
subnet = get_matching_subnet()
if not subnet:
subnet_obj = self._get_subnet_object(context,
fixed['subnet_id'])
# Call this method to keep original status code
# in case subnet is not found
self._get_subnet_object(context, fixed['subnet_id'])
msg = (_("Failed to create port on network %(network_id)s"
", because fixed_ips included invalid subnet "
"%(subnet_id)s") %
{'network_id': subnet_obj.network_id,
{'network_id': network_id,
'subnet_id': fixed['subnet_id']})
raise exc.InvalidInput(error_message=msg)
# Ensure that the IP is valid on the subnet

View File

@ -291,7 +291,8 @@ class IpamPluggableBackend(ipam_backend_mixin.IpamBackendMixin):
fixed_ip_list = []
for fixed in fixed_ips:
fixed['device_owner'] = device_owner
subnet = self._get_subnet_for_fixed_ip(context, fixed, subnets)
subnet = self._get_subnet_for_fixed_ip(context, fixed,
subnets, network_id)
is_auto_addr_subnet = ipv6_utils.is_auto_address_subnet(subnet)
if ('ip_address' in fixed and