diff options
Diffstat (limited to 'tests/topotests/lib/bgp.py')
| -rw-r--r-- | tests/topotests/lib/bgp.py | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/tests/topotests/lib/bgp.py b/tests/topotests/lib/bgp.py index 7b1eead944..e2f887bb89 100644 --- a/tests/topotests/lib/bgp.py +++ b/tests/topotests/lib/bgp.py @@ -46,6 +46,7 @@ from lib.common_config import ( LOGDIR = "/tmp/topotests/" TMPDIR = None + def create_router_bgp(tgen, topo, input_dict=None, build=False, load_config=True): """ API to configure bgp on router @@ -455,6 +456,15 @@ def __create_bgp_unicast_neighbor( cmd = "no {}".format(cmd) config_data.append(cmd) + import_vrf_data = addr_data.setdefault("import", {}) + if import_vrf_data: + cmd = "import vrf {}".format(import_vrf_data["vrf"]) + + del_action = import_vrf_data.setdefault("delete", False) + if del_action: + cmd = "no {}".format(cmd) + config_data.append(cmd) + if "neighbor" in addr_data: neigh_data = __create_bgp_neighbor( topo, input_dict, router, addr_type, add_neigh @@ -1219,11 +1229,17 @@ def verify_bgp_convergence(tgen, topo, dut=None): no_of_peer += 1 if no_of_peer == total_peer: - logger.info("[DUT: %s] VRF: %s, BGP is Converged for %s address-family", - router, vrf, addr_type) + logger.info( + "[DUT: %s] VRF: %s, BGP is Converged for %s address-family", + router, + vrf, + addr_type, + ) else: - errormsg = ("[DUT: %s] VRF: %s, BGP is not converged for %s address-family" % - (router, vrf, addr_type)) + errormsg = ( + "[DUT: %s] VRF: %s, BGP is not converged for %s address-family" + % (router, vrf, addr_type) + ) return errormsg logger.debug("Exiting API: verify_bgp_convergence()") @@ -2553,10 +2569,19 @@ def verify_bgp_rib(tgen, addr_type, dut, input_dict, next_hop=None, aspath=None) missing_routes = [] st_found = False nh_found = False + vrf = static_route.setdefault("vrf", None) + community = static_route.setdefault("community", None) + largeCommunity = static_route.setdefault("largeCommunity", None) + if vrf: cmd = "{} vrf {} {}".format(command, vrf, addr_type) + if community: + cmd = "{} community {}".format(cmd, community) + + if largeCommunity: + cmd = "{} large-community {}".format(cmd, largeCommunity) else: cmd = "{} {}".format(command, addr_type) @@ -2594,6 +2619,7 @@ def verify_bgp_rib(tgen, addr_type, dut, input_dict, next_hop=None, aspath=None) if not isinstance(next_hop, list): next_hop = [next_hop] list1 = next_hop + found_hops = [ rib_r["ip"] for rib_r in rib_routes_json["routes"][st_rt][0][ @@ -2601,6 +2627,7 @@ def verify_bgp_rib(tgen, addr_type, dut, input_dict, next_hop=None, aspath=None) ] ] list2 = found_hops + missing_list_of_nexthops = set(list2).difference(list1) additional_nexthops_in_required_nhs = set( list1 |
