Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olaf Bergmann
mininet
Commits
6a38811f
Commit
6a38811f
authored
10 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Clarify makeIntfPair behavior and pass code check
parent
4ac45a39
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mininet/util.py
+6
-7
6 additions, 7 deletions
mininet/util.py
with
6 additions
and
7 deletions
mininet/util.py
+
6
−
7
View file @
6a38811f
...
@@ -56,6 +56,7 @@ def oldQuietRun( *cmd ):
...
@@ -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 ):
...
@@ -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,
...
@@ -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)
r
eturns: ip link add result
"""
r
aises 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,
...
@@ -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 __init__( self, name, *args, **params ):
...
@@ -550,11 +549,11 @@ def __init__( self, name, *args, **params ):
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment