mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-09 13:18:52 +00:00
tests: [topojson]Enhance lib/topojson.py to support PIM automation
1. Enhanced lib/topojson.py for creating topologies with switches and routers 2. Ran it through (black) for expected formatting Signed-off-by: kuldeepkash <kashyapk@vmware.com>
This commit is contained in:
parent
aafca66993
commit
e58fdb55d6
@ -43,6 +43,7 @@ from lib.common_config import (
|
|||||||
create_vrf_cfg,
|
create_vrf_cfg,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from lib.pim import create_pim_config, create_igmp_config
|
||||||
from lib.bgp import create_router_bgp
|
from lib.bgp import create_router_bgp
|
||||||
from lib.ospf import create_router_ospf
|
from lib.ospf import create_router_ospf
|
||||||
|
|
||||||
@ -68,20 +69,18 @@ def build_topo_from_json(tgen, topo):
|
|||||||
topo["switches"].keys(), key=lambda x: int(re_search("\d+", x).group(0))
|
topo["switches"].keys(), key=lambda x: int(re_search("\d+", x).group(0))
|
||||||
)
|
)
|
||||||
|
|
||||||
listRouters = ROUTER_LIST[:]
|
listRouters = sorted(ROUTER_LIST[:])
|
||||||
listSwitches = SWITCH_LIST[:]
|
listSwitches = sorted(SWITCH_LIST[:])
|
||||||
listAllRouters = deepcopy(listRouters)
|
listAllRouters = deepcopy(listRouters)
|
||||||
dictSwitches = {}
|
dictSwitches = {}
|
||||||
|
|
||||||
for routerN in ROUTER_LIST:
|
for routerN in ROUTER_LIST:
|
||||||
logger.info("Topo: Add router {}".format(routerN))
|
logger.info("Topo: Add router {}".format(routerN))
|
||||||
tgen.add_router(routerN)
|
tgen.add_router(routerN)
|
||||||
listRouters.append(routerN)
|
|
||||||
|
|
||||||
for switchN in SWITCH_LIST:
|
for switchN in SWITCH_LIST:
|
||||||
logger.info("Topo: Add switch {}".format(switchN))
|
logger.info("Topo: Add switch {}".format(switchN))
|
||||||
dictSwitches[switchN] = tgen.add_switch(switchN)
|
dictSwitches[switchN] = tgen.add_switch(switchN)
|
||||||
listSwitches.append(switchN)
|
|
||||||
|
|
||||||
if "ipv4base" in topo:
|
if "ipv4base" in topo:
|
||||||
ipv4Next = ipaddress.IPv4Address(topo["link_ip_start"]["ipv4"])
|
ipv4Next = ipaddress.IPv4Address(topo["link_ip_start"]["ipv4"])
|
||||||
@ -101,18 +100,8 @@ def build_topo_from_json(tgen, topo):
|
|||||||
curRouter = listRouters.pop(0)
|
curRouter = listRouters.pop(0)
|
||||||
# Physical Interfaces
|
# Physical Interfaces
|
||||||
if "links" in topo["routers"][curRouter]:
|
if "links" in topo["routers"][curRouter]:
|
||||||
|
|
||||||
def link_sort(x):
|
|
||||||
if x == "lo":
|
|
||||||
return 0
|
|
||||||
elif "link" in x:
|
|
||||||
return int(x.split("-link")[1])
|
|
||||||
else:
|
|
||||||
return int(re_search("\d+", x).group(0))
|
|
||||||
|
|
||||||
for destRouterLink, data in sorted(
|
for destRouterLink, data in sorted(
|
||||||
topo["routers"][curRouter]["links"].items(),
|
topo["routers"][curRouter]["links"].iteritems()
|
||||||
key=lambda x: link_sort(x[0]),
|
|
||||||
):
|
):
|
||||||
currRouter_lo_json = topo["routers"][curRouter]["links"][destRouterLink]
|
currRouter_lo_json = topo["routers"][curRouter]["links"][destRouterLink]
|
||||||
# Loopback interfaces
|
# Loopback interfaces
|
||||||
@ -321,6 +310,8 @@ def build_config_from_json(tgen, topo, save_bkup=True):
|
|||||||
("prefix_lists", create_prefix_lists),
|
("prefix_lists", create_prefix_lists),
|
||||||
("bgp_community_list", create_bgp_community_lists),
|
("bgp_community_list", create_bgp_community_lists),
|
||||||
("route_maps", create_route_maps),
|
("route_maps", create_route_maps),
|
||||||
|
("pim", create_pim_config),
|
||||||
|
("igmp", create_igmp_config),
|
||||||
("bgp", create_router_bgp),
|
("bgp", create_router_bgp),
|
||||||
("ospf", create_router_ospf),
|
("ospf", create_router_ospf),
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user