From c1dc80571a0113c62e63181c691c2074c3cc3fa6 Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Wed, 4 Feb 2015 04:26:40 -0800 Subject: [PATCH] Correctly group switches for batch operations --- examples/cluster.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/cluster.py b/examples/cluster.py index ef1b759..787f3bb 100755 --- a/examples/cluster.py +++ b/examples/cluster.py @@ -79,7 +79,7 @@ from mininet.link import Link, Intf from mininet.net import Mininet from mininet.topo import LinearTopo from mininet.topolib import TreeTopo -from mininet.util import quietRun, errRun, retry +from mininet.util import quietRun, errRun from mininet.examples.clustercli import CLI from mininet.log import setLogLevel, debug, info, error from mininet.clean import addCleanupCallback @@ -326,7 +326,8 @@ class RemoteOVSSwitch( RemoteMixin, OVSSwitch ): @classmethod def batchStartup( cls, switches, **_kwargs ): "Start up switches in per-server batches" - for server, switchGroup in groupby( switches, attrgetter( 'server' ) ): + key = attrgetter( 'server' ) + for server, switchGroup in groupby( sorted( switches, key=key ), key ): info( '(%s)' % server ) group = tuple( switchGroup ) switch = group[ 0 ] @@ -336,7 +337,8 @@ class RemoteOVSSwitch( RemoteMixin, OVSSwitch ): @classmethod def batchShutdown( cls, switches, **_kwargs ): "Stop switches in per-server batches" - for server, switchGroup in groupby( switches, attrgetter( 'server' ) ): + key = attrgetter( 'server' ) + for server, switchGroup in groupby( sorted( switches, key=key ), key ): info( '(%s)' % server ) group = tuple( switchGroup ) switch = group[ 0 ]