-#!/usr/bin/env python
+#!/usr/bin/env python2
+# SPDX-License-Identifier: ISC
#
# test_bgp_ecmp_topo1.py
# Copyright (c) 2017 by
# Network Device Education Foundation, Inc. ("NetDEF")
#
-# Permission to use, copy, modify, and/or distribute this software
-# for any purpose with or without fee is hereby granted, provided
-# that the above copyright notice and this permission notice appear
-# in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
-# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
-# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
-# OF THIS SOFTWARE.
-#
"""
test_bgp_ecmp_topo1.py: Test BGP topology with ECMP (Equal Cost MultiPath).
from lib.topolog import logger
# Required to instantiate the topology builder class.
-from mininet.topo import Topo
pytestmark = [pytest.mark.bgpd]
#####################################################
-class BGPECMPTopo1(Topo):
- "BGP ECMP Topology 1"
-
- def build(self, **_opts):
- tgen = get_topogen(self)
+def build_topo(tgen):
+ router = tgen.add_router("r1")
- # Create the BGP router
- router = tgen.add_router("r1")
+ # Setup Switches - 1 switch per 5 peering routers
+ for swNum in range(1, (total_ebgp_peers + 4) // 5 + 1):
+ switch = tgen.add_switch("s{}".format(swNum))
+ switch.add_link(router)
- # Setup Switches - 1 switch per 5 peering routers
- for swNum in range(1, (total_ebgp_peers + 4) / 5 + 1):
- switch = tgen.add_switch("s{}".format(swNum))
- switch.add_link(router)
+ # Add 'total_ebgp_peers' number of eBGP ExaBGP neighbors
+ for peerNum in range(1, total_ebgp_peers + 1):
+ swNum = (peerNum - 1) // 5 + 1
- # Add 'total_ebgp_peers' number of eBGP ExaBGP neighbors
- for peerNum in range(1, total_ebgp_peers + 1):
- swNum = (peerNum - 1) / 5 + 1
-
- peer_ip = "10.0.{}.{}".format(swNum, peerNum + 100)
- peer_route = "via 10.0.{}.1".format(swNum)
- peer = tgen.add_exabgp_peer(
- "peer{}".format(peerNum), ip=peer_ip, defaultRoute=peer_route
- )
+ peer_ip = "10.0.{}.{}".format(swNum, peerNum + 100)
+ peer_route = "via 10.0.{}.1".format(swNum)
+ peer = tgen.add_exabgp_peer(
+ "peer{}".format(peerNum), ip=peer_ip, defaultRoute=peer_route
+ )
- switch = tgen.gears["s{}".format(swNum)]
- switch.add_link(peer)
+ switch = tgen.gears["s{}".format(swNum)]
+ switch.add_link(peer)
#####################################################
def setup_module(module):
- tgen = Topogen(BGPECMPTopo1, module.__name__)
+ tgen = Topogen(build_topo, module.__name__)
tgen.start_topology()
# Starting Routers
def teardown_module(module):
+ del module
tgen = get_topogen()
tgen.stop_topology()
with 'json') and compare with `data` contents.
"""
output = router.vtysh_cmd(cmd, isjson=True)
- if "ipv4Unicast" in output:
- output["ipv4Unicast"]["vrfName"] = output["ipv4Unicast"]["vrfName"].replace(
- "default", "Default"
- )
- elif "vrfName" in output:
- output["vrfName"] = output["vrfName"].replace("default", "Default")
return topotest.json_cmp(output, data)
test_func = functools.partial(