From 42cdda38bbb3a1d3950f3d42b05368bf726d8fd4 Mon Sep 17 00:00:00 2001 From: cody burkard Date: Fri, 1 Aug 2014 11:27:25 -0700 Subject: [PATCH] added some documentation --- mininet/link.py | 11 ++++++++--- mininet/net.py | 2 ++ mininet/node.py | 6 ++---- mininet/util.py | 19 ++----------------- 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/mininet/link.py b/mininet/link.py index c7e5c72..9eed928 100644 --- a/mininet/link.py +++ b/mininet/link.py @@ -42,6 +42,9 @@ class Intf( object ): self.link = link self.mac = mac self.ip, self.prefixLen = None, None + + # if interface is lo, we know the ip is 127.0.0.1. + # This saves an ifconfig command per node if self.name == 'lo': self.ip = '127.0.0.1' # Add to node (and move ourselves if necessary ) @@ -94,10 +97,12 @@ class Intf( object ): self.mac = macs[ 0 ] if macs else None return self.mac + # Instead of updating ip and mac separately, + # use one ifconfig call to do it simultaneously. + # This saves an ifconfig command, which improves performance. + def updateAddr( self ): - """Return IP address and MAC address based on ifconfig. - instead of updating ip and mac separately, - use one ifconfig call to do it simultaneously""" + "Return IP address and MAC address based on ifconfig." ifconfig = self.ifconfig() ips = self._ipMatchRegex.findall( ifconfig ) macs = self._macMatchRegex.findall( ifconfig ) diff --git a/mininet/net.py b/mininet/net.py index 3b822f4..a3ff824 100755 --- a/mininet/net.py +++ b/mininet/net.py @@ -166,6 +166,7 @@ class Mininet( object ): if topo and build: self.build() + def waitConnected( self, timeout=None, delay=.5 ): """wait for each switch to connect to a controller, up to 5 seconds @@ -384,6 +385,7 @@ class Mininet( object ): srcPort, dstPort = topo.port( srcName, dstName ) self.addLink( src, dst, srcPort, dstPort, **params ) info( '(%s, %s) ' % ( src.name, dst.name ) ) + info( '\n' ) def configureControlNetwork( self ): diff --git a/mininet/node.py b/mininet/node.py index 0b435fc..40a3c34 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -331,10 +331,7 @@ class Node( object ): # Shell requires a string, not a list! if defaults.get( 'shell', False ): cmd = ' '.join( cmd ) - old = signal.signal( signal.SIGINT, signal.SIG_IGN ) - popen = Popen( cmd, **defaults ) - signal.signal( signal.SIGINT, old ) - return popen + return Popen( cmd, **defaults ) def pexec( self, *args, **kwargs ): """Execute a command using popen @@ -1198,6 +1195,7 @@ class IVSSwitch(Switch): args.append( self.opts ) logfile = '/tmp/ivs.%s.log' % self.name + self.cmd( 'ifconfig lo up' ) self.cmd( ' '.join(args) + ' >' + logfile + ' 2>&1