]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: Add lib changes to support bgp local asn feature 12026/head
authorKuldeep Kashyap <kashyapk@vmware.com>
Tue, 27 Sep 2022 03:27:02 +0000 (08:57 +0530)
committerKuldeep Kashyap <kashyapk@vmware.com>
Fri, 21 Oct 2022 03:53:03 +0000 (09:23 +0530)
Added lib changes to support bgp local
asn feature config changes

Signed-off-by: Kuldeep Kashyap <kashyapk@vmware.com>
tests/topotests/lib/bgp.py

index 7ab36c4fcdd39a6de5e3852603467c5c26b265a6..218f2dbe2b8f8963750edfc04854795c74ccd36f 100644 (file)
@@ -830,22 +830,36 @@ def __create_bgp_neighbor(topo, input_dict, router, addr_type, add_neigh=True):
     global_connect = input_dict.get("connecttimer", 5)
 
     for name, peer_dict in neigh_data.items():
+        remote_as = 0
         for dest_link, peer in peer_dict["dest_link"].items():
+            local_asn = peer.setdefault("local_asn", {})
+            if local_asn:
+                local_as = local_asn.setdefault("local_as", 0)
+                remote_as = local_asn.setdefault("remote_as", 0)
+                no_prepend = local_asn.setdefault("no_prepend", False)
+                replace_as = local_asn.setdefault("replace_as", False)
+                if local_as == remote_as:
+                    assert False is True, (
+                        " Configuration Error : Router must not have "
+                        "same AS-NUMBER as Local AS NUMBER"
+                    )
             nh_details = topo[name]
 
             if "vrfs" in topo[router] or type(nh_details["bgp"]) is list:
                 for vrf_data in nh_details["bgp"]:
                     if "vrf" in nh_details["links"][dest_link] and "vrf" in vrf_data:
                         if nh_details["links"][dest_link]["vrf"] == vrf_data["vrf"]:
-                            remote_as = vrf_data["local_as"]
+                            if not remote_as:
+                                remote_as = vrf_data["local_as"]
                             break
                     else:
                         if "vrf" not in vrf_data:
-                            remote_as = vrf_data["local_as"]
-                            break
-
+                            if not remote_as:
+                                remote_as = vrf_data["local_as"]
+                                break
             else:
-                remote_as = nh_details["bgp"]["local_as"]
+                if not remote_as:
+                    remote_as = nh_details["bgp"]["local_as"]
 
             update_source = None
 
@@ -890,6 +904,14 @@ def __create_bgp_neighbor(topo, input_dict, router, addr_type, add_neigh=True):
                 elif add_neigh:
                     config_data.append("{} remote-as {}".format(neigh_cxt, remote_as))
 
+                if local_asn and local_as:
+                    cmd = "{} local-as {}".format(neigh_cxt, local_as)
+                    if no_prepend:
+                        cmd = "{} no-prepend".format(cmd)
+                    if replace_as:
+                        cmd = "{} replace-as".format(cmd)
+                    config_data.append("{}".format(cmd))
+
             if addr_type == "ipv6":
                 config_data.append("address-family ipv6 unicast")
                 config_data.append("{} activate".format(neigh_cxt))