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
e3a1fbb0
Commit
e3a1fbb0
authored
14 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Added support for pre- and post-test CLI scripts.
parent
9de7873b
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
bin/mn
+28
-10
28 additions, 10 deletions
bin/mn
mininet/cli.py
+5
-2
5 additions, 2 deletions
mininet/cli.py
with
33 additions
and
12 deletions
bin/mn
+
28
−
10
View file @
e3a1fbb0
...
...
@@ -17,6 +17,7 @@ import sys
import
time
from
mininet.clean
import
cleanup
from
mininet.cli
import
CLI
from
mininet.log
import
lg
,
LEVELS
,
info
from
mininet.net
import
Mininet
,
init
from
mininet.node
import
KernelSwitch
,
Host
,
Controller
,
ControllerParams
,
NOX
...
...
@@ -50,9 +51,11 @@ CONTROLLERS = { 'ref': Controller,
'
none
'
:
lambda
name
:
None
}
# optional tests to run
TESTS
=
[
'
cli
'
,
'
build
'
,
'
ping
A
ll
'
,
'
ping
P
air
'
,
'
iperf
'
,
'
all
'
,
'
iperf
U
dp
'
,
TESTS
=
[
'
cli
'
,
'
build
'
,
'
ping
a
ll
'
,
'
ping
p
air
'
,
'
iperf
'
,
'
all
'
,
'
iperf
u
dp
'
,
'
none
'
]
ALTSPELLING
=
{
'
pingall
'
:
'
pingAll
'
,
'
pingpair
'
:
'
pingPair
'
,
'
iperfudp
'
:
'
iperfUdp
'
,
'
iperfUDP
'
:
'
iperfUdp
'
}
def
buildTopo
(
topo
):
"
Create topology from string with format (object, arg1, arg2,...).
"
...
...
@@ -99,6 +102,7 @@ class MininetRunner( object ):
def
__init__
(
self
):
"
Init.
"
self
.
options
=
None
self
.
args
=
None
# May be used someday for more CLI scripts
self
.
validate
=
None
self
.
parseArgs
()
...
...
@@ -170,9 +174,14 @@ class MininetRunner( object ):
opts
.
add_option
(
'
--port
'
,
type
=
'
int
'
,
default
=
6633
,
help
=
'
[port integer for a listening remote
'
'
controller]
'
)
opts
.
add_option
(
'
--in
N
amespace
'
,
action
=
'
store_true
'
,
opts
.
add_option
(
'
--in
n
amespace
'
,
action
=
'
store_true
'
,
default
=
False
,
help
=
'
sw and ctrl in namespace?
'
)
self
.
options
=
opts
.
parse_args
()[
0
]
opts
.
add_option
(
'
--pre
'
,
type
=
'
string
'
,
default
=
None
,
help
=
'
[CLI script to run before tests]
'
)
opts
.
add_option
(
'
--post
'
,
type
=
'
string
'
,
default
=
None
,
help
=
'
[CLI script to run after tests]
'
)
self
.
options
,
self
.
args
=
opts
.
parse_args
()
def
setup
(
self
):
"
Setup and validate environment.
"
...
...
@@ -209,7 +218,7 @@ class MininetRunner( object ):
self
.
validate
(
self
.
options
)
controllerParams
=
ControllerParams
(
'
10.0.0.0
'
,
8
)
inNamespace
=
self
.
options
.
in
N
amespace
inNamespace
=
self
.
options
.
in
n
amespace
xterms
=
self
.
options
.
xterms
mac
=
self
.
options
.
mac
arp
=
self
.
options
.
arp
...
...
@@ -217,20 +226,29 @@ class MininetRunner( object ):
inNamespace
=
inNamespace
,
xterms
=
xterms
,
autoSetMacs
=
mac
,
autoStaticArp
=
arp
)
if
self
.
options
.
pre
:
CLI
(
mn
,
script
=
self
.
options
.
pre
)
test
=
self
.
options
.
test
test
=
ALTSPELLING
.
get
(
test
,
test
)
mn
.
start
()
if
test
==
'
none
'
:
mn
.
start
()
mn
.
stop
()
elif
test
==
'
cli
'
:
mn
.
interact
()
pass
elif
test
==
'
all
'
:
mn
.
start
()
mn
.
ping
()
mn
.
iperf
()
mn
.
stop
()
elif
test
==
'
cli
'
:
CLI
(
mn
)
elif
test
!=
'
build
'
:
mn
.
run
(
getattr
(
mn
,
test
)
)
getattr
(
mn
,
test
)()
if
self
.
options
.
post
:
CLI
(
mn
,
script
=
self
.
options
.
post
)
mn
.
stop
()
elapsed
=
float
(
time
.
time
()
-
start
)
info
(
'
completed in %0.3f seconds
\n
'
%
elapsed
)
...
...
This diff is collapsed.
Click to expand it.
mininet/cli.py
+
5
−
2
View file @
e3a1fbb0
...
...
@@ -40,7 +40,7 @@ class CLI( Cmd ):
prompt
=
'
mininet>
'
def
__init__
(
self
,
mininet
,
stdin
=
sys
.
stdin
):
def
__init__
(
self
,
mininet
,
stdin
=
sys
.
stdin
,
script
=
None
):
self
.
mn
=
mininet
self
.
nodelist
=
self
.
mn
.
controllers
+
self
.
mn
.
switches
+
self
.
mn
.
hosts
self
.
nodemap
=
{}
# map names to Node objects
...
...
@@ -50,9 +50,12 @@ def __init__( self, mininet, stdin=sys.stdin ):
self
.
stdin
=
stdin
self
.
inPoller
=
poll
()
self
.
inPoller
.
register
(
stdin
)
self
.
inputFile
=
None
self
.
inputFile
=
script
Cmd
.
__init__
(
self
)
info
(
'
*** Starting CLI:
\n
'
)
if
self
.
inputFile
:
self
.
do_source
(
self
.
inputFile
)
return
while
True
:
try
:
# Make sure no nodes are still waiting
...
...
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