Girish Gowdra | 267e25e | 2022-08-20 20:03:58 -0700 | [diff] [blame^] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | # SPDX-FileCopyrightText: 2022-present Intel Corporation |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | |
| 6 | import argparse |
| 7 | |
| 8 | from mininet.cli import CLI |
| 9 | from mininet.log import setLogLevel |
| 10 | from mininet.net import Mininet |
| 11 | from mininet.topo import Topo |
| 12 | from stratum import StratumBmv2Switch |
| 13 | |
| 14 | from mn_lib import IPv4Host |
| 15 | from mn_lib import TaggedIPv4Host |
| 16 | |
| 17 | CPU_PORT = 255 |
| 18 | |
| 19 | |
| 20 | class TutorialTopo(Topo): |
| 21 | """Single leaf switch with two hosts attached""" |
| 22 | |
| 23 | def __init__(self, *args, **kwargs): |
| 24 | Topo.__init__(self, *args, **kwargs) |
| 25 | |
| 26 | # Leaves |
| 27 | # gRPC port 50001 |
| 28 | leaf1 = self.addSwitch('leaf1', cls=StratumBmv2Switch, cpuport=CPU_PORT) |
| 29 | |
| 30 | # IPv4 hosts attached to leaf 1 |
| 31 | h1a = self.addHost('h1a', cls=IPv4Host, mac="00:00:00:00:00:1A", |
| 32 | ip='172.16.1.1/24', gw='172.16.1.254') |
| 33 | h1b = self.addHost('h1b', cls=IPv4Host, mac="00:00:00:00:00:1B", |
| 34 | ip='172.16.1.2/24', gw='172.16.1.254') |
| 35 | self.addLink(h1a, leaf1) # port 1 |
| 36 | self.addLink(h1b, leaf1) # port 2 |
| 37 | |
| 38 | |
| 39 | def main(): |
| 40 | net = Mininet(topo=TutorialTopo(), controller=None) |
| 41 | net.start() |
| 42 | CLI(net) |
| 43 | net.stop() |
| 44 | |
| 45 | |
| 46 | if __name__ == "__main__": |
| 47 | parser = argparse.ArgumentParser( |
| 48 | description='Mininet topology script for single leaf having two hosts with stratum_bmv2') |
| 49 | args = parser.parse_args() |
| 50 | setLogLevel('info') |
| 51 | |
| 52 | main() |