Merge branch 'dmahler-master'
This commit is contained in:
@@ -26,12 +26,13 @@ from mininet.log import lg, LEVELS, info, debug, warn, error
|
|||||||
from mininet.net import Mininet, MininetWithControlNet, VERSION
|
from mininet.net import Mininet, MininetWithControlNet, VERSION
|
||||||
from mininet.node import ( Host, CPULimitedHost, Controller, OVSController,
|
from mininet.node import ( Host, CPULimitedHost, Controller, OVSController,
|
||||||
Ryu, NOX, RemoteController, findController,
|
Ryu, NOX, RemoteController, findController,
|
||||||
DefaultController,
|
DefaultController, NullController,
|
||||||
UserSwitch, OVSSwitch, OVSBridge,
|
UserSwitch, OVSSwitch, OVSBridge,
|
||||||
IVSSwitch )
|
IVSSwitch )
|
||||||
from mininet.nodelib import LinuxBridge
|
from mininet.nodelib import LinuxBridge
|
||||||
from mininet.link import Link, TCLink, OVSLink
|
from mininet.link import Link, TCLink, OVSLink
|
||||||
from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo
|
from mininet.topo import ( SingleSwitchTopo, LinearTopo,
|
||||||
|
SingleSwitchReversedTopo, MinimalTopo )
|
||||||
from mininet.topolib import TreeTopo, TorusTopo
|
from mininet.topolib import TreeTopo, TorusTopo
|
||||||
from mininet.util import customClass, specialClass, splitArgs
|
from mininet.util import customClass, specialClass, splitArgs
|
||||||
from mininet.util import buildTopo
|
from mininet.util import buildTopo
|
||||||
@@ -49,7 +50,7 @@ PLACEMENT = { 'block': SwitchBinPlacer, 'random': RandomPlacer }
|
|||||||
|
|
||||||
# built in topologies, created only when run
|
# built in topologies, created only when run
|
||||||
TOPODEF = 'minimal'
|
TOPODEF = 'minimal'
|
||||||
TOPOS = { 'minimal': lambda: SingleSwitchTopo( k=2 ),
|
TOPOS = { 'minimal': MinimalTopo,
|
||||||
'linear': LinearTopo,
|
'linear': LinearTopo,
|
||||||
'reversed': SingleSwitchReversedTopo,
|
'reversed': SingleSwitchReversedTopo,
|
||||||
'single': SingleSwitchTopo,
|
'single': SingleSwitchTopo,
|
||||||
@@ -72,13 +73,14 @@ HOSTS = { 'proc': Host,
|
|||||||
'cfs': specialClass( CPULimitedHost, defaults=dict( sched='cfs' ) ) }
|
'cfs': specialClass( CPULimitedHost, defaults=dict( sched='cfs' ) ) }
|
||||||
|
|
||||||
CONTROLLERDEF = 'default'
|
CONTROLLERDEF = 'default'
|
||||||
|
|
||||||
CONTROLLERS = { 'ref': Controller,
|
CONTROLLERS = { 'ref': Controller,
|
||||||
'ovsc': OVSController,
|
'ovsc': OVSController,
|
||||||
'nox': NOX,
|
'nox': NOX,
|
||||||
'remote': RemoteController,
|
'remote': RemoteController,
|
||||||
'ryu': Ryu,
|
'ryu': Ryu,
|
||||||
'default': DefaultController, # Note: replaced below
|
'default': DefaultController, # Note: replaced below
|
||||||
'none': lambda name: None }
|
'none': NullController }
|
||||||
|
|
||||||
LINKDEF = 'default'
|
LINKDEF = 'default'
|
||||||
LINKS = { 'default': Link,
|
LINKS = { 'default': Link,
|
||||||
@@ -96,17 +98,18 @@ ALTSPELLING = { 'pingall': 'pingAll',
|
|||||||
'iperfUDP': 'iperfUdp' }
|
'iperfUDP': 'iperfUdp' }
|
||||||
|
|
||||||
|
|
||||||
def addDictOption( opts, choicesDict, default, name, helpStr=None, **kwargs ):
|
def addDictOption( opts, choicesDict, default, name, **kwargs ):
|
||||||
"""Convenience function to add choices dicts to OptionParser.
|
"""Convenience function to add choices dicts to OptionParser.
|
||||||
opts: OptionParser instance
|
opts: OptionParser instance
|
||||||
choicesDict: dictionary of valid choices, must include default
|
choicesDict: dictionary of valid choices, must include default
|
||||||
default: default choice key
|
default: default choice key
|
||||||
name: long option name
|
name: long option name
|
||||||
helpStr: help string
|
|
||||||
kwargs: additional arguments to add_option"""
|
kwargs: additional arguments to add_option"""
|
||||||
if not helpStr:
|
helpStr = ( '|'.join( sorted( choicesDict.keys() ) ) +
|
||||||
helpStr = ( '|'.join( sorted( choicesDict.keys() ) ) +
|
'[,param=value...]' )
|
||||||
'[,param=value...]' )
|
helpList = [ '%s=%s' % ( k, v.__name__ )
|
||||||
|
for k, v in choicesDict.items() ]
|
||||||
|
helpStr += ' ' + ( ' '.join( helpList ) )
|
||||||
params = dict( type='string', default=default, help=helpStr )
|
params = dict( type='string', default=default, help=helpStr )
|
||||||
params.update( **kwargs )
|
params.update( **kwargs )
|
||||||
opts.add_option( '--' + name, **params )
|
opts.add_option( '--' + name, **params )
|
||||||
|
|||||||
@@ -1517,3 +1517,7 @@ def DefaultController( name, controllers=DefaultControllers, **kwargs ):
|
|||||||
if not controller:
|
if not controller:
|
||||||
raise Exception( 'Could not find a default OpenFlow controller' )
|
raise Exception( 'Could not find a default OpenFlow controller' )
|
||||||
return controller( name, **kwargs )
|
return controller( name, **kwargs )
|
||||||
|
|
||||||
|
def NullController( *_args, **_kwargs ):
|
||||||
|
"Nonexistent controller - simply returns None"
|
||||||
|
return None
|
||||||
|
|||||||
@@ -318,6 +318,12 @@ class SingleSwitchReversedTopo( Topo ):
|
|||||||
port1=0, port2=( k - h + 1 ) )
|
port1=0, port2=( k - h + 1 ) )
|
||||||
|
|
||||||
|
|
||||||
|
class MinimalTopo( SingleSwitchTopo ):
|
||||||
|
"Minimal topology with two hosts and one switch"
|
||||||
|
def build( self ):
|
||||||
|
return SingleSwitchTopo.build( self, k=2 )
|
||||||
|
|
||||||
|
|
||||||
class LinearTopo( Topo ):
|
class LinearTopo( Topo ):
|
||||||
"Linear topology of k switches, with n hosts per switch."
|
"Linear topology of k switches, with n hosts per switch."
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user