Add static code checking for style and errors

This required a change to logging, which now uses a singleton pattern.

For all future checkins, 'make codecheck' should pass.
This commit is contained in:
Brandon Heller
2010-01-09 17:59:43 -08:00
parent ca58c896dd
commit 723d068c51
11 changed files with 200 additions and 132 deletions
+26 -25
View File
@@ -13,7 +13,7 @@ try:
except ImportError:
USE_RIPCORD = False
from mininet.logging_mod import lg, set_loglevel, LEVELS
from mininet.logging_mod import lg, LEVELS
from mininet.net import Mininet, init
from mininet.node import KernelSwitch, Host, Controller, ControllerParams, NOX
from mininet.node import RemoteController, UserSwitch
@@ -21,43 +21,44 @@ from mininet.topo import SingleSwitchTopo, LinearTopo, SingleSwitchReversedTopo
# built in topologies, created only when run
TOPO_DEF = 'minimal'
TOPOS = {'minimal' : (lambda: SingleSwitchTopo(k = 2)),
'reversed' : (lambda: SingleSwitchReversedTopo(k = 2)),
'single4' : (lambda: SingleSwitchTopo(k = 4)),
'single100' : (lambda: SingleSwitchTopo(k = 100)),
'linear2' : (lambda: LinearTopo(k = 2)),
'linear100' : (lambda: LinearTopo(k = 100))}
TOPOS = {'minimal': (lambda: SingleSwitchTopo(k = 2)),
'reversed': (lambda: SingleSwitchReversedTopo(k = 2)),
'single4': (lambda: SingleSwitchTopo(k = 4)),
'single100': (lambda: SingleSwitchTopo(k = 100)),
'linear2': (lambda: LinearTopo(k = 2)),
'linear100': (lambda: LinearTopo(k = 100))}
if USE_RIPCORD:
TOPOS_RIPCORD = {
'tree16' : (lambda: TreeTopo(depth = 3, fanout = 4)),
'tree64' : (lambda: TreeTopo(depth = 4, fanout = 4)),
'tree1024' : (lambda: TreeTopo(depth = 3, fanout = 32)),
'fattree4' : (lambda: FatTreeTopo(k = 4)),
'fattree6' : (lambda: FatTreeTopo(k = 6)),
'vl2' : (lambda: VL2Topo(da = 4, di = 4))}
'tree16': (lambda: TreeTopo(depth = 3, fanout = 4)),
'tree64': (lambda: TreeTopo(depth = 4, fanout = 4)),
'tree1024': (lambda: TreeTopo(depth = 3, fanout = 32)),
'fattree4': (lambda: FatTreeTopo(k = 4)),
'fattree6': (lambda: FatTreeTopo(k = 6)),
'vl2': (lambda: VL2Topo(da = 4, di = 4))}
TOPOS.update(TOPOS_RIPCORD)
SWITCH_DEF = 'kernel'
SWITCHES = {'kernel' : KernelSwitch,
'user' : UserSwitch}
SWITCHES = {'kernel': KernelSwitch,
'user': UserSwitch}
HOST_DEF = 'process'
HOSTS = {'process' : Host}
HOSTS = {'process': Host}
CONTROLLER_DEF = 'ref'
# a and b are the name and inNamespace params.
CONTROLLERS = {'ref' : Controller,
'nox_dump' : lambda a, b: NOX(a, b, 'packetdump'),
'nox_pysw' : lambda a, b: NOX(a, b, 'pyswitch'),
'remote' : lambda a, b: None,
'none' : lambda a, b: None}
CONTROLLERS = {'ref': Controller,
'nox_dump': lambda a, b: NOX(a, b, 'packetdump'),
'nox_pysw': lambda a, b: NOX(a, b, 'pyswitch'),
'remote': lambda a, b: None,
'none': lambda a, b: None}
# optional tests to run
TESTS = ['cli', 'build', 'ping_all', 'ping_pair', 'iperf', 'all', 'iperf_udp']
def add_dict_option(opts, choices_dict, default, name, help_str = None):
'''Convenience function to add choices dicts to OptionParser.
@param opts OptionParser instance
@param choices_dict dictionary of valid choices, must include default
@param default default choice key
@@ -82,14 +83,14 @@ class MininetRunner(object):
def __init__(self):
'''Init.'''
self.options = None
self.parse_args()
self.setup()
self.begin()
def parse_args(self):
'''Parse command-line args and return options object.
@return opts parse options dict
'''
opts = OptionParser()
@@ -124,7 +125,7 @@ class MininetRunner(object):
'''Setup and validate environment.'''
# set logging verbosity
set_loglevel(self.options.verbosity)
lg.set_loglevel(self.options.verbosity)
# validate environment setup
init()