]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_rfapi_basic_sanity/customize.py
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tests / topotests / bgp_rfapi_basic_sanity / customize.py
1 #!/usr/bin/env python
2 # SPDX-License-Identifier: ISC
3
4 #
5 # Part of NetDEF Topology Tests
6 #
7 # Copyright (c) 2017-2018 by
8 # Network Device Education Foundation, Inc. ("NetDEF")
9 # Modified by LabN Consulting, L.L.C.
10 #
11
12 r"""
13 customize.py: Simple FRR MPLS L3VPN test topology
14
15 +---------+
16 | r1 |
17 | 1.1.1.1 | PE Router
18 +----+----+
19 | .1 r1-eth0
20 |
21 ~~~~~~~~~~~~~
22 ~~ sw0 ~~
23 ~~ 10.0.1.0/24 ~~
24 ~~~~~~~~~~~~~
25 |10.0.1.0/24
26 |
27 | .2 r2-eth0
28 +----+----+
29 | r2 |
30 | 2.2.2.2 | P router
31 +--+---+--+
32 r2-eth2 .2 | | .2 r2-eth1
33 ______/ \______
34 / \
35 ~~~~~~~~~~~~~ ~~~~~~~~~~~~~
36 ~~ sw2 ~~ ~~ sw1 ~~
37 ~~ 10.0.3.0/24 ~~ ~~ 10.0.2.0/24 ~~
38 ~~~~~~~~~~~~~ ~~~~~~~~~~~~~
39 | / |
40 \ _________/ |
41 \ / \
42 r3-eth1 .3 | | .3 r3-eth0 | .4 r4-eth0
43 +----+--+---+ +----+----+
44 | r3 | | r4 |
45 | 3.3.3.3 | | 4.4.4.4 | PE Routers
46 +-----------+ +---------+
47
48 """
49
50 import os
51
52 # pylint: disable=C0413
53 # Import topogen and topotest helpers
54 from lib.topogen import get_topogen
55 from lib.topolog import logger
56 from lib.ltemplate import ltemplateRtrCmd
57
58 # Required to instantiate the topology builder class.
59
60
61 CWD = os.path.dirname(os.path.realpath(__file__))
62 # test name based on directory
63 TEST = os.path.basename(CWD)
64
65
66 def build_topo(tgen):
67 "Build function"
68
69 # This function only purpose is to define allocation and relationship
70 # between routers, switches and hosts.
71 #
72 # Create P/PE routers
73 tgen.add_router("r1")
74 for routern in range(2, 5):
75 tgen.add_router("r{}".format(routern))
76 # Create a switch with just one router connected to it to simulate a
77 # empty network.
78 switch = {}
79 switch[0] = tgen.add_switch("sw0")
80 switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
81 switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
82
83 switch[1] = tgen.add_switch("sw1")
84 switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
85 switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
86 switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
87
88 switch[2] = tgen.add_switch("sw2")
89 switch[2].add_link(tgen.gears["r2"], nodeif="r2-eth2")
90 switch[2].add_link(tgen.gears["r3"], nodeif="r3-eth1")
91
92
93 def ltemplatePreRouterStartHook():
94 cc = ltemplateRtrCmd()
95 tgen = get_topogen()
96 logger.info("pre router-start hook")
97 return True
98
99
100 def ltemplatePostRouterStartHook():
101 logger.info("post router-start hook")
102 return True