Merge pull request #309 from rlane/ivs-batch-shutdown
support batch shutdown for IVS
This commit is contained in:
+3
-4
@@ -91,7 +91,7 @@ import re
|
|||||||
import select
|
import select
|
||||||
import signal
|
import signal
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from itertools import chain
|
from itertools import chain, groupby
|
||||||
|
|
||||||
from mininet.cli import CLI
|
from mininet.cli import CLI
|
||||||
from mininet.log import info, error, debug, output
|
from mininet.log import info, error, debug, output
|
||||||
@@ -408,10 +408,9 @@ class Mininet( object ):
|
|||||||
info( '*** Stopping %i terms\n' % len( self.terms ) )
|
info( '*** Stopping %i terms\n' % len( self.terms ) )
|
||||||
self.stopXterms()
|
self.stopXterms()
|
||||||
info( '*** Stopping %i switches\n' % len( self.switches ) )
|
info( '*** Stopping %i switches\n' % len( self.switches ) )
|
||||||
if self.switches:
|
for swclass, switches in groupby( sorted( self.switches, key=type ), type ):
|
||||||
swclass = type( self.switches[ 0 ] )
|
|
||||||
if hasattr( swclass, 'batchShutdown' ):
|
if hasattr( swclass, 'batchShutdown' ):
|
||||||
swclass.batchShutdown( self.switches )
|
swclass.batchShutdown( switches )
|
||||||
for switch in self.switches:
|
for switch in self.switches:
|
||||||
info( switch.name + ' ' )
|
info( switch.name + ' ' )
|
||||||
switch.stop()
|
switch.stop()
|
||||||
|
|||||||
+7
-1
@@ -993,7 +993,7 @@ class OVSSwitch( Switch ):
|
|||||||
"Call ovs-vsctl del-br on all OVSSwitches in a list"
|
"Call ovs-vsctl del-br on all OVSSwitches in a list"
|
||||||
quietRun( 'ovs-vsctl ' +
|
quietRun( 'ovs-vsctl ' +
|
||||||
' -- '.join( '--if-exists del-br %s' % s
|
' -- '.join( '--if-exists del-br %s' % s
|
||||||
for s in switches if type(s) == cls ) )
|
for s in switches ) )
|
||||||
|
|
||||||
def dpctl( self, *args ):
|
def dpctl( self, *args ):
|
||||||
"Run ovs-ofctl command"
|
"Run ovs-ofctl command"
|
||||||
@@ -1106,6 +1106,12 @@ class IVSSwitch(Switch):
|
|||||||
'not be loaded. Try modprobe openvswitch.\n' )
|
'not be loaded. Try modprobe openvswitch.\n' )
|
||||||
exit( 1 )
|
exit( 1 )
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def batchShutdown( cls, switches ):
|
||||||
|
"Kill each IVS switch, to be waited on later in stop()"
|
||||||
|
for switch in switches:
|
||||||
|
switch.cmd( 'kill %ivs' )
|
||||||
|
|
||||||
def start( self, controllers ):
|
def start( self, controllers ):
|
||||||
"Start up a new IVS switch"
|
"Start up a new IVS switch"
|
||||||
args = ['ivs']
|
args = ['ivs']
|
||||||
|
|||||||
Reference in New Issue
Block a user