Revision b57e5d93 mininet/cli.py

View differences:

mininet/cli.py
351 351
        for link in self.mn.links:
352 352
            print link, link.status()
353 353

  
354
    def do_switch( self, line ):
355
        "Starts or stops a switch"
356
        args = line.split()
357
        if len(args) != 2:
358
            error( 'invalid number of args: switch <switch name> {start, stop}\n' )
359
            return
360
        sw = args[ 0 ]
361
        command = args[ 1 ]
362
        if sw not in self.mn or self.mn.get( sw ) not in self.mn.switches :
363
            error( 'invalid switch: %s\n' % args[ 1 ] )
364
        else:
365
            sw = args[ 0 ]
366
            command = args[ 1 ]
367
            if command == 'start':
368
                self.mn.get( sw ).start( self.mn.controllers )
369
            elif command == 'stop':
370
                self.mn.get( sw ).stop( False )
371
            else:
372
                error( 'invalid command: switch <switch name> {start, stop}\n' )
373

  
354 374
    def default( self, line ):
355 375
        """Called on an input line when the command prefix is not recognized.
356 376
        Overridden to run shell commands when a node is the first CLI argument.

Also available in: Unified diff