Merge "Revising log with wrong network_id when create port failed"

changes/57/715157/15
Zuul 2 years ago committed by Gerrit Code Review
commit 415ddbff82
  1. 9
      neutron/db/ipam_backend_mixin.py
  2. 3
      neutron/db/ipam_pluggable_backend.py

@ -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

@ -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

Loading…
Cancel
Save