blob: 1adae81f8b4c1914b42f5fd11d23945b4c82696f [file] [log] [blame]
Yi Tsengc4671422017-11-01 18:22:53 -07001#!/usr/bin/python
2
3import os
4import sys
5import argparse
6sys.path.append('..')
7
Yi Tsengc4671422017-11-01 18:22:53 -07008from mininet.topo import Topo
9from mininet.net import Mininet
10from mininet.cli import CLI
11from mininet.log import setLogLevel
12from mininet.node import Host, RemoteController
13from routinglib import RoutedHost
Yi Tseng37c843d2018-05-26 00:55:12 +080014from trellislib import TaggedRoutedHost
Yi Tsengc4671422017-11-01 18:22:53 -070015from bmv2 import ONOSBmv2Switch
16
17PIPECONF_ID = 'org.onosproject.pipelines.fabric'
18
19class Trellis( Topo ):
20 "Trellis basic topology"
21
22 def __init__( self, *args, **kwargs ):
23 Topo.__init__( self, *args, **kwargs )
24
25 # Spines
Yi Tseng915dff52018-04-12 17:08:43 +000026 s226 = self.addSwitch('s226', cls=ONOSBmv2Switch, grpcport=55226, pipeconf=PIPECONF_ID, portcfg=True)
27 s227 = self.addSwitch('s227', cls=ONOSBmv2Switch, grpcport=55227, pipeconf=PIPECONF_ID, portcfg=True)
Yi Tsengc4671422017-11-01 18:22:53 -070028
29 # Leaves
Yi Tseng915dff52018-04-12 17:08:43 +000030 s204 = self.addSwitch('s204', cls=ONOSBmv2Switch, grpcport=55204, pipeconf=PIPECONF_ID, portcfg=True)
31 s205 = self.addSwitch('s205', cls=ONOSBmv2Switch, grpcport=55205, pipeconf=PIPECONF_ID, portcfg=True)
Yi Tsengc4671422017-11-01 18:22:53 -070032
33 # Switch Links
34 self.addLink(s226, s204)
35 self.addLink(s226, s205)
36 self.addLink(s227, s204)
37 self.addLink(s227, s205)
38
39 # NOTE avoid using 10.0.1.0/24 which is the default subnet of quaggas
40 # NOTE avoid using 00:00:00:00:00:xx which is the default mac of host behind upstream router
41 # IPv4 Hosts
Yi Tseng73555a52018-02-12 15:58:02 -080042 h1 = self.addHost('h1', cls=RoutedHost, mac='00:aa:00:00:00:01', ips=['10.0.2.1/24'], gateway='10.0.2.254')
Yi Tseng37c843d2018-05-26 00:55:12 +080043 h2 = self.addHost('h2', cls=TaggedRoutedHost, mac='00:aa:00:00:00:02', ips=['10.0.2.2/24'], gateway='10.0.2.254', vlan=10)
Yi Tseng73555a52018-02-12 15:58:02 -080044 h3 = self.addHost('h3', cls=RoutedHost, mac='00:aa:00:00:00:03', ips=['10.0.3.1/24'], gateway='10.0.3.254')
Yi Tseng37c843d2018-05-26 00:55:12 +080045 h4 = self.addHost('h4', cls=TaggedRoutedHost, mac='00:aa:00:00:00:04', ips=['10.0.3.2/24'], gateway='10.0.3.254', vlan=20)
Yi Tsengc4671422017-11-01 18:22:53 -070046 self.addLink(h1, s204)
47 self.addLink(h2, s204)
48 self.addLink(h3, s205)
49 self.addLink(h4, s205)
50
51topos = { 'trellis' : Trellis }
52
53def main(args):
54 topo = Trellis()
55 controller = RemoteController('c0', ip=args.onos_ip)
56
57 net = Mininet(topo=topo, controller=None)
58 net.addController(controller)
59
60 net.start()
61 CLI(net)
62 net.stop()
63
64if __name__ == "__main__":
65 parser = argparse.ArgumentParser(
66 description='BMv2 mininet demo script (2 by 2 fabric)')
67 parser.add_argument('--onos-ip', help='ONOS-BMv2 controller IP address',
68 type=str, action="store", required=True)
69 args = parser.parse_args()
70 setLogLevel('debug')
71
72 main(args)