From 9188c900126e12a1b0182fe2e7b269edd6b45603 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Wed, 15 Apr 2026 09:24:14 +0200 Subject: [PATCH] Change signature of ``lsp_detach_mirror`` method The class used by this method, ``LspDetachMirror``, was using incorrectly ``if_exist`` instead of ``if_exists`` as input parameter in the ``__init__`` signature. The class was creating the member ``self.if_exist`` but it was also using the undefined member ``self.if_exists``. This API method was used only in "tap-as-as-service". That was checked in Github [1] and Codesearch [2]. The "tap-as-a-service" patch is [3]. [1]https://github.com/search?q=lsp_detach_mirror&type=code [2]https://codesearch.openstack.org/?q=lsp_detach_mirror&i=nope&literal=nope&files=&excludeFiles=&repos= [3]https://review.opendev.org/c/openstack/tap-as-a-service/+/984683 Depends-On: https://review.opendev.org/c/openstack/tap-as-a-service/+/984683 Closes-Bug: #2148376 Signed-off-by: Rodolfo Alonso Hernandez Change-Id: I4ea185c90bc7e334fd1159c308076cf0e4b3f00e --- ovsdbapp/schema/ovn_northbound/api.py | 6 +++--- ovsdbapp/schema/ovn_northbound/commands.py | 6 +++--- ovsdbapp/schema/ovn_northbound/impl_idl.py | 4 ++-- .../tests/functional/schema/ovn_northbound/test_impl_idl.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ovsdbapp/schema/ovn_northbound/api.py b/ovsdbapp/schema/ovn_northbound/api.py index 5ec93e27..1105d979 100644 --- a/ovsdbapp/schema/ovn_northbound/api.py +++ b/ovsdbapp/schema/ovn_northbound/api.py @@ -1600,15 +1600,15 @@ class API(api.API, metaclass=abc.ABCMeta): """ @abc.abstractmethod - def lsp_detach_mirror(self, port, mirror, if_exist=False): + def lsp_detach_mirror(self, port, mirror, if_exists=False): """Detaches an lsp from the given mirror :param port: the id of the lsp :type port: str :param mirror: the name or ID of the mirror :type mirror: str - :param if_exist: If True, don't fail if the mirror_rules entry + :param if_exists: If True, don't fail if the mirror_rules entry doesn't exist. - :type if_exist: Optional[bool] + :type if_exists: Optional[bool] :returns: :class:`Command` with RowView result """ diff --git a/ovsdbapp/schema/ovn_northbound/commands.py b/ovsdbapp/schema/ovn_northbound/commands.py index 81a08023..131e13ba 100644 --- a/ovsdbapp/schema/ovn_northbound/commands.py +++ b/ovsdbapp/schema/ovn_northbound/commands.py @@ -1293,17 +1293,17 @@ class LspAttachMirror(cmd.BaseCommand): class LspDetachMirror(cmd.BaseCommand): - def __init__(self, api, port, mirror, if_exist=False): + def __init__(self, api, port, mirror, if_exists=False): super().__init__(api) self.port = port self.mirror = mirror - self.if_exist = if_exist + self.if_exists = if_exists def run_idl(self, txn): try: lsp = self.api.lookup('Logical_Switch_Port', self.port) mirror = self.api.lookup('Mirror', self.mirror) - if mirror not in lsp.mirror_rules and not self.if_exist: + if mirror not in lsp.mirror_rules and not self.if_exists: msg = "Mirror Rule %s doesn't exist on LSP %s" % (self.mirror, self.port) raise RuntimeError(msg) diff --git a/ovsdbapp/schema/ovn_northbound/impl_idl.py b/ovsdbapp/schema/ovn_northbound/impl_idl.py index 27953075..3c018020 100644 --- a/ovsdbapp/schema/ovn_northbound/impl_idl.py +++ b/ovsdbapp/schema/ovn_northbound/impl_idl.py @@ -474,5 +474,5 @@ class OvnNbApiIdlImpl(ovs_idl.Backend, api.API): def lsp_attach_mirror(self, port, mirror, may_exist=False): return cmd.LspAttachMirror(self, port, mirror, may_exist) - def lsp_detach_mirror(self, port, mirror, if_exist=False): - return cmd.LspDetachMirror(self, port, mirror, if_exist) + def lsp_detach_mirror(self, port, mirror, if_exists=False): + return cmd.LspDetachMirror(self, port, mirror, if_exists) diff --git a/ovsdbapp/tests/functional/schema/ovn_northbound/test_impl_idl.py b/ovsdbapp/tests/functional/schema/ovn_northbound/test_impl_idl.py index 10ff9c0c..a389c6dc 100644 --- a/ovsdbapp/tests/functional/schema/ovn_northbound/test_impl_idl.py +++ b/ovsdbapp/tests/functional/schema/ovn_northbound/test_impl_idl.py @@ -3219,9 +3219,9 @@ class TestMirrorOps(OvnNorthboundTest): check_error=True ) - # detach with if_exist=True, and check the result, to be as previously + # detach with if_exists=True, and check the result, to be as previously self.api.lsp_detach_mirror( self.port_uuid, mirror2.uuid, - if_exist=True).execute(check_error=True) + if_exists=True).execute(check_error=True) self.assertEqual(1, len(port.mirror_rules)) self.assertEqual(mirror1.uuid, port.mirror_rules[0].uuid)