From a3d51b77e9d7d21b65548856b51f4a4a990f8ed2 Mon Sep 17 00:00:00 2001 From: cody burkard Date: Thu, 24 Jul 2014 15:59:38 -0700 Subject: [PATCH] few small fixes to syntax errors --- bin/mn | 2 +- mininet/link.py | 4 ++-- mininet/net.py | 19 ++----------------- mininet/node.py | 1 - mininet/util.py | 22 ++++++++++++++++++++-- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/bin/mn b/bin/mn index f96511c..edd4d98 100755 --- a/bin/mn +++ b/bin/mn @@ -282,7 +282,7 @@ class MininetRunner( object ): 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 2e6e171..c7e5c72 100644 --- a/mininet/link.py +++ b/mininet/link.py @@ -97,7 +97,7 @@ class Intf( object ): 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"""" + use one ifconfig call to do it simultaneously""" ifconfig = self.ifconfig() ips = self._ipMatchRegex.findall( ifconfig ) macs = self._macMatchRegex.findall( ifconfig ) @@ -118,7 +118,7 @@ class Intf( object ): if setUp: cmdOutput = self.ifconfig( 'up' ) if cmdOutput: - error( "Error setting %s up: %s " % ( self.name, cmdOutput ) + error( "Error setting %s up: %s " % ( self.name, cmdOutput ) ) return False else: return True diff --git a/mininet/net.py b/mininet/net.py index 30feb8f..3b822f4 100755 --- a/mininet/net.py +++ b/mininet/net.py @@ -303,21 +303,6 @@ class Mininet( object ): "return (key,value) tuple list for every node in net" return zip( self.keys(), self.values() ) - def generateMac( self ): - newMac = True - while True: - macList = [ 0x00 ] - for i in xrange ( 0, 5 ): - macList.append( random.randint( 0x00, 0xff ) ) - mac = ':'.join( map(lambda x: "%02x" % x, macList ) ) - for node in self.switches + self.hosts: - for intf in node.ports: - if intf.mac == mac: - newMac = False - break - if newMac: - return mac - def addLink( self, node1, node2, port1=None, port2=None, cls=None, **params ): """"Add a link from node1 to node2 @@ -326,8 +311,8 @@ class Mininet( object ): port1: source port port2: dest port returns: link object""" - mac1 = self.generateMac() - mac2 = self.generateMac() + mac1 = macColonHex( random.randint( 1, (2**24 - 1) ) ) + mac2 = macColonHex( random.randint( 1, (2**24 - 1) ) ) defaults = { 'port1': port1, 'port2': port2, 'addr1': mac1, diff --git a/mininet/node.py b/mininet/node.py index 472e66a..4eb27ad 100644 --- a/mininet/node.py +++ b/mininet/node.py @@ -1193,7 +1193,6 @@ 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