From 6fdacf85288df9be5964e61798e48bd325eeaada Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Tue, 21 Dec 2021 22:16:46 +0000 Subject: [PATCH] Use "api.lookup" to search for a "Logical_Switch" "api.lookup" will search for a "Logical_Switch" using the UUID and the "lookup_table". For "Logical_Switch", the name could be used too. Trivial-Fix Change-Id: Ib38080e65321148460b5c9b9b9b193b266a2baaf --- ovsdbapp/schema/ovn_northbound/commands.py | 3 +-- .../functional/schema/ovn_northbound/test_impl_idl.py | 11 +++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ovsdbapp/schema/ovn_northbound/commands.py b/ovsdbapp/schema/ovn_northbound/commands.py index f45d2132..a5bb1d46 100644 --- a/ovsdbapp/schema/ovn_northbound/commands.py +++ b/ovsdbapp/schema/ovn_northbound/commands.py @@ -410,8 +410,7 @@ class QoSDelExtIdCommand(cmd.BaseCommand): def run_idl(self, txn): try: - lswitch = idlutils.row_by_value(self.api.idl, 'Logical_Switch', - 'name', self.lswitch) + lswitch = self.api.lookup('Logical_Switch', self.lswitch) except idlutils.RowNotFound as e: if self.if_exists: return 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 e758a84d..af16a6cb 100644 --- a/ovsdbapp/tests/functional/schema/ovn_northbound/test_impl_idl.py +++ b/ovsdbapp/tests/functional/schema/ovn_northbound/test_impl_idl.py @@ -350,7 +350,7 @@ class TestQoSOps(OvnNorthboundTest): def setUp(self): super(TestQoSOps, self).setUp() self.switch = self.useFixture( - fixtures.LogicalSwitchFixture(self.api)).obj + fixtures.LogicalSwitchFixture(self.api, name='LS_for_QoS')).obj def _qos_add(self, *args, **kwargs): cmd = self.api.qos_add(self.switch.uuid, *args, **kwargs) @@ -464,6 +464,9 @@ class TestQoSOps(OvnNorthboundTest): dscp=10) def test_qos_delete_external_ids(self): + # NOTE(ralonsoh): the deletion method uses the LS name (first) and the + # UUID (second), in order to check that api.lookup() is working with + # both. self._create_fip_qoses() self.api.qos_del_ext_ids(self.switch.name, {'key1': 'value1'}).execute(check_error=True) @@ -472,7 +475,7 @@ class TestQoSOps(OvnNorthboundTest): self.assertCountEqual([self.qos_2, self.qos_3], qos_rules) self.api.qos_del_ext_ids( - self.switch.name, + self.switch.uuid, {'key3': 'value3', 'key4': 'value4'}).execute(check_error=True) qos_rules = self.api.qos_list( self.switch.uuid).execute(check_error=True) @@ -486,14 +489,14 @@ class TestQoSOps(OvnNorthboundTest): self.switch.uuid).execute(check_error=True) self.assertCountEqual([self.qos_1, self.qos_2, self.qos_3], qos_rules) - self.api.qos_del_ext_ids(self.switch.name, + self.api.qos_del_ext_ids(self.switch.uuid, {'key1': 'value_z'}).execute(check_error=True) qos_rules = self.api.qos_list( self.switch.uuid).execute(check_error=True) self.assertCountEqual([self.qos_1, self.qos_2, self.qos_3], qos_rules) self.api.qos_del_ext_ids( - self.switch.name, + self.switch.uuid, {'key3': 'value3', 'key4': 'value_z'}).execute(check_error=True) qos_rules = self.api.qos_list( self.switch.uuid).execute(check_error=True)