Revision 723d068c bin/mn_run.py

View differences:

bin/mn_run.py
13 13
except ImportError:
14 14
    USE_RIPCORD = False
15 15

  
16
from mininet.logging_mod import lg, set_loglevel, LEVELS
16
from mininet.logging_mod import lg, LEVELS
17 17
from mininet.net import Mininet, init
18 18
from mininet.node import KernelSwitch, Host, Controller, ControllerParams, NOX
19 19
from mininet.node import RemoteController, UserSwitch
......
21 21

  
22 22
# built in topologies, created only when run
23 23
TOPO_DEF = 'minimal'
24
TOPOS = {'minimal' :   (lambda: SingleSwitchTopo(k = 2)),
25
         'reversed' :  (lambda: SingleSwitchReversedTopo(k = 2)),
26
         'single4' :   (lambda: SingleSwitchTopo(k = 4)),
27
         'single100' : (lambda: SingleSwitchTopo(k = 100)),
28
         'linear2' :   (lambda: LinearTopo(k = 2)),
29
         'linear100' : (lambda: LinearTopo(k = 100))}
24
TOPOS = {'minimal': (lambda: SingleSwitchTopo(k = 2)),
25
         'reversed': (lambda: SingleSwitchReversedTopo(k = 2)),
26
         'single4': (lambda: SingleSwitchTopo(k = 4)),
27
         'single100': (lambda: SingleSwitchTopo(k = 100)),
28
         'linear2': (lambda: LinearTopo(k = 2)),
29
         'linear100': (lambda: LinearTopo(k = 100))}
30 30
if USE_RIPCORD:
31 31
    TOPOS_RIPCORD = {
32
         'tree16' :   (lambda: TreeTopo(depth = 3, fanout = 4)),
33
         'tree64' :   (lambda: TreeTopo(depth = 4, fanout = 4)),
34
         'tree1024' : (lambda: TreeTopo(depth = 3, fanout = 32)),
35
         'fattree4' : (lambda: FatTreeTopo(k = 4)),
36
         'fattree6' : (lambda: FatTreeTopo(k = 6)),
37
         'vl2'      : (lambda: VL2Topo(da = 4, di = 4))}
32
         'tree16': (lambda: TreeTopo(depth = 3, fanout = 4)),
33
         'tree64': (lambda: TreeTopo(depth = 4, fanout = 4)),
34
         'tree1024': (lambda: TreeTopo(depth = 3, fanout = 32)),
35
         'fattree4': (lambda: FatTreeTopo(k = 4)),
36
         'fattree6': (lambda: FatTreeTopo(k = 6)),
37
         'vl2': (lambda: VL2Topo(da = 4, di = 4))}
38 38
    TOPOS.update(TOPOS_RIPCORD)
39 39

  
40 40
SWITCH_DEF = 'kernel'
41
SWITCHES = {'kernel' : KernelSwitch,
42
            'user' : UserSwitch}
41
SWITCHES = {'kernel': KernelSwitch,
42
            'user': UserSwitch}
43 43

  
44 44
HOST_DEF = 'process'
45
HOSTS = {'process' : Host}
45
HOSTS = {'process': Host}
46 46

  
47 47
CONTROLLER_DEF = 'ref'
48 48
# a and b are the name and inNamespace params.
49
CONTROLLERS = {'ref' : Controller,
50
               'nox_dump' : lambda a, b: NOX(a, b, 'packetdump'),
51
               'nox_pysw' : lambda a, b: NOX(a, b, 'pyswitch'),
52
               'remote' : lambda a, b: None,
53
               'none' :     lambda a, b: None}
49
CONTROLLERS = {'ref': Controller,
50
               'nox_dump': lambda a, b: NOX(a, b, 'packetdump'),
51
               'nox_pysw': lambda a, b: NOX(a, b, 'pyswitch'),
52
               'remote': lambda a, b: None,
53
               'none': lambda a, b: None}
54 54

  
55 55
# optional tests to run
56 56
TESTS = ['cli', 'build', 'ping_all', 'ping_pair', 'iperf', 'all', 'iperf_udp']
57 57

  
58

  
58 59
def add_dict_option(opts, choices_dict, default, name, help_str = None):
59 60
    '''Convenience function to add choices dicts to OptionParser.
60
    
61

  
61 62
    @param opts OptionParser instance
62 63
    @param choices_dict dictionary of valid choices, must include default
63 64
    @param default default choice key
......
82 83
    def __init__(self):
83 84
        '''Init.'''
84 85
        self.options = None
85
        
86

  
86 87
        self.parse_args()
87 88
        self.setup()
88 89
        self.begin()
89 90

  
90 91
    def parse_args(self):
91 92
        '''Parse command-line args and return options object.
92
        
93

  
93 94
        @return opts parse options dict
94 95
        '''
95 96
        opts = OptionParser()
......
124 125
        '''Setup and validate environment.'''
125 126

  
126 127
        # set logging verbosity
127
        set_loglevel(self.options.verbosity)
128
        lg.set_loglevel(self.options.verbosity)
128 129

  
129 130
        # validate environment setup
130 131
        init()

Also available in: Unified diff