This is related to some attributes changes: aspath, med, localPref.
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
"prefix": "2001:db8:6::",
"prefixLen": 64,
"network": "2001:db8:6::\/64",
- "med": 0,
"metric": 0,
"weight": 0,
"peerId": "2001:db8:4::1",
"prefix": "2001:db8:7::",
"prefixLen": 64, "network":
"2001:db8:7::\/64",
- "med": 0,
"metric": 0,
"weight": 0,
"peerId": "2001:db8:4::1",
"prefix": "2001:db8:8::",
"prefixLen": 64,
"network": "2001:db8:8::\/64",
- "med": 0,
"metric": 0,
"weight": 32768,
"peerId": "(unspec)",
"prefix": "2001:db8:9::",
"prefixLen": 64,
"network": "2001:db8:9::\/64",
- "med": 0,
"metric": 0,
"weight": 32768,
"peerId": "(unspec)",
"prefix": "2001:db8:6::",
"prefixLen": 64,
"network": "2001:db8:6::\/64",
- "med": 0,
"metric": 0,
"weight": 32768,
"peerId": "(unspec)",
"prefix": "2001:db8:7::",
"prefixLen": 64,
"network": "2001:db8:7::\/64",
- "med": 0,
"metric": 0,
"weight": 32768,
"peerId": "(unspec)",
"routes": {
"10.254.254.2/32": [
{
- "aspath": "102",
+ "path": "102",
"prefix": "10.254.254.2",
"valid": true,
"peerId": "192.168.0.2",
],
"10.254.254.3/32": [
{
- "aspath": "102 103",
+ "path": "102 103",
"prefix": "10.254.254.3",
"valid": true,
"peerId": "192.168.0.2",
],
"10.254.254.4/32": [
{
- "aspath": "102 104",
+ "path": "102 104",
"prefix": "10.254.254.4",
"valid": true,
"peerId": "192.168.0.2",
"routes": {
"10.254.254.1/32": [
{
- "aspath": "101",
+ "path": "101",
"prefix": "10.254.254.1",
"valid": true,
"peerId": "192.168.0.1",
],
"10.254.254.3/32": [
{
- "aspath": "103",
+ "path": "103",
"prefix": "10.254.254.3",
"valid": true,
"peerId": "192.168.1.1",
],
"10.254.254.4/32": [
{
- "aspath": "104",
+ "path": "104",
"prefix": "10.254.254.4",
"valid": true,
"peerId": "192.168.2.1",
"routes": {
"10.254.254.1/32": [
{
- "aspath": "102 101",
+ "path": "102 101",
"prefix": "10.254.254.1",
"valid": true,
"peerId": "192.168.1.2",
],
"10.254.254.2/32": [
{
- "aspath": "102",
+ "path": "102",
"prefix": "10.254.254.2",
"valid": true,
"peerId": "192.168.1.2",
],
"10.254.254.4/32": [
{
- "aspath": "102 104",
+ "path": "102 104",
"prefix": "10.254.254.4",
"valid": true,
"peerId": "192.168.1.2",
"routes": {
"10.254.254.1/32": [
{
- "aspath": "102 101",
+ "path": "102 101",
"prefix": "10.254.254.1",
"valid": true,
"peerId": "192.168.2.2",
],
"10.254.254.2/32": [
{
- "aspath": "102",
+ "path": "102",
"prefix": "10.254.254.2",
"valid": true,
"peerId": "192.168.2.2",
],
"10.254.254.3/32": [
{
- "aspath": "102 103",
+ "path": "102 103",
"prefix": "10.254.254.3",
"valid": true,
"peerId": "192.168.2.2",
"routes": {
"10.254.254.2/32": [
{
- "aspath": "102",
+ "path": "102",
"prefix": "10.254.254.2",
"valid": true,
"peerId": "192.168.0.2",
],
"10.254.254.3/32": [
{
- "aspath": "102 103",
+ "path": "102 103",
"prefix": "10.254.254.3",
"valid": true,
"peerId": "192.168.0.2",
],
"10.254.254.4/32": [
{
- "aspath": "102 104",
+ "path": "102 104",
"prefix": "10.254.254.4",
"valid": true,
"peerId": "192.168.0.2",
"routes": {
"10.254.254.1/32": [
{
- "aspath": "101",
+ "path": "101",
"prefix": "10.254.254.1",
"valid": true,
"peerId": "192.168.0.1",
],
"10.254.254.3/32": [
{
- "aspath": "103",
+ "path": "103",
"prefix": "10.254.254.3",
"valid": true,
"peerId": "192.168.1.1",
],
"10.254.254.4/32": [
{
- "aspath": "104",
+ "path": "104",
"prefix": "10.254.254.4",
"valid": true,
"peerId": "192.168.2.1",
"routes": {
"10.254.254.1/32": [
{
- "aspath": "102 101",
+ "path": "102 101",
"prefix": "10.254.254.1",
"valid": true,
"peerId": "192.168.1.2",
],
"10.254.254.2/32": [
{
- "aspath": "102",
+ "path": "102",
"prefix": "10.254.254.2",
"valid": true,
"peerId": "192.168.1.2",
],
"10.254.254.4/32": [
{
- "aspath": "102 104",
+ "path": "102 104",
"prefix": "10.254.254.4",
"valid": true,
"peerId": "192.168.1.2",
"routes": {
"10.254.254.1/32": [
{
- "aspath": "102 101",
+ "path": "102 101",
"prefix": "10.254.254.1",
"valid": true,
"peerId": "192.168.2.2",
],
"10.254.254.2/32": [
{
- "aspath": "102",
+ "path": "102",
"prefix": "10.254.254.2",
"valid": true,
"peerId": "192.168.2.2",
],
"10.254.254.3/32": [
{
- "aspath": "102 103",
+ "path": "102 103",
"prefix": "10.254.254.3",
"valid": true,
"peerId": "192.168.2.2",
# Verifying best path
dut = "r1"
- attribute = "aspath"
+ attribute = "path"
for addr_type in ADDR_TYPES:
result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut,
{"r7": input_dict["r7"]},
}
},
"set": {
- "aspath": {
+ "path": {
"as_num": "111 222",
"as_action": "prepend"
}
}
},
"set": {
- "aspath": {
+ "path": {
"as_num": "111 222",
"as_action": "prepend"
}
# Verifying best path
dut = "r1"
- attribute = "aspath"
+ attribute = "path"
for addr_type in ADDR_TYPES:
result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut,
{"r7": input_dict["r7"]},
}
},
"set": {
- "localpref": 1111
+ "locPrf": 1111
}
},
{
}
},
"set": {
- "localpref": 1111
+ "locPrf": 1111
}
}]
}
# Verifying best path
dut = "r1"
- attribute = "localpref"
+ attribute = "locPrf"
for addr_type in ADDR_TYPES:
result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut,
{"r7": input_dict["r7"]},
}
},
"set": {
- "localpref": 50
+ "locPrf": 50
}
},
{
}
},
"set": {
- "localpref": 50
+ "locPrf": 50
}
}]
}
# Verifying best path
dut = "r1"
- attribute = "localpref"
+ attribute = "locPrf"
for addr_type in ADDR_TYPES:
result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut,
{"r7": input_dict["r7"]},
}
},
"set": {
- "med": 100
+ "metric": 100
}
},
{
}
},
"set": {
- "med": 100
+ "metric": 100
}
}]
}
}
},
"set": {
- "med": 10
+ "metric": 10
}
},
{
}
},
"set": {
- "med": 10
+ "metric": 10
}
}]
}
# Verifying best path
dut = "r1"
- attribute = "med"
+ attribute = "metric"
for addr_type in ADDR_TYPES:
result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut,
input_dict, attribute)
}
},
"set": {
- "med": 200
+ "metric": 200
}
},
{
}
},
"set": {
- "med": 200
+ "metric": 200
}
}]
}
# Verifying best path
dut = "r1"
- attribute = "med"
+ attribute = "metric"
for addr_type in ADDR_TYPES:
result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut,
input_dict, attribute)
}
},
"set": {
- "aspath": {
+ "path": {
"as_num": 500
}
}
}
},
"set": {
- "localpref": 150,
+ "locPrf": 150,
}
},
{
}
},
"set": {
- "med": 50
+ "metric": 50
}
}
]
"route_maps": {
"rmap_match_pf_list1": [{
"set": {
- "med": 50,
+ "metric": 50,
}
}],
}
{
"action": "permit",
"set": {
- "med": 50,
- "localpref": 150,
+ "metric": 50,
+ "locPrf": 150,
"weight": 4000
}
}
{
"action": "permit",
"set": {
- "med": 50,
+ "metric": 50,
}
}
]
"rmap_match_pf_1_{}".format(addr_type): [{
"action": "permit",
"set": {
- "med": 50,
- "localpref": 150,
+ "metric": 50,
+ "locPrf": 150,
}
}
]
}
},
"set": {
- "localpref": 150,
+ "locPrf": 150,
"weight": 100
}
},
}
},
"set": {
- "med": 50
+ "metric": 50
}
},
]
}
},
"set": {
- "localpref": 150,
+ "locPrf": 150,
}
}],
"rmap_match_pf_2_{}".format(addr_type): [{
}
},
"set": {
- "med": 50
+ "metric": 50
}
}]
}
}
},
"set": {
- "localpref": 1000,
+ "locPrf": 1000,
}
}],
"rmap_match_pf_2_{}".format(addr_type): [{
}
},
"set": {
- "med": 2000
+ "metric": 2000
}
}]
}
}
},
"set": {
- "localpref": 150,
+ "locPrf": 150,
"weight": 100
}
}],
}
},
"set": {
- "med": 50
+ "metric": 50
}
}]
}
}
},
"set": {
- "localpref": 150,
+ "locPrf": 150,
}
}],
"rmap_match_pf_2_{}".format(addr_type): [{
}
},
"set": {
- "med": 50
+ "metric": 50
}
}]
}
}
},
"set": {
- "localpref": 150
+ "locPrf": 150
}
}]
}
}
},
"set": {
- "localpref": 200
+ "locPrf": 200
}
}]
}
}
},
"set": {
- "localpref": 150,
+ "locPrf": 150,
}
}]
}
}
},
"set": {
- "localpref": 150,
+ "locPrf": 150,
}
}]
}
}
},
"set": {
- "localpref": 150,
+ "locPrf": 150,
}
}]
}
}
},
"set": {
- "localpref": 150,
+ "locPrf": 150,
"weight": 100
}
}]
}
},
"set": {
- "med": 50
+ "metric": 50
}
}],
"rmap_match_pf_2_{}".format(addr_type): [{
addr_type)
}},
"set": {
- "localpref": 150
+ "locPrf": 150
}
}],
"rmap_match_pf_3_{}".format(addr_type): [{
}
},
"set": {
- "localpref": 150,
+ "locPrf": 150,
"weight": 100,
- "med": 50
+ "metric": 50
}
}]
}
}
},
"set": {
- "localpref": 150
+ "locPrf": 150
},
"continue": "30"
},
}
},
"set": {
- "med": 200
+ "metric": 200
}
},
{
}
},
"set": {
- "med": 100
+ "metric": 100
}
}
]
}
},
"set": {
- "med": 100
+ "metric": 100
}
},
{
}
},
"set": {
- "med": 200
+ "metric": 200
}
}
]
}
},
"set": {
- "localpref": 150
+ "locPrf": 150
},
"call": "rmap_match_pf_2_{}".format(addr_type)
}],
}
},
"set": {
- "med": 200
+ "metric": 200
}
}]
}
}
},
"set": {
- "localpref": 150,
+ "locPrf": 150,
}
}],
"rmap_match_pf_2_{}".format(addr_type): [{
}
},
"set": {
- "med": 50
+ "metric": 50
}
}]
}
expected = {
'paths': [
{
- 'med': 123
+ 'metric': 123
}
]
}
expected = {
'paths': [
{
- 'med': 123
+ 'metric': 123
}
]
}
"community_list": {"id": "ANY"}
},
"set": {
- "aspath": {
+ "path": {
"as_num": "4000000",
"as_action": "prepend"
}
expected = {
'advertisedRoutes': {
'172.16.0.0/16': {
- 'asPath': ''
+ 'path': ''
},
'192.168.254.0/30': {
- 'asPath': '65003'
+ 'path': '65003'
},
'192.168.255.0/30': {
- 'asPath': '65001'
+ 'path': '65001'
}
},
'totalPrefixCounter': 3
expected = {
'paths': [
{
- 'localpref': 50,
+ 'locPrf': 50,
'nexthops': [
{
'ip': '192.168.255.3'
]
},
{
- 'localpref': 150,
+ 'locPrf': 150,
'nexthops': [
{
'ip': '192.168.255.2'
}
},
"set": {
- "localpref": 150,
+ "locPrf": 150,
"weight": 100
}
}],
}
},
"set": {
- "med": 50
+ "metric": 50
}
}]
}
}
}
}
- attribute = "localpref"
+ attribute = "locPrf"
result = verify_best_path_as_per_bgp_attribute(tgen, "ipv4", dut, \
input_dict, attribute)
Returns
attribute_dict[next_hop_ip] = route_attribute[attribute]
# AS_PATH attribute
- if attribute == "aspath":
+ if attribute == "path":
# Find next_hop for the route have minimum as_path
_next_hop = min(attribute_dict, key=lambda x: len(set(
attribute_dict[x])))
compare = "SHORTEST"
# LOCAL_PREF attribute
- elif attribute == "localpref":
+ elif attribute == "locPrf":
# Find next_hop for the route have highest local preference
_next_hop = max(attribute_dict, key=(lambda k:
attribute_dict[k]))
compare = ""
# MED attribute
- elif attribute == "med":
+ elif attribute == "metric":
# Find next_hop for the route have LOWEST MED
_next_hop = min(attribute_dict, key=(lambda k:
attribute_dict[k]))
{"network": "200.50.2.0/32", \
"admin_distance": 60, "next_hop": "10.0.0.18"}]
}}
- attribute = "localpref"
+ attribute = "locPrf"
result = verify_best_path_as_per_admin_distance(tgen, "ipv4", dut, \
input_dict, attribute):
Returns
"tag": "tag_id"
},
"set": {
- "localpref": 150,
- "med": 30,
- "aspath": {
+ "locPrf": 150,
+ "metric": 30,
+ "path": {
"num": 20000,
"action": "prepend",
},
set_data = rmap_dict["set"]
ipv4_data = set_data.setdefault("ipv4", {})
ipv6_data = set_data.setdefault("ipv6", {})
- local_preference = set_data.setdefault("localpref",
+ local_preference = set_data.setdefault("locPrf",
None)
- metric = set_data.setdefault("med", None)
- as_path = set_data.setdefault("aspath", {})
+ metric = set_data.setdefault("metric", None)
+ as_path = set_data.setdefault("path", {})
weight = set_data.setdefault("weight", None)
community = set_data.setdefault("community", {})
large_community = set_data.setdefault(