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
b739cd11
Commit
b739cd11
authored
10 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Remove obsolete util.custom(), and make custom() a method
parent
bc6ef0da
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
bin/mn
+29
-32
29 additions, 32 deletions
bin/mn
with
29 additions
and
32 deletions
bin/mn
+
29
−
32
View file @
b739cd11
...
@@ -32,7 +32,7 @@ from mininet.nodelib import LinuxBridge
...
@@ -32,7 +32,7 @@ from mininet.nodelib import LinuxBridge
from
mininet.link
import
Link
,
TCLink
from
mininet.link
import
Link
,
TCLink
from
mininet.topo
import
SingleSwitchTopo
,
LinearTopo
,
SingleSwitchReversedTopo
from
mininet.topo
import
SingleSwitchTopo
,
LinearTopo
,
SingleSwitchReversedTopo
from
mininet.topolib
import
TreeTopo
,
TorusTopo
from
mininet.topolib
import
TreeTopo
,
TorusTopo
from
mininet.util
import
custom
,
customConstructor
from
mininet.util
import
customConstructor
from
mininet.util
import
buildTopo
from
mininet.util
import
buildTopo
from
functools
import
partial
from
functools
import
partial
...
@@ -67,8 +67,8 @@ SWITCHES = { 'user': UserSwitch,
...
@@ -67,8 +67,8 @@ SWITCHES = { 'user': UserSwitch,
HOSTDEF
=
'
proc
'
HOSTDEF
=
'
proc
'
HOSTS
=
{
'
proc
'
:
Host
,
HOSTS
=
{
'
proc
'
:
Host
,
'
rt
'
:
custom
(
CPULimitedHost
,
sched
=
'
rt
'
),
'
rt
'
:
partial
(
CPULimitedHost
,
sched
=
'
rt
'
),
'
cfs
'
:
custom
(
CPULimitedHost
,
sched
=
'
cfs
'
)
}
'
cfs
'
:
partial
(
CPULimitedHost
,
sched
=
'
cfs
'
)
}
CONTROLLERDEF
=
'
default
'
CONTROLLERDEF
=
'
default
'
CONTROLLERS
=
{
'
ref
'
:
Controller
,
CONTROLLERS
=
{
'
ref
'
:
Controller
,
...
@@ -118,32 +118,6 @@ def version( *_args ):
...
@@ -118,32 +118,6 @@ def version( *_args ):
print
"
%s
"
%
VERSION
print
"
%s
"
%
VERSION
exit
()
exit
()
def
custom
(
option
,
opt_str
,
value
,
parser
,
*
args
,
**
kwargs
):
"""
Parse custom file and add params.
option: option e.g. --custom
opt_str: option string e.g. --custom
value: the value the follows the option
parser: option parser instance
args: empty tuple
kwargs: dict that contains { self : MininetRunner reference }
"""
self
=
kwargs
[
'
self
'
]
files
=
[]
if
os
.
path
.
isfile
(
value
):
# accept any single file (including those with commas)
files
.
append
(
value
)
else
:
# accept a comma-separated list of filenames
files
+=
value
.
split
(
'
,
'
)
for
fileName
in
files
:
customs
=
{}
if
os
.
path
.
isfile
(
fileName
):
execfile
(
fileName
,
customs
,
customs
)
for
name
,
val
in
customs
.
iteritems
():
self
.
setCustom
(
name
,
val
)
else
:
raise
Exception
(
'
could not find custom file: %s
'
%
fileName
)
class
MininetRunner
(
object
):
class
MininetRunner
(
object
):
"
Build, setup, and run Mininet.
"
"
Build, setup, and run Mininet.
"
...
@@ -158,6 +132,29 @@ class MininetRunner( object ):
...
@@ -158,6 +132,29 @@ class MininetRunner( object ):
self
.
setup
()
self
.
setup
()
self
.
begin
()
self
.
begin
()
def
custom
(
self
,
option
,
opt_str
,
value
,
parser
):
"""
Parse custom file and add params.
option: option e.g. --custom
opt_str: option string e.g. --custom
value: the value the follows the option
parser: option parser instance
"""
files
=
[]
if
os
.
path
.
isfile
(
value
):
# Accept any single file (including those with commas)
files
.
append
(
value
)
else
:
# Accept a comma-separated list of filenames
files
+=
value
.
split
(
'
,
'
)
for
fileName
in
files
:
customs
=
{}
if
os
.
path
.
isfile
(
fileName
):
execfile
(
fileName
,
customs
,
customs
)
for
name
,
val
in
customs
.
iteritems
():
self
.
setCustom
(
name
,
val
)
else
:
raise
Exception
(
'
could not find custom file: %s
'
%
fileName
)
def
setCustom
(
self
,
name
,
value
):
def
setCustom
(
self
,
name
,
value
):
"
Set custom parameters for MininetRunner.
"
"
Set custom parameters for MininetRunner.
"
if
name
in
(
'
topos
'
,
'
switches
'
,
'
hosts
'
,
'
controllers
'
):
if
name
in
(
'
topos
'
,
'
switches
'
,
'
hosts
'
,
'
controllers
'
):
...
@@ -191,9 +188,9 @@ class MininetRunner( object ):
...
@@ -191,9 +188,9 @@ class MininetRunner( object ):
opts
.
add_option
(
'
--clean
'
,
'
-c
'
,
action
=
'
store_true
'
,
opts
.
add_option
(
'
--clean
'
,
'
-c
'
,
action
=
'
store_true
'
,
default
=
False
,
help
=
'
clean and exit
'
)
default
=
False
,
help
=
'
clean and exit
'
)
opts
.
add_option
(
'
--custom
'
,
action
=
'
callback
'
,
callback
=
custom
,
opts
.
add_option
(
'
--custom
'
,
action
=
'
callback
'
,
type
=
'
string
'
,
callback_kwargs
=
{
'
self
'
:
self
}
,
callback
=
partial
(
self
.
custom
,
self
=
self
)
,
help
=
'
read custom classes or params from .py file
'
)
type
=
'
string
'
,
help
=
'
read custom classes or params from .py file
(s)
'
)
opts
.
add_option
(
'
--test
'
,
type
=
'
choice
'
,
choices
=
TESTS
,
opts
.
add_option
(
'
--test
'
,
type
=
'
choice
'
,
choices
=
TESTS
,
default
=
TESTS
[
0
],
default
=
TESTS
[
0
],
help
=
'
|
'
.
join
(
TESTS
)
)
help
=
'
|
'
.
join
(
TESTS
)
)
...
...
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