Fix address_scope calculation

Fix in the iteration to obtain address_scope linked to a subnet.
A network can be linked to more than one subnet (ipv4 and ipv6),
but if one of them does not have an address_scope, a null object
element access failure occurs.

Closes-bug: #1998104
Change-Id: Ic6d48a86043aaf4b458bb2230883a355fc841ee9
(cherry picked from commit feff164b60)
This commit is contained in:
ROBERTO BARTZEN ACOSTA 2022-11-04 17:01:08 -03:00 committed by Dr. Jens Harbott
parent 0d7fb34b87
commit 962bb66743

View File

@ -1189,9 +1189,11 @@ class BgpDbMixin(object):
ext_net_id = gw_subnet.network_id
ext_pool = subnetpool_obj.SubnetPool.get_object(
ctx, id=gw_subnet.subnetpool_id)
ext_scope_set = ext_net_subnetpool_map.get(ext_net_id, set())
ext_scope_set.add(ext_pool.address_scope_id)
ext_net_subnetpool_map[ext_net_id] = ext_scope_set
if ext_pool is not None:
ext_scope_set = ext_net_subnetpool_map.get(ext_net_id,
set())
ext_scope_set.add(ext_pool.address_scope_id)
ext_net_subnetpool_map[ext_net_id] = ext_scope_set
ext_nets = []