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
07aad110
Commit
07aad110
authored
15 years ago
by
Brandon Heller
Browse files
Options
Downloads
Patches
Plain Diff
Add ability to pause and resume any node
parent
28cd95c3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mininet/cli.py
+20
-0
20 additions, 0 deletions
mininet/cli.py
mininet/node.py
+60
-0
60 additions, 0 deletions
mininet/node.py
with
80 additions
and
0 deletions
mininet/cli.py
+
20
−
0
View file @
07aad110
...
...
@@ -157,6 +157,26 @@ def do_link( self, args ):
else
:
self
.
mn
.
link
(
*
args
)
def
do_pause
(
self
,
args
):
"
Temporarily bring a node down.
"
args
=
args
.
split
()
if
len
(
args
)
!=
1
:
error
(
'
invalid number of args: pause [node]
\n
'
)
elif
args
[
0
]
not
in
self
.
nodemap
:
error
(
'
invalid node: %s
\n
'
%
args
[
0
]
)
else
:
self
.
nodemap
[
args
[
0
]
].
pause
()
def
do_resume
(
self
,
args
):
"
Temporarily bring a node up.
"
args
=
args
.
split
()
if
len
(
args
)
!=
1
:
error
(
'
invalid number of args: resume [node]
\n
'
)
elif
args
[
0
]
not
in
self
.
nodemap
:
error
(
'
invalid node: %s
\n
'
%
args
[
0
]
)
else
:
self
.
nodemap
[
args
[
0
]
].
resume
()
def
do_exit
(
self
,
args
):
"
Exit
"
return
'
exited by user command
'
...
...
This diff is collapsed.
Click to expand it.
mininet/node.py
+
60
−
0
View file @
07aad110
...
...
@@ -337,6 +337,12 @@ def intfIsUp( self, intf ):
"
Check if an interface is up.
"
return
'
UP
'
in
self
.
cmd
(
'
ifconfig
'
+
intf
)
def
modIntfs
(
self
,
action
):
"""
Bring all interfaces up or down.
action: string to pass to ifconfig
"""
for
intf
in
self
.
intfs
.
values
():
result
=
self
.
cmd
(
[
'
ifconfig
'
,
intf
,
action
]
)
# Other methods
def
__str__
(
self
):
result
=
self
.
name
+
'
:
'
...
...
@@ -351,6 +357,16 @@ class Host( Node ):
"
A host is simply a Node.
"
pass
# Ideally, pausing a host would pause the process. However, when one
# tries to run a command on a paused host, it leads to an exception later.
# For now, disable interfaces to "pause" the host.
def
pause
(
self
):
"
Disable interfaces.
"
self
.
modIntfs
(
'
down
'
)
def
resume
(
self
):
"
Re-enable interfaces
"
self
.
modIntfs
(
'
up
'
)
class
Switch
(
Node
):
"""
A Switch is a Node that is running (or has execed?)
...
...
@@ -405,6 +421,17 @@ def stop( self ):
self
.
cmd
(
'
kill %ofprotocol
'
)
self
.
deleteIntfs
()
def
pause
(
self
):
"
Pause ofprotocol and ofdatapath.
"
self
.
cmd
(
'
kill -STOP %ofdatapath
'
)
self
.
cmd
(
'
kill -STOP %ofprotocol
'
)
def
resume
(
self
):
"
Resume ofprotocol and datapath.
"
self
.
cmd
(
'
kill -CONT %ofdatapath
'
)
self
.
cmd
(
'
kill -CONT %ofprotocol
'
)
class
KernelSwitch
(
Switch
):
"""
Kernel-space switch.
Currently only works in root namespace.
"""
...
...
@@ -452,6 +479,18 @@ def stop( self ):
self
.
cmd
(
'
kill %ofprotocol
'
)
self
.
deleteIntfs
()
# Since kernel threads cannot receive signals like user-space processes,
# disabling the interfaces and ofdatapath is our workaround.
def
pause
(
self
):
"
Disable interfaces and pause ofprotocol.
"
self
.
cmd
(
'
kill -STOP %ofprotocol
'
)
self
.
modIntfs
(
'
down
'
)
def
resume
(
self
):
"
Re-enable interfaces and resume ofprotocol.
"
self
.
cmd
(
'
kill -CONT %ofprotocol
'
)
self
.
modIntfs
(
'
up
'
)
class
OVSKernelSwitch
(
Switch
):
"""
Open VSwitch kernel-space switch.
Currently only works in the root namespace.
"""
...
...
@@ -500,6 +539,18 @@ def stop( self ):
self
.
cmd
(
'
kill %ovs-openflowd
'
)
self
.
deleteIntfs
()
# Since kernel threads cannot receive signals like user-space processes,
# disabling the interfaces and ofdatapath is our workaround.
def
pause
(
self
):
"
Disable interfaces and pause ovs-openflowd.
"
self
.
cmd
(
'
kill -STOP %ovs-openflowd
'
)
self
.
modIntfs
(
'
down
'
)
def
resume
(
self
):
"
Re-enable interfaces and resume ovs-openflowd.
"
self
.
cmd
(
'
kill -CONT %ovs-openflowd
'
)
self
.
modIntfs
(
'
up
'
)
class
Controller
(
Node
):
"""
A Controller is a Node that is running (or has execed?) an
...
...
@@ -530,6 +581,14 @@ def stop( self ):
self
.
cmd
(
'
kill %
'
+
self
.
controller
)
self
.
terminate
()
def
pause
(
self
):
"
Pause controller.
"
self
.
cmd
(
'
kill -STOP %
'
+
self
.
controller
)
def
resume
(
self
):
"
Resume controller.
"
self
.
cmd
(
'
kill -CONT %
'
+
self
.
controller
)
def
IP
(
self
,
intf
=
None
):
"
Return IP address of the Controller
"
ip
=
Node
.
IP
(
self
,
intf
=
intf
)
...
...
@@ -537,6 +596,7 @@ def IP( self, intf=None ):
ip
=
self
.
defaultIP
return
ip
class
ControllerParams
(
object
):
"
Container for controller IP parameters.
"
...
...
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