Skip to content

Instantly share code, notes, and snippets.

@StephenKing
Last active September 29, 2015 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephenKing/a367fb2163ec7028a6c6 to your computer and use it in GitHub Desktop.
Save StephenKing/a367fb2163ec7028a6c6 to your computer and use it in GitHub Desktop.
ONOS Hackaton
#!/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.log import setLogLevel
from mininet.cli import CLI
def hackathonNet():
setLogLevel( 'info' )
# Ignore the warning message that the remote controllers are not (yet) running
c0 = RemoteController( 'c0', ip='192.168.100.1', port=6633 )
net = Mininet( switch=OVSSwitch )
print "*** Creating switches"
s1 = net.addSwitch( 's1' )
s2 = net.addSwitch( 's2' )
print "*** Creating hosts"
h1 = net.addHost( 'h1', mac="00:00:00:00:00:01" )
h2 = net.addHost( 'h2', mac="00:00:00:00:00:02" )
h3 = net.addHost( 'h3', mac="00:00:00:00:00:03" )
h4 = net.addHost( 'h4', mac="00:00:00:00:00:04" )
print "*** Creating links"
net.addLink( s1, s2 )
net.addLink( h1, s1 )
net.addLink( h2, s1 )
net.addLink( h3, s2 )
net.addLink( h4, s2 )
print "*** Starting network"
net.build()
s1.start( [ c0 ] )
s2.start( [ c0 ] )
print "*** Running CLI"
CLI( net )
print "*** Stopping network"
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' ) # for CLI output
hackathonNet()
s1 ovs-vsctl set port s1-eth2 qos=@hackqos -- --id=@hackqos create qos type=linux-htb other-config:max-rate=1000000 queues:10=@s1eth2queue -- --id=@s1eth2queue create queue other-config:max-rate=5000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment