nb: provide lrp_get method
This change adds function and command to get only one logical router port by name or uuid. Closes-Bug: #1948947 Change-Id: I8395cc22d7143a53bb507876a62d923ea3874602
This commit is contained in:
parent
0e4c7a056c
commit
faea17101b
@ -547,6 +547,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'
|
||||
|
@ -815,6 +815,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)
|
||||
|
@ -180,6 +180,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)
|
||||
|
||||
|
@ -1136,6 +1136,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'])
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Added function and command to get one logical router port by name or uuid.
|
Loading…
Reference in New Issue
Block a user