Revision 49654212 bin/mn

View differences:

bin/mn
25 25
from mininet.log import lg, LEVELS, info, debug, warn, error
26 26
from mininet.net import Mininet, MininetWithControlNet, VERSION
27 27
from mininet.node import ( Host, CPULimitedHost, Controller, OVSController,
28
                           RYU, NOX, RemoteController, findController, DefaultController,
28
                           RYU, NOX, RemoteController, findController,
29
                           DefaultController,
29 30
                           UserSwitch, OVSSwitch, OVSBridge,
30 31
                           OVSLegacyKernelSwitch, IVSSwitch )
31 32
from mininet.nodelib import LinuxBridge
......
132 133
        self.setup()
133 134
        self.begin()
134 135

  
135
    def custom( self, option, opt_str, value, parser ):
136
    def custom( self, _option, _opt_str, value, _parser ):
136 137
        """Parse custom file and add params.
137 138
           option: option e.g. --custom
138 139
           opt_str: option string e.g. --custom
......
168 169
            # Add or modify global variable or class
169 170
            globals()[ name ] = value
170 171

  
171
    def setNat( self, option, opt_str, value, parser ):
172
    def setNat( self, _option, opt_str, value, parser ):
173
        "Set NAT option(s)"
174
        assert self  # satisfy pylint
172 175
        parser.values.nat = True
173
        if parser.rargs and parser.rargs[ 0 ][ 0 ] != '-': #first arg, first char != '-'
176
        # first arg, first char != '-'
177
        if parser.rargs and parser.rargs[ 0 ][ 0 ] != '-':
174 178
            value = parser.rargs.pop( 0 )
175 179
            _, args, kwargs = splitArgs( opt_str + ',' + value )
176 180
            parser.values.nat_args = args
......
201 205
                         default=False, help='clean and exit' )
202 206
        opts.add_option( '--custom', action='callback',
203 207
                         callback=self.custom,
204
                         type='string', help='read custom classes or params from .py file(s)' )
208
                         type='string',
209
                         help='read custom classes or params from .py file(s)' )
205 210
        opts.add_option( '--test', type='choice', choices=TESTS,
206 211
                         default=TESTS[ 0 ],
207 212
                         help='|'.join( TESTS ) )
......
231 236
                         default=False, help="pin hosts to CPU cores "
232 237
                         "(requires --host cfs or --host rt)" )
233 238
        opts.add_option( '--nat', action='callback', callback=self.setNat,
234
                         help="adds a NAT to the topology that connects Mininet hosts"
235
                         " to the physical network."
236
                         " Warning: This may route any traffic on the machine that uses Mininet's"
237
                         " IP subnet into the Mininet network. If you need to change"
239
                         help="adds a NAT to the topology that"
240
                         " connects Mininet hosts to the physical network."
241
                         " Warning: This may route any traffic on the machine"
242
                         " that uses Mininet's"
243
                         " IP subnet into the Mininet network."
244
                         " If you need to change"
238 245
                         " Mininet's IP subnet, see the --ipbase option." )
239 246
        opts.add_option( '--version', action='callback', callback=version,
240 247
                         help='prints the version and exits' )
......
265 272
                    % self.options.verbosity )
266 273
        lg.setLogLevel( self.options.verbosity )
267 274

  
275
    # Maybe we'll reorganize this someday...
276
    # pylint: disable=too-many-branches,too-many-statements
277

  
268 278
    def begin( self ):
269 279
        "Create and run mininet."
270 280

  
......
279 289
            CONTROLLERS[ 'default' ] = findController()
280 290
            if CONTROLLERS[ 'default' ] is None:
281 291
                if self.options.switch == 'default':
282
                    # Fall back to OVS Bridge, which does not use an OF controller
283
                    info( '*** No default OpenFlow controller found for default switch!\n' )
292
                    info( '*** No default OpenFlow controller found '
293
                          'for default switch!\n' )
284 294
                    info( '*** Falling back to OVS Bridge\n' )
285 295
                    self.options.switch = 'ovsbr'
286 296
                    self.options.controller = 'none'
287 297
                elif self.options.switch in ( 'ovsbr', 'lxbr' ):
288 298
                    self.options.controller = 'none'
289 299
                else:
290
                    raise Exception( "Could not find a default controller for switch %s" %
300
                    raise Exception( "Could not find a default controller "
301
                                     "for switch %s" %
291 302
                                     self.options.switch )
292 303

  
293 304
        topo = buildTopo( TOPOS, self.options.topo )

Also available in: Unified diff