Ubuntu 20.04 fixes:
- fixes sshd test
- speeds up examples/{treeping64,tree1024}.py
- debugging hacks/output for testLinkChange
- removes cfs from examples/popen.py
- improves nat in nodelib (netplan fixes?)
- makes some tests executable
- waits for switches to connect in tests to
avoid race conditions
-- adds mn -w option and wait CLI command
Changes:
- REMOVES default "-v" argument for Controller()
and adds verbose(=False) option; avoiding logging
makes it faster
- CHANGES waitConnected to wait for 5 seconds
as documented; we may wish to implement an argument
to -w to set this timeout
Issues?
- There may still be an issue with the ovs-netplan-clean
service causing the boot to hang ;-(
64 lines
1.7 KiB
Python
Executable File
64 lines
1.7 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
"""
|
|
This example creates a multi-controller network from semi-scratch by
|
|
using the net.add*() API and manually starting the switches and controllers.
|
|
|
|
This is the "mid-level" API, which is an alternative to the "high-level"
|
|
Topo() API which supports parametrized topology classes.
|
|
|
|
Note that one could also create a custom switch class and pass it into
|
|
the Mininet() constructor.
|
|
"""
|
|
|
|
|
|
from mininet.net import Mininet
|
|
from mininet.node import Controller, OVSSwitch
|
|
from mininet.cli import CLI
|
|
from mininet.log import setLogLevel, info
|
|
|
|
def multiControllerNet():
|
|
"Create a network from semi-scratch with multiple controllers."
|
|
|
|
net = Mininet( controller=Controller, switch=OVSSwitch,
|
|
waitConnected=True )
|
|
|
|
info( "*** Creating (reference) controllers\n" )
|
|
c1 = net.addController( 'c1', port=6633 )
|
|
c2 = net.addController( 'c2', port=6634 )
|
|
|
|
info( "*** Creating switches\n" )
|
|
s1 = net.addSwitch( 's1' )
|
|
s2 = net.addSwitch( 's2' )
|
|
|
|
info( "*** Creating hosts\n" )
|
|
hosts1 = [ net.addHost( 'h%d' % n ) for n in ( 3, 4 ) ]
|
|
hosts2 = [ net.addHost( 'h%d' % n ) for n in ( 5, 6 ) ]
|
|
|
|
info( "*** Creating links\n" )
|
|
for h in hosts1:
|
|
net.addLink( s1, h )
|
|
for h in hosts2:
|
|
net.addLink( s2, h )
|
|
net.addLink( s1, s2 )
|
|
|
|
info( "*** Starting network\n" )
|
|
net.build()
|
|
c1.start()
|
|
c2.start()
|
|
s1.start( [ c1 ] )
|
|
s2.start( [ c2 ] )
|
|
|
|
info( "*** Testing network\n" )
|
|
net.pingAll()
|
|
|
|
info( "*** Running CLI\n" )
|
|
CLI( net )
|
|
|
|
info( "*** Stopping network\n" )
|
|
net.stop()
|
|
|
|
if __name__ == '__main__':
|
|
setLogLevel( 'info' ) # for CLI output
|
|
multiControllerNet()
|