From 6bc9d6848529367144a51ebbe149997668c00f61 Mon Sep 17 00:00:00 2001
From: cody burkard <cody@onlab.us>
Date: Tue, 22 Jul 2014 23:00:43 -0700
Subject: [PATCH] removed comments and cleaned up code.

---
 bin/mn          |  3 ++-
 mininet/link.py | 29 ++++++++++++++---------------
 mininet/net.py  |  8 --------
 mininet/util.py |  6 ++----
 4 files changed, 18 insertions(+), 28 deletions(-)

diff --git a/bin/mn b/bin/mn
index fbe1f05b..f96511cf 100755
--- a/bin/mn
+++ b/bin/mn
@@ -281,7 +281,8 @@ class MininetRunner( object ):
         if self.options.post:
             CLI( mn, script=self.options.post )
 
-
+        mn.stop()
+        
         elapsed = float( time.time() - start )
         info( 'completed in %0.3f seconds\n' % elapsed )
 
diff --git a/mininet/link.py b/mininet/link.py
index e9df6cc8..2e6e1711 100644
--- a/mininet/link.py
+++ b/mininet/link.py
@@ -89,12 +89,22 @@ def updateIP( self ):
 
     def updateMAC( self ):
         "Return updated MAC address based on ifconfig"
-        #heres where we send the unecessary ifconfigs
         ifconfig = self.ifconfig()
         macs = self._macMatchRegex.findall( ifconfig )
         self.mac = macs[ 0 ] if macs else None
         return self.mac
 
+    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""""
+        ifconfig = self.ifconfig()
+        ips = self._ipMatchRegex.findall( ifconfig )
+        macs = self._macMatchRegex.findall( ifconfig )
+        self.ip = ips[ 0 ] if ips else None
+        self.mac = macs[ 0 ] if macs else None
+        return self.ip, self.mac
+
     def IP( self ):
         "Return IP address"
         return self.ip
@@ -106,8 +116,9 @@ def MAC( self ):
     def isUp( self, setUp=False ):
         "Return whether interface is up"
         if setUp:
-            r = self.ifconfig( 'up' )
-            if r:
+            cmdOutput = self.ifconfig( 'up' )
+            if cmdOutput:
+                error( "Error setting %s up: %s " % ( self.name, cmdOutput )
                 return False
             else:
                 return True
@@ -147,15 +158,6 @@ def setParam( self, results, method, **param ):
         results[ name ] = result
         return result
 
-    def updateAddr( self ):
-        "instead of updating ip and mac separately, use one ifconfig call to do it simultaneously"
-        ifconfig = self.ifconfig()
-        ips = self._ipMatchRegex.findall( ifconfig )
-        macs = self._macMatchRegex.findall( ifconfig )
-        self.ip = ips[ 0 ] if ips else None
-        self.mac = macs[ 0 ] if macs else None
-        return self.ip, self.mac
-
     def config( self, mac=None, ip=None, ifconfig=None,
                 up=True, **_params ):
         """Configure Node according to (optional) parameters:
@@ -172,9 +174,6 @@ def config( self, mac=None, ip=None, ifconfig=None,
         self.setParam( r, 'setIP', ip=ip )
         self.setParam( r, 'isUp', up=up )
         self.setParam( r, 'ifconfig', ifconfig=ifconfig )
-        #self.updateAddr()
-        #self.updateIP()
-        #self.updateMAC()
         return r
 
     def delete( self ):
diff --git a/mininet/net.py b/mininet/net.py
index 5be34f8a..30feb8fd 100755
--- a/mininet/net.py
+++ b/mininet/net.py
@@ -102,7 +102,6 @@
 from mininet.util import quietRun, fixLimits, numCores, ensureRoot
 from mininet.util import macColonHex, ipStr, ipParse, netParse, ipAdd
 from mininet.term import cleanUpScreens, makeTerms
-from multiprocessing import Process
 
 # Mininet version: should be consistent with README and LICENSE
 VERSION = "2.1.0+"
@@ -161,15 +160,12 @@ def __init__( self, topo=None, switch=OVSKernelSwitch, host=Host,
 
         self.terms = []  # list of spawned xterm processes
 
-        #self.pool = Pool( 64 )
-
         Mininet.init()  # Initialize Mininet if necessary
 
         self.built = False
         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
@@ -397,16 +393,12 @@ def buildFromTopo( self, topo=None ):
             info( switchName + ' ' )
 
         info( '\n*** Adding links:\n' )
-        # need to 'asynchronize' this too
         for srcName, dstName in topo.links(sort=True):
             src, dst = self.nameToNode[ srcName ], self.nameToNode[ dstName ]
             params = topo.linkInfo( srcName, dstName )
             srcPort, dstPort = topo.port( srcName, dstName )
             self.addLink( src, dst, srcPort, dstPort, **params )
-            #self.pool.apply_async( self.addLink,  ( src, dst, srcPort, dstPort, params ) )
             info( '(%s, %s) ' % ( src.name, dst.name ) )
-        #self.pool.close()
-        #self.pool.join()
         info( '\n' )
 
     def configureControlNetwork( self ):
diff --git a/mininet/util.py b/mininet/util.py
index 1a866fab..32160be1 100644
--- a/mininet/util.py
+++ b/mininet/util.py
@@ -82,8 +82,6 @@ def errRun( *cmd, **kwargs ):
     poller.register( popen.stdout, POLLIN )
     fdtofile = { popen.stdout.fileno(): popen.stdout }
     outDone, errDone = False, True
-    #bookmark: rearrange this for aynch startup. shouldnt have to keep 
-    # maybe we dont rearrange this. we really just need a method to call a command and NOT poll for output
     if popen.stderr:
         fdtofile[ popen.stderr.fileno() ] = popen.stderr
         poller.register( popen.stderr, POLLIN )
@@ -191,9 +189,9 @@ def moveIntfNoRetry( intf, dstNode, srcNode=None, printError=False ):
     intf = str( intf )
     cmd = 'ip link set %s netns %s' % ( intf, dstNode.pid )
     if srcNode:
-        output = srcNode.cmd( cmd )
+        cmdOutput = srcNode.cmd( cmd )
     else:
-        output = quietRun( cmd )
+        cmdOutput = quietRun( cmd )
     if output:
         if printError:
             error( '*** Error: moveIntf: ' + intf +
-- 
GitLab