Revision b57e5d93

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.
mininet/node.py
981 981
                if not intf.IP():
982 982
                    self.TCReapply( intf )
983 983

  
984
    def stop( self ):
984
    def stop( self, deleteIntfs=True ):
985 985
        "Stop OpenFlow reference user datapath."
986 986
        self.cmd( 'kill %ofdatapath' )
987 987
        self.cmd( 'kill %ofprotocol' )
988
        self.deleteIntfs()
988
        if deleteIntfs:
989
            self.deleteIntfs()
989 990

  
990 991

  
991 992
class OVSLegacyKernelSwitch( Switch ):
......
1031 1032
                  ' 1>' + ofplog + ' 2>' + ofplog + '&' )
1032 1033
        self.execed = False
1033 1034

  
1034
    def stop( self ):
1035
    def stop( self, deleteIntfs=True ):
1035 1036
        "Terminate kernel datapath."
1036 1037
        quietRun( 'ovs-dpctl del-dp ' + self.dp )
1037 1038
        self.cmd( 'kill %ovs-openflowd' )
1038
        self.deleteIntfs()
1039
        if deleteIntfs:
1040
            self.deleteIntfs()
1039 1041

  
1040 1042

  
1041 1043
class OVSSwitch( Switch ):
......
1183 1185
            self.TCReapply( intf )
1184 1186

  
1185 1187

  
1186
    def stop( self ):
1188
    def stop( self, deleteIntfs=True ):
1187 1189
        "Terminate OVS switch."
1188 1190
        self.cmd( 'ovs-vsctl del-br', self )
1189 1191
        if self.datapath == 'user':
1190 1192
            self.cmd( 'ip link del', self )
1191
        self.deleteIntfs()
1193
        if deleteIntfs:
1194
            self.deleteIntfs()
1192 1195

  
1193 1196

  
1194 1197
OVSKernelSwitch = OVSSwitch
......
1205 1208
        OVSSwitch.start( self, controllers=[] )
1206 1209

  
1207 1210

  
1208
class IVSSwitch(Switch):
1211
class IVSSwitch( Switch ):
1209 1212
    """IVS virtual switch"""
1210 1213

  
1211 1214
    def __init__( self, name, verbose=True, **kwargs ):
......
1251 1254

  
1252 1255
        self.cmd( ' '.join(args) + ' >' + logfile + ' 2>&1 </dev/null &' )
1253 1256

  
1254
    def stop( self ):
1257
    def stop( self, deleteIntfs=True ):
1255 1258
        "Terminate IVS switch."
1256 1259
        self.cmd( 'kill %ivs' )
1257 1260
        self.cmd( 'wait' )
1258
        self.deleteIntfs()
1261
        if deleteIntfs:
1262
            self.deleteIntfs()
1259 1263

  
1260 1264
    def attach( self, intf ):
1261 1265
        "Connect a data port"

Also available in: Unified diff