Let Mininet() explicitly delete links.
This commit is contained in:
+16
-7
@@ -152,7 +152,8 @@ class Mininet( object ):
|
||||
self.hosts = []
|
||||
self.switches = []
|
||||
self.controllers = []
|
||||
|
||||
self.links = []
|
||||
|
||||
self.nameToNode = {} # name to Node (Host/Switch) objects
|
||||
|
||||
self.terms = [] # list of spawned xterm processes
|
||||
@@ -252,7 +253,9 @@ class Mininet( object ):
|
||||
defaults.update( params )
|
||||
if not cls:
|
||||
cls = self.link
|
||||
return cls( node1, node2, **defaults )
|
||||
link = cls( node1, node2, **defaults )
|
||||
self.links.append( link )
|
||||
return link
|
||||
|
||||
def configHosts( self ):
|
||||
"Configure a set of hosts."
|
||||
@@ -372,15 +375,21 @@ class Mininet( object ):
|
||||
if self.terms:
|
||||
info( '*** Stopping %i terms\n' % len( self.terms ) )
|
||||
self.stopXterms()
|
||||
info( '*** Stopping %i hosts\n' % len( self.hosts ) )
|
||||
for host in self.hosts:
|
||||
info( host.name + ' ' )
|
||||
host.terminate()
|
||||
info( '\n' )
|
||||
info( '*** Stopping %i switches\n' % len( self.switches ) )
|
||||
for switch in self.switches:
|
||||
info( switch.name + ' ' )
|
||||
switch.stop()
|
||||
switch.stop( deleteIntfs=False )
|
||||
info( '\n' )
|
||||
info( '*** Removing %i links\n' % len( self.links ) )
|
||||
for link in self.links:
|
||||
info( '.' )
|
||||
link.delete()
|
||||
info( '\n' )
|
||||
info( '*** Stopping %i hosts\n' % len( self.hosts ) )
|
||||
for host in self.hosts:
|
||||
info( host.name + ' ' )
|
||||
host.terminate()
|
||||
info( '\n' )
|
||||
info( '*** Stopping %i controllers\n' % len( self.controllers ) )
|
||||
for controller in self.controllers:
|
||||
|
||||
+12
-7
@@ -49,6 +49,7 @@ import re
|
||||
import signal
|
||||
import select
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
from sys import stdout
|
||||
|
||||
from mininet.log import info, error, warn, debug
|
||||
from mininet.util import ( quietRun, errRun, errFail, moveIntf, isShellBuiltin,
|
||||
@@ -405,6 +406,7 @@ class Node( object ):
|
||||
for intf in self.intfs.values():
|
||||
intf.delete()
|
||||
info( '.' )
|
||||
stdout.flush()
|
||||
|
||||
# Routing support
|
||||
|
||||
@@ -840,11 +842,12 @@ class UserSwitch( Switch ):
|
||||
' --fail=closed ' + self.opts +
|
||||
' 1> ' + ofplog + ' 2>' + ofplog + ' &' )
|
||||
|
||||
def stop( self ):
|
||||
def stop( self, deleteIntfs=True ):
|
||||
"Stop OpenFlow reference user datapath."
|
||||
self.cmd( 'kill %ofdatapath' )
|
||||
self.cmd( 'kill %ofprotocol' )
|
||||
self.deleteIntfs()
|
||||
if deleteIntfs:
|
||||
self.deleteIntfs()
|
||||
|
||||
|
||||
class OVSLegacyKernelSwitch( Switch ):
|
||||
@@ -891,11 +894,12 @@ class OVSLegacyKernelSwitch( Switch ):
|
||||
' 1>' + ofplog + ' 2>' + ofplog + '&' )
|
||||
self.execed = False
|
||||
|
||||
def stop( self ):
|
||||
def stop( self, deleteIntfs=True ):
|
||||
"Terminate kernel datapath."
|
||||
quietRun( 'ovs-dpctl del-dp ' + self.dp )
|
||||
self.cmd( 'kill %ovs-openflowd' )
|
||||
self.deleteIntfs()
|
||||
if deleteIntfs:
|
||||
self.deleteIntfs()
|
||||
|
||||
|
||||
class OVSSwitch( Switch ):
|
||||
@@ -974,10 +978,11 @@ class OVSSwitch( Switch ):
|
||||
clist += ' ptcp:%s' % self.listenPort
|
||||
self.cmd( 'ovs-vsctl set-controller', self, clist )
|
||||
|
||||
def stop( self ):
|
||||
"Terminate OVS switch."
|
||||
def stop( self, deleteIntfs=True ):
|
||||
"Stop OVS switch."
|
||||
self.cmd( 'ovs-vsctl del-br', self )
|
||||
self.deleteIntfs()
|
||||
if deleteIntfs:
|
||||
self.deleteIntfs()
|
||||
|
||||
OVSKernelSwitch = OVSSwitch
|
||||
|
||||
|
||||
Reference in New Issue
Block a user