Simply use class names as option help
The justification for this is that 1) the options are already documented in the API documentation and 2) the class names are fairly self-explanatory, so adding short descriptions doesn't add much. In the future, however, we could add a short description by simply using the first line or sentence of the docstring; note that docstrings would have to be canonicalized, which they aren't now.
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,
|
||||||
@@ -65,13 +66,6 @@ SWITCHES = { 'user': UserSwitch,
|
|||||||
'ivs': IVSSwitch,
|
'ivs': IVSSwitch,
|
||||||
'lxbr': LinuxBridge,
|
'lxbr': LinuxBridge,
|
||||||
'default': OVSSwitch }
|
'default': OVSSwitch }
|
||||||
SWITCHESHELP = { 'user': 'OpenFlow reference user-space switch.',
|
|
||||||
'ovs': 'Open vSwitch OpenFlow-compatible switch.',
|
|
||||||
'ovsbr': 'Open vSwitch as an L2 MAC learning switch.',
|
|
||||||
'ovsk': 'Same as the ovs type.',
|
|
||||||
'ivs': 'Indigo Virtual Switch.',
|
|
||||||
'lxbr': 'Linux Bridge.',
|
|
||||||
'default': 'Open vSwitch OpenFlow-compatible switch.'}
|
|
||||||
|
|
||||||
HOSTDEF = 'proc'
|
HOSTDEF = 'proc'
|
||||||
HOSTS = { 'proc': Host,
|
HOSTS = { 'proc': Host,
|
||||||
@@ -79,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,
|
||||||
@@ -103,20 +98,18 @@ ALTSPELLING = { 'pingall': 'pingAll',
|
|||||||
'iperfUDP': 'iperfUdp' }
|
'iperfUDP': 'iperfUdp' }
|
||||||
|
|
||||||
|
|
||||||
def addDictOption( opts, choicesDict, default, name, helpDict=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
|
||||||
helpDict: dictionary describing choices
|
|
||||||
kwargs: additional arguments to add_option"""
|
kwargs: additional arguments to add_option"""
|
||||||
helpStr = ( '|'.join( sorted( choicesDict.keys() ) ) +
|
helpStr = ( '|'.join( sorted( choicesDict.keys() ) ) +
|
||||||
'[,param=value...]' )
|
'[,param=value...]' )
|
||||||
if helpDict:
|
helpList = [ '%s=%s' % ( k, v.__name__ )
|
||||||
helpList = [ k + "=" + helpDict[k]
|
for k, v in choicesDict.items() ]
|
||||||
for k in sorted( helpDict.keys() ) ]
|
helpStr += ' ' + ( ' '.join( helpList ) )
|
||||||
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 )
|
||||||
@@ -202,7 +195,7 @@ class MininetRunner( object ):
|
|||||||
'(type %prog -h for details)' )
|
'(type %prog -h for details)' )
|
||||||
|
|
||||||
opts = OptionParser( description=desc, usage=usage )
|
opts = OptionParser( description=desc, usage=usage )
|
||||||
addDictOption( opts, SWITCHES, SWITCHDEF, 'switch', SWITCHESHELP )
|
addDictOption( opts, SWITCHES, SWITCHDEF, 'switch' )
|
||||||
addDictOption( opts, HOSTS, HOSTDEF, 'host' )
|
addDictOption( opts, HOSTS, HOSTDEF, 'host' )
|
||||||
addDictOption( opts, CONTROLLERS, [], 'controller', action='append' )
|
addDictOption( opts, CONTROLLERS, [], 'controller', action='append' )
|
||||||
addDictOption( opts, LINKS, LINKDEF, 'link' )
|
addDictOption( opts, LINKS, LINKDEF, 'link' )
|
||||||
|
|||||||
@@ -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