ovn-bgp-agent/ovn_bgp_agent/utils/helpers.py
Jakub Libosvar 8cda2174db Fix sync for OVN LB VIPs
There was a bad comparison of datapath types, we compared router
datapath is equal to loadbalancer datapaths instead of if it is included
there.

Closes-bug: #2064922

Change-Id: I4f92d75f512ca906ad884e9da21ee7048b1dc5d6
Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
2024-05-06 13:18:10 +00:00

48 lines
1.4 KiB
Python

# Copyright 2023 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_log import log as logging
LOG = logging.getLogger(__name__)
def parse_bridge_mapping(bridge_mapping):
try:
network, bridge = bridge_mapping.split(":")
except ValueError:
LOG.warning("Incorrect bridge mapping settings: %s",
bridge_mapping)
return None, None
return network, bridge
def _get_lb_datapaths_from_group(lb, attr):
try:
dps = getattr(lb, attr)[0].datapaths
if dps:
return dps
except (AttributeError, IndexError):
pass
return []
def get_lb_datapaths(lb):
for attr in ('ls_datapath_group', 'datapath_group'):
ls_dps = _get_lb_datapaths_from_group(lb, attr)
if ls_dps:
break
lr_dps = _get_lb_datapaths_from_group(lb, 'lr_datapath_group')
return (ls_dps, lr_dps)