Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 31b1093d86 | |||
| ea48a0e6e8 | |||
| ae8c12c471 | |||
| a30d2fb42d | |||
| 2c0f29d361 | |||
| aacd47136c | |||
| 38a4c3309c | |||
| c8aff1dab0 | |||
| 71bdfd37bd | |||
| b558055c3e | |||
| 2554a2d02d | |||
| b21782d121 | |||
| 5e216acca4 | |||
| fe923b2a18 | |||
| 66ccff9275 | |||
| 89ec246bd2 | |||
| ac4a673e6f | |||
| d2d27043a8 | |||
| 023a6169a8 | |||
| 6fdf8dcf2b | |||
| dbba9dc711 | |||
| 305651c006 | |||
| c359825be9 | |||
| f86fe7f9d2 | |||
| befde4825b | |||
| dc9399b308 | |||
| 095e4e299a | |||
| b1d84855cc | |||
| 7476c5e051 | |||
| a8a9e7d2eb |
@@ -1,19 +0,0 @@
|
||||
Mininet uses GitHub issues for bug reports and feature requests only.
|
||||
These issues can be viewed at bugs.mininet.org
|
||||
|
||||
If you have a question that is not a bug report or a feature request,
|
||||
please use the documentation at docs.mininet.org, the FAQ
|
||||
at faq.mininet.org, and the mininet-discuss mailing list.
|
||||
|
||||
For bug reports, please fill in the following information in detail,
|
||||
and also feel free to include additional information such as debug
|
||||
output from mn -v debug, etc.
|
||||
--- Cut Here ---
|
||||
### Expected/Desired Behavior:
|
||||
|
||||
### Actual Behavior:
|
||||
|
||||
### Detailed Steps to Reproduce the Behavior:
|
||||
|
||||
### Additional Information:
|
||||
|
||||
@@ -44,9 +44,7 @@ load-plugins=
|
||||
disable=pointless-except, invalid-name, super-init-not-called, fixme, star-args,
|
||||
too-many-instance-attributes, too-few-public-methods, too-many-arguments,
|
||||
too-many-locals, too-many-public-methods, duplicate-code, bad-whitespace,
|
||||
locally-disabled, locally-enabled
|
||||
|
||||
# bad-continuation, wrong-import-order
|
||||
locally-disabled
|
||||
|
||||
[REPORTS]
|
||||
|
||||
@@ -63,7 +61,7 @@ include-ids=yes
|
||||
# written in a file name "pylint_global.[txt|html]".
|
||||
files-output=no
|
||||
|
||||
# Tells whether to display a full report or only the messages
|
||||
# Tells wether to display a full report or only the messages
|
||||
reports=no
|
||||
|
||||
# Python expression which should return a note less than 10 (10 is the highes
|
||||
@@ -113,10 +111,10 @@ const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
|
||||
class-rgx=[A-Z_][a-zA-Z0-9]+$
|
||||
|
||||
# Regular expression which should only match correct function names
|
||||
function-rgx=[a-z_][a-z0-9]{2,30}$
|
||||
function-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression which should only match correct method names
|
||||
method-rgx=[a-z_][a-z0-9]{2,30}$
|
||||
method-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression which should only match correct instance attribute names
|
||||
attr-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
@@ -125,7 +123,7 @@ attr-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
argument-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression which should only match correct variable names
|
||||
variable-rgx=[a-z_][a-z0-9]{2,30}$
|
||||
variable-rgx=[a-z_][a-z0-9_]{2,30}$
|
||||
|
||||
# Regular expression which should only match correct list comprehension /
|
||||
# generator expression variable names
|
||||
|
||||
+3
-10
@@ -1,19 +1,12 @@
|
||||
language: python
|
||||
sudo: required
|
||||
|
||||
python:
|
||||
- "2.7
|
||||
- "3.6"
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- dist: trusty
|
||||
env: dist="14.04 LTS trusty"
|
||||
# - dist: xenial
|
||||
# env: dist="16.04 LTS xenial"
|
||||
# Travis-CI only proposes 14.04 LTS Trusty and there is no plan to update to 16.04 xenial
|
||||
# (c.f. https://github.com/travis-ci/travis-ci/issues/5821)
|
||||
# It is useless to add a second job because it will run in the same Ubuntu version (14.04)
|
||||
- dist: xenial
|
||||
env: dist="16.04 LTS xenial"
|
||||
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
@@ -21,7 +14,7 @@ before_install:
|
||||
- sudo util/install.sh -n
|
||||
|
||||
install:
|
||||
- bash -c "if [ `lsb_release -rs` == '14.04' ]; then make codecheck; fi"
|
||||
- bash -c "[ `lsb_release -rs` == '14.04' ] && make codecheck"
|
||||
- sudo util/install.sh -fnvw
|
||||
|
||||
script:
|
||||
|
||||
@@ -18,6 +18,7 @@ Cody Burkard
|
||||
|
||||
Additional Mininet Contributors
|
||||
|
||||
M S Vishwanath Bhat
|
||||
Tomasz Buchert
|
||||
Gustavo Pantuza Coelho Pinto
|
||||
Fernando Cappi
|
||||
@@ -29,6 +30,7 @@ Andrew Ferguson
|
||||
Eder Leao Fernandes
|
||||
Gregory Gee
|
||||
Jon Hall
|
||||
Jono Hart
|
||||
Roan Huang
|
||||
Vitaly Ivanov
|
||||
Babis Kaidos
|
||||
@@ -39,10 +41,12 @@ David Mahler
|
||||
Murphy McCauley
|
||||
José Pedro Oliveira
|
||||
James Page
|
||||
Rahman Pujianto
|
||||
Angad Singh
|
||||
Piyush Srivastava
|
||||
Ed Swierk
|
||||
Darshan Thaker
|
||||
Olivier Tilmans
|
||||
Andreas Wundsam
|
||||
Isaku Yamahata
|
||||
Baohua Yang
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Mininet Installation/Configuration Notes
|
||||
----------------------------------------
|
||||
|
||||
Mininet 2.3.0d1
|
||||
Mininet 2.2.2
|
||||
---
|
||||
|
||||
The supported installation methods for Mininet are 1) using a
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Mininet 2.3.0d1 License
|
||||
Mininet 2.2.2 License
|
||||
|
||||
Copyright (c) 2013-2018 Open Networking Laboratory
|
||||
Copyright (c) 2013-2017 Open Networking Laboratory
|
||||
Copyright (c) 2009-2012 Bob Lantz and The Board of Trustees of
|
||||
The Leland Stanford Junior University
|
||||
|
||||
|
||||
@@ -2,16 +2,14 @@ MININET = mininet/*.py
|
||||
TEST = mininet/test/*.py
|
||||
EXAMPLES = mininet/examples/*.py
|
||||
MN = bin/mn
|
||||
PYTHON ?= python
|
||||
PYMN = $(PYTHON) -B bin/mn
|
||||
PYMN = python -B bin/mn
|
||||
BIN = $(MN)
|
||||
PYSRC = $(MININET) $(TEST) $(EXAMPLES) $(BIN)
|
||||
MNEXEC = mnexec
|
||||
MANPAGES = mn.1 mnexec.1
|
||||
P8IGN = E251,E201,E302,E202,E126,E127,E203,E226
|
||||
PREFIX ?= /usr
|
||||
BINDIR ?= $(PREFIX)/bin
|
||||
MANDIR ?= $(PREFIX)/share/man/man1
|
||||
BINDIR = /usr/bin
|
||||
MANDIR = /usr/share/man/man1
|
||||
DOCDIRS = doc/html doc/latex
|
||||
PDF = doc/latex/refman.pdf
|
||||
|
||||
@@ -48,20 +46,16 @@ slowtest: $(MININET)
|
||||
mnexec: mnexec.c $(MN) mininet/net.py
|
||||
cc $(CFLAGS) $(LDFLAGS) -DVERSION=\"`PYTHONPATH=. $(PYMN) --version`\" $< -o $@
|
||||
|
||||
install-mnexec: $(MNEXEC)
|
||||
install -D $(MNEXEC) $(BINDIR)/$(MNEXEC)
|
||||
|
||||
install-manpages: $(MANPAGES)
|
||||
install -D -t $(MANDIR) $(MANPAGES)
|
||||
|
||||
install: install-mnexec install-manpages
|
||||
$(PYTHON) setup.py install
|
||||
install: $(MNEXEC) $(MANPAGES)
|
||||
install $(MNEXEC) $(BINDIR)
|
||||
install $(MANPAGES) $(MANDIR)
|
||||
python setup.py install
|
||||
|
||||
develop: $(MNEXEC) $(MANPAGES)
|
||||
# Perhaps we should link these as well
|
||||
install $(MNEXEC) $(BINDIR)
|
||||
install $(MANPAGES) $(MANDIR)
|
||||
$(PYTHON) setup.py develop
|
||||
python setup.py develop
|
||||
|
||||
man: $(MANPAGES)
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
Mininet: Rapid Prototyping for Software Defined Networks
|
||||
========================================================
|
||||
|
||||
*The best way to emulate almost any network on your laptop!*
|
||||
|
||||
Mininet 2.3.0d1
|
||||
Mininet 2.2.2
|
||||
|
||||
[![Build Status][1]](https://travis-ci.org/mininet/mininet)
|
||||
|
||||
@@ -126,7 +127,7 @@ hard work that Mininet continues to grow and improve.
|
||||
Best wishes, and we look forward to seeing what you can do with
|
||||
Mininet to change the networking world!
|
||||
|
||||
Bob Lantz
|
||||
Bob Lantz
|
||||
Mininet Core Team
|
||||
|
||||
[1]: https://travis-ci.org/mininet/mininet.svg?branch=master
|
||||
[1]: https://travis-ci.org/mininet/mininet.svg?branch=devel/2.2.2
|
||||
|
||||
@@ -21,8 +21,8 @@ if 'PYTHONPATH' in os.environ:
|
||||
sys.path = os.environ[ 'PYTHONPATH' ].split( ':' ) + sys.path
|
||||
|
||||
from mininet.clean import cleanup
|
||||
import mininet.cli
|
||||
from mininet.log import lg, LEVELS, info, debug, warn, error, output
|
||||
from mininet.cli import CLI
|
||||
from mininet.log import lg, LEVELS, info, debug, warn, error
|
||||
from mininet.net import Mininet, MininetWithControlNet, VERSION
|
||||
from mininet.node import ( Host, CPULimitedHost, Controller, OVSController,
|
||||
Ryu, NOX, RemoteController, findController,
|
||||
@@ -87,51 +87,16 @@ LINKS = { 'default': Link, # Note: overridden below
|
||||
'tcu': TCULink,
|
||||
'ovs': OVSLink }
|
||||
|
||||
# TESTS dict can contain functions and/or Mininet() method names
|
||||
# XXX: it would be nice if we could specify a default test, but
|
||||
# this may be tricky
|
||||
TESTS = { name: True
|
||||
for name in ( 'pingall', 'pingpair', 'iperf', 'iperfudp' ) }
|
||||
|
||||
CLI = None # Set below if needed
|
||||
# Names of tests that are Mininet() methods
|
||||
TESTNAMES = [ 'cli', 'build', 'pingall', 'pingpair', 'iperf', 'all',
|
||||
'iperfudp', 'none' ]
|
||||
|
||||
# Locally defined tests
|
||||
def allTest( net ):
|
||||
"Run ping and iperf tests"
|
||||
net.waitConnected()
|
||||
net.start()
|
||||
net.ping()
|
||||
net.iperf()
|
||||
|
||||
def nullTest( _net ):
|
||||
"Null 'test' (does nothing)"
|
||||
pass
|
||||
|
||||
TESTS.update( all=allTest, none=nullTest, build=nullTest )
|
||||
|
||||
# Map to alternate spellings of Mininet() methods
|
||||
ALTSPELLING = { 'pingall': 'pingAll', 'pingpair': 'pingPair',
|
||||
'iperfudp': 'iperfUdp' }
|
||||
|
||||
def runTests( mn, options ):
|
||||
"""Run tests
|
||||
mn: Mininet object
|
||||
option: list of test optinos """
|
||||
# Split option into test name and parameters
|
||||
for option in options:
|
||||
# Multiple tests may be separated by '+' for now
|
||||
for test in option.split( '+' ):
|
||||
test, args, kwargs = splitArgs( test )
|
||||
test = ALTSPELLING.get( test.lower(), test )
|
||||
testfn = TESTS.get( test, test )
|
||||
if callable( testfn ):
|
||||
testfn( mn, *args, **kwargs )
|
||||
elif hasattr( mn, test ):
|
||||
mn.waitConnected()
|
||||
getattr( mn, test )( *args, **kwargs )
|
||||
else:
|
||||
raise Exception( 'Test %s is unknown - please specify one of '
|
||||
'%s ' % ( test, TESTS.keys() ) )
|
||||
# Map to alternate functions and/or spellings of Mininet() methods
|
||||
TESTS = { 'pingall': 'pingAll',
|
||||
'pingpair': 'pingPair',
|
||||
'iperfudp': 'iperfUdp',
|
||||
'iperfUDP': 'iperfUdp' }
|
||||
|
||||
|
||||
def addDictOption( opts, choicesDict, default, name, **kwargs ):
|
||||
@@ -152,7 +117,7 @@ def addDictOption( opts, choicesDict, default, name, **kwargs ):
|
||||
|
||||
def version( *_args ):
|
||||
"Print Mininet version and exit"
|
||||
output( "%s\n" % VERSION )
|
||||
print "%s" % VERSION
|
||||
exit()
|
||||
|
||||
|
||||
@@ -186,10 +151,8 @@ class MininetRunner( object ):
|
||||
for fileName in files:
|
||||
customs = {}
|
||||
if os.path.isfile( fileName ):
|
||||
# pylint: disable=exec-used
|
||||
exec( compile( open( fileName ).read(), fileName, 'exec' ),
|
||||
customs, customs )
|
||||
for name, val in customs.items():
|
||||
execfile( fileName, customs, customs )
|
||||
for name, val in customs.iteritems():
|
||||
self.setCustom( name, val )
|
||||
else:
|
||||
raise Exception( 'could not find custom file: %s' % fileName )
|
||||
@@ -247,8 +210,9 @@ class MininetRunner( object ):
|
||||
type='string',
|
||||
help='read custom classes or params from .py file(s)'
|
||||
)
|
||||
testList = TESTNAMES + TESTS.keys()
|
||||
opts.add_option( '--test', default=[], action='append',
|
||||
dest='test', help='|'.join( TESTS.keys() ) )
|
||||
dest='tests', help='|'.join( testList ) )
|
||||
opts.add_option( '--xterms', '-x', action='store_true',
|
||||
default=False, help='spawn xterms for each node' )
|
||||
opts.add_option( '--ipbase', '-i', type='string', default='10.0.0.0/8',
|
||||
@@ -258,7 +222,7 @@ class MininetRunner( object ):
|
||||
opts.add_option( '--arp', action='store_true',
|
||||
default=False, help='set all-pairs ARP entries' )
|
||||
opts.add_option( '--verbosity', '-v', type='choice',
|
||||
choices=list( LEVELS.keys() ), default = 'info',
|
||||
choices=LEVELS.keys(), default = 'info',
|
||||
help = '|'.join( LEVELS.keys() ) )
|
||||
opts.add_option( '--innamespace', action='store_true',
|
||||
default=False, help='sw and ctrl in namespace?' )
|
||||
@@ -288,7 +252,7 @@ class MininetRunner( object ):
|
||||
metavar='server1,server2...',
|
||||
help=( 'run on multiple servers (experimental!)' ) )
|
||||
opts.add_option( '--placement', type='choice',
|
||||
choices=list( PLACEMENT.keys() ), default='block',
|
||||
choices=PLACEMENT.keys(), default='block',
|
||||
metavar='block|random',
|
||||
help=( 'node placement for --cluster '
|
||||
'(experimental!) ' ) )
|
||||
@@ -305,106 +269,124 @@ class MininetRunner( object ):
|
||||
|
||||
# set logging verbosity
|
||||
if LEVELS[self.options.verbosity] > LEVELS['output']:
|
||||
warn( '*** WARNING: selected verbosity level (%s) will hide CLI '
|
||||
print ( '*** WARNING: selected verbosity level (%s) will hide CLI '
|
||||
'output!\n'
|
||||
'Please restart Mininet with -v [debug, info, output].\n'
|
||||
'Please restart Mininet with -v [debug, info, output].'
|
||||
% self.options.verbosity )
|
||||
lg.setLogLevel( self.options.verbosity )
|
||||
|
||||
# Maybe we'll reorganize this someday...
|
||||
# pylint: disable=too-many-branches,too-many-statements,global-statement
|
||||
# pylint: disable=too-many-branches,too-many-statements
|
||||
|
||||
def begin( self ):
|
||||
"Create and run mininet."
|
||||
|
||||
global CLI
|
||||
|
||||
opts = self.options
|
||||
|
||||
if opts.cluster:
|
||||
servers = opts.cluster.split( ',' )
|
||||
if self.options.cluster:
|
||||
servers = self.options.cluster.split( ',' )
|
||||
for server in servers:
|
||||
ClusterCleanup.add( server )
|
||||
|
||||
if opts.clean:
|
||||
if self.options.clean:
|
||||
cleanup()
|
||||
exit()
|
||||
|
||||
start = time.time()
|
||||
|
||||
if not opts.controller:
|
||||
if not self.options.controller:
|
||||
# Update default based on available controllers
|
||||
CONTROLLERS[ 'default' ] = findController()
|
||||
opts.controller = [ 'default' ]
|
||||
self.options.controller = [ 'default' ]
|
||||
if not CONTROLLERS[ 'default' ]:
|
||||
opts.controller = [ 'none' ]
|
||||
if opts.switch == 'default':
|
||||
self.options.controller = [ 'none' ]
|
||||
if self.options.switch == 'default':
|
||||
info( '*** No default OpenFlow controller found '
|
||||
'for default switch!\n' )
|
||||
info( '*** Falling back to OVS Bridge\n' )
|
||||
opts.switch = 'ovsbr'
|
||||
elif opts.switch not in ( 'ovsbr', 'lxbr' ):
|
||||
self.options.switch = 'ovsbr'
|
||||
elif self.options.switch not in ( 'ovsbr', 'lxbr' ):
|
||||
raise Exception( "Could not find a default controller "
|
||||
"for switch %s" %
|
||||
opts.switch )
|
||||
self.options.switch )
|
||||
|
||||
topo = buildTopo( TOPOS, opts.topo )
|
||||
switch = customClass( SWITCHES, opts.switch )
|
||||
host = customClass( HOSTS, opts.host )
|
||||
topo = buildTopo( TOPOS, self.options.topo )
|
||||
switch = customClass( SWITCHES, self.options.switch )
|
||||
host = customClass( HOSTS, self.options.host )
|
||||
controller = [ customClass( CONTROLLERS, c )
|
||||
for c in opts.controller ]
|
||||
|
||||
if opts.switch == 'user' and opts.link == 'default':
|
||||
for c in self.options.controller ]
|
||||
if self.options.switch == 'user' and self.options.link == 'default':
|
||||
debug( '*** Using TCULink with UserSwitch\n' )
|
||||
# Use link configured correctly for UserSwitch
|
||||
opts.link = 'tcu'
|
||||
|
||||
link = customClass( LINKS, opts.link )
|
||||
self.options.link = 'tcu'
|
||||
link = customClass( LINKS, self.options.link )
|
||||
|
||||
if self.validate:
|
||||
self.validate( opts )
|
||||
self.validate( self.options )
|
||||
|
||||
if opts.nolistenport:
|
||||
opts.listenport = None
|
||||
ipBase = self.options.ipbase
|
||||
xterms = self.options.xterms
|
||||
mac = self.options.mac
|
||||
arp = self.options.arp
|
||||
pin = self.options.pin
|
||||
listenPort = None
|
||||
if not self.options.nolistenport:
|
||||
listenPort = self.options.listenport
|
||||
|
||||
# Handle innamespace, cluster options
|
||||
if opts.innamespace and opts.cluster:
|
||||
error( "Please specify --innamespace OR --cluster\n" )
|
||||
# Handle inNamespace, cluster options
|
||||
inNamespace = self.options.innamespace
|
||||
cluster = self.options.cluster
|
||||
if inNamespace and cluster:
|
||||
print "Please specify --innamespace OR --cluster"
|
||||
exit()
|
||||
Net = MininetWithControlNet if opts.innamespace else Mininet
|
||||
if opts.cluster:
|
||||
Net = MininetWithControlNet if inNamespace else Mininet
|
||||
cli = ClusterCLI if cluster else CLI
|
||||
if cluster:
|
||||
warn( '*** WARNING: Experimental cluster mode!\n'
|
||||
'*** Using RemoteHost, RemoteOVSSwitch, RemoteLink\n' )
|
||||
host, switch, link = RemoteHost, RemoteOVSSwitch, RemoteLink
|
||||
Net = partial( MininetCluster, servers=servers,
|
||||
placement=PLACEMENT[ opts.placement ] )
|
||||
mininet.cli.CLI = ClusterCLI
|
||||
placement=PLACEMENT[ self.options.placement ] )
|
||||
|
||||
mn = Net( topo=topo,
|
||||
switch=switch, host=host, controller=controller, link=link,
|
||||
ipBase=opts.ipbase, inNamespace=opts.innamespace,
|
||||
xterms=opts.xterms, autoSetMacs=opts.mac,
|
||||
autoStaticArp=opts.arp, autoPinCpus=opts.pin,
|
||||
listenPort=opts.listenport )
|
||||
switch=switch, host=host, controller=controller,
|
||||
link=link,
|
||||
ipBase=ipBase,
|
||||
inNamespace=inNamespace,
|
||||
xterms=xterms, autoSetMacs=mac,
|
||||
autoStaticArp=arp, autoPinCpus=pin,
|
||||
listenPort=listenPort )
|
||||
|
||||
if opts.ensure_value( 'nat', False ):
|
||||
mn.addNAT( *opts.nat_args, **opts.nat_kwargs ).configDefault()
|
||||
if self.options.ensure_value( 'nat', False ):
|
||||
nat = mn.addNAT( *self.options.nat_args,
|
||||
**self.options.nat_kwargs )
|
||||
nat.configDefault()
|
||||
|
||||
# --custom files can set CLI or change mininet.cli.CLI
|
||||
CLI = mininet.cli.CLI if CLI is None else CLI
|
||||
|
||||
if opts.pre:
|
||||
CLI( mn, script=opts.pre )
|
||||
if self.options.pre:
|
||||
cli( mn, script=self.options.pre )
|
||||
|
||||
mn.start()
|
||||
|
||||
if opts.test:
|
||||
runTests( mn, opts.test )
|
||||
else:
|
||||
CLI( mn )
|
||||
if not self.options.tests:
|
||||
cli( mn )
|
||||
|
||||
if opts.post:
|
||||
CLI( mn, script=opts.post )
|
||||
for test in self.options.tests:
|
||||
test = TESTS.get( test, test )
|
||||
if callable( test ): # user added TESTMAP={'mytest': testfn}
|
||||
test( mn )
|
||||
elif test == 'none':
|
||||
pass
|
||||
elif test == 'all':
|
||||
mn.waitConnected()
|
||||
mn.start()
|
||||
mn.ping()
|
||||
mn.iperf()
|
||||
elif test == 'cli':
|
||||
cli( mn )
|
||||
elif test != 'build':
|
||||
mn.waitConnected()
|
||||
getattr( mn, test )()
|
||||
|
||||
if self.options.post:
|
||||
cli( mn, script=self.options.post )
|
||||
|
||||
mn.stop()
|
||||
|
||||
|
||||
+9
-12
@@ -3,35 +3,32 @@
|
||||
"This example doesn't use OpenFlow, but attempts to run sshd in a namespace."
|
||||
|
||||
import sys
|
||||
|
||||
from mininet.node import Host
|
||||
from mininet.util import ensureRoot, waitListening
|
||||
from mininet.log import info, warn, output
|
||||
|
||||
|
||||
ensureRoot()
|
||||
timeout = 5
|
||||
|
||||
info( "*** Creating nodes\n" )
|
||||
print "*** Creating nodes"
|
||||
h1 = Host( 'h1' )
|
||||
|
||||
root = Host( 'root', inNamespace=False )
|
||||
|
||||
info( "*** Creating link\n" )
|
||||
print "*** Creating links"
|
||||
h1.linkTo( root )
|
||||
|
||||
info( h1 )
|
||||
print h1
|
||||
|
||||
info( "*** Configuring nodes\n" )
|
||||
print "*** Configuring nodes"
|
||||
h1.setIP( '10.0.0.1', 8 )
|
||||
root.setIP( '10.0.0.2', 8 )
|
||||
|
||||
info( "*** Creating banner file\n" )
|
||||
print "*** Creating banner file"
|
||||
f = open( '/tmp/%s.banner' % h1.name, 'w' )
|
||||
f.write( 'Welcome to %s at %s\n' % ( h1.name, h1.IP() ) )
|
||||
f.close()
|
||||
|
||||
info( "*** Running sshd\n" )
|
||||
print "*** Running sshd"
|
||||
cmd = '/usr/sbin/sshd -o UseDNS=no -u0 -o "Banner /tmp/%s.banner"' % h1.name
|
||||
# add arguments from the command line
|
||||
if len( sys.argv ) > 1:
|
||||
@@ -40,7 +37,7 @@ h1.cmd( cmd )
|
||||
listening = waitListening( server=h1, port=22, timeout=timeout )
|
||||
|
||||
if listening:
|
||||
output( "*** You may now ssh into", h1.name, "at", h1.IP(), '\n' )
|
||||
print "*** You may now ssh into", h1.name, "at", h1.IP()
|
||||
else:
|
||||
warn( "*** Warning: after %s seconds, %s is not listening on port 22"
|
||||
% ( timeout, h1.name ), '\n' )
|
||||
print ( "*** Warning: after %s seconds, %s is not listening on port 22"
|
||||
% ( timeout, h1.name ) )
|
||||
|
||||
+47
-134
@@ -74,7 +74,6 @@ Things to do:
|
||||
- hifi support (e.g. delay compensation)
|
||||
"""
|
||||
|
||||
|
||||
from mininet.node import Node, Host, OVSSwitch, Controller
|
||||
from mininet.link import Link, Intf
|
||||
from mininet.net import Mininet
|
||||
@@ -126,7 +125,7 @@ class ClusterCleanup( object ):
|
||||
def cleanup( cls ):
|
||||
"Clean up"
|
||||
info( '*** Cleaning up cluster\n' )
|
||||
for server, user in cls.serveruser.items():
|
||||
for server, user in cls.serveruser.iteritems():
|
||||
if server == 'localhost':
|
||||
# Handled by mininet.clean.cleanup()
|
||||
continue
|
||||
@@ -239,7 +238,7 @@ class RemoteMixin( object ):
|
||||
args: string or list of strings
|
||||
returns: stdout and stderr"""
|
||||
popen = self.rpopen( *cmd, **opts )
|
||||
# info( 'RCMD: POPEN:', popen, '\n' )
|
||||
# print 'RCMD: POPEN:', popen
|
||||
# These loops are tricky to get right.
|
||||
# Once the process exits, we can read
|
||||
# EOF twice if necessary.
|
||||
@@ -288,7 +287,7 @@ class RemoteMixin( object ):
|
||||
|
||||
def addIntf( self, *args, **kwargs ):
|
||||
"Override: use RemoteLink.moveIntf"
|
||||
# kwargs.update( moveIntfFn=RemoteLink.moveIntf )
|
||||
kwargs.update( moveIntfFn=RemoteLink.moveIntf )
|
||||
return super( RemoteMixin, self).addIntf( *args, **kwargs )
|
||||
|
||||
|
||||
@@ -393,30 +392,33 @@ class RemoteLink( Link ):
|
||||
return self.tunnel
|
||||
|
||||
@staticmethod
|
||||
def moveIntf( intf, node ):
|
||||
def moveIntf( intf, node, printError=True ):
|
||||
"""Move remote interface from root ns to node
|
||||
intf: string, interface
|
||||
dstNode: destination Node
|
||||
srcNode: source Node or None (default) for root ns"""
|
||||
srcNode: source Node or None (default) for root ns
|
||||
printError: if true, print error"""
|
||||
intf = str( intf )
|
||||
cmd = 'ip link set %s netns %s' % ( intf, node.pid )
|
||||
result = node.rcmd( cmd )
|
||||
if result:
|
||||
raise Exception('error executing command %s' % cmd)
|
||||
node.rcmd( cmd )
|
||||
links = node.cmd( 'ip link show' )
|
||||
if not re.search( r' %s[:@]' % intf, links ):
|
||||
if printError:
|
||||
error( '*** Error: RemoteLink.moveIntf: ' + intf +
|
||||
' not successfully moved to ' + node.name + '\n' )
|
||||
return False
|
||||
return True
|
||||
|
||||
def makeTunnel( self, node1, node2, intfname1, intfname2,
|
||||
addr1=None, addr2=None ):
|
||||
"Make a tunnel across switches on different servers"
|
||||
# We should never try to create a tunnel to ourselves!
|
||||
assert node1.server != node2.server
|
||||
assert node1.server != 'localhost' or node2.server != 'localhost'
|
||||
# And we can't ssh into this server remotely as 'localhost',
|
||||
# so try again swappping node1 and node2
|
||||
if node2.server == 'localhost':
|
||||
return self.makeTunnel( node2, node1, intfname2, intfname1,
|
||||
addr2, addr1 )
|
||||
debug( '\n*** Make SSH tunnel ' + node1.server + ':' + intfname1 +
|
||||
' == ' + node2.server + ':' + intfname2 )
|
||||
# 1. Create tap interfaces
|
||||
for node in node1, node2:
|
||||
# For now we are hard-wiring tap9, which we will rename
|
||||
@@ -472,91 +474,6 @@ class RemoteLink( Link ):
|
||||
return result
|
||||
|
||||
|
||||
class RemoteSSHLink( RemoteLink ):
|
||||
"Remote link using SSH tunnels"
|
||||
def __init__(self, node1, node2, **kwargs):
|
||||
RemoteLink.__init__( self, node1, node2, **kwargs )
|
||||
|
||||
|
||||
class RemoteGRELink( RemoteLink ):
|
||||
"Remote link using GRE tunnels"
|
||||
|
||||
GRE_KEY = 0
|
||||
|
||||
def __init__(self, node1, node2, **kwargs):
|
||||
RemoteLink.__init__( self, node1, node2, **kwargs )
|
||||
|
||||
def stop( self ):
|
||||
"Stop this link"
|
||||
if self.tunnel:
|
||||
self.intf1.delete()
|
||||
self.intf2.delete()
|
||||
else:
|
||||
Link.stop( self )
|
||||
self.tunnel = None
|
||||
|
||||
def makeIntfPair( self, intfname1, intfname2, addr1=None, addr2=None,
|
||||
node1=None, node2=None, deleteIntfs=True ):
|
||||
"""Create pair of interfaces
|
||||
intfname1: name of interface 1
|
||||
intfname2: name of interface 2
|
||||
(override this method [and possibly delete()]
|
||||
to change link type)"""
|
||||
node1 = self.node1 if node1 is None else node1
|
||||
node2 = self.node2 if node2 is None else node2
|
||||
server1 = getattr( node1, 'server', 'localhost' )
|
||||
server2 = getattr( node2, 'server', 'localhost' )
|
||||
if server1 == server2:
|
||||
# Link within same server
|
||||
Link.makeIntfPair( intfname1, intfname2, addr1, addr2,
|
||||
node1, node2, deleteIntfs=deleteIntfs )
|
||||
# Need to reduce the MTU of all emulated hosts to 1450 for GRE
|
||||
# tunneling, otherwise packets larger than 1400 bytes cannot be
|
||||
# successfully transmitted through the tunnel.
|
||||
node1.cmd('ip link set dev %s mtu 1450' % intfname1)
|
||||
node2.cmd('ip link set dev %s mtu 1450' % intfname2)
|
||||
else:
|
||||
# Otherwise, make a tunnel
|
||||
self.makeTunnel( node1, node2, intfname1, intfname2, addr1, addr2 )
|
||||
self.tunnel = 1
|
||||
|
||||
def makeTunnel(self, node1, node2, intfname1, intfname2,
|
||||
addr1=None, addr2=None):
|
||||
"Make a tunnel across switches on different servers"
|
||||
# We should never try to create a tunnel to ourselves!
|
||||
assert node1.server != node2.server
|
||||
if node2.server == 'localhost':
|
||||
return self.makeTunnel( node2, node1, intfname2, intfname1,
|
||||
addr2, addr1 )
|
||||
IP1, IP2 = node1.serverIP, node2.serverIP
|
||||
# GRE tunnel needs to be set up with the IP of the local interface
|
||||
# that connects the remote node, NOT '127.0.0.1' of localhost
|
||||
if node1.server == 'localhost':
|
||||
output = quietRun('ip route get %s' % node2.serverIP)
|
||||
IP1 = output.split(' src ')[1].split()[0]
|
||||
debug( '\n*** Make GRE tunnel ' + node1.server + ':' + intfname1 +
|
||||
' == ' + node2.server + ':' + intfname2 )
|
||||
tun1 = 'local ' + IP1 + ' remote ' + IP2
|
||||
tun2 = 'local ' + IP2 + ' remote ' + IP1
|
||||
self.__class__.GRE_KEY += 1
|
||||
for (node, intfname, addr, tun) in [(node1, intfname1, addr1, tun1),
|
||||
(node2, intfname2, addr2, tun2)]:
|
||||
node.rcmd('ip link delete ' + intfname)
|
||||
result = node.rcmd('ip link add name ' + intfname + ' type gretap '
|
||||
+ tun + ' ttl 64 key '
|
||||
+ str( self.__class__.GRE_KEY) )
|
||||
if result:
|
||||
raise Exception('error creating gretap on %s: %s'
|
||||
% (node, result))
|
||||
if addr:
|
||||
node.rcmd('ip link set %s address %s' % (intfname, addr))
|
||||
|
||||
node.rcmd('ip link set dev %s up' % intfname)
|
||||
node.rcmd('ip link set dev %s mtu 1450' % intfname)
|
||||
if not self.moveIntf(intfname, node):
|
||||
raise Exception('interface move failed on node %s' % node)
|
||||
|
||||
|
||||
# Some simple placement algorithms for MininetCluster
|
||||
|
||||
class Placer( object ):
|
||||
@@ -858,11 +775,11 @@ class MininetCluster( Mininet ):
|
||||
Mininet.buildFromTopo( self, *args, **kwargs )
|
||||
|
||||
|
||||
def testNsTunnels( remote='ubuntu2', link=RemoteGRELink ):
|
||||
def testNsTunnels():
|
||||
"Test tunnels between nodes in namespaces"
|
||||
net = Mininet( host=RemoteHost, link=link )
|
||||
h1 = net.addHost( 'h1')
|
||||
h2 = net.addHost( 'h2', server=remote )
|
||||
net = Mininet( host=RemoteHost, link=RemoteLink )
|
||||
h1 = net.addHost( 'h1' )
|
||||
h2 = net.addHost( 'h2', server='ubuntu2' )
|
||||
net.addLink( h1, h2 )
|
||||
net.start()
|
||||
net.pingAll()
|
||||
@@ -873,30 +790,30 @@ def testNsTunnels( remote='ubuntu2', link=RemoteGRELink ):
|
||||
# This shows how node options may be used to manage
|
||||
# cluster placement using the net.add*() API
|
||||
|
||||
def testRemoteNet( remote='ubuntu2', link=RemoteGRELink ):
|
||||
def testRemoteNet( remote='ubuntu2' ):
|
||||
"Test remote Node classes"
|
||||
info( '*** Remote Node Test\n' )
|
||||
net = Mininet( host=RemoteHost, switch=RemoteOVSSwitch, link=link )
|
||||
print '*** Remote Node Test'
|
||||
net = Mininet( host=RemoteHost, switch=RemoteOVSSwitch,
|
||||
link=RemoteLink )
|
||||
c0 = net.addController( 'c0' )
|
||||
# Make sure controller knows its non-loopback address
|
||||
Intf( 'eth0', node=c0 ).updateIP()
|
||||
info( "*** Creating local h1\n" )
|
||||
print "*** Creating local h1"
|
||||
h1 = net.addHost( 'h1' )
|
||||
info( "*** Creating remote h2\n" )
|
||||
print "*** Creating remote h2"
|
||||
h2 = net.addHost( 'h2', server=remote )
|
||||
info( "*** Creating local s1\n" )
|
||||
print "*** Creating local s1"
|
||||
s1 = net.addSwitch( 's1' )
|
||||
info( "*** Creating remote s2\n" )
|
||||
print "*** Creating remote s2"
|
||||
s2 = net.addSwitch( 's2', server=remote )
|
||||
info( "*** Adding links\n" )
|
||||
print "*** Adding links"
|
||||
net.addLink( h1, s1 )
|
||||
net.addLink( s1, s2 )
|
||||
net.addLink( h2, s2 )
|
||||
net.start()
|
||||
info( 'Mininet is running on', quietRun( 'hostname' ).strip(), '\n' )
|
||||
print 'Mininet is running on', quietRun( 'hostname' ).strip()
|
||||
for node in c0, h1, h2, s1, s2:
|
||||
info( 'Node', node, 'is running on',
|
||||
node.cmd( 'hostname' ).strip(), '\n' )
|
||||
print 'Node', node, 'is running on', node.cmd( 'hostname' ).strip()
|
||||
net.pingAll()
|
||||
CLI( net )
|
||||
net.stop()
|
||||
@@ -934,11 +851,11 @@ def ClusterController( *args, **kwargs):
|
||||
Intf( 'eth0', node=controller ).updateIP()
|
||||
return controller
|
||||
|
||||
def testRemoteTopo( link=RemoteGRELink ):
|
||||
def testRemoteTopo():
|
||||
"Test remote Node classes using Mininet()/Topo() API"
|
||||
topo = LinearTopo( 2 )
|
||||
net = Mininet( topo=topo, host=HostPlacer, switch=SwitchPlacer,
|
||||
link=link, controller=ClusterController )
|
||||
link=RemoteLink, controller=ClusterController )
|
||||
net.start()
|
||||
net.pingAll()
|
||||
net.stop()
|
||||
@@ -948,17 +865,18 @@ def testRemoteTopo( link=RemoteGRELink ):
|
||||
# do random switch placement rather than completely random
|
||||
# host placement.
|
||||
|
||||
def testRemoteSwitches( remote='ubuntu2', link=RemoteGRELink ):
|
||||
def testRemoteSwitches():
|
||||
"Test with local hosts and remote switches"
|
||||
servers = [ 'localhost', remote]
|
||||
servers = [ 'localhost', 'ubuntu2']
|
||||
topo = TreeTopo( depth=4, fanout=2 )
|
||||
net = MininetCluster( topo=topo, servers=servers, link=link,
|
||||
net = MininetCluster( topo=topo, servers=servers,
|
||||
placement=RoundRobinPlacer )
|
||||
net.start()
|
||||
net.pingAll()
|
||||
net.stop()
|
||||
|
||||
|
||||
#
|
||||
# For testing and demo purposes it would be nice to draw the
|
||||
# network graph and color it based on server.
|
||||
|
||||
@@ -966,36 +884,31 @@ def testRemoteSwitches( remote='ubuntu2', link=RemoteGRELink ):
|
||||
# functions, for maximum ease of use. MininetCluster() also
|
||||
# pre-flights and multiplexes server connections.
|
||||
|
||||
def testMininetCluster( remote='ubuntu2', link=RemoteGRELink ):
|
||||
def testMininetCluster():
|
||||
"Test MininetCluster()"
|
||||
servers = [ 'localhost', remote ]
|
||||
servers = [ 'localhost', 'ubuntu2' ]
|
||||
topo = TreeTopo( depth=3, fanout=3 )
|
||||
net = MininetCluster( topo=topo, servers=servers, link=link,
|
||||
net = MininetCluster( topo=topo, servers=servers,
|
||||
placement=SwitchBinPlacer )
|
||||
net.start()
|
||||
net.pingAll()
|
||||
net.stop()
|
||||
|
||||
def signalTest( remote='ubuntu2'):
|
||||
def signalTest():
|
||||
"Make sure hosts are robust to signals"
|
||||
h = RemoteHost( 'h0', server=remote )
|
||||
h = RemoteHost( 'h0', server='ubuntu1' )
|
||||
h.shell.send_signal( SIGINT )
|
||||
h.shell.poll()
|
||||
if h.shell.returncode is None:
|
||||
info( 'signalTest: SUCCESS: ', h, 'has not exited after SIGINT', '\n' )
|
||||
print 'OK: ', h, 'has not exited'
|
||||
else:
|
||||
info( 'signalTest: FAILURE:', h, 'exited with code',
|
||||
h.shell.returncode, '\n' )
|
||||
print 'FAILURE:', h, 'exited with code', h.shell.returncode
|
||||
h.stop()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
setLogLevel( 'info' )
|
||||
remoteServer = 'ubuntu2'
|
||||
remoteLink = RemoteSSHLink
|
||||
testRemoteTopo(link=remoteLink)
|
||||
testNsTunnels( remote=remoteServer, link=remoteLink )
|
||||
testRemoteNet( remote=remoteServer, link=remoteLink)
|
||||
testMininetCluster( remote=remoteServer, link=remoteLink)
|
||||
testRemoteSwitches( remote=remoteServer, link=remoteLink)
|
||||
signalTest( remote=remoteServer )
|
||||
# testRemoteTopo()
|
||||
# testRemoteNet()
|
||||
# testMininetCluster()
|
||||
# testRemoteSwitches()
|
||||
signalTest()
|
||||
|
||||
+4
-10
@@ -27,21 +27,16 @@ class ClusterCLI( CLI ):
|
||||
def do_plot( self, _line ):
|
||||
"Plot topology colored by node placement"
|
||||
# Import networkx if needed
|
||||
global nx, plt, graphviz_layout
|
||||
global nx, plt
|
||||
if not nx:
|
||||
try:
|
||||
# pylint: disable=import-error
|
||||
import networkx
|
||||
nx = networkx # satisfy pylint
|
||||
from matplotlib import pyplot
|
||||
plt = pyplot # satisfy pylint
|
||||
plt = pyplot # satisfiy pylint
|
||||
import pygraphviz
|
||||
assert pygraphviz # silence pyflakes
|
||||
# Networkx moved this around
|
||||
if hasattr( nx, 'graphviz_layout' ):
|
||||
graphviz_layout = nx.graphviz_layout
|
||||
else:
|
||||
graphviz_layout = nx.drawing.nx_agraph.graphviz_layout
|
||||
# pylint: enable=import-error
|
||||
except ImportError:
|
||||
error( 'plot requires networkx, matplotlib and pygraphviz - '
|
||||
@@ -50,8 +45,7 @@ class ClusterCLI( CLI ):
|
||||
# Make a networkx Graph
|
||||
g = nx.Graph()
|
||||
mn = self.mn
|
||||
servers = getattr( mn, 'servers', [ 'localhost' ] )
|
||||
hosts, switches = mn.hosts, mn.switches
|
||||
servers, hosts, switches = mn.servers, mn.hosts, mn.switches
|
||||
nodes = hosts + switches
|
||||
g.add_nodes_from( nodes )
|
||||
links = [ ( link.intf1.node, link.intf2.node )
|
||||
@@ -61,7 +55,7 @@ class ClusterCLI( CLI ):
|
||||
# shapes = hlen * [ 's' ] + slen * [ 'o' ]
|
||||
color = dict( zip( servers, self.colorsFor( servers ) ) )
|
||||
# Plot it!
|
||||
pos = graphviz_layout( g )
|
||||
pos = nx.graphviz_layout( g )
|
||||
opts = { 'ax': None, 'font_weight': 'bold',
|
||||
'width': 2, 'edge_color': 'darkblue' }
|
||||
hcolors = [ color[ getattr( h, 'server', 'localhost' ) ]
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
"clusterdemo.py: demo of Mininet Cluster Edition prototype"
|
||||
|
||||
from mininet.examples.cluster import ( MininetCluster, SwitchBinPlacer,
|
||||
RemoteLink )
|
||||
# ^ Could also use: RemoteSSHLink, RemoteGRELink
|
||||
from mininet.examples.cluster import MininetCluster, SwitchBinPlacer
|
||||
from mininet.topolib import TreeTopo
|
||||
from mininet.log import setLogLevel
|
||||
from mininet.examples.clustercli import ClusterCLI as CLI
|
||||
@@ -13,7 +11,7 @@ def demo():
|
||||
"Simple Demo of Cluster Mode"
|
||||
servers = [ 'localhost', 'ubuntu2', 'ubuntu3' ]
|
||||
topo = TreeTopo( depth=3, fanout=3 )
|
||||
net = MininetCluster( topo=topo, servers=servers, Link=RemoteLink,
|
||||
net = MininetCluster( topo=topo, servers=servers,
|
||||
placement=SwitchBinPlacer )
|
||||
net.start()
|
||||
CLI( net )
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
"clusterperf.py compare the maximum throughput between SSH and GRE tunnels"
|
||||
|
||||
from mininet.examples.cluster import RemoteSSHLink, RemoteGRELink, RemoteHost
|
||||
from mininet.net import Mininet
|
||||
from mininet.log import setLogLevel
|
||||
|
||||
def perf(Link):
|
||||
"Test connectivity nand performance over Link"
|
||||
net = Mininet( host=RemoteHost, link=Link )
|
||||
h1 = net.addHost( 'h1')
|
||||
h2 = net.addHost( 'h2', server='ubuntu2' )
|
||||
net.addLink( h1, h2 )
|
||||
net.start()
|
||||
net.pingAll()
|
||||
net.iperf()
|
||||
net.stop()
|
||||
|
||||
if __name__ == '__main__':
|
||||
setLogLevel('info')
|
||||
perf( RemoteSSHLink )
|
||||
perf( RemoteGRELink )
|
||||
+11
-12
@@ -11,50 +11,49 @@ 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
|
||||
from mininet.log import setLogLevel
|
||||
|
||||
def multiControllerNet():
|
||||
"Create a network from semi-scratch with multiple controllers."
|
||||
|
||||
net = Mininet( controller=Controller, switch=OVSSwitch )
|
||||
|
||||
info( "*** Creating (reference) controllers\n" )
|
||||
print "*** Creating (reference) controllers"
|
||||
c1 = net.addController( 'c1', port=6633 )
|
||||
c2 = net.addController( 'c2', port=6634 )
|
||||
|
||||
info( "*** Creating switches\n" )
|
||||
print "*** Creating switches"
|
||||
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 ) ]
|
||||
print "*** Creating hosts"
|
||||
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" )
|
||||
print "*** Creating links"
|
||||
for h in hosts1:
|
||||
net.addLink( s1, h )
|
||||
for h in hosts2:
|
||||
net.addLink( s2, h )
|
||||
net.addLink( s1, s2 )
|
||||
|
||||
info( "*** Starting network\n" )
|
||||
print "*** Starting network"
|
||||
net.build()
|
||||
c1.start()
|
||||
c2.start()
|
||||
s1.start( [ c1 ] )
|
||||
s2.start( [ c2 ] )
|
||||
|
||||
info( "*** Testing network\n" )
|
||||
print "*** Testing network"
|
||||
net.pingAll()
|
||||
|
||||
info( "*** Running CLI\n" )
|
||||
print "*** Running CLI"
|
||||
CLI( net )
|
||||
|
||||
info( "*** Stopping network\n" )
|
||||
print "*** Stopping network"
|
||||
net.stop()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -49,7 +49,7 @@ class MininetFacade( object ):
|
||||
args: unnamed networks passed as arguments
|
||||
kwargs: named networks passed as arguments"""
|
||||
self.net = net
|
||||
self.nets = [ net ] + list( args ) + list( kwargs.values() )
|
||||
self.nets = [ net ] + list( args ) + kwargs.values()
|
||||
self.nameToNet = kwargs
|
||||
self.nameToNet['net'] = net
|
||||
|
||||
|
||||
+4
-5
@@ -31,9 +31,9 @@ rate includes buffering.
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import CPULimitedHost
|
||||
from mininet.topolib import TreeTopo
|
||||
from mininet.util import custom, waitListening, decode
|
||||
from mininet.util import custom, waitListening
|
||||
from mininet.log import setLogLevel, info
|
||||
from mininet.clean import cleanup
|
||||
|
||||
|
||||
def bwtest( cpuLimits, period_us=100000, seconds=10 ):
|
||||
"""Example/test of link and CPU bandwidth limits
|
||||
@@ -55,8 +55,7 @@ def bwtest( cpuLimits, period_us=100000, seconds=10 ):
|
||||
net = Mininet( topo=topo, host=host )
|
||||
# pylint: disable=bare-except
|
||||
except:
|
||||
info( '*** Skipping scheduler %s and cleaning up\n' % sched )
|
||||
cleanup()
|
||||
info( '*** Skipping scheduler %s\n' % sched )
|
||||
break
|
||||
net.start()
|
||||
net.pingAll()
|
||||
@@ -71,7 +70,7 @@ def bwtest( cpuLimits, period_us=100000, seconds=10 ):
|
||||
# ignore empty result from waitListening/telnet
|
||||
popen.stdout.readline()
|
||||
client.cmd( 'iperf -yc -t %s -c %s' % ( seconds, server.IP() ) )
|
||||
result = decode( popen.stdout.readline() ).split( ',' )
|
||||
result = popen.stdout.readline().split( ',' )
|
||||
bps = float( result[ -1 ] )
|
||||
popen.terminate()
|
||||
net.stop()
|
||||
|
||||
@@ -23,7 +23,6 @@ of switches, this example demonstrates:
|
||||
|
||||
"""
|
||||
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import UserSwitch, OVSKernelSwitch, Controller
|
||||
from mininet.topo import Topo
|
||||
@@ -84,7 +83,7 @@ def linearBandwidthTest( lengths ):
|
||||
assert 'reno' in output
|
||||
|
||||
for datapath in switches.keys():
|
||||
info( "*** testing", datapath, "datapath\n" )
|
||||
print "*** testing", datapath, "datapath"
|
||||
Switch = switches[ datapath ]
|
||||
results[ datapath ] = []
|
||||
link = partial( TCLink, delay='2ms', bw=10 )
|
||||
@@ -92,10 +91,10 @@ def linearBandwidthTest( lengths ):
|
||||
controller=Controller, waitConnected=True,
|
||||
link=link )
|
||||
net.start()
|
||||
info( "*** testing basic connectivity\n" )
|
||||
print "*** testing basic connectivity"
|
||||
for n in lengths:
|
||||
net.ping( [ net.hosts[ 0 ], net.hosts[ n ] ] )
|
||||
info( "*** testing bandwidth\n" )
|
||||
print "*** testing bandwidth"
|
||||
for n in lengths:
|
||||
src, dst = net.hosts[ 0 ], net.hosts[ n ]
|
||||
# Try to prime the pump to reduce PACKET_INs during test
|
||||
@@ -110,7 +109,9 @@ def linearBandwidthTest( lengths ):
|
||||
net.stop()
|
||||
|
||||
for datapath in switches.keys():
|
||||
info( "\n*** Linear network results for", datapath, "datapath:\n" )
|
||||
print
|
||||
print "*** Linear network results for", datapath, "datapath:"
|
||||
print
|
||||
result = results[ datapath ]
|
||||
info( "SwitchCount\tiperf Results\n" )
|
||||
for switchCount, serverbw in result:
|
||||
@@ -119,8 +120,9 @@ def linearBandwidthTest( lengths ):
|
||||
info( '\n')
|
||||
info( '\n' )
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
lg.setLogLevel( 'info' )
|
||||
sizes = [ 1, 10, 20, 40, 60, 80 ]
|
||||
info( "*** Running linearBandwidthTest", sizes, '\n' )
|
||||
print "*** Running linearBandwidthTest", sizes
|
||||
linearBandwidthTest( sizes )
|
||||
|
||||
@@ -27,14 +27,12 @@ Additional routes may be added to the router or hosts by
|
||||
executing 'ip route' or 'route' commands on the router or hosts.
|
||||
"""
|
||||
|
||||
|
||||
from mininet.topo import Topo
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import Node
|
||||
from mininet.log import setLogLevel, info
|
||||
from mininet.cli import CLI
|
||||
|
||||
|
||||
class LinuxRouter( Node ):
|
||||
"A Node with IP forwarding enabled."
|
||||
|
||||
@@ -56,7 +54,7 @@ class NetworkTopo( Topo ):
|
||||
defaultIP = '192.168.1.1/24' # IP address for r0-eth1
|
||||
router = self.addNode( 'r0', cls=LinuxRouter, ip=defaultIP )
|
||||
|
||||
s1, s2, s3 = [ self.addSwitch( s ) for s in ( 's1', 's2', 's3' ) ]
|
||||
s1, s2, s3 = [ self.addSwitch( s ) for s in 's1', 's2', 's3' ]
|
||||
|
||||
self.addLink( s1, router, intfName2='r0-eth1',
|
||||
params2={ 'ip' : defaultIP } ) # for clarity
|
||||
@@ -82,7 +80,7 @@ def run():
|
||||
net = Mininet( topo=topo ) # controller is used by s1-s3
|
||||
net.start()
|
||||
info( '*** Routing Table on Router:\n' )
|
||||
info( net[ 'r0' ].cmd( 'route' ) )
|
||||
print net[ 'r0' ].cmd( 'route' )
|
||||
CLI( net )
|
||||
net.stop()
|
||||
|
||||
|
||||
+59
-74
@@ -20,39 +20,24 @@ OpenFlow icon from https://www.opennetworking.org/
|
||||
|
||||
MINIEDIT_VERSION = '2.2.0.1'
|
||||
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
# from Tkinter import *
|
||||
from Tkinter import ( Frame, Label, LabelFrame, Entry, OptionMenu, Checkbutton,
|
||||
Menu, Toplevel, Button, BitmapImage, PhotoImage, Canvas,
|
||||
Scrollbar, Wm, TclError, StringVar, IntVar,
|
||||
E, W, EW, NW, Y, VERTICAL, SOLID, CENTER,
|
||||
RIGHT, LEFT, BOTH, TRUE, FALSE )
|
||||
from ttk import Notebook
|
||||
from tkMessageBox import showerror
|
||||
from subprocess import call
|
||||
|
||||
if sys.version_info[0] == 2:
|
||||
from Tkinter import ( Frame, Label, LabelFrame, Entry, OptionMenu,
|
||||
Checkbutton, Menu, Toplevel, Button, BitmapImage,
|
||||
PhotoImage, Canvas, Scrollbar, Wm, TclError,
|
||||
StringVar, IntVar, E, W, EW, NW, Y, VERTICAL, SOLID,
|
||||
CENTER, RIGHT, LEFT, BOTH, TRUE, FALSE )
|
||||
from ttk import Notebook
|
||||
from tkMessageBox import showerror
|
||||
from subprocess import call
|
||||
import tkFont
|
||||
import tkFileDialog
|
||||
import tkSimpleDialog
|
||||
import tkFileDialog
|
||||
else:
|
||||
from tkinter import ( Frame, Label, LabelFrame, Entry, OptionMenu,
|
||||
Checkbutton, Menu, Toplevel, Button, BitmapImage,
|
||||
PhotoImage, Canvas, Scrollbar, Wm, TclError,
|
||||
StringVar, IntVar, E, W, EW, NW, Y, VERTICAL, SOLID,
|
||||
CENTER, RIGHT, LEFT, BOTH, TRUE, FALSE )
|
||||
from tkinter.ttk import Notebook
|
||||
from tkinter.messagebox import showerror
|
||||
from tkinter import font as tkFont
|
||||
from tkinter import simpledialog as tkSimpleDialog
|
||||
from tkinter import filedialog as tkFileDialog
|
||||
|
||||
import tkFont
|
||||
import tkFileDialog
|
||||
import tkSimpleDialog
|
||||
import re
|
||||
import json
|
||||
from distutils.version import StrictVersion
|
||||
import os
|
||||
import sys
|
||||
from functools import partial
|
||||
|
||||
if 'PYTHONPATH' in os.environ:
|
||||
@@ -60,7 +45,7 @@ if 'PYTHONPATH' in os.environ:
|
||||
|
||||
# someday: from ttk import *
|
||||
|
||||
from mininet.log import info, debug, warn, setLogLevel
|
||||
from mininet.log import info, setLogLevel
|
||||
from mininet.net import Mininet, VERSION
|
||||
from mininet.util import netParse, ipAdd, quietRun
|
||||
from mininet.util import buildTopo
|
||||
@@ -75,7 +60,7 @@ from mininet.moduledeps import moduleDeps
|
||||
from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo
|
||||
from mininet.topolib import TreeTopo
|
||||
|
||||
info( 'MiniEdit running against Mininet '+VERSION, '\n' )
|
||||
print 'MiniEdit running against Mininet '+VERSION
|
||||
MININET_VERSION = re.sub(r'[^\d\.]', '', VERSION)
|
||||
if StrictVersion(MININET_VERSION) > StrictVersion('2.0'):
|
||||
from mininet.node import IVSSwitch
|
||||
@@ -394,14 +379,14 @@ class PrefsDialog(tkSimpleDialog.Dialog):
|
||||
@staticmethod
|
||||
def getOvsVersion():
|
||||
"Return OVS version"
|
||||
outp = quietRun("ovs-vsctl --version")
|
||||
r = r'ovs-vsctl \(Open vSwitch\) (.*)'
|
||||
outp = quietRun("ovs-vsctl show")
|
||||
r = r'ovs_version: "(.*)"'
|
||||
m = re.search(r, outp)
|
||||
if m is None:
|
||||
warn( 'Version check failed' )
|
||||
print 'Version check failed'
|
||||
return None
|
||||
else:
|
||||
info( 'Open vSwitch version is '+m.group(1), '\n' )
|
||||
print 'Open vSwitch version is '+m.group(1)
|
||||
return m.group(1)
|
||||
|
||||
|
||||
@@ -770,7 +755,7 @@ class SwitchDialog(CustomDialog):
|
||||
def apply(self):
|
||||
externalInterfaces = []
|
||||
for row in range(self.tableFrame.rows):
|
||||
# debug( 'Interface is ' + self.tableFrame.get(row, 0), '\n' )
|
||||
#print 'Interface is ' + self.tableFrame.get(row, 0)
|
||||
if len(self.tableFrame.get(row, 0)) > 0:
|
||||
externalInterfaces.append(self.tableFrame.get(row, 0))
|
||||
|
||||
@@ -881,7 +866,7 @@ class TableFrame(Frame):
|
||||
return widget.get()
|
||||
|
||||
def addRow( self, value=None, readonly=False ):
|
||||
# debug( "Adding row " + str(self.rows +1), '\n' )
|
||||
#print "Adding row " + str(self.rows +1)
|
||||
current_row = []
|
||||
for column in range(self.columns):
|
||||
label = Entry(self, borderwidth=0)
|
||||
@@ -1423,7 +1408,7 @@ class MiniEdit( Frame ):
|
||||
def convertJsonUnicode(self, text):
|
||||
"Some part of Mininet don't like Unicode"
|
||||
if isinstance(text, dict):
|
||||
return {self.convertJsonUnicode(key): self.convertJsonUnicode(value) for key, value in text.items()}
|
||||
return {self.convertJsonUnicode(key): self.convertJsonUnicode(value) for key, value in text.iteritems()}
|
||||
elif isinstance(text, list):
|
||||
return [self.convertJsonUnicode(element) for element in text]
|
||||
elif isinstance(text, unicode):
|
||||
@@ -1684,7 +1669,7 @@ class MiniEdit( Frame ):
|
||||
f.write(json.dumps(savingDictionary, sort_keys=True, indent=4, separators=(',', ': ')))
|
||||
# pylint: disable=broad-except
|
||||
except Exception as er:
|
||||
warn( er, '\n' )
|
||||
print er
|
||||
# pylint: enable=broad-except
|
||||
finally:
|
||||
f.close()
|
||||
@@ -1698,7 +1683,7 @@ class MiniEdit( Frame ):
|
||||
|
||||
fileName = tkFileDialog.asksaveasfilename(filetypes=myFormats ,title="Export the topology as...")
|
||||
if len(fileName ) > 0:
|
||||
# debug( "Now saving under %s\n" % fileName )
|
||||
#print "Now saving under %s" % fileName
|
||||
f = open(fileName, 'wb')
|
||||
|
||||
f.write("#!/usr/bin/python\n")
|
||||
@@ -1850,7 +1835,7 @@ class MiniEdit( Frame ):
|
||||
|
||||
# Save Links
|
||||
f.write(" info( '*** Add links\\n')\n")
|
||||
for key,linkDetail in self.links.items():
|
||||
for key,linkDetail in self.links.iteritems():
|
||||
tags = self.canvas.gettags(key)
|
||||
if 'data' in tags:
|
||||
optsExist = False
|
||||
@@ -2504,7 +2489,7 @@ class MiniEdit( Frame ):
|
||||
if len(hostBox.result['privateDirectory']) > 0:
|
||||
newHostOpts['privateDirectory'] = hostBox.result['privateDirectory']
|
||||
self.hostOpts[name] = newHostOpts
|
||||
info( 'New host details for ' + name + ' = ' + str(newHostOpts), '\n' )
|
||||
print 'New host details for ' + name + ' = ' + str(newHostOpts)
|
||||
|
||||
def switchDetails( self, _ignore=None ):
|
||||
if ( self.selection is None or
|
||||
@@ -2542,7 +2527,7 @@ class MiniEdit( Frame ):
|
||||
newSwitchOpts['sflow'] = switchBox.result['sflow']
|
||||
newSwitchOpts['netflow'] = switchBox.result['netflow']
|
||||
self.switchOpts[name] = newSwitchOpts
|
||||
info( 'New switch details for ' + name + ' = ' + str(newSwitchOpts), '\n' )
|
||||
print 'New switch details for ' + name + ' = ' + str(newSwitchOpts)
|
||||
|
||||
def linkUp( self ):
|
||||
if ( self.selection is None or
|
||||
@@ -2581,12 +2566,12 @@ class MiniEdit( Frame ):
|
||||
linkBox = LinkDialog(self, title='Link Details', linkDefaults=linkopts)
|
||||
if linkBox.result is not None:
|
||||
linkDetail['linkOpts'] = linkBox.result
|
||||
info( 'New link details = ' + str(linkBox.result), '\n' )
|
||||
print 'New link details = ' + str(linkBox.result)
|
||||
|
||||
def prefDetails( self ):
|
||||
prefDefaults = self.appPrefs
|
||||
prefBox = PrefsDialog(self, title='Preferences', prefDefaults=prefDefaults)
|
||||
info( 'New Prefs = ' + str(prefBox.result), '\n' )
|
||||
print 'New Prefs = ' + str(prefBox.result)
|
||||
if prefBox.result:
|
||||
self.appPrefs = prefBox.result
|
||||
|
||||
@@ -2605,14 +2590,14 @@ class MiniEdit( Frame ):
|
||||
|
||||
ctrlrBox = ControllerDialog(self, title='Controller Details', ctrlrDefaults=self.controllers[name])
|
||||
if ctrlrBox.result:
|
||||
# debug( 'Controller is ' + ctrlrBox.result[0], '\n' )
|
||||
#print 'Controller is ' + ctrlrBox.result[0]
|
||||
if len(ctrlrBox.result['hostname']) > 0:
|
||||
name = ctrlrBox.result['hostname']
|
||||
widget[ 'text' ] = name
|
||||
else:
|
||||
ctrlrBox.result['hostname'] = name
|
||||
self.controllers[name] = ctrlrBox.result
|
||||
info( 'New controller details for ' + name + ' = ' + str(self.controllers[name]), '\n' )
|
||||
print 'New controller details for ' + name + ' = ' + str(self.controllers[name])
|
||||
# Find references to controller and change name
|
||||
if oldName != name:
|
||||
for widget in self.widgetToItem:
|
||||
@@ -2713,15 +2698,15 @@ class MiniEdit( Frame ):
|
||||
|
||||
def buildNodes( self, net):
|
||||
# Make nodes
|
||||
info( "Getting Hosts and Switches.\n" )
|
||||
print "Getting Hosts and Switches."
|
||||
for widget in self.widgetToItem:
|
||||
name = widget[ 'text' ]
|
||||
tags = self.canvas.gettags( self.widgetToItem[ widget ] )
|
||||
# debug( name+' has '+str(tags), '\n' )
|
||||
#print name+' has '+str(tags)
|
||||
|
||||
if 'Switch' in tags:
|
||||
opts = self.switchOpts[name]
|
||||
# debug( str(opts), '\n' )
|
||||
#print str(opts)
|
||||
|
||||
# Create the correct switch class
|
||||
switchClass = customOvs
|
||||
@@ -2787,7 +2772,7 @@ class MiniEdit( Frame ):
|
||||
newSwitch = net.addHost( name , cls=LegacyRouter)
|
||||
elif 'Host' in tags:
|
||||
opts = self.hostOpts[name]
|
||||
# debug( str(opts), '\n' )
|
||||
#print str(opts)
|
||||
ip = None
|
||||
defaultRoute = None
|
||||
if 'defaultRoute' in opts and len(opts['defaultRoute']) > 0:
|
||||
@@ -2812,7 +2797,7 @@ class MiniEdit( Frame ):
|
||||
privateDirs=opts['privateDirectory'] )
|
||||
else:
|
||||
hostCls=Host
|
||||
debug( hostCls, '\n' )
|
||||
print hostCls
|
||||
newHost = net.addHost( name,
|
||||
cls=hostCls,
|
||||
ip=ip,
|
||||
@@ -2832,7 +2817,7 @@ class MiniEdit( Frame ):
|
||||
Intf( extInterface, node=newHost )
|
||||
if 'vlanInterfaces' in opts:
|
||||
if len(opts['vlanInterfaces']) > 0:
|
||||
info( 'Checking that OS is VLAN prepared\n' )
|
||||
print 'Checking that OS is VLAN prepared'
|
||||
self.pathCheck('vconfig', moduleName='vlan package')
|
||||
moduleDeps( add='8021q' )
|
||||
elif 'Controller' in tags:
|
||||
@@ -2849,7 +2834,7 @@ class MiniEdit( Frame ):
|
||||
controllerPort = opts['remotePort']
|
||||
|
||||
# Make controller
|
||||
info( 'Getting controller selection:'+controllerType, '\n' )
|
||||
print 'Getting controller selection:'+controllerType
|
||||
if controllerType == 'remote':
|
||||
net.addController(name=name,
|
||||
controller=RemoteController,
|
||||
@@ -2889,8 +2874,8 @@ class MiniEdit( Frame ):
|
||||
|
||||
def buildLinks( self, net):
|
||||
# Make links
|
||||
info( "Getting Links.\n" )
|
||||
for key,link in self.links.items():
|
||||
print "Getting Links."
|
||||
for key,link in self.links.iteritems():
|
||||
tags = self.canvas.gettags(key)
|
||||
if 'data' in tags:
|
||||
src=link['src']
|
||||
@@ -2901,14 +2886,14 @@ class MiniEdit( Frame ):
|
||||
if linkopts:
|
||||
net.addLink(srcNode, dstNode, cls=TCLink, **linkopts)
|
||||
else:
|
||||
# debug( str(srcNode) )
|
||||
# debug( str(dstNode), '\n' )
|
||||
#print str(srcNode)
|
||||
#print str(dstNode)
|
||||
net.addLink(srcNode, dstNode)
|
||||
self.canvas.itemconfig(key, dash=())
|
||||
|
||||
|
||||
def build( self ):
|
||||
"Build network based on our topology."
|
||||
print "Build network based on our topology."
|
||||
|
||||
dpctl = None
|
||||
if len(self.appPrefs['dpctl']) > 0:
|
||||
@@ -2939,7 +2924,7 @@ class MiniEdit( Frame ):
|
||||
# Attach vlan interfaces
|
||||
if 'vlanInterfaces' in opts:
|
||||
for vlanInterface in opts['vlanInterfaces']:
|
||||
info( 'adding vlan interface '+vlanInterface[1], '\n' )
|
||||
print 'adding vlan interface '+vlanInterface[1]
|
||||
newHost.cmdPrint('ifconfig '+name+'-eth0.'+vlanInterface[1]+' '+vlanInterface[0])
|
||||
# Run User Defined Start Command
|
||||
if 'startCommand' in opts:
|
||||
@@ -2965,7 +2950,7 @@ class MiniEdit( Frame ):
|
||||
opts = self.switchOpts[name]
|
||||
if 'netflow' in opts:
|
||||
if opts['netflow'] == '1':
|
||||
info( name+' has Netflow enabled\n' )
|
||||
print name+' has Netflow enabled'
|
||||
nflowSwitches = nflowSwitches+' -- set Bridge '+name+' netflow=@MiniEditNF'
|
||||
nflowEnabled=True
|
||||
if nflowEnabled:
|
||||
@@ -2974,13 +2959,13 @@ class MiniEdit( Frame ):
|
||||
nflowCmd = nflowCmd + ' add_id_to_interface=true'
|
||||
else:
|
||||
nflowCmd = nflowCmd + ' add_id_to_interface=false'
|
||||
info( 'cmd = '+nflowCmd+nflowSwitches, '\n' )
|
||||
print 'cmd = '+nflowCmd+nflowSwitches
|
||||
call(nflowCmd+nflowSwitches, shell=True)
|
||||
|
||||
else:
|
||||
info( 'No switches with Netflow\n' )
|
||||
print 'No switches with Netflow'
|
||||
else:
|
||||
info( 'No NetFlow targets specified.\n' )
|
||||
print 'No NetFlow targets specified.'
|
||||
|
||||
# Configure sFlow
|
||||
sflowValues = self.appPrefs['sflow']
|
||||
@@ -2995,18 +2980,18 @@ class MiniEdit( Frame ):
|
||||
opts = self.switchOpts[name]
|
||||
if 'sflow' in opts:
|
||||
if opts['sflow'] == '1':
|
||||
info( name+' has sflow enabled\n' )
|
||||
print name+' has sflow enabled'
|
||||
sflowSwitches = sflowSwitches+' -- set Bridge '+name+' sflow=@MiniEditSF'
|
||||
sflowEnabled=True
|
||||
if sflowEnabled:
|
||||
sflowCmd = 'ovs-vsctl -- --id=@MiniEditSF create sFlow '+ 'target=\\\"'+sflowValues['sflowTarget']+'\\\" '+ 'header='+sflowValues['sflowHeader']+' '+ 'sampling='+sflowValues['sflowSampling']+' '+ 'polling='+sflowValues['sflowPolling']
|
||||
info( 'cmd = '+sflowCmd+sflowSwitches, '\n' )
|
||||
print 'cmd = '+sflowCmd+sflowSwitches
|
||||
call(sflowCmd+sflowSwitches, shell=True)
|
||||
|
||||
else:
|
||||
info( 'No switches with sflow\n' )
|
||||
print 'No switches with sflow'
|
||||
else:
|
||||
info( 'No sFlow targets specified.\n' )
|
||||
print 'No sFlow targets specified.'
|
||||
|
||||
## NOTE: MAKE SURE THIS IS LAST THING CALLED
|
||||
# Start the CLI if enabled
|
||||
@@ -3226,13 +3211,13 @@ class MiniEdit( Frame ):
|
||||
customs = {}
|
||||
if os.path.isfile( fileName ):
|
||||
execfile( fileName, customs, customs )
|
||||
for name, val in customs.items():
|
||||
for name, val in customs.iteritems():
|
||||
self.setCustom( name, val )
|
||||
else:
|
||||
raise Exception( 'could not find custom file: %s' % fileName )
|
||||
|
||||
def importTopo( self ):
|
||||
info( 'topo='+self.options.topo, '\n' )
|
||||
print 'topo='+self.options.topo
|
||||
if self.options.topo == 'none':
|
||||
return
|
||||
self.newTopology()
|
||||
@@ -3246,7 +3231,7 @@ class MiniEdit( Frame ):
|
||||
currentY = 100
|
||||
|
||||
# Add Controllers
|
||||
info( 'controllers:'+str(len(importNet.controllers)), '\n' )
|
||||
print 'controllers:'+str(len(importNet.controllers))
|
||||
for controller in importNet.controllers:
|
||||
name = controller.name
|
||||
x = self.controllerCount*100+100
|
||||
@@ -3266,7 +3251,7 @@ class MiniEdit( Frame ):
|
||||
currentY = currentY + rowIncrement
|
||||
|
||||
# Add switches
|
||||
info( 'switches:'+str(len(importNet.switches)), '\n' )
|
||||
print 'switches:'+str(len(importNet.switches))
|
||||
columnCount = 0
|
||||
for switch in importNet.switches:
|
||||
name = switch.name
|
||||
@@ -3307,7 +3292,7 @@ class MiniEdit( Frame ):
|
||||
|
||||
currentY = currentY + rowIncrement
|
||||
# Add hosts
|
||||
info( 'hosts:'+str(len(importNet.hosts)), '\n' )
|
||||
print 'hosts:'+str(len(importNet.hosts))
|
||||
columnCount = 0
|
||||
for host in importNet.hosts:
|
||||
name = host.name
|
||||
@@ -3327,10 +3312,10 @@ class MiniEdit( Frame ):
|
||||
else:
|
||||
columnCount =columnCount+1
|
||||
|
||||
info( 'links:'+str(len(topo.links())), '\n' )
|
||||
print 'links:'+str(len(topo.links()))
|
||||
#[('h1', 's3'), ('h2', 's4'), ('s3', 's4')]
|
||||
for link in topo.links():
|
||||
info( str(link), '\n' )
|
||||
print str(link)
|
||||
srcNode = link[0]
|
||||
src = self.findWidgetByName(srcNode)
|
||||
sx, sy = self.canvas.coords( self.widgetToItem[ src ] )
|
||||
@@ -3340,7 +3325,7 @@ class MiniEdit( Frame ):
|
||||
dx, dy = self.canvas.coords( self.widgetToItem[ dest] )
|
||||
|
||||
params = topo.linkInfo( srcNode, destNode )
|
||||
info( 'Link Parameters='+str(params), '\n' )
|
||||
print 'Link Parameters='+str(params)
|
||||
|
||||
self.link = self.canvas.create_line( sx, sy, dx, dy, width=4,
|
||||
fill='blue', tag='link' )
|
||||
|
||||
+10
-12
@@ -19,11 +19,10 @@ to-do:
|
||||
- think about clearing last hop - why doesn't that work?
|
||||
"""
|
||||
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import OVSSwitch
|
||||
from mininet.topo import LinearTopo
|
||||
from mininet.log import info, output, warn, setLogLevel
|
||||
from mininet.log import output, warn
|
||||
|
||||
from random import randint
|
||||
|
||||
@@ -106,31 +105,30 @@ def moveHost( host, oldSwitch, newSwitch, newPort=None ):
|
||||
|
||||
def mobilityTest():
|
||||
"A simple test of mobility"
|
||||
info( '* Simple mobility test\n' )
|
||||
print '* Simple mobility test'
|
||||
net = Mininet( topo=LinearTopo( 3 ), switch=MobilitySwitch )
|
||||
info( '* Starting network:\n' )
|
||||
print '* Starting network:'
|
||||
net.start()
|
||||
printConnections( net.switches )
|
||||
info( '* Testing network\n' )
|
||||
print '* Testing network'
|
||||
net.pingAll()
|
||||
info( '* Identifying switch interface for h1\n' )
|
||||
print '* Identifying switch interface for h1'
|
||||
h1, old = net.get( 'h1', 's1' )
|
||||
for s in 2, 3, 1:
|
||||
new = net[ 's%d' % s ]
|
||||
port = randint( 10, 20 )
|
||||
info( '* Moving', h1, 'from', old, 'to', new, 'port', port, '\n' )
|
||||
print '* Moving', h1, 'from', old, 'to', new, 'port', port
|
||||
hintf, sintf = moveHost( h1, old, new, newPort=port )
|
||||
info( '*', hintf, 'is now connected to', sintf, '\n' )
|
||||
info( '* Clearing out old flows\n' )
|
||||
print '*', hintf, 'is now connected to', sintf
|
||||
print '* Clearing out old flows'
|
||||
for sw in net.switches:
|
||||
sw.dpctl( 'del-flows' )
|
||||
info( '* New network:\n' )
|
||||
print '* New network:'
|
||||
printConnections( net.switches )
|
||||
info( '* Testing connectivity:\n' )
|
||||
print '* Testing connectivity:'
|
||||
net.pingAll()
|
||||
old = new
|
||||
net.stop()
|
||||
|
||||
if __name__ == '__main__':
|
||||
setLogLevel( 'info' )
|
||||
mobilityTest()
|
||||
|
||||
@@ -8,11 +8,10 @@ multiple hosts and monitor their output interactively for a period=
|
||||
of time.
|
||||
"""
|
||||
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import Node
|
||||
from mininet.topo import SingleSwitchTopo
|
||||
from mininet.log import info, setLogLevel
|
||||
from mininet.log import setLogLevel
|
||||
|
||||
from select import poll, POLLIN
|
||||
from time import time
|
||||
@@ -35,8 +34,8 @@ def startpings( host, targetips ):
|
||||
' done; '
|
||||
'done &' )
|
||||
|
||||
info( '*** Host %s (%s) will be pinging ips: %s\n' %
|
||||
( host.name, host.IP(), targetips ) )
|
||||
print ( '*** Host %s (%s) will be pinging ips: %s' %
|
||||
( host.name, host.IP(), targetips ) )
|
||||
|
||||
host.cmd( cmd )
|
||||
|
||||
@@ -45,7 +44,7 @@ def multiping( netsize, chunksize, seconds):
|
||||
|
||||
# Create network and identify subnets
|
||||
topo = SingleSwitchTopo( netsize )
|
||||
net = Mininet( topo=topo, waitConnected=True )
|
||||
net = Mininet( topo=topo )
|
||||
net.start()
|
||||
hosts = net.hosts
|
||||
subnets = chunks( hosts, chunksize )
|
||||
@@ -70,7 +69,7 @@ def multiping( netsize, chunksize, seconds):
|
||||
readable = poller.poll(1000)
|
||||
for fd, _mask in readable:
|
||||
node = Node.outToNode[ fd ]
|
||||
info( '%s:' % node.name, node.monitor().strip(), '\n' )
|
||||
print '%s:' % node.name, node.monitor().strip()
|
||||
|
||||
# Stop pings
|
||||
for host in hosts:
|
||||
|
||||
@@ -5,22 +5,19 @@ Simple example of sending output to multiple files and
|
||||
monitoring them
|
||||
"""
|
||||
|
||||
|
||||
from mininet.topo import SingleSwitchTopo
|
||||
from mininet.net import Mininet
|
||||
from mininet.log import info, setLogLevel
|
||||
from mininet.util import decode
|
||||
from mininet.log import setLogLevel
|
||||
|
||||
from time import time
|
||||
from select import poll, POLLIN
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
|
||||
def monitorFiles( outfiles, seconds, timeoutms ):
|
||||
"Monitor set of files and return [(host, line)...]"
|
||||
devnull = open( '/dev/null', 'w' )
|
||||
tails, fdToFile, fdToHost = {}, {}, {}
|
||||
for h, outfile in outfiles.items():
|
||||
for h, outfile in outfiles.iteritems():
|
||||
tail = Popen( [ 'tail', '-f', outfile ],
|
||||
stdout=PIPE, stderr=devnull )
|
||||
fd = tail.stdout.fileno()
|
||||
@@ -41,7 +38,7 @@ def monitorFiles( outfiles, seconds, timeoutms ):
|
||||
host = fdToHost[ fd ]
|
||||
# Wait for a line of output
|
||||
line = f.readline().strip()
|
||||
yield host, decode( line )
|
||||
yield host, line
|
||||
else:
|
||||
# If we timed out, return nothing
|
||||
yield None, ''
|
||||
@@ -56,7 +53,7 @@ def monitorTest( N=3, seconds=3 ):
|
||||
net = Mininet( topo )
|
||||
net.start()
|
||||
hosts = net.hosts
|
||||
info( "Starting test...\n" )
|
||||
print "Starting test..."
|
||||
server = hosts[ 0 ]
|
||||
outfiles, errfiles = {}, {}
|
||||
for h in hosts:
|
||||
@@ -70,10 +67,10 @@ def monitorTest( N=3, seconds=3 ):
|
||||
'>', outfiles[ h ],
|
||||
'2>', errfiles[ h ],
|
||||
'&' )
|
||||
info( "Monitoring output for", seconds, "seconds\n" )
|
||||
print "Monitoring output for", seconds, "seconds"
|
||||
for h, line in monitorFiles( outfiles, seconds, timeoutms=500 ):
|
||||
if h:
|
||||
info( '%s: %s\n' % ( h.name, line ) )
|
||||
print '%s: %s' % ( h.name, line )
|
||||
for h in hosts:
|
||||
h.cmd('kill %ping')
|
||||
net.stop()
|
||||
|
||||
+3
-5
@@ -4,20 +4,18 @@
|
||||
Example to create a Mininet topology and connect it to the internet via NAT
|
||||
"""
|
||||
|
||||
|
||||
from mininet.cli import CLI
|
||||
from mininet.log import lg, info
|
||||
from mininet.log import lg
|
||||
from mininet.topolib import TreeNet
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
lg.setLogLevel( 'info')
|
||||
net = TreeNet( depth=1, fanout=4 )
|
||||
# Add NAT connectivity
|
||||
net.addNAT().configDefault()
|
||||
net.start()
|
||||
info( "*** Hosts are running and should have internet connectivity\n" )
|
||||
info( "*** Type 'exit' or control-D to shut down network\n" )
|
||||
print "*** Hosts are running and should have internet connectivity"
|
||||
print "*** Type 'exit' or control-D to shut down network"
|
||||
CLI( net )
|
||||
# Shut down NAT
|
||||
net.stop()
|
||||
|
||||
@@ -6,7 +6,6 @@ Validate that the port numbers match to the interface name,
|
||||
and that the ovs ports match the mininet ports.
|
||||
"""
|
||||
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import Controller
|
||||
from mininet.log import setLogLevel, info, warn
|
||||
@@ -66,13 +65,13 @@ def testPortNumbering():
|
||||
'is actually on port', s1.ports[intfs], '... ' )
|
||||
if validatePort( s1, intfs ):
|
||||
info( 'Validated.\n' )
|
||||
info( '\n' )
|
||||
print '\n'
|
||||
|
||||
# test the network with pingall
|
||||
net.pingAll()
|
||||
info( '\n' )
|
||||
print '\n'
|
||||
|
||||
info( '*** Stopping network\n' )
|
||||
info( '*** Stopping network' )
|
||||
net.stop()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
+2
-3
@@ -5,11 +5,10 @@ This example monitors a number of hosts using host.popen() and
|
||||
pmonitor()
|
||||
"""
|
||||
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import CPULimitedHost
|
||||
from mininet.topo import SingleSwitchTopo
|
||||
from mininet.log import setLogLevel, info
|
||||
from mininet.log import setLogLevel
|
||||
from mininet.util import custom, pmonitor
|
||||
|
||||
def monitorhosts( hosts=5, sched='cfs' ):
|
||||
@@ -28,7 +27,7 @@ def monitorhosts( hosts=5, sched='cfs' ):
|
||||
# Monitor them and print output
|
||||
for host, line in pmonitor( popens ):
|
||||
if host:
|
||||
info( "<%s>: %s" % ( host.name, line ) )
|
||||
print "<%s>: %s" % ( host.name, line.strip() )
|
||||
# Done
|
||||
net.stop()
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
from mininet.net import Mininet
|
||||
from mininet.topo import SingleSwitchTopo
|
||||
from mininet.util import pmonitor
|
||||
from mininet.log import setLogLevel, info
|
||||
|
||||
from time import time
|
||||
from signal import SIGINT
|
||||
|
||||
@@ -16,21 +14,20 @@ def pmonitorTest( N=3, seconds=10 ):
|
||||
net = Mininet( topo )
|
||||
net.start()
|
||||
hosts = net.hosts
|
||||
info( "Starting test...\n" )
|
||||
print "Starting test..."
|
||||
server = hosts[ 0 ]
|
||||
popens = {}
|
||||
for h in hosts:
|
||||
popens[ h ] = h.popen('ping', server.IP() )
|
||||
info( "Monitoring output for", seconds, "seconds\n" )
|
||||
print "Monitoring output for", seconds, "seconds"
|
||||
endTime = time() + seconds
|
||||
for h, line in pmonitor( popens, timeoutms=500 ):
|
||||
if h:
|
||||
info( '<%s>: %s' % ( h.name, line ) )
|
||||
print '<%s>: %s' % ( h.name, line ),
|
||||
if time() >= endTime:
|
||||
for p in popens.values():
|
||||
p.send_signal( SIGINT )
|
||||
net.stop()
|
||||
|
||||
if __name__ == '__main__':
|
||||
setLogLevel( 'info' )
|
||||
pmonitorTest()
|
||||
|
||||
@@ -8,7 +8,6 @@ but it exposes the configuration details and allows customization.
|
||||
For most tasks, the higher-level API will be preferable.
|
||||
"""
|
||||
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import Node
|
||||
from mininet.link import Link
|
||||
@@ -41,7 +40,7 @@ def scratchNet( cname='controller', cargs='-v ptcp:' ):
|
||||
switch.cmd( 'ovs-vsctl del-br dp0' )
|
||||
switch.cmd( 'ovs-vsctl add-br dp0' )
|
||||
for intf in switch.intfs.values():
|
||||
switch.cmd( 'ovs-vsctl add-port dp0 %s\n' % intf )
|
||||
print switch.cmd( 'ovs-vsctl add-port dp0 %s' % intf )
|
||||
|
||||
# Note: controller and switch are in root namespace, and we
|
||||
# can connect via loopback interface
|
||||
|
||||
@@ -52,7 +52,7 @@ def scratchNetUser( cname='controller', cargs='ptcp:' ):
|
||||
info( '*** Starting controller and user datapath\n' )
|
||||
controller.cmd( cname + ' ' + cargs + '&' )
|
||||
switch.cmd( 'ifconfig lo 127.0.0.1' )
|
||||
intfs = str( sintf1 ), str( sintf2 )
|
||||
intfs = [ str( i ) for i in sintf1, sintf2 ]
|
||||
switch.cmd( 'ofdatapath -i ' + ','.join( intfs ) + ' ptcp: &' )
|
||||
switch.cmd( 'ofprotocol tcp:' + controller.IP() + ' tcp:localhost &' )
|
||||
|
||||
|
||||
@@ -9,22 +9,19 @@ iperf will hang indefinitely if the TCP handshake fails
|
||||
to complete.
|
||||
"""
|
||||
|
||||
|
||||
from mininet.topo import Topo
|
||||
from mininet.net import Mininet
|
||||
from mininet.node import CPULimitedHost
|
||||
from mininet.link import TCLink
|
||||
from mininet.util import dumpNodeConnections
|
||||
from mininet.log import setLogLevel, info
|
||||
from mininet.log import setLogLevel
|
||||
|
||||
from sys import argv
|
||||
|
||||
# It would be nice if we didn't have to do this:
|
||||
# pylint: disable=arguments-differ
|
||||
|
||||
class SingleSwitchTopo( Topo ):
|
||||
class SingleSwitchTopo(Topo):
|
||||
"Single switch connected to n hosts."
|
||||
def build( self, n=2, lossy=True ):
|
||||
def __init__(self, n=2, lossy=True, **opts):
|
||||
Topo.__init__(self, **opts)
|
||||
switch = self.addSwitch('s1')
|
||||
for h in range(n):
|
||||
# Each host gets 50%/n of system CPU
|
||||
@@ -47,9 +44,9 @@ def perfTest( lossy=True ):
|
||||
host=CPULimitedHost, link=TCLink,
|
||||
autoStaticArp=True )
|
||||
net.start()
|
||||
info( "Dumping host connections\n" )
|
||||
print "Dumping host connections"
|
||||
dumpNodeConnections(net.hosts)
|
||||
info( "Testing bandwidth between h1 and h4\n" )
|
||||
print "Testing bandwidth between h1 and h4"
|
||||
h1, h4 = net.getNodeByName('h1', 'h4')
|
||||
net.iperf( ( h1, h4 ), l4Type='UDP' )
|
||||
net.stop()
|
||||
|
||||
+8
-6
@@ -20,12 +20,11 @@ import sys
|
||||
|
||||
from mininet.net import Mininet
|
||||
from mininet.cli import CLI
|
||||
from mininet.log import lg, info
|
||||
from mininet.log import lg
|
||||
from mininet.node import Node
|
||||
from mininet.topolib import TreeTopo
|
||||
from mininet.util import waitListening
|
||||
|
||||
|
||||
def TreeNet( depth=1, fanout=2, **kwargs ):
|
||||
"Convenience function for creating tree networks."
|
||||
topo = TreeTopo( depth, fanout )
|
||||
@@ -60,14 +59,17 @@ def sshd( network, cmd='/usr/sbin/sshd', opts='-D',
|
||||
connectToRootNS( network, switch, ip, routes )
|
||||
for host in network.hosts:
|
||||
host.cmd( cmd + ' ' + opts + '&' )
|
||||
info( "*** Waiting for ssh daemons to start\n" )
|
||||
print "*** Waiting for ssh daemons to start"
|
||||
for server in network.hosts:
|
||||
waitListening( server=server, port=22, timeout=5 )
|
||||
|
||||
info( "\n*** Hosts are running sshd at the following addresses:\n" )
|
||||
print
|
||||
print "*** Hosts are running sshd at the following addresses:"
|
||||
print
|
||||
for host in network.hosts:
|
||||
info( host.name, host.IP(), '\n' )
|
||||
info( "\n*** Type 'exit' or control-D to shut down network\n" )
|
||||
print host.name, host.IP()
|
||||
print
|
||||
print "*** Type 'exit' or control-D to shut down network"
|
||||
CLI( network )
|
||||
for host in network.hosts:
|
||||
host.cmd( 'kill %' + cmd )
|
||||
|
||||
@@ -32,8 +32,7 @@ def runTests( testDir, verbosity=1 ):
|
||||
# discover all tests in testDir
|
||||
testSuite = unittest.defaultTestLoader.discover( testDir )
|
||||
# run tests
|
||||
success = MininetTestRunner( verbosity=verbosity ).run( testSuite ).wasSuccessful()
|
||||
sys.exit( 0 if success else 1 )
|
||||
MininetTestRunner( verbosity=verbosity ).run( testSuite )
|
||||
|
||||
if __name__ == '__main__':
|
||||
# get the directory containing example tests
|
||||
|
||||
@@ -5,9 +5,8 @@ Tests for baresshd.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
from mininet.clean import cleanup, sh
|
||||
from sys import stdout
|
||||
|
||||
class testBareSSHD( unittest.TestCase ):
|
||||
|
||||
@@ -15,9 +14,7 @@ class testBareSSHD( unittest.TestCase ):
|
||||
|
||||
def connected( self ):
|
||||
"Log into ssh server, check banner, then exit"
|
||||
p = pexpect.spawn( 'ssh 10.0.0.1 -o ConnectTimeout=1 '
|
||||
'-o StrictHostKeyChecking=no '
|
||||
'-i /tmp/ssh/test_rsa exit' )
|
||||
p = pexpect.spawn( 'ssh 10.0.0.1 -o StrictHostKeyChecking=no -i /tmp/ssh/test_rsa exit' )
|
||||
while True:
|
||||
index = p.expect( self.opts )
|
||||
if index == 0:
|
||||
@@ -25,7 +22,6 @@ class testBareSSHD( unittest.TestCase ):
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def setUp( self ):
|
||||
# verify that sshd is not running
|
||||
self.assertFalse( self.connected() )
|
||||
@@ -59,7 +55,7 @@ class testBareSSHD( unittest.TestCase ):
|
||||
|
||||
def tearDown( self ):
|
||||
# kill the ssh process
|
||||
sh( "ps aux | grep ssh |grep Banner| awk '{ print $2 }' | xargs kill" )
|
||||
sh( "ps aux | grep 'ssh.*Banner' | awk '{ print $2 }' | xargs kill" )
|
||||
cleanup()
|
||||
# remove public key pair
|
||||
sh( 'rm -rf /tmp/ssh' )
|
||||
|
||||
@@ -5,7 +5,7 @@ Tests for bind.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
|
||||
class testBind( unittest.TestCase ):
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ A simple sanity check test for cluster edition
|
||||
'''
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
|
||||
class clusterSanityCheck( unittest.TestCase ):
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Tests for controllers.py and controllers2.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
|
||||
class testControllers( unittest.TestCase ):
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for controlnet.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
|
||||
class testControlNet( unittest.TestCase ):
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ cfs 10% 1.29e+09
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
import sys
|
||||
|
||||
class testCPU( unittest.TestCase ):
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for emptynet.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
|
||||
class testEmptyNet( unittest.TestCase ):
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ Test for hwintf.py
|
||||
import unittest
|
||||
import re
|
||||
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
|
||||
from mininet.log import setLogLevel
|
||||
from mininet.node import Node
|
||||
@@ -57,8 +57,8 @@ class testHwintf( unittest.TestCase ):
|
||||
p.wait()
|
||||
|
||||
def tearDown( self ):
|
||||
self.h3.stop( deleteIntfs=True )
|
||||
self.n0.stop( deleteIntfs=True )
|
||||
self.h3.terminate()
|
||||
self.n0.terminate()
|
||||
|
||||
if __name__ == '__main__':
|
||||
setLogLevel( 'warning' )
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for intfOptions.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
import sys
|
||||
|
||||
class testIntfOptions( unittest.TestCase ):
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for limit.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
import sys
|
||||
|
||||
class testLimit( unittest.TestCase ):
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for linearbandwidth.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
import sys
|
||||
|
||||
class testLinearBandwidth( unittest.TestCase ):
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for linuxrouter.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
from mininet.util import quietRun
|
||||
|
||||
class testLinuxRouter( unittest.TestCase ):
|
||||
|
||||
@@ -6,7 +6,7 @@ validates mininet interfaces against systems interfaces
|
||||
'''
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
|
||||
class testMultiLink( unittest.TestCase ):
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for multiping.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
from collections import defaultdict
|
||||
|
||||
class testMultiPing( unittest.TestCase ):
|
||||
@@ -31,20 +31,18 @@ class testMultiPing( unittest.TestCase ):
|
||||
target = p.match.group(3)
|
||||
received = int( p.match.group(4) )
|
||||
if target == '10.0.0.200':
|
||||
self.assertEqual( received, 0, p.match.group(0) + '\n' +
|
||||
target + ' received %d != 0 packets' % received )
|
||||
self.assertEqual( received, 0 )
|
||||
else:
|
||||
self.assertEqual( received, 1, p.match.group(0) + '\n' +
|
||||
target + ' received %d != 1 packets' % received )
|
||||
self.assertEqual( received, 1 )
|
||||
try:
|
||||
pings[ name ].remove( target )
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
break
|
||||
self.assertTrue( len( pings ) > 0, 'too few pings' )
|
||||
self.assertTrue( len( pings ) > 0 )
|
||||
for t in pings.values():
|
||||
self.assertEqual( len( t ), 0, 'missed ping target(s): %s' % t )
|
||||
self.assertEqual( len( t ), 0 )
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for multipoll.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
|
||||
class testMultiPoll( unittest.TestCase ):
|
||||
|
||||
@@ -16,7 +16,7 @@ class testMultiPoll( unittest.TestCase ):
|
||||
"(h\d+): \d+ bytes from",
|
||||
"Monitoring output for (\d+) seconds",
|
||||
pexpect.EOF ]
|
||||
pings, seconds = {}, -1
|
||||
pings = {}
|
||||
while True:
|
||||
index = p.expect( opts )
|
||||
if index == 0:
|
||||
@@ -32,8 +32,7 @@ class testMultiPoll( unittest.TestCase ):
|
||||
self.assertTrue( len( pings ) > 0 )
|
||||
# make sure we have received at least one ping per second
|
||||
for count in pings.values():
|
||||
self.assertTrue( count >= seconds,
|
||||
'%d pings < %d seconds' % ( count, seconds ) )
|
||||
self.assertTrue( count >= seconds )
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for multitest.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
|
||||
class testMultiTest( unittest.TestCase ):
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for nat.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
from mininet.util import quietRun
|
||||
|
||||
destIP = '8.8.8.8' # Google DNS
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for natnet.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
from mininet.util import quietRun
|
||||
|
||||
class testNATNet( unittest.TestCase ):
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for numberedports.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
from collections import defaultdict
|
||||
from mininet.node import OVSSwitch
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for popen.py and popenpoll.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
|
||||
class testPopen( unittest.TestCase ):
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for scratchnet.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
|
||||
class testScratchNet( unittest.TestCase ):
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for simpleperf.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
import sys
|
||||
from mininet.log import setLogLevel
|
||||
|
||||
@@ -18,7 +18,7 @@ class testSimplePerf( unittest.TestCase ):
|
||||
"Run the example and verify iperf results"
|
||||
# 10 Mb/s, plus or minus 20% tolerance
|
||||
BW = 10
|
||||
TOLERANCE = .2
|
||||
TOLERANCE = .2
|
||||
p = pexpect.spawn( 'python -m mininet.examples.simpleperf testmode' )
|
||||
# check iperf results
|
||||
p.expect( "Results: \['10M', '([\d\.]+) .bits/sec", timeout=480 )
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for sshd.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
from mininet.clean import sh
|
||||
|
||||
class testSSHD( unittest.TestCase ):
|
||||
@@ -20,7 +20,7 @@ class testSSHD( unittest.TestCase ):
|
||||
while True:
|
||||
index = p.expect( self.opts )
|
||||
if index == 0:
|
||||
print( p.match.group(0) )
|
||||
print p.match.group(0)
|
||||
p.sendline( 'yes' )
|
||||
elif index == 1:
|
||||
return False
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for tree1024.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
import sys
|
||||
|
||||
class testTree1024( unittest.TestCase ):
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for treeping64.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
import sys
|
||||
|
||||
class testTreePing64( unittest.TestCase ):
|
||||
|
||||
@@ -5,7 +5,7 @@ Test for vlanhost.py
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from mininet.util import pexpect
|
||||
import pexpect
|
||||
import sys
|
||||
from mininet.util import quietRun
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
"Create a 64-node tree network, and test connectivity using ping."
|
||||
|
||||
|
||||
from mininet.log import setLogLevel, info
|
||||
from mininet.log import setLogLevel
|
||||
from mininet.node import UserSwitch, OVSKernelSwitch # , KernelSwitch
|
||||
from mininet.topolib import TreeNet
|
||||
|
||||
@@ -16,16 +15,17 @@ def treePing64():
|
||||
'Open vSwitch kernel': OVSKernelSwitch }
|
||||
|
||||
for name in switches:
|
||||
info( "*** Testing", name, "datapath\n" )
|
||||
print "*** Testing", name, "datapath"
|
||||
switch = switches[ name ]
|
||||
network = TreeNet( depth=2, fanout=8, switch=switch )
|
||||
result = network.run( network.pingAll )
|
||||
results[ name ] = result
|
||||
|
||||
info( "\n*** Tree network ping results:\n" )
|
||||
print
|
||||
print "*** Tree network ping results:"
|
||||
for name in switches:
|
||||
info( "%s: %d%% packet loss\n" % ( name, results[ name ] ) )
|
||||
info( '\n' )
|
||||
print "%s: %d%% packet loss" % ( name, results[ name ] )
|
||||
print
|
||||
|
||||
if __name__ == '__main__':
|
||||
setLogLevel( 'info' )
|
||||
|
||||
+6
-7
@@ -16,13 +16,12 @@ import time
|
||||
|
||||
from mininet.log import info
|
||||
from mininet.term import cleanUpScreens
|
||||
from mininet.util import decode
|
||||
|
||||
|
||||
def sh( cmd ):
|
||||
"Print a command and send it to the shell"
|
||||
info( cmd + '\n' )
|
||||
result = Popen( [ '/bin/sh', '-c', cmd ], stdout=PIPE ).communicate()[ 0 ]
|
||||
return decode( result )
|
||||
return Popen( [ '/bin/sh', '-c', cmd ], stdout=PIPE ).communicate()[ 0 ]
|
||||
|
||||
def killprocs( pattern ):
|
||||
"Reliably terminate processes matching a pattern (including args)"
|
||||
@@ -51,9 +50,8 @@ class Cleanup( object ):
|
||||
|
||||
info( "*** Removing excess controllers/ofprotocols/ofdatapaths/"
|
||||
"pings/noxes\n" )
|
||||
zombies = ( 'controller ofprotocol ofdatapath ping nox_core'
|
||||
'lt-nox_core ovs-openflowd ovs-controller'
|
||||
'ovs-testcontroller udpbwtest mnexec ivs ryu-manager' )
|
||||
zombies = 'controller ofprotocol ofdatapath ping nox_core lt-nox_core '
|
||||
zombies += 'ovs-openflowd ovs-controller udpbwtest mnexec ivs'
|
||||
# Note: real zombie processes can't actually be killed, since they
|
||||
# are already (un)dead. Then again,
|
||||
# you can't connect to them either, so they're mostly harmless.
|
||||
@@ -77,6 +75,7 @@ class Cleanup( object ):
|
||||
for dp in dps:
|
||||
if dp:
|
||||
sh( 'dpctl deldp ' + dp )
|
||||
|
||||
info( "*** Removing OVS datapaths\n" )
|
||||
dps = sh("ovs-vsctl --timeout=1 list-br").strip().splitlines()
|
||||
if dps:
|
||||
@@ -93,7 +92,7 @@ class Cleanup( object ):
|
||||
).splitlines()
|
||||
# Delete blocks of links
|
||||
n = 1000 # chunk size
|
||||
for i in range( 0, len( links ), n ):
|
||||
for i in xrange( 0, len( links ), n ):
|
||||
cmd = ';'.join( 'ip link del %s' % link
|
||||
for link in links[ i : i + n ] )
|
||||
sh( '( %s ) 2> /dev/null' % cmd )
|
||||
|
||||
+7
-8
@@ -178,7 +178,7 @@ class CLI( Cmd ):
|
||||
output( result + '\n' )
|
||||
else:
|
||||
output( repr( result ) + '\n' )
|
||||
except Exception as e:
|
||||
except Exception, e:
|
||||
output( str( e ) + '\n' )
|
||||
|
||||
# We are in fact using the exec() pseudo-function
|
||||
@@ -189,7 +189,7 @@ class CLI( Cmd ):
|
||||
Node names may be used, e.g.: px print h1.cmd('ls')"""
|
||||
try:
|
||||
exec( line, globals(), self.getLocals() )
|
||||
except Exception as e:
|
||||
except Exception, e:
|
||||
output( str( e ) + '\n' )
|
||||
|
||||
# pylint: enable=broad-except,exec-used
|
||||
@@ -373,7 +373,7 @@ class CLI( Cmd ):
|
||||
def do_links( self, _line ):
|
||||
"Report on links"
|
||||
for link in self.mn.links:
|
||||
output( link, link.status(), '\n' )
|
||||
print link, link.status()
|
||||
|
||||
def do_switch( self, line ):
|
||||
"Starts or stops a switch"
|
||||
@@ -399,16 +399,15 @@ class CLI( Cmd ):
|
||||
|
||||
def default( self, line ):
|
||||
"""Called on an input line when the command prefix is not recognized.
|
||||
Overridden to run shell commands when a node is the first
|
||||
CLI argument. Past the first CLI argument, node names are
|
||||
automatically replaced with corresponding IP addrs."""
|
||||
Overridden to run shell commands when a node is the first CLI argument.
|
||||
Past the first CLI argument, node names are automatically replaced with
|
||||
corresponding IP addrs."""
|
||||
|
||||
first, args, line = self.parseline( line )
|
||||
|
||||
if first in self.mn:
|
||||
if not args:
|
||||
error( '*** Please enter a command for node: %s <cmd>\n'
|
||||
% first )
|
||||
print "*** Enter a command for node: %s <cmd>" % first
|
||||
return
|
||||
node = self.mn[ first ]
|
||||
rest = args.split( ' ' )
|
||||
|
||||
+20
-19
@@ -26,6 +26,7 @@ Link: basic link class for creating veth pairs
|
||||
|
||||
from mininet.log import info, error, debug
|
||||
from mininet.util import makeIntfPair
|
||||
import mininet.node
|
||||
import re
|
||||
|
||||
class Intf( object ):
|
||||
@@ -50,12 +51,11 @@ class Intf( object ):
|
||||
self.ip = '127.0.0.1'
|
||||
self.prefixLen = 8
|
||||
# Add to node (and move ourselves if necessary )
|
||||
if node:
|
||||
moveIntfFn = params.pop( 'moveIntfFn', None )
|
||||
if moveIntfFn:
|
||||
node.addIntf( self, port=port, moveIntfFn=moveIntfFn )
|
||||
else:
|
||||
node.addIntf( self, port=port )
|
||||
moveIntfFn = params.pop( 'moveIntfFn', None )
|
||||
if moveIntfFn:
|
||||
node.addIntf( self, port=port, moveIntfFn=moveIntfFn )
|
||||
else:
|
||||
node.addIntf( self, port=port )
|
||||
# Save params for future reference
|
||||
self.params = params
|
||||
self.config( **params )
|
||||
@@ -164,7 +164,7 @@ class Intf( object ):
|
||||
method: config method name
|
||||
param: arg=value (ignore if value=None)
|
||||
value may also be list or dict"""
|
||||
name, value = list( param.items() )[ 0 ]
|
||||
name, value = param.items()[ 0 ]
|
||||
f = getattr( self, method, None )
|
||||
if not f or value is None:
|
||||
return
|
||||
@@ -202,8 +202,6 @@ class Intf( object ):
|
||||
# if self.node.inNamespace:
|
||||
# Link may have been dumped into root NS
|
||||
# quietRun( 'ip link del ' + self.name )
|
||||
self.node.delIntf( self )
|
||||
self.link = None
|
||||
|
||||
def status( self ):
|
||||
"Return intf status as a string"
|
||||
@@ -253,7 +251,7 @@ class TCIntf( Intf ):
|
||||
+ 'rate %fMbit ul rate %fMbit' % ( bw, bw ) ]
|
||||
elif use_tbf:
|
||||
if latency_ms is None:
|
||||
latency_ms = 15.0 * 8 / bw
|
||||
latency_ms = 15 * 8 / bw
|
||||
cmds += [ '%s qdisc add dev %s root handle 5: tbf ' +
|
||||
'rate %fMbit burst 15000 latency %fms' %
|
||||
( bw, latency_ms ) ]
|
||||
@@ -285,14 +283,18 @@ class TCIntf( Intf ):
|
||||
loss=None, max_queue_size=None ):
|
||||
"Internal method: return tc commands for delay and loss"
|
||||
cmds = []
|
||||
if loss and ( loss < 0 or loss > 100 ):
|
||||
if delay and delay < 0:
|
||||
error( 'Negative delay', delay, '\n' )
|
||||
elif jitter and jitter < 0:
|
||||
error( 'Negative jitter', jitter, '\n' )
|
||||
elif loss and ( loss < 0 or loss > 100 ):
|
||||
error( 'Bad loss percentage', loss, '%%\n' )
|
||||
else:
|
||||
# Delay/jitter/loss/max queue size
|
||||
netemargs = '%s%s%s%s' % (
|
||||
'delay %s ' % delay if delay is not None else '',
|
||||
'%s ' % jitter if jitter is not None else '',
|
||||
'loss %.5f ' % loss if loss is not None else '',
|
||||
'loss %d ' % loss if loss is not None else '',
|
||||
'limit %d' % max_queue_size if max_queue_size is not None
|
||||
else '' )
|
||||
if netemargs:
|
||||
@@ -376,7 +378,7 @@ class TCIntf( Intf ):
|
||||
stuff = ( ( [ '%.2fMbit' % bw ] if bw is not None else [] ) +
|
||||
( [ '%s delay' % delay ] if delay is not None else [] ) +
|
||||
( [ '%s jitter' % jitter ] if jitter is not None else [] ) +
|
||||
( ['%.5f%% loss' % loss ] if loss is not None else [] ) +
|
||||
( ['%d%% loss' % loss ] if loss is not None else [] ) +
|
||||
( [ 'ECN' ] if enable_ecn else [ 'RED' ]
|
||||
if enable_red else [] ) )
|
||||
info( '(' + ' '.join( stuff ) + ') ' )
|
||||
@@ -493,9 +495,9 @@ class Link( object ):
|
||||
def delete( self ):
|
||||
"Delete this link"
|
||||
self.intf1.delete()
|
||||
self.intf1 = None
|
||||
self.intf2.delete()
|
||||
self.intf2 = None
|
||||
# We only need to delete one side, though this doesn't seem to
|
||||
# cost us much and might help subclasses.
|
||||
# self.intf2.delete()
|
||||
|
||||
def stop( self ):
|
||||
"Override to stop and clean up link as needed"
|
||||
@@ -528,10 +530,9 @@ class OVSLink( Link ):
|
||||
|
||||
def __init__( self, node1, node2, **kwargs ):
|
||||
"See Link.__init__() for options"
|
||||
from mininet.node import OVSSwitch
|
||||
self.isPatchLink = False
|
||||
if ( isinstance( node1, OVSSwitch ) and
|
||||
isinstance( node2, OVSSwitch ) ):
|
||||
if ( isinstance( node1, mininet.node.OVSSwitch ) and
|
||||
isinstance( node2, mininet.node.OVSSwitch ) ):
|
||||
self.isPatchLink = True
|
||||
kwargs.update( cls1=OVSIntf, cls2=OVSIntf )
|
||||
Link.__init__( self, node1, node2, **kwargs )
|
||||
|
||||
+5
-6
@@ -160,7 +160,7 @@ def makeListCompatible( fn ):
|
||||
"Generated function. Closure-ish."
|
||||
if len( args ) == 1:
|
||||
return fn( *args )
|
||||
args = ' '.join( str( arg ) for arg in args )
|
||||
args = ' '.join( [ str( arg ) for arg in args ] )
|
||||
return fn( args )
|
||||
|
||||
# Fix newfn's name and docstring
|
||||
@@ -168,10 +168,9 @@ def makeListCompatible( fn ):
|
||||
setattr( newfn, '__doc__', fn.__doc__ )
|
||||
return newfn
|
||||
|
||||
_loggers = lg.info, lg.output, lg.warn, lg.error, lg.debug
|
||||
_loggers = tuple( makeListCompatible( logger )
|
||||
for logger in _loggers )
|
||||
lg.info, lg.output, lg.warn, lg.error, lg.debug = _loggers
|
||||
info, output, warn, error, debug = _loggers
|
||||
info, output, warn, error, debug = (
|
||||
lg.info, lg.output, lg.warn, lg.error, lg.debug ) = [
|
||||
makeListCompatible( f ) for f in
|
||||
lg.info, lg.output, lg.warn, lg.error, lg.debug ]
|
||||
|
||||
setLogLevel = lg.setLogLevel
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"Module dependency utility functions for Mininet."
|
||||
|
||||
from mininet.util import quietRun, BaseString
|
||||
from mininet.util import quietRun
|
||||
from mininet.log import info, error, debug
|
||||
from os import environ
|
||||
|
||||
@@ -28,9 +28,9 @@ def moduleDeps( subtract=None, add=None ):
|
||||
add: string or list of module names to add, if not already loaded"""
|
||||
subtract = subtract if subtract is not None else []
|
||||
add = add if add is not None else []
|
||||
if isinstance( subtract, BaseString ):
|
||||
if isinstance( subtract, basestring ):
|
||||
subtract = [ subtract ]
|
||||
if isinstance( add, BaseString ):
|
||||
if isinstance( add, basestring ):
|
||||
add = [ add ]
|
||||
for mod in subtract:
|
||||
if mod in lsmod():
|
||||
|
||||
+17
-74
@@ -104,11 +104,11 @@ from mininet.nodelib import NAT
|
||||
from mininet.link import Link, Intf
|
||||
from mininet.util import ( quietRun, fixLimits, numCores, ensureRoot,
|
||||
macColonHex, ipStr, ipParse, netParse, ipAdd,
|
||||
waitListening, BaseString )
|
||||
waitListening )
|
||||
from mininet.term import cleanUpScreens, makeTerms
|
||||
|
||||
# Mininet version: should be consistent with README and LICENSE
|
||||
VERSION = "2.3.0d1"
|
||||
VERSION = "2.2.2"
|
||||
|
||||
class Mininet( object ):
|
||||
"Network emulation with hosts spawned in network namespaces."
|
||||
@@ -144,9 +144,7 @@ class Mininet( object ):
|
||||
self.intf = intf
|
||||
self.ipBase = ipBase
|
||||
self.ipBaseNum, self.prefixLen = netParse( self.ipBase )
|
||||
hostIP = ( 0xffffffff >> self.prefixLen ) & self.ipBaseNum
|
||||
# Start for address allocation
|
||||
self.nextIP = hostIP if hostIP > 0 else 1
|
||||
self.nextIP = 1 # start for address allocation
|
||||
self.inNamespace = inNamespace
|
||||
self.xterms = xterms
|
||||
self.cleanup = cleanup
|
||||
@@ -190,7 +188,7 @@ class Mininet( object ):
|
||||
if not remaining:
|
||||
info( '\n' )
|
||||
return True
|
||||
if timeout is not None and time > timeout:
|
||||
if time > timeout and timeout is not None:
|
||||
break
|
||||
sleep( delay )
|
||||
time += delay
|
||||
@@ -228,24 +226,6 @@ class Mininet( object ):
|
||||
self.nameToNode[ name ] = h
|
||||
return h
|
||||
|
||||
def delNode( self, node, nodes=None):
|
||||
"""Delete node
|
||||
node: node to delete
|
||||
nodes: optional list to delete from (e.g. self.hosts)"""
|
||||
if nodes is None:
|
||||
nodes = ( self.hosts if node in self.hosts else
|
||||
( self.switches if node in self.switches else
|
||||
( self.controllers if node in self.controllers else
|
||||
[] ) ) )
|
||||
node.stop( deleteIntfs=True )
|
||||
node.terminate()
|
||||
nodes.remove( node )
|
||||
del self.nameToNode[ node.name ]
|
||||
|
||||
def delHost( self, host ):
|
||||
"Delete a host"
|
||||
self.delNode( host, nodes=self.hosts )
|
||||
|
||||
def addSwitch( self, name, cls=None, **params ):
|
||||
"""Add switch.
|
||||
name: name of switch to add
|
||||
@@ -264,10 +244,6 @@ class Mininet( object ):
|
||||
self.nameToNode[ name ] = sw
|
||||
return sw
|
||||
|
||||
def delSwitch( self, switch ):
|
||||
"Delete a switch"
|
||||
self.delNode( switch, nodes=self.switches )
|
||||
|
||||
def addController( self, name='c0', controller=None, **params ):
|
||||
"""Add controller.
|
||||
controller: Controller class"""
|
||||
@@ -289,12 +265,6 @@ class Mininet( object ):
|
||||
self.nameToNode[ name ] = controller_new
|
||||
return controller_new
|
||||
|
||||
def delController( self, controller ):
|
||||
"""Delete a controller
|
||||
Warning - does not reconfigure switches, so they
|
||||
may still attempt to connect to it!"""
|
||||
self.delNode( controller )
|
||||
|
||||
def addNAT( self, name='nat0', connect=True, inNamespace=False,
|
||||
**params):
|
||||
"""Add a NAT to the Mininet network
|
||||
@@ -333,13 +303,9 @@ class Mininet( object ):
|
||||
|
||||
# Even more convenient syntax for node lookup and iteration
|
||||
def __getitem__( self, key ):
|
||||
"net[ name ] operator: Return node with given name"
|
||||
"""net [ name ] operator: Return node(s) with given name(s)"""
|
||||
return self.nameToNode[ key ]
|
||||
|
||||
def __delitem__( self, key ):
|
||||
"del net[ name ] operator - delete node with given name"
|
||||
self.delNode( self.nameToNode[ key ] )
|
||||
|
||||
def __iter__( self ):
|
||||
"return iterator over node names"
|
||||
for node in chain( self.hosts, self.switches, self.controllers ):
|
||||
@@ -383,8 +349,8 @@ class Mininet( object ):
|
||||
params: additional link params (optional)
|
||||
returns: link object"""
|
||||
# Accept node objects or names
|
||||
node1 = node1 if not isinstance( node1, BaseString ) else self[ node1 ]
|
||||
node2 = node2 if not isinstance( node2, BaseString ) else self[ node2 ]
|
||||
node1 = node1 if not isinstance( node1, basestring ) else self[ node1 ]
|
||||
node2 = node2 if not isinstance( node2, basestring ) else self[ node2 ]
|
||||
options = dict( params )
|
||||
# Port is optional
|
||||
if port1 is not None:
|
||||
@@ -401,30 +367,6 @@ class Mininet( object ):
|
||||
self.links.append( link )
|
||||
return link
|
||||
|
||||
def delLink( self, link ):
|
||||
"Remove a link from this network"
|
||||
link.delete()
|
||||
self.links.remove( link )
|
||||
|
||||
def linksBetween( self, node1, node2 ):
|
||||
"Return Links between node1 and node2"
|
||||
return [ link for link in self.links
|
||||
if ( node1, node2 ) in (
|
||||
( link.intf1.node, link.intf2.node ),
|
||||
( link.intf2.node, link.intf1.node ) ) ]
|
||||
|
||||
def delLinkBetween( self, node1, node2, index=0, allLinks=False ):
|
||||
"""Delete link(s) between node1 and node2
|
||||
index: index of link to delete if multiple links (0)
|
||||
allLinks: ignore index and delete all such links (False)
|
||||
returns: deleted link(s)"""
|
||||
links = self.linksBetween( node1, node2 )
|
||||
if not allLinks:
|
||||
links = [ links[ index ] ]
|
||||
for link in links:
|
||||
self.delLink( link )
|
||||
return links
|
||||
|
||||
def configHosts( self ):
|
||||
"Configure a set of hosts."
|
||||
for host in self.hosts:
|
||||
@@ -549,8 +491,7 @@ class Mininet( object ):
|
||||
switch.start( self.controllers )
|
||||
started = {}
|
||||
for swclass, switches in groupby(
|
||||
sorted( self.switches,
|
||||
key=lambda s: str( type( s ) ) ), type ):
|
||||
sorted( self.switches, key=type ), type ):
|
||||
switches = tuple( switches )
|
||||
if hasattr( swclass, 'batchStartup' ):
|
||||
success = swclass.batchStartup( switches )
|
||||
@@ -577,8 +518,7 @@ class Mininet( object ):
|
||||
info( '*** Stopping %i switches\n' % len( self.switches ) )
|
||||
stopped = {}
|
||||
for swclass, switches in groupby(
|
||||
sorted( self.switches,
|
||||
key=lambda s: str( type( s ) ) ), type ):
|
||||
sorted( self.switches, key=type ), type ):
|
||||
switches = tuple( switches )
|
||||
if hasattr( swclass, 'batchShutdown' ):
|
||||
success = swclass.batchShutdown( switches )
|
||||
@@ -636,7 +576,7 @@ class Mininet( object ):
|
||||
# Check for downed link
|
||||
if 'connect: Network is unreachable' in pingOutput:
|
||||
return 1, 0
|
||||
r = r'(\d+) packets transmitted, (\d+)( packets)? received'
|
||||
r = r'(\d+) packets transmitted, (\d+) received'
|
||||
m = re.search( r, pingOutput )
|
||||
if m is None:
|
||||
error( '*** Error: could not parse ping output: %s\n' %
|
||||
@@ -698,7 +638,7 @@ class Mininet( object ):
|
||||
m = re.search( r, pingOutput )
|
||||
if m is not None:
|
||||
return errorTuple
|
||||
r = r'(\d+) packets transmitted, (\d+)( packets)? received'
|
||||
r = r'(\d+) packets transmitted, (\d+) received'
|
||||
m = re.search( r, pingOutput )
|
||||
if m is None:
|
||||
error( '*** Error: could not parse ping output: %s\n' %
|
||||
@@ -829,7 +769,7 @@ class Mininet( object ):
|
||||
debug( 'Client output: %s\n' % cliout )
|
||||
servout = ''
|
||||
# We want the last *b/sec from the iperf server output
|
||||
# for TCP, there are two of them because of waitListening
|
||||
# for TCP, there are two fo them because of waitListening
|
||||
count = 2 if l4Type == 'TCP' else 1
|
||||
while len( re.findall( '/sec', servout ) ) < count:
|
||||
servout += server.monitor( timeoutms=5000 )
|
||||
@@ -848,6 +788,7 @@ class Mininet( object ):
|
||||
duration: test duration in seconds (integer)
|
||||
returns a single list of measured CPU fractions as floats.
|
||||
"""
|
||||
cores = int( quietRun( 'nproc' ) )
|
||||
pct = cpu * 100
|
||||
info( '*** Testing CPU %.0f%% bandwidth limit\n' % pct )
|
||||
hosts = self.hosts
|
||||
@@ -899,8 +840,10 @@ class Mininet( object ):
|
||||
elif dst not in self.nameToNode:
|
||||
error( 'dst not in network: %s\n' % dst )
|
||||
else:
|
||||
src = self.nameToNode[ src ]
|
||||
dst = self.nameToNode[ dst ]
|
||||
if isinstance( src, basestring ):
|
||||
src = self.nameToNode[ src ]
|
||||
if isinstance( dst, basestring ):
|
||||
dst = self.nameToNode[ dst ]
|
||||
connections = src.connectionsTo( dst )
|
||||
if len( connections ) == 0:
|
||||
error( 'src and dst not connected: %s %s\n' % ( src, dst) )
|
||||
|
||||
+24
-48
@@ -62,8 +62,7 @@ from time import sleep
|
||||
|
||||
from mininet.log import info, error, warn, debug
|
||||
from mininet.util import ( quietRun, errRun, errFail, moveIntf, isShellBuiltin,
|
||||
numCores, retry, mountCgroups, BaseString, decode,
|
||||
encode, Python3 )
|
||||
numCores, retry, mountCgroups )
|
||||
from mininet.moduledeps import moduleDeps, pathCheck, TUN
|
||||
from mininet.link import Link, Intf, TCIntf, OVSIntf
|
||||
from re import findall
|
||||
@@ -88,9 +87,6 @@ class Node( object ):
|
||||
self.privateDirs = params.get( 'privateDirs', [] )
|
||||
self.inNamespace = params.get( 'inNamespace', inNamespace )
|
||||
|
||||
# Python 3 complains if we don't wait for shell exit
|
||||
self.waitExited = params.get( 'waitExited', Python3 == True )
|
||||
|
||||
# Stash configuration parameters for future reference
|
||||
self.params = params
|
||||
|
||||
@@ -139,18 +135,14 @@ class Node( object ):
|
||||
# -s: pass $* to shell, and make process easy to find in ps
|
||||
# prompt is set to sentinel chr( 127 )
|
||||
cmd = [ 'mnexec', opts, 'env', 'PS1=' + chr( 127 ),
|
||||
'bash', '--norc', '--noediting',
|
||||
'-is', 'mininet:' + self.name ]
|
||||
|
||||
'bash', '--norc', '-is', 'mininet:' + self.name ]
|
||||
# Spawn a shell subprocess in a pseudo-tty, to disable buffering
|
||||
# in the subprocess and insulate it from signals (e.g. SIGINT)
|
||||
# received by the parent
|
||||
master, slave = pty.openpty()
|
||||
self.shell = self._popen( cmd, stdin=slave, stdout=slave, stderr=slave,
|
||||
close_fds=False )
|
||||
# XXX BL: This doesn't seem right, and we should also probably
|
||||
# close our files when we exit...
|
||||
self.stdin = os.fdopen( master, 'r' )
|
||||
self.stdin = os.fdopen( master, 'rw' )
|
||||
self.stdout = self.stdin
|
||||
self.pid = self.shell.pid
|
||||
self.pollOut = select.poll()
|
||||
@@ -177,7 +169,7 @@ class Node( object ):
|
||||
def mountPrivateDirs( self ):
|
||||
"mount private directories"
|
||||
# Avoid expanding a string into a list of chars
|
||||
assert not isinstance( self.privateDirs, BaseString )
|
||||
assert not isinstance( self.privateDirs, basestring )
|
||||
for directory in self.privateDirs:
|
||||
if isinstance( directory, tuple ):
|
||||
# mount given private directory
|
||||
@@ -206,9 +198,7 @@ class Node( object ):
|
||||
params: parameters to Popen()"""
|
||||
# Leave this is as an instance method for now
|
||||
assert self
|
||||
popen = Popen( cmd, **params )
|
||||
debug( '_popen', cmd, popen.pid )
|
||||
return popen
|
||||
return Popen( cmd, **params )
|
||||
|
||||
def cleanup( self ):
|
||||
"Help python collect its garbage."
|
||||
@@ -217,9 +207,6 @@ class Node( object ):
|
||||
# for intfName in self.intfNames():
|
||||
# if self.name in intfName:
|
||||
# quietRun( 'ip link del ' + intfName )
|
||||
if self.waitExited and self.shell:
|
||||
debug( 'waiting for', self.pid, 'to terminate\n' )
|
||||
self.shell.wait()
|
||||
self.shell = None
|
||||
|
||||
# Subshell I/O, commands and control
|
||||
@@ -229,7 +216,7 @@ class Node( object ):
|
||||
maxbytes: maximum number of bytes to return"""
|
||||
count = len( self.readbuf )
|
||||
if count < maxbytes:
|
||||
data = decode( os.read( self.stdout.fileno(), maxbytes - count ) )
|
||||
data = os.read( self.stdout.fileno(), maxbytes - count )
|
||||
self.readbuf += data
|
||||
if maxbytes >= len( self.readbuf ):
|
||||
result = self.readbuf
|
||||
@@ -253,7 +240,7 @@ class Node( object ):
|
||||
def write( self, data ):
|
||||
"""Write data to node.
|
||||
data: string"""
|
||||
os.write( self.stdin.fileno(), encode( data ) )
|
||||
os.write( self.stdin.fileno(), data )
|
||||
|
||||
def terminate( self ):
|
||||
"Send kill signal to Node and clean up after it."
|
||||
@@ -387,7 +374,7 @@ class Node( object ):
|
||||
if isinstance( args[ 0 ], list ):
|
||||
# popen([cmd, arg1, arg2...])
|
||||
cmd = args[ 0 ]
|
||||
elif isinstance( args[ 0 ], BaseString ):
|
||||
elif isinstance( args[ 0 ], basestring ):
|
||||
# popen("cmd arg1 arg2...")
|
||||
cmd = args[ 0 ].split()
|
||||
else:
|
||||
@@ -411,7 +398,7 @@ class Node( object ):
|
||||
# Warning: this can fail with large numbers of fds!
|
||||
out, err = popen.communicate()
|
||||
exitcode = popen.wait()
|
||||
return decode( out ), decode( err ), exitcode
|
||||
return out, err, exitcode
|
||||
|
||||
# Interface management, configuration, and routing
|
||||
|
||||
@@ -444,15 +431,6 @@ class Node( object ):
|
||||
debug( 'moving', intf, 'into namespace for', self.name, '\n' )
|
||||
moveIntfFn( intf.name, self )
|
||||
|
||||
def delIntf( self, intf ):
|
||||
"""Remove interface from Node's known interfaces
|
||||
Note: to fully delete interface, call intf.delete() instead"""
|
||||
port = self.ports.get( intf )
|
||||
if port is not None:
|
||||
del self.intfs[ port ]
|
||||
del self.ports[ intf ]
|
||||
del self.nameToIntf[ intf.name ]
|
||||
|
||||
def defaultIntf( self ):
|
||||
"Return interface for lowest port"
|
||||
ports = self.intfs.keys()
|
||||
@@ -473,7 +451,7 @@ class Node( object ):
|
||||
"""
|
||||
if not intf:
|
||||
return self.defaultIntf()
|
||||
elif isinstance( intf, BaseString):
|
||||
elif isinstance( intf, basestring):
|
||||
return self.nameToIntf[ intf ]
|
||||
else:
|
||||
return intf
|
||||
@@ -500,7 +478,7 @@ class Node( object ):
|
||||
# explicitly so that we won't get errors if we run before they
|
||||
# have been removed by the kernel. Unfortunately this is very slow,
|
||||
# at least with Linux kernels before 2.6.33
|
||||
for intf in list( self.intfs.values() ):
|
||||
for intf in self.intfs.values():
|
||||
# Protect against deleting hardware interfaces
|
||||
if ( self.name in intf.name ) or ( not checkName ):
|
||||
intf.delete()
|
||||
@@ -525,7 +503,7 @@ class Node( object ):
|
||||
"""Set the default route to go through intf.
|
||||
intf: Intf or {dev <intfname> via <gw-ip> ...}"""
|
||||
# Note setParam won't call us if intf is none
|
||||
if isinstance( intf, BaseString ) and ' ' in intf:
|
||||
if isinstance( intf, basestring ) and ' ' in intf:
|
||||
params = intf
|
||||
else:
|
||||
params = 'dev %s' % intf
|
||||
@@ -572,7 +550,7 @@ class Node( object ):
|
||||
method: config method name
|
||||
param: arg=value (ignore if value=None)
|
||||
value may also be list or dict"""
|
||||
name, value = list( param.items() )[ 0 ]
|
||||
name, value = param.items()[ 0 ]
|
||||
if value is None:
|
||||
return
|
||||
f = getattr( self, method, None )
|
||||
@@ -621,7 +599,7 @@ class Node( object ):
|
||||
|
||||
def intfList( self ):
|
||||
"List of our interfaces sorted by port number"
|
||||
return [ self.intfs[ p ] for p in sorted( self.intfs.keys() ) ]
|
||||
return [ self.intfs[ p ] for p in sorted( self.intfs.iterkeys() ) ]
|
||||
|
||||
def intfNames( self ):
|
||||
"The names of our interfaces sorted by port number"
|
||||
@@ -715,8 +693,8 @@ class CPULimitedHost( Host ):
|
||||
args: Popen() args, single list, or string
|
||||
kwargs: Popen() keyword args"""
|
||||
# Tell mnexec to execute command in our cgroup
|
||||
mncmd = kwargs.pop( 'mncmd', [ 'mnexec', '-g', self.name,
|
||||
'-da', str( self.pid ) ] )
|
||||
mncmd = [ 'mnexec', '-g', self.name,
|
||||
'-da', str( self.pid ) ]
|
||||
# if our cgroup is not given any cpu time,
|
||||
# we cannot assign the RR Scheduler.
|
||||
if self.sched == 'rt':
|
||||
@@ -892,7 +870,7 @@ class Switch( Node ):
|
||||
"Return correctly formatted dpid from dpid or switch name (s1 -> 1)"
|
||||
if dpid:
|
||||
# Remove any colons and make sure it's a good hex number
|
||||
dpid = dpid.replace( ':', '' )
|
||||
dpid = dpid.translate( None, ':' )
|
||||
assert len( dpid ) <= self.dpidLen and int( dpid, 16 ) >= 0
|
||||
else:
|
||||
# Use hex of the first number in the switch name
|
||||
@@ -900,7 +878,6 @@ class Switch( Node ):
|
||||
if nums:
|
||||
dpid = hex( int( nums[ 0 ] ) )[ 2: ]
|
||||
else:
|
||||
self.terminate() # Python 3.6 crash workaround
|
||||
raise Exception( 'Unable to derive default datapath ID - '
|
||||
'please either specify a dpid or use a '
|
||||
'canonical switch name such as s23.' )
|
||||
@@ -1174,7 +1151,6 @@ class OVSSwitch( Switch ):
|
||||
opts += ' protocols=%s' % self.protocols
|
||||
if self.stp and self.failMode == 'standalone':
|
||||
opts += ' stp_enable=true'
|
||||
opts += ' other-config:dp-desc=%s' % self.name
|
||||
return opts
|
||||
|
||||
def start( self, controllers ):
|
||||
@@ -1244,7 +1220,7 @@ class OVSSwitch( Switch ):
|
||||
run( cmds, shell=True )
|
||||
# Reapply link config if necessary...
|
||||
for switch in switches:
|
||||
for intf in switch.intfs.values():
|
||||
for intf in switch.intfs.itervalues():
|
||||
if isinstance( intf, TCIntf ):
|
||||
intf.config( **intf.params )
|
||||
return switches
|
||||
@@ -1270,7 +1246,7 @@ class OVSSwitch( Switch ):
|
||||
pids = ' '.join( str( switch.pid ) for switch in switches )
|
||||
run( 'kill -HUP ' + pids )
|
||||
for switch in switches:
|
||||
switch.terminate()
|
||||
switch.shell = None
|
||||
return switches
|
||||
|
||||
|
||||
@@ -1447,16 +1423,16 @@ class Controller( Node ):
|
||||
|
||||
class OVSController( Controller ):
|
||||
"Open vSwitch controller"
|
||||
def __init__( self, name, **kwargs ):
|
||||
kwargs.setdefault( 'command', self.isAvailable() or
|
||||
'ovs-controller' )
|
||||
Controller.__init__( self, name, **kwargs )
|
||||
def __init__( self, name, command='ovs-controller', **kwargs ):
|
||||
if quietRun( 'which test-controller' ):
|
||||
command = 'test-controller'
|
||||
Controller.__init__( self, name, command=command, **kwargs )
|
||||
|
||||
@classmethod
|
||||
def isAvailable( cls ):
|
||||
return ( quietRun( 'which ovs-controller' ) or
|
||||
quietRun( 'which test-controller' ) or
|
||||
quietRun( 'which ovs-testcontroller' ) ).strip()
|
||||
quietRun( 'which ovs-testcontroller' ) )
|
||||
|
||||
class NOX( Controller ):
|
||||
"Controller to run a NOX application."
|
||||
|
||||
@@ -21,9 +21,7 @@ def runTests( testDir, verbosity=1 ):
|
||||
# discover all tests in testDir
|
||||
testSuite = defaultTestLoader.discover( testDir )
|
||||
# run tests
|
||||
success = ( TextTestRunner( verbosity=verbosity )
|
||||
.run( testSuite ).wasSuccessful() )
|
||||
sys.exit( 0 if success else 1 )
|
||||
TextTestRunner( verbosity=verbosity ).run( testSuite )
|
||||
|
||||
if __name__ == '__main__':
|
||||
setLogLevel( 'warning' )
|
||||
|
||||
@@ -30,10 +30,10 @@ class TestSwitchDpidAssignmentOVS( unittest.TestCase ):
|
||||
def testDefaultDpid( self ):
|
||||
"""Verify that the default dpid is assigned using a valid provided
|
||||
canonical switchname if no dpid is passed in switch creation."""
|
||||
net = Mininet( Topo(), self.switchClass, Host, Controller )
|
||||
switch = net.addSwitch( 's1' )
|
||||
switch = Mininet( Topo(),
|
||||
self.switchClass,
|
||||
Host, Controller ).addSwitch( 's1' )
|
||||
self.assertEqual( switch.defaultDpid(), switch.dpid )
|
||||
net.stop()
|
||||
|
||||
def dpidFrom( self, num ):
|
||||
"Compute default dpid from number"
|
||||
@@ -44,34 +44,31 @@ class TestSwitchDpidAssignmentOVS( unittest.TestCase ):
|
||||
"""Verify that Switch dpid is the actual dpid assigned if dpid is
|
||||
passed in switch creation."""
|
||||
dpid = self.dpidFrom( 0xABCD )
|
||||
net = Mininet( Topo(), self.switchClass, Host, Controller )
|
||||
switch = net.addSwitch( 's1', dpid=dpid )
|
||||
switch = Mininet( Topo(), self.switchClass,
|
||||
Host, Controller ).addSwitch(
|
||||
's1', dpid=dpid )
|
||||
self.assertEqual( switch.dpid, dpid )
|
||||
net.stop()
|
||||
|
||||
def testDefaultDpidAssignmentFailure( self ):
|
||||
"""Verify that Default dpid assignment raises an Exception if the
|
||||
name of the switch does not contin a digit. Also verify the
|
||||
exception message."""
|
||||
net = Mininet( Topo(), self.switchClass, Host, Controller )
|
||||
with self.assertRaises( Exception ) as raises_cm:
|
||||
net.addSwitch( 'A' )
|
||||
self.assertTrue( 'Unable to derive '
|
||||
Mininet( Topo(), self.switchClass,
|
||||
Host, Controller ).addSwitch( 'A' )
|
||||
self.assertEqual(raises_cm.exception.message, 'Unable to derive '
|
||||
'default datapath ID - please either specify a dpid '
|
||||
'or use a canonical switch name such as s23.'
|
||||
in str( raises_cm.exception ) )
|
||||
net.stop()
|
||||
'or use a canonical switch name such as s23.')
|
||||
|
||||
def testDefaultDpidLen( self ):
|
||||
"""Verify that Default dpid length is 16 characters consisting of
|
||||
16 - len(hex of first string of contiguous digits passed in switch
|
||||
name) 0's followed by hex of first string of contiguous digits passed
|
||||
in switch name."""
|
||||
net = Mininet( Topo(), self.switchClass, Host, Controller )
|
||||
switch = net.addSwitch( 's123' )
|
||||
self.assertEqual( switch.dpid, self.dpidFrom( 123 ) )
|
||||
net.stop()
|
||||
switch = Mininet( Topo(), self.switchClass,
|
||||
Host, Controller ).addSwitch( 's123' )
|
||||
|
||||
self.assertEqual( switch.dpid, self.dpidFrom( 123 ) )
|
||||
|
||||
class OVSUser( OVSSwitch):
|
||||
"OVS User Switch convenience class"
|
||||
@@ -98,4 +95,3 @@ class testSwitchUserspace( TestSwitchDpidAssignmentOVS ):
|
||||
if __name__ == '__main__':
|
||||
setLogLevel( 'warning' )
|
||||
unittest.main()
|
||||
cleanup()
|
||||
|
||||
@@ -7,13 +7,13 @@ TODO: missing xterm test
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import pexpect
|
||||
import os
|
||||
import re
|
||||
from mininet.util import quietRun, pexpect
|
||||
from mininet.util import quietRun
|
||||
from distutils.version import StrictVersion
|
||||
from time import sleep
|
||||
|
||||
|
||||
def tsharkVersion():
|
||||
"Return tshark version"
|
||||
versionStr = quietRun( 'tshark -v' )
|
||||
@@ -95,8 +95,7 @@ class testWalkthrough( unittest.TestCase ):
|
||||
p = pexpect.spawn( 'mn' )
|
||||
p.expect( self.prompt )
|
||||
# Third pattern is a local interface beginning with 'eth' or 'en'
|
||||
interfaces = [ r'h1-eth0[:\s]', r's1-eth1[:\s]',
|
||||
r'[^-](eth|en)\w*\d[:\s]', r'lo[:\s]',
|
||||
interfaces = [ 'h1-eth0', 's1-eth1', r'[^-](eth|en)\w*\d', 'lo',
|
||||
self.prompt ]
|
||||
# h1 ifconfig
|
||||
p.sendline( 'h1 ifconfig -a' )
|
||||
@@ -123,7 +122,7 @@ class testWalkthrough( unittest.TestCase ):
|
||||
ifcount += 1
|
||||
else:
|
||||
break
|
||||
self.assertTrue( ifcount <= 3, 'Missing interfaces on s1')
|
||||
self.assertTrue( ifcount >= 3, 'Missing interfaces on s1')
|
||||
# h1 ps
|
||||
p.sendline( "h1 ps -a | egrep -v 'ps|grep'" )
|
||||
p.expect( self.prompt )
|
||||
@@ -157,13 +156,9 @@ class testWalkthrough( unittest.TestCase ):
|
||||
|
||||
def testSimpleHTTP( self ):
|
||||
"Start an HTTP server on h1 and wget from h2"
|
||||
if 'Python 2' in quietRun( 'python --version' ):
|
||||
httpserver = 'SimpleHTTPServer'
|
||||
else:
|
||||
httpserver = 'http.server'
|
||||
p = pexpect.spawn( 'mn' )
|
||||
p.expect( self.prompt )
|
||||
p.sendline( 'h1 python -m %s 80 &' % httpserver )
|
||||
p.sendline( 'h1 python -m SimpleHTTPServer 80 &' )
|
||||
# The walkthrough doesn't specify a delay here, and
|
||||
# we also don't read the output (also a possible problem),
|
||||
# but for now let's wait a couple of seconds to make
|
||||
@@ -219,16 +214,16 @@ class testWalkthrough( unittest.TestCase ):
|
||||
p.sendline( 'iperf' )
|
||||
p.expect( r"Results: \['([\d\.]+) Mbits/sec'," )
|
||||
bw = float( p.match.group( 1 ) )
|
||||
self.assertTrue( bw < 10.1, 'Bandwidth %.2f >= 10.1 Mb/s' % bw )
|
||||
self.assertTrue( bw > 9.0, 'Bandwidth %.2f <= 9 Mb/s' % bw )
|
||||
self.assertTrue( bw < 10.1, 'Bandwidth > 10 Mb/s')
|
||||
self.assertTrue( bw > 9.0, 'Bandwidth < 9 Mb/s')
|
||||
p.expect( self.prompt )
|
||||
# test delay
|
||||
p.sendline( 'h1 ping -c 4 h2' )
|
||||
p.expect( r'rtt min/avg/max/mdev = '
|
||||
r'([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+) ms' )
|
||||
delay = float( p.match.group( 2 ) )
|
||||
self.assertTrue( delay >= 40, 'Delay < 40ms' )
|
||||
self.assertTrue( delay <= 50, 'Delay > 50s' )
|
||||
self.assertTrue( delay > 40, 'Delay < 40ms' )
|
||||
self.assertTrue( delay < 45, 'Delay > 40ms' )
|
||||
p.expect( self.prompt )
|
||||
p.sendline( 'exit' )
|
||||
p.wait()
|
||||
@@ -265,7 +260,7 @@ class testWalkthrough( unittest.TestCase ):
|
||||
p.expect( self.prompt )
|
||||
for i in range( 1, 3 ):
|
||||
p.sendline( 'h%d ifconfig' % i )
|
||||
p.expect( r'\s00:00:00:00:00:0%d\s' % i )
|
||||
p.expect( 'HWaddr 00:00:00:00:00:0%d' % i )
|
||||
p.expect( self.prompt )
|
||||
p.sendline( 'exit' )
|
||||
p.expect( pexpect.EOF )
|
||||
@@ -291,9 +286,7 @@ class testWalkthrough( unittest.TestCase ):
|
||||
"Test running user switch in its own namespace"
|
||||
p = pexpect.spawn( 'mn --innamespace --switch user' )
|
||||
p.expect( self.prompt )
|
||||
interfaces = [ r'h1-eth0[:\s]', r's1-eth1[:\s]',
|
||||
r'[^-](eth|en)\w*\d[:\s]', r'lo[:\s]',
|
||||
self.prompt ]
|
||||
interfaces = [ 'h1-eth0', 's1-eth1', '[^-]eth0', 'lo', self.prompt ]
|
||||
p.sendline( 's1 ifconfig -a' )
|
||||
ifcount = 0
|
||||
while True:
|
||||
|
||||
+4
-4
@@ -56,13 +56,13 @@ class MultiGraph( object ):
|
||||
return self.node.items() if data else self.node.keys()
|
||||
|
||||
def edges_iter( self, data=False, keys=False ):
|
||||
"Iterator: return graph edges, optionally with data and keys"
|
||||
for src, entry in self.edge.items():
|
||||
for dst, entrykeys in entry.items():
|
||||
"Iterator: return graph edges"
|
||||
for src, entry in self.edge.iteritems():
|
||||
for dst, keys in entry.iteritems():
|
||||
if src > dst:
|
||||
# Skip duplicate edges
|
||||
continue
|
||||
for k, attrs in entrykeys.items():
|
||||
for k, attrs in keys.iteritems():
|
||||
if data:
|
||||
if keys:
|
||||
yield( src, dst, k, attrs )
|
||||
|
||||
+14
-58
@@ -1,6 +1,5 @@
|
||||
"Utility functions for Mininet."
|
||||
|
||||
|
||||
from mininet.log import output, info, error, warn, debug
|
||||
|
||||
from time import sleep
|
||||
@@ -12,36 +11,6 @@ from fcntl import fcntl, F_GETFL, F_SETFL
|
||||
from os import O_NONBLOCK
|
||||
import os
|
||||
from functools import partial
|
||||
import sys
|
||||
|
||||
# Python 2/3 compatibility
|
||||
Python3 = sys.version_info[0] == 3
|
||||
BaseString = str if Python3 else getattr( str, '__base__' )
|
||||
Encoding = 'utf-8' if Python3 else None
|
||||
def decode( s ):
|
||||
"Decode a byte string if needed for Python 3"
|
||||
return s.decode( Encoding ) if Python3 else s
|
||||
def encode( s ):
|
||||
"Encode a byte string if needed for Python 3"
|
||||
return s.encode( Encoding ) if Python3 else s
|
||||
try:
|
||||
import pexpect as oldpexpect
|
||||
|
||||
class Pexpect( object ):
|
||||
"Custom pexpect that is compatible with str"
|
||||
@staticmethod
|
||||
def spawn( *args, **kwargs):
|
||||
"pexpect.spawn that is compatible with str"
|
||||
if Python3 and 'encoding' not in kwargs:
|
||||
kwargs.update( encoding='utf-8' )
|
||||
return oldpexpect.spawn( *args, **kwargs )
|
||||
|
||||
def __getattr__( self, name ):
|
||||
return getattr( oldpexpect, name )
|
||||
pexpect = Pexpect()
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
# Command execution support
|
||||
|
||||
@@ -87,7 +56,7 @@ def oldQuietRun( *cmd ):
|
||||
# This is a bit complicated, but it enables us to
|
||||
# monitor command output as it is happening
|
||||
|
||||
# pylint: disable=too-many-branches,too-many-statements
|
||||
# pylint: disable=too-many-branches
|
||||
def errRun( *cmd, **kwargs ):
|
||||
"""Run a command and return stdout, stderr and return code
|
||||
cmd: string or list of command and args
|
||||
@@ -128,8 +97,6 @@ def errRun( *cmd, **kwargs ):
|
||||
f = fdtofile[ fd ]
|
||||
if event & POLLIN:
|
||||
data = f.read( 1024 )
|
||||
if Python3:
|
||||
data = data.decode( Encoding )
|
||||
if echo:
|
||||
output( data )
|
||||
if f == popen.stdout:
|
||||
@@ -148,10 +115,6 @@ def errRun( *cmd, **kwargs ):
|
||||
poller.unregister( fd )
|
||||
|
||||
returncode = popen.wait()
|
||||
# Python 3 complains if we don't explicitly close these
|
||||
popen.stdout.close()
|
||||
if stderr == PIPE:
|
||||
popen.stderr.close()
|
||||
debug( out, err, returncode )
|
||||
return out, err, returncode
|
||||
# pylint: enable=too-many-branches
|
||||
@@ -357,7 +320,7 @@ def ipParse( ip ):
|
||||
"Parse an IP address and return an unsigned int."
|
||||
args = [ int( arg ) for arg in ip.split( '.' ) ]
|
||||
while len(args) < 4:
|
||||
args.insert( len(args) - 1, 0 )
|
||||
args.append( 0 )
|
||||
return ipNum( *args )
|
||||
|
||||
def netParse( ipstr ):
|
||||
@@ -410,7 +373,7 @@ def pmonitor(popens, timeoutms=500, readline=True,
|
||||
terminates: when all EOFs received"""
|
||||
poller = poll()
|
||||
fdToHost = {}
|
||||
for host, popen in popens.items():
|
||||
for host, popen in popens.iteritems():
|
||||
fd = popen.stdout.fileno()
|
||||
fdToHost[ fd ] = host
|
||||
poller.register( fd, POLLIN )
|
||||
@@ -418,13 +381,6 @@ def pmonitor(popens, timeoutms=500, readline=True,
|
||||
# Use non-blocking reads
|
||||
flags = fcntl( fd, F_GETFL )
|
||||
fcntl( fd, F_SETFL, flags | O_NONBLOCK )
|
||||
|
||||
def readit( f ):
|
||||
"Helper function - read line or data"
|
||||
# Note this will block if readline is True
|
||||
line = f.readline() if readline else f.read( readmax )
|
||||
return decode( line )
|
||||
|
||||
while popens:
|
||||
fds = poller.poll( timeoutms )
|
||||
if fds:
|
||||
@@ -432,15 +388,15 @@ def pmonitor(popens, timeoutms=500, readline=True,
|
||||
host = fdToHost[ fd ]
|
||||
popen = popens[ host ]
|
||||
if event & POLLIN:
|
||||
line = readit( popen.stdout )
|
||||
if readline:
|
||||
# Attempt to read a line of output
|
||||
# This blocks until we receive a newline!
|
||||
line = popen.stdout.readline()
|
||||
else:
|
||||
line = popen.stdout.read( readmax )
|
||||
yield host, line
|
||||
if event & POLLHUP:
|
||||
while True:
|
||||
# Drain buffer
|
||||
line = readit( popen.stdout )
|
||||
yield host, line
|
||||
if line == '':
|
||||
break
|
||||
# Check for EOF
|
||||
elif event & POLLHUP:
|
||||
poller.unregister( fd )
|
||||
del popens[ host ]
|
||||
else:
|
||||
@@ -503,7 +459,7 @@ def fixLimits():
|
||||
|
||||
def mountCgroups():
|
||||
"Make sure cgroups file system is mounted"
|
||||
mounts = quietRun( 'grep cgroup /proc/mounts' )
|
||||
mounts = quietRun( 'cat /proc/mounts' )
|
||||
cgdir = '/sys/fs/cgroup'
|
||||
csdir = cgdir + '/cpuset'
|
||||
if ('cgroup %s' % cgdir not in mounts and
|
||||
@@ -631,7 +587,7 @@ def ensureRoot():
|
||||
Probably we should only sudo when needed as per Big Switch's patch.
|
||||
"""
|
||||
if os.getuid() != 0:
|
||||
error( '*** Mininet must run as root.\n' )
|
||||
print "*** Mininet must run as root."
|
||||
exit( 1 )
|
||||
return
|
||||
|
||||
@@ -643,7 +599,7 @@ def waitListening( client=None, server='127.0.0.1', port=80, timeout=None ):
|
||||
if not runCmd( 'which telnet' ):
|
||||
raise Exception('Could not find telnet' )
|
||||
# pylint: disable=maybe-no-member
|
||||
serverIP = server if isinstance( server, BaseString ) else server.IP()
|
||||
serverIP = server if isinstance( server, basestring ) else server.IP()
|
||||
cmd = ( 'echo A | telnet -e A %s %s' % ( serverIP, port ) )
|
||||
time = 0
|
||||
result = runCmd( cmd )
|
||||
|
||||
+37
-71
@@ -40,7 +40,6 @@ if [ "$DIST" = "Ubuntu" ] || [ "$DIST" = "Debian" ]; then
|
||||
install='sudo DEBIAN_FRONTEND=noninteractive apt-get -y -q install'
|
||||
remove='sudo DEBIAN_FRONTEND=noninteractive apt-get -y -q remove'
|
||||
pkginst='sudo dpkg -i'
|
||||
update='sudo apt-get'
|
||||
# Prereqs for this script
|
||||
if ! which lsb_release &> /dev/null; then
|
||||
$install lsb-release
|
||||
@@ -52,22 +51,11 @@ if [ "$DIST" = "Fedora" -o "$DIST" = "RedHatEnterpriseServer" ]; then
|
||||
install='sudo yum -y install'
|
||||
remove='sudo yum -y erase'
|
||||
pkginst='sudo rpm -ivh'
|
||||
update='sudo yum'
|
||||
# Prereqs for this script
|
||||
if ! which lsb_release &> /dev/null; then
|
||||
$install redhat-lsb-core
|
||||
fi
|
||||
fi
|
||||
test -e /etc/SuSE-release && DIST="SUSE Linux"
|
||||
if [ "$DIST" = "SUSE Linux" ]; then
|
||||
install='sudo zypper --non-interactive install '
|
||||
remove='sudo zypper --non-interactive remove '
|
||||
pkginst='sudo rpm -ivh'
|
||||
# Prereqs for this script
|
||||
if ! which lsb_release &> /dev/null; then
|
||||
$install openSUSE-release
|
||||
fi
|
||||
fi
|
||||
if which lsb_release &> /dev/null; then
|
||||
DIST=`lsb_release -is`
|
||||
RELEASE=`lsb_release -rs`
|
||||
@@ -80,12 +68,8 @@ echo "Detected Linux distribution: $DIST $RELEASE $CODENAME $ARCH"
|
||||
KERNEL_NAME=`uname -r`
|
||||
KERNEL_HEADERS=kernel-headers-${KERNEL_NAME}
|
||||
|
||||
# Treat Raspbian as Debian
|
||||
[ "$DIST" = 'Raspbian' ] && DIST='Debian'
|
||||
|
||||
DISTS='Ubuntu|Debian|Fedora|RedHatEnterpriseServer|SUSE LINUX'
|
||||
if ! echo $DIST | egrep "$DISTS" >/dev/null; then
|
||||
echo "Install.sh currently only supports $DISTS."
|
||||
if ! echo $DIST | egrep 'Ubuntu|Debian|Fedora|RedHatEnterpriseServer'; then
|
||||
echo "Install.sh currently only supports Ubuntu, Debian, RedHat and Fedora."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -102,14 +86,6 @@ function version_ge {
|
||||
[ "$1" == "$latest" ]
|
||||
}
|
||||
|
||||
# Attempt to identify Python version
|
||||
PYTHON=${PYTHON:-python}
|
||||
if $PYTHON --version |& grep 'Python 2' > /dev/null; then
|
||||
PYTHON_VERSION=2; PYPKG=python
|
||||
else
|
||||
PYTHON_VERSION=3; PYPKG=python3
|
||||
fi
|
||||
echo "${PYTHON} is version ${PYTHON_VERSION}"
|
||||
|
||||
# Kernel Deb pkg to be removed:
|
||||
KERNEL_IMAGE_OLD=linux-image-2.6.26-33-generic
|
||||
@@ -127,7 +103,7 @@ OF13_SWITCH_REV=${OF13_SWITCH_REV:-""}
|
||||
|
||||
function kernel {
|
||||
echo "Install Mininet-compatible kernel if necessary"
|
||||
$update update
|
||||
sudo apt-get update
|
||||
if ! $install linux-image-$KERNEL_NAME; then
|
||||
echo "Could not install linux-image-$KERNEL_NAME"
|
||||
echo "Skipping - assuming installed kernel is OK."
|
||||
@@ -153,20 +129,15 @@ function mn_deps {
|
||||
$install gcc make socat psmisc xterm openssh-clients iperf \
|
||||
iproute telnet python-setuptools libcgroup-tools \
|
||||
ethtool help2man pyflakes pylint python-pep8 python-pexpect
|
||||
elif [ "$DIST" = "SUSE LINUX" ]; then
|
||||
$install gcc make socat psmisc xterm openssh iperf \
|
||||
iproute telnet ${PYPKG}-setuptools libcgroup-tools \
|
||||
ethtool help2man python-pyflakes python3-pylint \
|
||||
python-pep8 ${PYPKG}-pexpect ${PYPKG}-tk
|
||||
else # Debian/Ubuntu
|
||||
$install gcc make socat psmisc xterm ssh iperf iproute2 telnet \
|
||||
cgroup-bin ethtool help2man pyflakes pylint pep8 \
|
||||
${PYPKG}-setuptools ${PYPKG}-pexpect ${PYPKG}-tk
|
||||
else
|
||||
$install gcc make socat psmisc xterm ssh iperf iproute telnet \
|
||||
python-setuptools cgroup-bin ethtool help2man \
|
||||
pyflakes pylint pep8 python-pexpect
|
||||
fi
|
||||
|
||||
echo "Installing Mininet core"
|
||||
pushd $MININET_DIR/mininet
|
||||
sudo PYTHON=${PYTHON} make install
|
||||
sudo make install
|
||||
popd
|
||||
}
|
||||
|
||||
@@ -189,8 +160,6 @@ function of {
|
||||
$install autoconf automake libtool make gcc
|
||||
if [ "$DIST" = "Fedora" -o "$DIST" = "RedHatEnterpriseServer" ]; then
|
||||
$install git pkgconfig glibc-devel
|
||||
elif [ "$DIST" = "SUSE LINUX" ]; then
|
||||
$install git pkgconfig glibc-devel
|
||||
else
|
||||
$install git-core autotools-dev pkg-config libc6-dev
|
||||
fi
|
||||
@@ -213,14 +182,10 @@ function of {
|
||||
function of13 {
|
||||
echo "Installing OpenFlow 1.3 soft switch implementation..."
|
||||
cd $BUILD_DIR/
|
||||
$install git-core autoconf automake autotools-dev pkg-config \
|
||||
make gcc g++ libtool libc6-dev cmake libpcap-dev \
|
||||
$install git-core autoconf automake autotools-dev pkg-config \
|
||||
make gcc g++ libtool libc6-dev cmake libpcap-dev libxerces-c2-dev \
|
||||
unzip libpcre3-dev flex bison libboost-dev
|
||||
if [ "$DIST" = "Ubuntu" ] && version_le $RELEASE 16.04; then
|
||||
$install libxerces-c2-dev
|
||||
else
|
||||
$install libxerces-c-dev
|
||||
fi
|
||||
|
||||
if [ ! -d "ofsoftswitch13" ]; then
|
||||
git clone https://github.com/CPqD/ofsoftswitch13.git
|
||||
if [[ -n "$OF13_SWITCH_REV" ]]; then
|
||||
@@ -231,17 +196,24 @@ function of13 {
|
||||
fi
|
||||
|
||||
# Install netbee
|
||||
if [ ! -d "netbee" ]; then
|
||||
git clone https://github.com/netgroup-polito/netbee.git
|
||||
if [ "$DIST" = "Ubuntu" ] && version_ge $RELEASE 14.04; then
|
||||
NBEESRC="nbeesrc-feb-24-2015"
|
||||
NBEEDIR="netbee"
|
||||
else
|
||||
NBEESRC="nbeesrc-jan-10-2013"
|
||||
NBEEDIR="nbeesrc-jan-10-2013"
|
||||
fi
|
||||
cd netbee/src
|
||||
|
||||
NBEEURL=${NBEEURL:-http://www.nbee.org/download/}
|
||||
wget -nc ${NBEEURL}${NBEESRC}.zip
|
||||
unzip ${NBEESRC}.zip
|
||||
cd ${NBEEDIR}/src
|
||||
cmake .
|
||||
make
|
||||
|
||||
cd $BUILD_DIR
|
||||
sudo cp netbee/bin/libn*.so /usr/local/lib
|
||||
cd $BUILD_DIR/
|
||||
sudo cp ${NBEEDIR}/bin/libn*.so /usr/local/lib
|
||||
sudo ldconfig
|
||||
sudo cp -R netbee/include/ /usr/
|
||||
sudo cp -R ${NBEEDIR}/include/ /usr/
|
||||
|
||||
# Resume the install:
|
||||
cd $BUILD_DIR/ofsoftswitch13
|
||||
@@ -258,8 +230,6 @@ function install_wireshark {
|
||||
echo "Installing Wireshark"
|
||||
if [ "$DIST" = "Fedora" -o "$DIST" = "RedHatEnterpriseServer" ]; then
|
||||
$install wireshark wireshark-gnome
|
||||
elif [ "$DIST" = "SUSE LINUX" ]; then
|
||||
$install wireshark
|
||||
else
|
||||
$install wireshark tshark
|
||||
fi
|
||||
@@ -444,19 +414,12 @@ function ivs {
|
||||
IVS_SRC=$BUILD_DIR/ivs
|
||||
|
||||
# Install dependencies
|
||||
$install gcc make
|
||||
if [ "$DIST" = "Fedora" -o "$DIST" = "RedHatEnterpriseServer" ]; then
|
||||
$install git pkgconfig libnl3-devel libcap-devel openssl-devel
|
||||
else
|
||||
$install git-core pkg-config libnl-3-dev libnl-route-3-dev \
|
||||
libnl-genl-3-dev
|
||||
fi
|
||||
$install git pkg-config gcc make libnl-3-dev libnl-route-3-dev libnl-genl-3-dev
|
||||
|
||||
# Install IVS from source
|
||||
cd $BUILD_DIR
|
||||
git clone git://github.com/floodlight/ivs $IVS_SRC
|
||||
git clone git://github.com/floodlight/ivs $IVS_SRC --recursive
|
||||
cd $IVS_SRC
|
||||
git submodule update --init
|
||||
make
|
||||
sudo make install
|
||||
}
|
||||
@@ -468,19 +431,24 @@ function ryu {
|
||||
# install Ryu dependencies"
|
||||
$install autoconf automake g++ libtool python make
|
||||
if [ "$DIST" = "Ubuntu" -o "$DIST" = "Debian" ]; then
|
||||
$install gcc python-pip python-dev libffi-dev libssl-dev \
|
||||
libxml2-dev libxslt1-dev zlib1g-dev
|
||||
$install libxml2 libxslt-dev python-pip python-dev
|
||||
sudo pip install --upgrade gevent pbr webob routes paramiko \\
|
||||
oslo.config
|
||||
fi
|
||||
|
||||
# if needed, update python-six
|
||||
SIX_VER=`pip show six | grep Version | awk '{print $2}'`
|
||||
if version_ge 1.7.0 $SIX_VER; then
|
||||
echo "Installing python-six version 1.7.0..."
|
||||
sudo pip install -I six==1.7.0
|
||||
fi
|
||||
# fetch RYU
|
||||
cd $BUILD_DIR/
|
||||
git clone git://github.com/osrg/ryu.git ryu
|
||||
cd ryu
|
||||
|
||||
# install ryu
|
||||
sudo pip install -r tools/pip-requires -r tools/optional-requires \
|
||||
-r tools/test-requires
|
||||
sudo python setup.py install
|
||||
sudo python ./setup.py install
|
||||
|
||||
# Add symbolic link to /usr/bin
|
||||
sudo ln -s ./bin/ryu-manager /usr/local/bin/ryu-manager
|
||||
@@ -593,8 +561,6 @@ function cbench {
|
||||
|
||||
if [ "$DIST" = "Fedora" -o "$DIST" = "RedHatEnterpriseServer" ]; then
|
||||
$install net-snmp-devel libpcap-devel libconfig-devel
|
||||
elif [ "$DIST" = "SUSE LINUX" ]; then
|
||||
$install net-snmp-devel libpcap-devel libconfig-devel
|
||||
else
|
||||
$install libsnmp-dev libpcap-dev libconfig-dev
|
||||
fi
|
||||
|
||||
+1
-2
@@ -40,7 +40,6 @@ Bob Lantz, rlantz@cs.stanford.edu
|
||||
1/24/2010
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
import re, sys
|
||||
|
||||
def fixUnderscoreTriplet( match ):
|
||||
@@ -196,4 +195,4 @@ def convertFromPep8( program ):
|
||||
return program
|
||||
|
||||
if __name__ == '__main__':
|
||||
print( convertFromPep8( sys.stdin.read() ) )
|
||||
print convertFromPep8( sys.stdin.read() )
|
||||
+5
-10
@@ -1,19 +1,14 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from subprocess import check_output as co
|
||||
from sys import exit, version_info
|
||||
|
||||
def run(*args, **kwargs):
|
||||
"Run co and decode for python3"
|
||||
result = co(*args, **kwargs)
|
||||
return result.decode() if version_info[ 0 ] >= 3 else result
|
||||
from sys import exit
|
||||
|
||||
# Actually run bin/mn rather than importing via python path
|
||||
version = 'Mininet ' + run( 'PYTHONPATH=. bin/mn --version 2>&1', shell=True )
|
||||
version = 'Mininet ' + co( 'PYTHONPATH=. bin/mn --version', shell=True )
|
||||
version = version.strip()
|
||||
|
||||
# Find all Mininet path references
|
||||
lines = run( "egrep -or 'Mininet [0-9\.\+]+\w*' *", shell=True )
|
||||
lines = co( "egrep -or 'Mininet [0-9\.\+]+\w*' *", shell=True )
|
||||
|
||||
error = False
|
||||
|
||||
@@ -21,8 +16,8 @@ for line in lines.split( '\n' ):
|
||||
if line and 'Binary' not in line:
|
||||
fname, fversion = line.split( ':' )
|
||||
if version != fversion:
|
||||
print( "%s: incorrect version '%s' (should be '%s')" % (
|
||||
fname, fversion, version ) )
|
||||
print "%s: incorrect version '%s' (should be '%s')" % (
|
||||
fname, fversion, version )
|
||||
error = True
|
||||
|
||||
if error:
|
||||
|
||||
+6
-6
@@ -118,9 +118,9 @@ def log( *args, **kwargs ):
|
||||
msg = ' '.join( str( arg ) for arg in args )
|
||||
output = '%s [ %.3f ] %s' % ( clocktime, elapsed, msg )
|
||||
if cr:
|
||||
print( output )
|
||||
print output
|
||||
else:
|
||||
print( output, )
|
||||
print output,
|
||||
# Optionally mirror to LogFile
|
||||
if type( LogFile ) is file:
|
||||
if cr:
|
||||
@@ -208,7 +208,7 @@ def attachNBD( cow, flags='' ):
|
||||
continue
|
||||
srun( 'modprobe nbd max-part=64' )
|
||||
srun( 'qemu-nbd %s -c %s %s' % ( flags, nbd, cow ) )
|
||||
print()
|
||||
print
|
||||
return nbd
|
||||
raise Exception( "Error: could not find unused /dev/nbdX device" )
|
||||
|
||||
@@ -1002,7 +1002,7 @@ def parseArgs():
|
||||
if args.depend:
|
||||
depend()
|
||||
if args.list:
|
||||
print( buildFlavorString() )
|
||||
print buildFlavorString()
|
||||
if args.clean:
|
||||
cleanup()
|
||||
if args.verbose:
|
||||
@@ -1023,8 +1023,8 @@ def parseArgs():
|
||||
Chown = args.chown
|
||||
for flavor in args.flavor:
|
||||
if flavor not in isoURLs:
|
||||
print( "Unknown build flavor:", flavor )
|
||||
print( buildFlavorString() )
|
||||
print "Unknown build flavor:", flavor
|
||||
print buildFlavorString()
|
||||
break
|
||||
try:
|
||||
build( flavor, tests=args.test, pre=args.run, post=args.post,
|
||||
|
||||
Reference in New Issue
Block a user