7b0fccfb5a
This patch also refactor a few things in the OvsdbSbOvnIdl class: * is_provider_network() now returns a boolean, as expected by is_* methods. * The methods get_ports_on_datapath() and _get_ports_by_datapath() were merged since they were the same thing. * The methods get_evpn_info_from_port() and get_evpn_info() are now merged since they were the same thing. * The methods get_evpn_info_from_crlrp_port_name() and get_evpn_info_from_lrp_port_name() were merged into get_evpn_info_from_port_name() * get_ip_from_port_peer() now can raise PortNotFound This patch also adds unittests for the methods in the OvsdbSbOvnIdl class. Story: 2009165 Task: 43262 Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com> Change-Id: I3d1e3b20727227f32d094deedc897d034ab6f7f6
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
# Copyright 2021 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 neutron_lib._i18n import _
|
|
|
|
|
|
class OVNBGPAgentException(Exception):
|
|
"""Base OVN BGP Agebt Exception.
|
|
|
|
To correctly use this class, inherit from it and define
|
|
a 'message' property. That message will get printf'd
|
|
with the keyword arguments provided to the constructor.
|
|
"""
|
|
|
|
message = _("An unknown exception occurred.")
|
|
|
|
def __init__(self, **kwargs):
|
|
super().__init__(self.message % kwargs)
|
|
self.msg = self.message % kwargs
|
|
|
|
def __str__(self):
|
|
return self.msg
|
|
|
|
|
|
class InvalidPortIP(OVNBGPAgentException):
|
|
"""OVN Port has Invalid IP.
|
|
|
|
:param ip: The (wrong) IP of the port
|
|
"""
|
|
|
|
message = _("OVN port with invalid IP: %(ip)s.")
|
|
|
|
|
|
class PortNotFound(OVNBGPAgentException):
|
|
"""OVN Port not found.
|
|
|
|
:param port: The port name or UUID.
|
|
"""
|
|
|
|
message = _("OVN port was not found: %(port)s.")
|