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
445c0959
Commit
445c0959
authored
11 years ago
by
Bob Lantz
Committed by
Brian O'Connor
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Pass code check (except bogus Popen error)
parent
0c5aae15
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
examples/bind.py
+17
-14
17 additions, 14 deletions
examples/bind.py
with
17 additions
and
14 deletions
examples/bind.py
+
17
−
14
View file @
445c0959
...
...
@@ -34,20 +34,20 @@ def mountPoints():
mounts
.
append
(
mount
)
return
mounts
def
unmountAll
(
dir
=
MNRUNDIR
):
def
unmountAll
(
root
dir
=
MNRUNDIR
):
"
Unmount all mounts under a directory tree
"
dir
=
realpath
(
dir
)
# Find all mounts below dir
root
dir
=
realpath
(
root
dir
)
# Find all mounts below
root
dir
# This is subtle because /foo is not
# a parent of /foot
dirslash
=
dir
+
'
/
'
dirslash
=
root
dir
+
'
/
'
mounts
=
[
m
for
m
in
mountPoints
()
if
m
==
dir
or
m
.
find
(
dirslash
)
==
0
]
# Unmount them from bottom to top
mounts
.
sort
(
reverse
=
True
)
for
mount
in
mounts
:
debug
(
'
Unmounting
'
,
mount
,
'
\n
'
)
out
,
err
,
code
=
errRun
(
'
umount
'
,
mount
)
_
out
,
err
,
code
=
errRun
(
'
umount
'
,
mount
)
if
code
!=
0
:
info
(
'
*** Warning: failed to umount
'
,
mount
,
'
\n
'
)
info
(
err
)
...
...
@@ -69,6 +69,7 @@ def __init__(self, name, *args, **kwargs ):
self
.
unmount
=
kwargs
.
pop
(
'
unmount
'
,
True
)
Host
.
__init__
(
self
,
name
,
*
args
,
**
kwargs
)
self
.
rundir
=
'
%s/%s
'
%
(
self
.
mnRunDir
,
name
)
self
.
root
,
self
.
private
=
None
,
None
# set in createBindMounts
if
self
.
privateDirs
:
self
.
privateDirs
=
[
realpath
(
d
)
for
d
in
self
.
privateDirs
]
self
.
createBindMounts
()
...
...
@@ -88,28 +89,30 @@ def __init__(self, name, *args, **kwargs ):
def
mountPrivateDirs
(
self
):
"
Create and bind mount private dirs
"
for
dir
in
self
.
privateDirs
:
privateDir
=
self
.
private
+
dir
for
dir
_
in
self
.
privateDirs
:
privateDir
=
self
.
private
+
dir
_
errFail
(
'
mkdir -p
'
+
privateDir
)
mountPoint
=
self
.
root
+
dir
mountPoint
=
self
.
root
+
dir
_
errFail
(
'
mount -B %s %s
'
%
(
privateDir
,
mountPoint
)
)
def
mountDirs
(
self
,
dirs
):
"
Mount a list of directories
"
for
dir
in
dirs
:
mountpoint
=
self
.
root
+
dir
for
dir
_
in
dirs
:
mountpoint
=
self
.
root
+
dir
_
errFail
(
'
mount -B %s %s
'
%
(
dir
,
mountpoint
)
)
(
dir
_
,
mountpoint
)
)
@classmethod
def
findRemounts
(
cls
,
fstypes
=
[
'
nfs
'
]
):
def
findRemounts
(
cls
,
fstypes
=
None
):
"""
Identify mount points in /proc/mounts to remount
fstypes: file system types to match
"""
if
fstypes
is
None
:
fstypes
=
[
'
nfs
'
]
dirs
=
quietRun
(
'
cat /proc/mounts
'
).
strip
().
split
(
'
\n
'
)
remounts
=
[]
for
dir
in
dirs
:
line
=
dir
.
split
()
for
dir
_
in
dirs
:
line
=
dir
_
.
split
()
mountpoint
,
fstype
=
line
[
1
],
line
[
2
]
# Don't re-remount directories!!!
if
mountpoint
.
find
(
cls
.
mnRunDir
)
==
0
:
...
...
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