#!/usr/bin/env python
+# SPDX-License-Identifier: ISC
#
# test_ospf6_topo1_vrf.py
# Used Copyright (c) 2016 by Network Device Education Foundation,
# Inc. ("NetDEF") in this file.
#
-# 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.
-#
-"""
+r"""
test_ospf6_topo1_vrf.py:
-----\
import re
import sys
import pytest
-import platform
-from time import sleep
from functools import partial
-from mininet.topo import Topo
# Save the Current Working Directory to find configuration files later.
CWD = os.path.dirname(os.path.realpath(__file__))
from lib.topotest import iproute2_is_vrf_capable
from lib.common_config import required_linux_kernel_version
-pytestmark = [pytest.mark.ospfd]
-
-
-#####################################################
-##
-## Network Topology Definition
-##
-#####################################################
-
-class NetworkTopo(Topo):
- "OSPFv3 (IPv6) Test Topology 1"
+pytestmark = [pytest.mark.ospfd]
- def build(self, **_opts):
- "Build function"
- tgen = get_topogen(self)
+def build_topo(tgen):
+ "Build function"
- # Create 4 routers
- for routern in range(1, 5):
- tgen.add_router("r{}".format(routern))
+ # Create 4 routers
+ for routern in range(1, 5):
+ tgen.add_router("r{}".format(routern))
- #
- # Wire up the switches and routers
- # Note that we specify the link names so we match the config files
- #
+ #
+ # Wire up the switches and routers
+ # Note that we specify the link names so we match the config files
+ #
- # Create a empty network for router 1
- switch = tgen.add_switch("s1")
- switch.add_link(tgen.gears["r1"], nodeif="r1-stubnet")
+ # Create a empty network for router 1
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"], nodeif="r1-stubnet")
- # Create a empty network for router 2
- switch = tgen.add_switch("s2")
- switch.add_link(tgen.gears["r2"], nodeif="r2-stubnet")
+ # Create a empty network for router 2
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r2"], nodeif="r2-stubnet")
- # Create a empty network for router 3
- switch = tgen.add_switch("s3")
- switch.add_link(tgen.gears["r3"], nodeif="r3-stubnet")
+ # Create a empty network for router 3
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r3"], nodeif="r3-stubnet")
- # Create a empty network for router 4
- switch = tgen.add_switch("s4")
- switch.add_link(tgen.gears["r4"], nodeif="r4-stubnet")
+ # Create a empty network for router 4
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r4"], nodeif="r4-stubnet")
- # Interconnect routers 1, 2, and 3
- switch = tgen.add_switch("s5")
- switch.add_link(tgen.gears["r1"], nodeif="r1-sw5")
- switch.add_link(tgen.gears["r2"], nodeif="r2-sw5")
- switch.add_link(tgen.gears["r3"], nodeif="r3-sw5")
+ # Interconnect routers 1, 2, and 3
+ switch = tgen.add_switch("s5")
+ switch.add_link(tgen.gears["r1"], nodeif="r1-sw5")
+ switch.add_link(tgen.gears["r2"], nodeif="r2-sw5")
+ switch.add_link(tgen.gears["r3"], nodeif="r3-sw5")
- # Interconnect routers 3 and 4
- switch = tgen.add_switch("s6")
- switch.add_link(tgen.gears["r3"], nodeif="r3-sw6")
- switch.add_link(tgen.gears["r4"], nodeif="r4-sw6")
+ # Interconnect routers 3 and 4
+ switch = tgen.add_switch("s6")
+ switch.add_link(tgen.gears["r3"], nodeif="r3-sw6")
+ switch.add_link(tgen.gears["r4"], nodeif="r4-sw6")
#####################################################
if result is not True:
pytest.skip("Kernel requirements are not met")
- tgen = Topogen(NetworkTopo, mod.__name__)
+ tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology()
logger.info("** %s: Setup Topology" % mod.__name__)
# For debugging, uncomment the next line
# tgen.mininet_cli()
# Verify OSPFv3 Routing Table
- for router, rnode in tgen.routers().iteritems():
+ for router, rnode in tgen.routers().items():
logger.info('Waiting for router "%s" convergence', router)
# Load expected results from the command
r1.vtysh_cmd("clear ipv6 ospf interface r1-sw5")
# Verify OSPFv3 Routing Table
- for router, rnode in tgen.routers().iteritems():
+ for router, rnode in tgen.routers().items():
logger.info('Waiting for router "%s" convergence', router)
# Load expected results from the command