Update and rename MantenerFIFO to MantenerFIFO.md
[vsorcdistro/.git] / mininet / examples / controllers.py
1 #!/usr/bin/python
2
3 """
4 Create a network where different switches are connected to
5 different controllers, by creating a custom Switch() subclass.
6 """
7
8 from mininet.net import Mininet
9 from mininet.node import OVSSwitch, Controller, RemoteController
10 from mininet.topolib import TreeTopo
11 from mininet.log import setLogLevel
12 from mininet.cli import CLI
13
14 setLogLevel( 'info' )
15
16 # Two local and one "external" controller (which is actually c0)
17 # Ignore the warning message that the remote isn't (yet) running
18 c0 = Controller( 'c0', port=6633 )
19 c1 = Controller( 'c1', port=6634 )
20 c2 = RemoteController( 'c2', ip='127.0.0.1', port=6633 )
21
22 cmap = { 's1': c0, 's2': c1, 's3': c2 }
23
24 class MultiSwitch( OVSSwitch ):
25     "Custom Switch() subclass that connects to different controllers"
26     def start( self, controllers ):
27         return OVSSwitch.start( self, [ cmap[ self.name ] ] )
28
29 topo = TreeTopo( depth=2, fanout=2 )
30 net = Mininet( topo=topo, switch=MultiSwitch, build=False )
31 for c in [ c0, c1 ]:
32     net.addController(c)
33 net.build()
34 net.start()
35 CLI( net )
36 net.stop()