]> git.proxmox.com Git - mirror_frr.git/blame - tests/topotests/bgp_l3vpn_to_bgp_direct/customize.py
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / tests / topotests / bgp_l3vpn_to_bgp_direct / customize.py
CommitLineData
db2dbd24 1#!/usr/bin/env python
acddc0ed 2# SPDX-License-Identifier: ISC
db2dbd24
LB
3
4#
5# Part of NetDEF Topology Tests
6#
7# Copyright (c) 2017 by
8# Network Device Education Foundation, Inc. ("NetDEF")
9#
db2dbd24 10
21b5cd1d 11r"""
622c4996 12customize.py: Simple FRR MPLS L3VPN test topology
db2dbd24
LB
13
14 |
15 +----+----+
16 | ce1 |
17 | 99.0.0.1| CE Router
18 +----+----+
19 192.168.1. | .2 ce1-eth0
20 | .1 r1-eth4
21 +---------+
22 | r1 |
23 | 1.1.1.1 | PE Router
24 +----+----+
25 | .1 r1-eth0
26 |
27 ~~~~~~~~~~~~~
28 ~~ sw0 ~~
29 ~~ 10.0.1.0/24 ~~
30 ~~~~~~~~~~~~~
31 |10.0.1.0/24
32 |
33 | .2 r2-eth0
34 +----+----+
35 | r2 |
36 | 2.2.2.2 | P router
37 +--+---+--+
38 r2-eth2 .2 | | .2 r2-eth1
39 ______/ \______
40 / \
41 ~~~~~~~~~~~~~ ~~~~~~~~~~~~~
42~~ sw2 ~~ ~~ sw1 ~~
43~~ 10.0.3.0/24 ~~ ~~ 10.0.2.0/24 ~~
44 ~~~~~~~~~~~~~ ~~~~~~~~~~~~~
45 | / |
46 \ _________/ |
47 \ / \
48r3-eth1 .3 | | .3 r3-eth0 | .4 r4-eth0
49 +----+--+---+ +----+----+
50 | r3 | | r4 |
51 | 3.3.3.3 | | 4.4.4.4 | PE Routers
52 +-----------+ +---------+
53 192.168.1. | .1 192.168.1. | .1 rX-eth4
54 | .2 | .2 ceX-eth0
55 +-----+-----+ +----+-----+
56 | ce2 | | ce3 |
57 | 99.0.0.2 | | 99.0.0.3 | CE Routers
58 +-----+-----+ +----+-----+
59 | |
60
61"""
62
63import os
db2dbd24
LB
64
65# pylint: disable=C0413
66# Import topogen and topotest helpers
4953ca97 67from lib.topogen import get_topogen
db2dbd24 68from lib.topolog import logger
a209417d 69from lib.ltemplate import ltemplateRtrCmd
db2dbd24
LB
70
71# Required to instantiate the topology builder class.
db2dbd24 72
787e7624 73
db2dbd24
LB
74CWD = os.path.dirname(os.path.realpath(__file__))
75# test name based on directory
76TEST = os.path.basename(CWD)
77
787e7624 78
e82b531d
CH
79def build_topo(tgen):
80 "Build function"
81
82 # This function only purpose is to define allocation and relationship
83 # between routers, switches and hosts.
84 #
85 # Create P/PE routers
86 tgen.add_router("r1")
87 # check for mpls
88 if tgen.hasmpls != True:
89 logger.info("MPLS not available, tests will be skipped")
90 return
91 for routern in range(2, 5):
92 tgen.add_router("r{}".format(routern))
93 # Create CE routers
94 for routern in range(1, 4):
95 tgen.add_router("ce{}".format(routern))
96
97 # CE/PE links
98 tgen.add_link(tgen.gears["ce1"], tgen.gears["r1"], "ce1-eth0", "r1-eth4")
99 tgen.add_link(tgen.gears["ce2"], tgen.gears["r3"], "ce2-eth0", "r3-eth4")
100 tgen.add_link(tgen.gears["ce3"], tgen.gears["r4"], "ce3-eth0", "r4-eth4")
101
102 # Create a switch with just one router connected to it to simulate a
103 # empty network.
104 switch = {}
105 switch[0] = tgen.add_switch("sw0")
106 switch[0].add_link(tgen.gears["r1"], nodeif="r1-eth0")
107 switch[0].add_link(tgen.gears["r2"], nodeif="r2-eth0")
108
109 switch[1] = tgen.add_switch("sw1")
110 switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth1")
111 switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth0")
112 switch[1].add_link(tgen.gears["r4"], nodeif="r4-eth0")
113
114 switch[1] = tgen.add_switch("sw2")
115 switch[1].add_link(tgen.gears["r2"], nodeif="r2-eth2")
116 switch[1].add_link(tgen.gears["r3"], nodeif="r3-eth1")
db2dbd24 117
db2dbd24 118
3eff4cc9 119def ltemplatePreRouterStartHook():
a209417d 120 cc = ltemplateRtrCmd()
c30e3e40 121 tgen = get_topogen()
787e7624 122 logger.info("pre router-start hook")
123 # check for mpls
d868d685 124 if tgen.hasmpls != True:
787e7624 125 logger.info("MPLS not available, skipping setup")
a209417d 126 return False
787e7624 127 logger.info("setup mpls input")
a209417d 128 return True
c30e3e40 129
787e7624 130
3eff4cc9 131def ltemplatePostRouterStartHook():
787e7624 132 logger.info("post router-start hook")
a209417d 133 return True