Merge "Add bfd parameter for lr_route_add"

This commit is contained in:
Zuul 2025-01-10 09:57:18 +00:00 committed by Gerrit Code Review
commit 1430077902
4 changed files with 18 additions and 4 deletions

View File

@ -746,7 +746,7 @@ class API(api.API, metaclass=abc.ABCMeta):
@abc.abstractmethod
def lr_route_add(self, router, prefix, nexthop, port=None,
policy='dst-ip', may_exist=False, ecmp=False,
route_table=const.MAIN_ROUTE_TABLE):
route_table=const.MAIN_ROUTE_TABLE, bfd=None):
"""Add a route to 'router'
:param router: The name or uuid of the router
@ -771,6 +771,8 @@ class API(api.API, metaclass=abc.ABCMeta):
:type ecmp: boolean
:param route_table: The name of route table
:type route_table: str
:param bfd: A reference to the BFD table row.
:type bfd: uuid.UUID
returns: :class:`Command` with RowView result
"""

View File

@ -1256,7 +1256,7 @@ class LspDetachMirror(cmd.BaseCommand):
class LrRouteAddCommand(cmd.BaseCommand):
def __init__(self, api, router, prefix, nexthop, port=None,
policy='dst-ip', may_exist=False, ecmp=False,
route_table=const.MAIN_ROUTE_TABLE):
route_table=const.MAIN_ROUTE_TABLE, bfd=None):
prefix = str(netaddr.IPNetwork(prefix))
if nexthop != const.ROUTE_DISCARD:
nexthop = str(netaddr.IPAddress(nexthop))
@ -1268,6 +1268,7 @@ class LrRouteAddCommand(cmd.BaseCommand):
self.policy = policy
self.ecmp = ecmp
self.route_table = route_table
self.bfd = bfd
self.may_exist = may_exist
def run_idl(self, txn):
@ -1297,6 +1298,8 @@ class LrRouteAddCommand(cmd.BaseCommand):
route.route_table = self.route_table
if self.port:
route.output_port = self.port
if self.bfd:
route.bfd = self.bfd
lr.addvalue('static_routes', route)
self.result = route.uuid

View File

@ -242,9 +242,9 @@ class OvnNbApiIdlImpl(ovs_idl.Backend, api.API):
def lr_route_add(self, router, prefix, nexthop, port=None,
policy='dst-ip', may_exist=False, ecmp=False,
route_table=const.MAIN_ROUTE_TABLE):
route_table=const.MAIN_ROUTE_TABLE, bfd=None):
return cmd.LrRouteAddCommand(self, router, prefix, nexthop, port,
policy, may_exist, ecmp, route_table)
policy, may_exist, ecmp, route_table, bfd)
def lr_route_del(self, router, prefix=None, if_exists=False, nexthop=None,
route_table=const.MAIN_ROUTE_TABLE):

View File

@ -1079,6 +1079,15 @@ class TestLogicalRouterOps(OvnNorthboundTest):
self.assertNotEqual(learned_route.uuid, route.uuid)
self.assertNotIn("ic-learned-route", route.external_ids)
def test_lr_route_add_with_bfd(self):
router_name = utils.get_rand_device_name()
data = utils.get_rand_name()
bfd = self.api.bfd_add(data, data).execute(check_error=True)
route = self._lr_add_route(router_name, bfd=bfd.uuid)
self.assertEqual(bfd, route.bfd[0])
def test_lr_route_del(self):
prefix = "192.0.2.0/25"
route = self._lr_add_route(prefix=prefix)