testing link stuff
This commit is contained in:
@@ -281,7 +281,6 @@ class MininetRunner( object ):
|
|||||||
if self.options.post:
|
if self.options.post:
|
||||||
CLI( mn, script=self.options.post )
|
CLI( mn, script=self.options.post )
|
||||||
|
|
||||||
mn.stop()
|
|
||||||
|
|
||||||
elapsed = float( time.time() - start )
|
elapsed = float( time.time() - start )
|
||||||
info( 'completed in %0.3f seconds\n' % elapsed )
|
info( 'completed in %0.3f seconds\n' % elapsed )
|
||||||
|
|||||||
+22
-4
@@ -86,6 +86,7 @@ class Intf( object ):
|
|||||||
|
|
||||||
def updateMAC( self ):
|
def updateMAC( self ):
|
||||||
"Return updated MAC address based on ifconfig"
|
"Return updated MAC address based on ifconfig"
|
||||||
|
#heres where we send the unecessary ifconfigs
|
||||||
ifconfig = self.ifconfig()
|
ifconfig = self.ifconfig()
|
||||||
macs = self._macMatchRegex.findall( ifconfig )
|
macs = self._macMatchRegex.findall( ifconfig )
|
||||||
self.mac = macs[ 0 ] if macs else None
|
self.mac = macs[ 0 ] if macs else None
|
||||||
@@ -102,8 +103,13 @@ class Intf( object ):
|
|||||||
def isUp( self, setUp=False ):
|
def isUp( self, setUp=False ):
|
||||||
"Return whether interface is up"
|
"Return whether interface is up"
|
||||||
if setUp:
|
if setUp:
|
||||||
self.ifconfig( 'up' )
|
r = self.ifconfig( 'up' )
|
||||||
return "UP" in self.ifconfig()
|
if r:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return "UP" in self.ifconfig()
|
||||||
|
|
||||||
def rename( self, newname ):
|
def rename( self, newname ):
|
||||||
"Rename interface"
|
"Rename interface"
|
||||||
@@ -138,6 +144,16 @@ class Intf( object ):
|
|||||||
results[ name ] = result
|
results[ name ] = result
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def updateAddr( self ):
|
||||||
|
"instead of updating ip and mac separately, use one ifconfig call to do it simultaneously"
|
||||||
|
ifconfig = self.ifconfig()
|
||||||
|
print 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,
|
def config( self, mac=None, ip=None, ifconfig=None,
|
||||||
up=True, **_params ):
|
up=True, **_params ):
|
||||||
"""Configure Node according to (optional) parameters:
|
"""Configure Node according to (optional) parameters:
|
||||||
@@ -154,8 +170,10 @@ class Intf( object ):
|
|||||||
self.setParam( r, 'setIP', ip=ip )
|
self.setParam( r, 'setIP', ip=ip )
|
||||||
self.setParam( r, 'isUp', up=up )
|
self.setParam( r, 'isUp', up=up )
|
||||||
self.setParam( r, 'ifconfig', ifconfig=ifconfig )
|
self.setParam( r, 'ifconfig', ifconfig=ifconfig )
|
||||||
self.updateIP()
|
#should combine these next two operations into one. this is unecessary
|
||||||
self.updateMAC()
|
#self.updateAddr()
|
||||||
|
#self.updateIP()
|
||||||
|
#self.updateMAC()
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def delete( self ):
|
def delete( self ):
|
||||||
|
|||||||
+8
-1
@@ -101,6 +101,7 @@ from mininet.link import Link, Intf
|
|||||||
from mininet.util import quietRun, fixLimits, numCores, ensureRoot
|
from mininet.util import quietRun, fixLimits, numCores, ensureRoot
|
||||||
from mininet.util import macColonHex, ipStr, ipParse, netParse, ipAdd
|
from mininet.util import macColonHex, ipStr, ipParse, netParse, ipAdd
|
||||||
from mininet.term import cleanUpScreens, makeTerms
|
from mininet.term import cleanUpScreens, makeTerms
|
||||||
|
from multiprocessing.pool import ThreadPool
|
||||||
|
|
||||||
# Mininet version: should be consistent with README and LICENSE
|
# Mininet version: should be consistent with README and LICENSE
|
||||||
VERSION = "2.1.0+"
|
VERSION = "2.1.0+"
|
||||||
@@ -159,6 +160,8 @@ class Mininet( object ):
|
|||||||
|
|
||||||
self.terms = [] # list of spawned xterm processes
|
self.terms = [] # list of spawned xterm processes
|
||||||
|
|
||||||
|
self.pool = ThreadPool( 64 )
|
||||||
|
|
||||||
Mininet.init() # Initialize Mininet if necessary
|
Mininet.init() # Initialize Mininet if necessary
|
||||||
|
|
||||||
self.built = False
|
self.built = False
|
||||||
@@ -374,13 +377,17 @@ class Mininet( object ):
|
|||||||
info( switchName + ' ' )
|
info( switchName + ' ' )
|
||||||
|
|
||||||
info( '\n*** Adding links:\n' )
|
info( '\n*** Adding links:\n' )
|
||||||
|
# need to 'asynchronize' this too
|
||||||
for srcName, dstName in topo.links(sort=True):
|
for srcName, dstName in topo.links(sort=True):
|
||||||
src, dst = self.nameToNode[ srcName ], self.nameToNode[ dstName ]
|
src, dst = self.nameToNode[ srcName ], self.nameToNode[ dstName ]
|
||||||
params = topo.linkInfo( srcName, dstName )
|
params = topo.linkInfo( srcName, dstName )
|
||||||
srcPort, dstPort = topo.port( srcName, dstName )
|
srcPort, dstPort = topo.port( srcName, dstName )
|
||||||
self.addLink( src, dst, srcPort, dstPort, **params )
|
self.addLink( src, dst, srcPort, dstPort, **params )
|
||||||
|
#self.pool.apply( self.addLink, ( src, dst, srcPort, dstPort, params, ) )
|
||||||
|
#self.pool.apply_async( self.addLink, args = ( src, dst )+ params, kwds = { 'Port1':srcPort, 'Port2':dstPort } )
|
||||||
info( '(%s, %s) ' % ( src.name, dst.name ) )
|
info( '(%s, %s) ' % ( src.name, dst.name ) )
|
||||||
|
#self.pool.close()
|
||||||
|
#self.pool.join()
|
||||||
info( '\n' )
|
info( '\n' )
|
||||||
|
|
||||||
def configureControlNetwork( self ):
|
def configureControlNetwork( self ):
|
||||||
|
|||||||
+5
-3
@@ -82,6 +82,8 @@ def errRun( *cmd, **kwargs ):
|
|||||||
poller.register( popen.stdout, POLLIN )
|
poller.register( popen.stdout, POLLIN )
|
||||||
fdtofile = { popen.stdout.fileno(): popen.stdout }
|
fdtofile = { popen.stdout.fileno(): popen.stdout }
|
||||||
outDone, errDone = False, True
|
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:
|
if popen.stderr:
|
||||||
fdtofile[ popen.stderr.fileno() ] = popen.stderr
|
fdtofile[ popen.stderr.fileno() ] = popen.stderr
|
||||||
poller.register( popen.stderr, POLLIN )
|
poller.register( popen.stderr, POLLIN )
|
||||||
@@ -185,10 +187,10 @@ def moveIntfNoRetry( intf, dstNode, srcNode=None, printError=False ):
|
|||||||
intf = str( intf )
|
intf = str( intf )
|
||||||
cmd = 'ip link set %s netns %s' % ( intf, dstNode.pid )
|
cmd = 'ip link set %s netns %s' % ( intf, dstNode.pid )
|
||||||
if srcNode:
|
if srcNode:
|
||||||
srcNode.cmd( cmd )
|
output = srcNode.cmd( cmd )
|
||||||
else:
|
else:
|
||||||
quietRun( cmd )
|
output = quietRun( cmd )
|
||||||
if ( ' %s:' % intf ) not in dstNode.cmd( 'ip link show', intf ):
|
if output:
|
||||||
if printError:
|
if printError:
|
||||||
error( '*** Error: moveIntf: ' + intf +
|
error( '*** Error: moveIntf: ' + intf +
|
||||||
' not successfully moved to ' + dstNode.name + '\n' )
|
' not successfully moved to ' + dstNode.name + '\n' )
|
||||||
|
|||||||
Reference in New Issue
Block a user