Skip to content

Instantly share code, notes, and snippets.

@pichuang
Last active August 29, 2015 14:23
Show Gist options
  • Save pichuang/3c9fb9265464c4de0564 to your computer and use it in GitHub Desktop.
Save pichuang/3c9fb9265464c4de0564 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from mininet.examples.cluster import MininetCluster, SwitchBinPlacer
from mininet.topolib import TreeTopo
from mininet.topo import LinearTopo
from mininet.log import setLogLevel, info
from mininet.examples.clustercli import ClusterCLI as CLI
from mininet.net import Mininet
from mininet.node import Controller, RemoteController
from mininet.util import dumpNodeConnections
REMOTE_CONTROLLER_A_IP="192.168.59.100"
REMOTE_CONTROLLER_B_IP="192.168.59.101"
def demo():
# AAAA
net_a = Mininet (topo=None, build=False)
controller_a = net_a.addController(name='controller0',
controller=RemoteController,
ip=REMOTE_CONTROLLER_A_IP,
port=6633)
info("Create Host node\n")
host1 = net_a.addHost('h1', ip='10.0.0.1')
host2 = net_a.addHost('h2', ip='10.0.0.2')
info("Create Switch\n")
switch1 = net_a.addSwitch('ovs1')
switch2 = net_a.addSwitch('ovs2')
info("Link switch\n")
net_a.addLink(switch1, host1)
net_a.addLink(switch2, host2)
net_a.addLink(switch1, switch2)
# BBBBB
net_b = Mininet (topo=None, build=False)
controller_b = net_b.addController(name='controller1',
controller=RemoteController,
ip=REMOTE_CONTROLLER_B_IP,
port=6633)
info("Create Host node\n")
host3 = net_b.addHost('h3', ip='10.0.0.3')
host4 = net_b.addHost('h4', ip='10.0.0.4')
info("Create Switch\n")
switch3 = net_b.addSwitch('ovs3')
switch4 = net_b.addSwitch('ovs4')
info("Link switch\n")
net_b.addLink(switch3, host3)
net_b.addLink(switch4, host4)
net_b.addLink(switch3, switch4)
info("Connect two domain between net_a and net_b")
net_a.addLink(switch1, switch3)
net_a.start()
dumpNodeConnections(net_a.hosts)
net_a.pingAll()
net_b.start()
dumpNodeConnections(net_b.hosts)
net_b.pingAll()
net_a.stop()
net_b.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
demo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment