Clarify makeIntfPair behavior and pass code check
This commit is contained in:
+6
-7
@@ -56,6 +56,7 @@ def oldQuietRun( *cmd ):
|
|||||||
# This is a bit complicated, but it enables us to
|
# This is a bit complicated, but it enables us to
|
||||||
# monitor command output as it is happening
|
# monitor command output as it is happening
|
||||||
|
|
||||||
|
# pylint: disable=too-many-branches
|
||||||
def errRun( *cmd, **kwargs ):
|
def errRun( *cmd, **kwargs ):
|
||||||
"""Run a command and return stdout, stderr and return code
|
"""Run a command and return stdout, stderr and return code
|
||||||
cmd: string or list of command and args
|
cmd: string or list of command and args
|
||||||
@@ -116,6 +117,7 @@ def errRun( *cmd, **kwargs ):
|
|||||||
returncode = popen.wait()
|
returncode = popen.wait()
|
||||||
debug( out, err, returncode )
|
debug( out, err, returncode )
|
||||||
return out, err, returncode
|
return out, err, returncode
|
||||||
|
# pylint: enable=too-many-branches
|
||||||
|
|
||||||
def errFail( *cmd, **kwargs ):
|
def errFail( *cmd, **kwargs ):
|
||||||
"Run a command using errRun and raise exception on nonzero exit"
|
"Run a command using errRun and raise exception on nonzero exit"
|
||||||
@@ -166,7 +168,7 @@ def makeIntfPair( intf1, intf2, addr1=None, addr2=None, node1=None, node2=None,
|
|||||||
node2: home node for interface 2 (optional)
|
node2: home node for interface 2 (optional)
|
||||||
deleteIntfs: delete intfs before creating them
|
deleteIntfs: delete intfs before creating them
|
||||||
runCmd: function to run shell commands (quietRun)
|
runCmd: function to run shell commands (quietRun)
|
||||||
returns: ip link add result"""
|
raises Exception on failure"""
|
||||||
if not runCmd:
|
if not runCmd:
|
||||||
runCmd = quietRun if not node1 else node1.cmd
|
runCmd = quietRun if not node1 else node1.cmd
|
||||||
runCmd2 = quietRun if not node2 else node2.cmd
|
runCmd2 = quietRun if not node2 else node2.cmd
|
||||||
@@ -187,12 +189,9 @@ def makeIntfPair( intf1, intf2, addr1=None, addr2=None, node1=None, node2=None,
|
|||||||
'address %s '
|
'address %s '
|
||||||
'netns %s' %
|
'netns %s' %
|
||||||
( intf1, addr1, intf2, addr2, netns ) )
|
( intf1, addr1, intf2, addr2, netns ) )
|
||||||
if cmdOutput == '':
|
if cmdOutput:
|
||||||
return True
|
|
||||||
else:
|
|
||||||
raise Exception( "Error creating interface pair (%s,%s): %s " %
|
raise Exception( "Error creating interface pair (%s,%s): %s " %
|
||||||
( intf1, intf2, cmdOutput ) )
|
( intf1, intf2, cmdOutput ) )
|
||||||
return False
|
|
||||||
|
|
||||||
def retry( retries, delaySecs, fn, *args, **keywords ):
|
def retry( retries, delaySecs, fn, *args, **keywords ):
|
||||||
"""Try something several times before giving up.
|
"""Try something several times before giving up.
|
||||||
@@ -550,11 +549,11 @@ def customConstructor( constructors, argStr ):
|
|||||||
params = params.copy()
|
params = params.copy()
|
||||||
params.update( kwargs )
|
params.update( kwargs )
|
||||||
if not newargs:
|
if not newargs:
|
||||||
return cls.__init__( self, name, *args, **params )
|
cls.__init__( self, name, *args, **params )
|
||||||
if args:
|
if args:
|
||||||
warn( 'warning: %s replacing %s with %s\n' %
|
warn( 'warning: %s replacing %s with %s\n' %
|
||||||
( constructor, args, newargs ) )
|
( constructor, args, newargs ) )
|
||||||
return cls.__init__( self, name, *newargs, **params )
|
cls.__init__( self, name, *newargs, **params )
|
||||||
|
|
||||||
CustomClass.__name__ = '%s%s' % ( cls.__name__, kwargs )
|
CustomClass.__name__ = '%s%s' % ( cls.__name__, kwargs )
|
||||||
return CustomClass
|
return CustomClass
|
||||||
|
|||||||
Reference in New Issue
Block a user