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 <ralonsoh@redhat.com>
Change-Id: I4ea185c90bc7e334fd1159c308076cf0e4b3f00e
This commit is contained in:
Rodolfo Alonso Hernandez
2026-04-17 08:17:22 +00:00
committed by Rodolfo Alonso
parent 2d63f81ad7
commit 9188c90012
4 changed files with 10 additions and 10 deletions
+3 -3
View File
@@ -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
"""
+3 -3
View File
@@ -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)
+2 -2
View File
@@ -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)
@@ -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)