few small fixes to syntax errors
This commit is contained in:
@@ -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 )
|
||||
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
+2
-17
@@ -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,
|
||||
|
||||
@@ -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 </dev/null &' )
|
||||
|
||||
|
||||
+20
-2
@@ -192,7 +192,7 @@ def moveIntfNoRetry( intf, dstNode, srcNode=None, printError=False ):
|
||||
cmdOutput = srcNode.cmd( cmd )
|
||||
else:
|
||||
cmdOutput = quietRun( cmd )
|
||||
if output:
|
||||
if cmdOutput:
|
||||
if printError:
|
||||
error( '*** Error: moveIntf: ' + intf +
|
||||
' not successfully moved to ' + dstNode.name + '\n' )
|
||||
@@ -249,11 +249,29 @@ def _colonHex( val, bytecount ):
|
||||
chStr = ':'.join( pieces )
|
||||
return chStr
|
||||
|
||||
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 macColonHex( mac ):
|
||||
"""Generate MAC colon-hex string from unsigned int.
|
||||
mac: MAC address as unsigned int
|
||||
returns: macStr MAC colon-hex string"""
|
||||
return _colonHex( mac, 6 )
|
||||
if mac < 2**24:
|
||||
return 'A4:23:05:' + _colonHex( mac, 3 )
|
||||
else:
|
||||
return _colonHex( mac, 6 )
|
||||
|
||||
def ipStr( ip ):
|
||||
"""Generate IP address string from an unsigned int.
|
||||
|
||||
Reference in New Issue
Block a user