This helps with virtualenv although it can open up another security hole if you end up using an unexpected python interpreter. Overall it seems to make sense to err on the side of usability but it's good to be aware of security. However, for the remaining utility scripts that require python 2, we explicitly note this with #!/usr/bin/python2.
46 lines
985 B
Python
Executable File
46 lines
985 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
"""
|
|
This example shows how to create an empty Mininet object
|
|
(without a topology object) and add nodes to it manually.
|
|
"""
|
|
|
|
from mininet.net import Mininet
|
|
from mininet.node import Controller
|
|
from mininet.cli import CLI
|
|
from mininet.log import setLogLevel, info
|
|
|
|
def emptyNet():
|
|
|
|
"Create an empty network and add nodes to it."
|
|
|
|
net = Mininet( controller=Controller, waitConnected=True )
|
|
|
|
info( '*** Adding controller\n' )
|
|
net.addController( 'c0' )
|
|
|
|
info( '*** Adding hosts\n' )
|
|
h1 = net.addHost( 'h1', ip='10.0.0.1' )
|
|
h2 = net.addHost( 'h2', ip='10.0.0.2' )
|
|
|
|
info( '*** Adding switch\n' )
|
|
s3 = net.addSwitch( 's3' )
|
|
|
|
info( '*** Creating links\n' )
|
|
net.addLink( h1, s3 )
|
|
net.addLink( h2, s3 )
|
|
|
|
info( '*** Starting network\n')
|
|
net.start()
|
|
|
|
info( '*** Running CLI\n' )
|
|
CLI( net )
|
|
|
|
info( '*** Stopping network' )
|
|
net.stop()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
setLogLevel( 'info' )
|
|
emptyNet()
|