From 9db6cdc2618562d314ae8a4ac65145762e0bcfed Mon Sep 17 00:00:00 2001 From: Bob Lantz Date: Thu, 22 Jan 2015 03:22:43 -0800 Subject: [PATCH] Call delete() in link.stop() ; warn on exited node.cmd() We should think a bit about the semantics that we want here. The comments say "stop and clean up link" so perhaps that's what we want. However, we could also imagine stop stopping forwarding on the link (and possibly allowing restarts). We warn on exited node.cmd() because we terminate the controller before stopping/deleting the links. This makes sense to avoid a storm of link/port down events, but since the controller's shell has exited we cannot call link.stop() on any of its links. We may want to simply stop the controller and not terminate it, but at least it doesn't hang for now. --- mininet/link.py | 8 ++++---- mininet/node.py | 9 ++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/mininet/link.py b/mininet/link.py index 3bc63ec..a1d1ad9 100644 --- a/mininet/link.py +++ b/mininet/link.py @@ -465,13 +465,13 @@ class Link( object ): def delete( self ): "Delete this link" self.intf1.delete() - # We only need to delete one side, but this doesn't seem to - # cost us anything and may help subclasses. - self.intf2.delete() + # We only need to delete one side, though this doesn't seem to + # cost us much and might help subclasses. + # self.intf2.delete() def stop( self ): "Override to stop and clean up link as needed" - pass + self.delete() def status( self ): "Return link status as a string" diff --git a/mininet/node.py b/mininet/node.py index f263ad0..ffbedec 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -259,7 +259,7 @@ class Node( object ): and return without waiting for the command to complete. args: command and arguments, or string printPid: print command's PID?""" - assert not self.waiting + assert self.shell and not self.waiting printPid = kwargs.get( 'printPid', True ) # Allow sendCmd( [ list ] ) if len( args ) == 1 and isinstance( args[ 0 ], list ): @@ -339,8 +339,11 @@ class Node( object ): verbose = kwargs.get( 'verbose', False ) log = info if verbose else debug log( '*** %s : %s\n' % ( self.name, args ) ) - self.sendCmd( *args, **kwargs ) - return self.waitOutput( verbose ) + if self.shell: + self.sendCmd( *args, **kwargs ) + return self.waitOutput( verbose ) + else: + warn( '(%s exited - ignoring cmd%s)\n' % ( self, args ) ) def cmdPrint( self, *args): """Call cmd and printing its output