summaryrefslogtreecommitdiff
path: root/tests/topotests/lib/bgp.py
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2024-12-03 08:42:24 -0500
committerGitHub <noreply@github.com>2024-12-03 08:42:24 -0500
commit6e1eeed50754c99c5593c01cb3983ece71b0549e (patch)
tree67c298a5b010a9b0720b0104afefc4425e6b551f /tests/topotests/lib/bgp.py
parentee5a3456d34a756c70ad8856ab7be7bed75ee31c (diff)
parentd1301f1c2a891704df8a2af56fbd4bbc7c08562b (diff)
Merge pull request #17306 from pguibert6WIND/bmp_test_factorise_plus_fix
BMP test rework
Diffstat (limited to 'tests/topotests/lib/bgp.py')
-rw-r--r--tests/topotests/lib/bgp.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/topotests/lib/bgp.py b/tests/topotests/lib/bgp.py
index bcd1c74812..329c2b54f5 100644
--- a/tests/topotests/lib/bgp.py
+++ b/tests/topotests/lib/bgp.py
@@ -5638,3 +5638,22 @@ def configure_bgp_soft_configuration(tgen, dut, neighbor_dict, direction):
)
)
return True
+
+
+def bgp_configure_prefixes(router, asn, safi, prefixes, vrf=None, update=True):
+ """
+ Configure the bgp prefixes.
+ """
+ withdraw = "no " if not update else ""
+ vrf = " vrf {}".format(vrf) if vrf else ""
+ for p in prefixes:
+ ip = ipaddress.ip_network(p)
+ cmd = [
+ "conf t\n",
+ f"router bgp {asn}{vrf}\n"
+ f"address-family ipv{ip.version} {safi}\n"
+ f"{withdraw}network {ip}\n".format(withdraw, ip),
+ "exit-address-family\n",
+ ]
+ logger.debug(f"setting prefix: ipv{ip.version} {safi} {ip}")
+ router.vtysh_cmd("".join(cmd))