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
ea420ee2
Commit
ea420ee2
authored
15 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
First crack at converting cleanup to Python.
parent
2708cadd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cleanup
+57
-33
57 additions, 33 deletions
cleanup
with
57 additions
and
33 deletions
cleanup
+
57
−
33
View file @
ea420ee2
#!/bin/bash
# Unfortunately, Mininet and OpenFlow don't always clean up
# properly after themselves. Until they do (or until cleanup
# functionality is integrated into the python code), this
# script may be used to get rid of unwanted garbage. It may
# also get rid of "false positives", but hopefully nothing
# irreplaceable!
echo
"Removing all links of the pattern foo-ethX"
for
f
in
`
ip
link
show | egrep
-o
'(\w+-eth\w+)'
`
;
do
cmd
=
"ip link del
$f
"
echo
$smd
$cmd
done
echo
"Removing excess controllers/ofprotocols/ofdatapaths/pings"
killall
-9
controller ofprotocol ofdatapath ping 2> /dev/null
echo
"Removing excess kernel datapath processes"
ps ax | egrep
-o
'dp[0-9]+'
|
sed
's/dp/nl:/'
| xargs
-l1
echo
dpctl deldp
echo
"Removing junk in /tmp"
rm
-f
/tmp/vconn
*
/tmp/vlogs
*
/tmp/
*
.out /tmp/
*
.log
echo
"Killing nox"
killall lt-nox_core
killall nox_core
echo
"Removing old screen sessions"
screen
-ls
| egrep
-o
'[0-9]+\.[hsc][0-9]+'
|
sed
's/\.[hsc][0-9]*//g'
|
kill
-9
#!/usr/bin/python
"""
Unfortunately, Mininet and OpenFlow don
'
t always clean up
properly after themselves. Until they do (or until cleanup
functionality is integrated into the python code), this
script may be used to get rid of unwanted garbage. It may
also get rid of
'
false positives
'
, but hopefully nothing
irreplaceable!
"""
from
subprocess
import
Popen
,
PIPE
import
re
def
sh
(
cmd
):
"
Print a command and send it to the shell
"
print
cmd
return
Popen
(
[
'
/bin/sh
'
,
'
-c
'
,
cmd
],
stdout
=
PIPE
).
communicate
()[
0
]
def
cleanUpScreens
():
"
Remove moldy old screen sessions.
"
r
=
r
'
(\d+.[hsc]\d+)
'
output
=
sh
(
'
screen -ls
'
).
split
(
'
\n
'
)
for
line
in
output
:
m
=
re
.
search
(
r
,
line
)
if
m
is
not
None
:
quietRun
(
'
screen -S
'
+
m
.
group
(
1
)
+
'
-X kill
'
)
def
cleanup
():
print
"
*** Removing all links of the pattern foo-ethX
"
links
=
sh
(
"
ip link show | egrep -o
'
(\w+-eth\w+)
'"
).
split
(
'
\n
'
)
for
link
in
links
:
if
link
:
sh
(
"
ip link del
"
+
link
)
print
"
*** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes
"
zombies
=
'
controller ofprotocol ofdatapath ping nox_core lt-nox_core
'
# Note: real zombie processes can't actually be killed, since they
# are already (un)dead. Then again,
# you can't connect to them either, so they're mostly harmless.
sh
(
'
killall -9
'
+
zombies
+
'
2> /dev/null
'
)
print
"
*** Removing excess kernel datapaths
"
dps
=
sh
(
"
ps ax | egrep -o
'
dp[0-9]+
'
| sed
'
s/dp/nl:/
'"
).
split
(
'
\n
'
)
for
dp
in
dps
:
if
dp
:
sh
(
'
ip link del
'
+
link
)
print
"
*** Removing junk from /tmp
"
sh
(
'
rm -f /tmp/vconn* /tmp/vlogs* /tmp/*.out /tmp/*.log
'
)
print
"
*** Removing old screen sessions
"
cleanUpScreens
()
print
"
*** Cleanup complete.
"
if
__name__
==
"
__main__
"
:
cleanup
()
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