blob: 7f8f82a059029769320e120161f3b738b5c64e72 [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
8if 'ONOS_ROOT' not in os.environ:
9 print "Environment var $ONOS_ROOT not set"
10 exit()
11else:
12 ONOS_ROOT = os.environ["ONOS_ROOT"]
13 sys.path.append(ONOS_ROOT + "/tools/dev/mininet")
14
15from mininet.topo import Topo
16from mininet.net import Mininet
17from mininet.cli import CLI
18from mininet.log import setLogLevel
19from mininet.node import Host, RemoteController
20from routinglib import RoutedHost
21from bmv2 import ONOSBmv2Switch
22
23PIPECONF_ID = 'org.onosproject.pipelines.fabric'
24
25class Trellis( Topo ):
26 "Trellis basic topology"
27
28 def __init__( self, *args, **kwargs ):
29 Topo.__init__( self, *args, **kwargs )
30
31 # Spines
32 s226 = self.addSwitch('s226', cls=ONOSBmv2Switch, deviceId='226', grpcPort=55226, pipeconfId=PIPECONF_ID, netcfgDelay=0.5)
33 s227 = self.addSwitch('s227', cls=ONOSBmv2Switch, deviceId='227', grpcPort=55227, pipeconfId=PIPECONF_ID, netcfgDelay=0.5)
34
35 # Leaves
36 s204 = self.addSwitch('s204', cls=ONOSBmv2Switch, deviceId='204', grpcPort=55204, pipeconfId=PIPECONF_ID, netcfgDelay=0.5)
37 s205 = self.addSwitch('s205', cls=ONOSBmv2Switch, deviceId='205', grpcPort=55205, pipeconfId=PIPECONF_ID, netcfgDelay=0.5)
38
39 # Switch Links
40 self.addLink(s226, s204)
41 self.addLink(s226, s205)
42 self.addLink(s227, s204)
43 self.addLink(s227, s205)
44
45 # NOTE avoid using 10.0.1.0/24 which is the default subnet of quaggas
46 # NOTE avoid using 00:00:00:00:00:xx which is the default mac of host behind upstream router
47 # IPv4 Hosts
48 h1 = self.addHost('h1', cls=RoutedHost, mac='00:aa:00:00:00:01', ips=['10.0.10.1/24'], gateway='10.0.10.254')
49 h2 = self.addHost('h2', cls=RoutedHost, mac='00:aa:00:00:00:02', ips=['10.0.10.2/24'], gateway='10.0.10.254')
50 h3 = self.addHost('h3', cls=RoutedHost, mac='00:aa:00:00:00:03', ips=['10.0.20.1/24'], gateway='10.0.20.254')
51 h4 = self.addHost('h4', cls=RoutedHost, mac='00:aa:00:00:00:04', ips=['10.0.20.2/24'], gateway='10.0.20.254')
52 self.addLink(h1, s204)
53 self.addLink(h2, s204)
54 self.addLink(h3, s205)
55 self.addLink(h4, s205)
56
57topos = { 'trellis' : Trellis }
58
59def main(args):
60 topo = Trellis()
61 controller = RemoteController('c0', ip=args.onos_ip)
62
63 net = Mininet(topo=topo, controller=None)
64 net.addController(controller)
65
66 net.start()
67 CLI(net)
68 net.stop()
69
70if __name__ == "__main__":
71 parser = argparse.ArgumentParser(
72 description='BMv2 mininet demo script (2 by 2 fabric)')
73 parser.add_argument('--onos-ip', help='ONOS-BMv2 controller IP address',
74 type=str, action="store", required=True)
75 args = parser.parse_args()
76 setLogLevel('debug')
77
78 main(args)