Fix for adding multiple controllers and swtiches #676

Open
wants to merge 1 commit into
from

Projects

None yet

2 participants

@tnkteja
tnkteja commented Oct 4, 2016

For adding multiple controllers and switches with custom mapping, the implementation suggested in the examples is not straight forward. The implementation here is mapping the swithes to controllers in start.

@tnkteja tnkteja Fix for adding multiple controllers and swtiches
For adding multiple controllers and switches with custom mapping, the implementation suggested in the examples is not  straight forward. The implementation here is mapping the swithes to controllers in start.
2e40981
@lantz
Member
lantz commented Oct 6, 2016

Could you provide an example of how this API would be used?

@tnkteja
tnkteja commented Oct 6, 2016 edited
#!/usr/bin/python

"""
Create a network where different switches are connected to
different controllers, by creating a custom Switch() subclass.
"""

from mininet.net import Mininet
from mininet.node import OVSSwitch, Controller, RemoteController
from mininet.topolib import TreeTopo
from mininet.log import setLogLevel
from mininet.cli import CLI

setLogLevel( 'info' )

# Two local and one "external" controller (which is actually c0)
# Ignore the warning message that the remote isn't (yet) running
c0 = Controller( 'c0', port=6633 )
c1 = Controller( 'c1', port=6634 )
c2 = RemoteController( 'c2', ip='127.0.0.1', port=6633 )

cmap = { 's1': c0, 's2': c1, 's3': c2 }
topo = TreeTopo( depth=2, fanout=2 )
net = Mininet( topo=topo )

net.addSwitch("s1")
net.addSwitch("s2")
net.addSwitch("s3")

for c in [ c0, c1 ]:
    net.addController(c)
net.build()
net.start(cmap)
CLI( net )
net.stop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment