[OVN] Use the Neutron port ID in `UpdateLSwitchPortQosOptionsCommand`

Instead of using the Logical_Switch_Port UUID, that requires to
retrieve it first from the OVN database, the command
``UpdateLSwitchPortQosOptionsCommand`` accepts the Neutron port ID
(that is the Logical_Switch_Port.name); the command uses ``api.lookup``
for the ``Logical_Switch_Port`` that accepts both the UUID or the
name.

Related-Bug: #2015376
Change-Id: I433dfaa0a97d1f0aec202151caf13272b79e0a4a
This commit is contained in:
Rodolfo Alonso Hernandez
2024-12-13 12:54:58 +00:00
committed by Rodolfo Alonso
parent 526f238fa4
commit e6c789b196
4 changed files with 7 additions and 4 deletions

View File

@@ -246,10 +246,13 @@ class UpdateLSwitchPortQosOptionsCommand(command.BaseCommand):
self.qos = qos
def run_idl(self, txn):
# NOTE(ralonsoh): this command can be called from inside a transaction
# where the LSP is being created. If this is not the case, the value
# provided in the Neutron port ID (== LSP.name).
if isinstance(self.lport, command.BaseCommand):
port_id = self.lport.result
else:
port_id = self.lport.uuid
port_id = self.lport
try:
port = self.api.lookup('Logical_Switch_Port', port_id)

View File

@@ -263,7 +263,7 @@ class OVNClientQosExtension:
the LSP.options. If the values are None, the keys
are removed.
"""
lsp = lsp or self.nb_idl.lsp_get(port_id).execute()
lsp = lsp or port_id
if lsp:
txn.add(self.nb_idl.update_lswitch_qos_options(lsp,
**ovn_rule_lsp))

View File

@@ -35,7 +35,7 @@ class GetPortQosTestCase(base.TestOVNFunctionalBase):
else:
options = {qos_param: None}
lsp = self.nb_api.lsp_get(lsp_name).execute(check_error=True)
self.nb_api.update_lswitch_qos_options(lsp, **options).execute(
self.nb_api.update_lswitch_qos_options(lsp.uuid, **options).execute(
check_error=True)
if qos_value is not None:
self.assertEqual(qos_value,

View File

@@ -151,7 +151,7 @@ class QoSLogicalSwitchPortEventTestCase(base.TestOVNFunctionalBase):
lsp = self.nb_api.lsp_get(port_id).execute(check_error=True)
options = {ovn_const.LSP_OPTIONS_QOS_MAX_RATE: str(max_bps),
ovn_const.LSP_OPTIONS_QOS_MIN_RATE: str(min_bps)}
self.nb_api.update_lswitch_qos_options(lsp, **options).execute(
self.nb_api.update_lswitch_qos_options(lsp.uuid, **options).execute(
check_error=True)
n_utils.wait_until_true(
lambda: check_update_egress_called(max_kbps, min_kbps), timeout=5)