[OVN] Optimization in the router port options generation

The networks are retrieved only if needed, that is if the configuration
flags ``ovn_emit_need_to_frag`` or ``enable_distributed_floating_ip``
are set.

Trivial-Fix

Change-Id: I6cd904310827bdb8692de632f91bfc90774e55a5
This commit is contained in:
Rodolfo Alonso Hernandez
2024-12-04 13:40:43 +00:00
parent 24e70ea166
commit 7c8be3ccbc

View File

@@ -1715,9 +1715,10 @@ class OVNClient:
LOG.debug("Router %s not found", port['device_id'])
else:
network_ids = {port['network_id'] for port in router_ports}
networks = self._plugin.get_networks(
admin_context, filters={'id': network_ids})
networks = None
if ovn_conf.is_ovn_emit_need_to_frag_enabled():
networks = self._plugin.get_networks(
admin_context, filters={'id': network_ids})
for net in networks:
if net['mtu'] > network_mtu:
options[
@@ -1732,6 +1733,8 @@ class OVNClient:
# If there are no VLAN type networks attached we need to
# still make it centralized.
enable_redirect = False
networks = networks or self._plugin.get_networks(
admin_context, filters={'id': network_ids})
if networks:
enable_redirect = all(
net.get(pnet.NETWORK_TYPE) in [const.TYPE_VLAN,