diff --git a/ovsdbapp/schema/ovn_northbound/api.py b/ovsdbapp/schema/ovn_northbound/api.py index d51ce32e..90a9f290 100644 --- a/ovsdbapp/schema/ovn_northbound/api.py +++ b/ovsdbapp/schema/ovn_northbound/api.py @@ -609,6 +609,15 @@ class API(api.API, metaclass=abc.ABCMeta): :returns: :class:`Command` with RowView list result """ + @abc.abstractmethod + def lrp_get(self, port): + """Get logical router port for 'port' + + :param port: The name or uuid of the port + :type port: string or uuid.UUID + :returns: :class:`Command` with RowView result + """ + @abc.abstractmethod def lrp_set_enabled(self, port, is_enabled): """Set administrative state of 'port' diff --git a/ovsdbapp/schema/ovn_northbound/commands.py b/ovsdbapp/schema/ovn_northbound/commands.py index 38123497..f45d2132 100644 --- a/ovsdbapp/schema/ovn_northbound/commands.py +++ b/ovsdbapp/schema/ovn_northbound/commands.py @@ -897,6 +897,10 @@ class LrpListCommand(cmd.ReadOnlyCommand): self.result = [rowview.RowView(r) for r in router.ports] +class LrpGetCommand(cmd.BaseGetRowCommand): + table = 'Logical_Router_Port' + + class LrpSetEnabledCommand(cmd.BaseCommand): def __init__(self, api, port, is_enabled): super().__init__(api) diff --git a/ovsdbapp/schema/ovn_northbound/impl_idl.py b/ovsdbapp/schema/ovn_northbound/impl_idl.py index 67fd6b90..a1b4ef00 100644 --- a/ovsdbapp/schema/ovn_northbound/impl_idl.py +++ b/ovsdbapp/schema/ovn_northbound/impl_idl.py @@ -198,6 +198,9 @@ class OvnNbApiIdlImpl(ovs_idl.Backend, api.API): def lrp_list(self, router): return cmd.LrpListCommand(self, router) + def lrp_get(self, port): + return cmd.LrpGetCommand(self, port) + def lrp_set_enabled(self, port, is_enabled): return cmd.LrpSetEnabledCommand(self, port, is_enabled) 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 6e0ea800..e758a84d 100644 --- a/ovsdbapp/tests/functional/schema/ovn_northbound/test_impl_idl.py +++ b/ovsdbapp/tests/functional/schema/ovn_northbound/test_impl_idl.py @@ -1251,6 +1251,18 @@ class TestLogicalRouterPortOps(OvnNorthboundTest): self.assertEqual(set(networks), set(lrp.networks)) return lrp + def _test_lrp_get(self, col): + lrp = self._lrp_add(None) + val = getattr(lrp, col) + found = self.api.lrp_get(val).execute(check_error=True) + self.assertEqual(lrp, found) + + def test_lrp_get_uuid(self): + self._test_lrp_get('uuid') + + def test_lrp_get_name(self): + self._test_lrp_get('name') + def test_lrp_add(self): self._lrp_add(None, 'de:ad:be:ef:4d:ad', ['192.0.2.0/24']) diff --git a/releasenotes/notes/provide-lrp-get-method-a33a99a7f86b827e.yaml b/releasenotes/notes/provide-lrp-get-method-a33a99a7f86b827e.yaml new file mode 100644 index 00000000..9848d2ed --- /dev/null +++ b/releasenotes/notes/provide-lrp-get-method-a33a99a7f86b827e.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Added function and command to get one logical router port by name or uuid.