Reduce interface move delay and make configurable
Much faster now; from 1 s delay to 100 us.
This commit is contained in:
+6
-4
@@ -333,6 +333,8 @@ class Switch( Node ):
|
||||
# live in the root namespace and thus do not have to be
|
||||
# explicitly moved.
|
||||
|
||||
MOVEINTF_DELAY = 0.0001
|
||||
|
||||
def makeIntfPair( intf1, intf2 ):
|
||||
"Make a veth pair of intf1 and intf2."
|
||||
# Delete any old interfaces with the same names
|
||||
@@ -353,11 +355,11 @@ def moveIntf( intf, node ):
|
||||
return False
|
||||
return True
|
||||
|
||||
def retry( n, fn, *args):
|
||||
def retry( n, retry_delay, fn, *args):
|
||||
"Try something N times before giving up."
|
||||
tries = 0
|
||||
while not apply( fn, args ) and tries < n:
|
||||
sleep( 1 )
|
||||
sleep( retry_delay )
|
||||
print "*** retrying..."; flush()
|
||||
tries += 1
|
||||
if tries >= n:
|
||||
@@ -369,8 +371,8 @@ def createLink( node1, node2 ):
|
||||
intf1 = node1.newIntf()
|
||||
intf2 = node2.newIntf()
|
||||
makeIntfPair( intf1, intf2 )
|
||||
if node1.inNamespace: retry( 3, moveIntf, intf1, node1 )
|
||||
if node2.inNamespace: retry( 3, moveIntf, intf2, node2 )
|
||||
if node1.inNamespace: retry( 3, MOVEINTF_DELAY, moveIntf, intf1, node1 )
|
||||
if node2.inNamespace: retry( 3, MOVEINTF_DELAY, moveIntf, intf2, node2 )
|
||||
node1.connection[ intf1 ] = ( node2, intf2 )
|
||||
node2.connection[ intf2 ] = ( node1, intf1 )
|
||||
return intf1, intf2
|
||||
|
||||
Reference in New Issue
Block a user