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
1fdcd676
Commit
1fdcd676
authored
15 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Added py command to evaluate Python expressions, e.g. h1.cmd('ls')
parent
137ec305
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
mininet/cli.py
+25
-5
25 additions, 5 deletions
mininet/cli.py
with
25 additions
and
5 deletions
mininet/cli.py
+
25
−
5
View file @
1fdcd676
...
...
@@ -47,7 +47,7 @@ class CLI( Cmd ):
def
__init__
(
self
,
mininet
):
self
.
mn
=
mininet
self
.
nodelist
=
self
.
mn
.
host
s
+
self
.
mn
.
switches
+
self
.
mn
.
controller
s
self
.
nodelist
=
self
.
mn
.
controller
s
+
self
.
mn
.
switches
+
self
.
mn
.
host
s
self
.
nodemap
=
{}
# map names to Node objects
for
node
in
self
.
nodelist
:
self
.
nodemap
[
node
.
name
]
=
node
...
...
@@ -69,9 +69,9 @@ def do_help( self, args ):
'
\n
'
'
The interpreter automatically substitutes IP
'
'
addresses
\n
'
'
for node names when a node is the first arg, so command
'
'
for node names when a node is the first arg, so command
s
'
'
like
\n
'
'
mininet> h0 ping -c1 h1
\n
'
'
mininet> h0 ping -c1 h1
\n
'
'
should work.
\n
'
'
\n
'
'
Interactive commands are not really supported yet,
\n
'
...
...
@@ -90,7 +90,7 @@ def do_net( self, args ):
"
List network connections.
"
for
switch
in
self
.
mn
.
switches
:
info
(
'
%s <->
'
,
switch
.
name
)
for
intf
in
switch
.
intfs
:
for
intf
in
switch
.
intfs
.
values
()
:
name
=
switch
.
connection
[
intf
][
1
]
info
(
'
%s
'
%
name
)
info
(
'
\n
'
)
...
...
@@ -99,6 +99,25 @@ def do_sh( self, args ):
"
Run an external shell command
"
call
(
args
,
shell
=
True
)
# do_py() needs to catch any exception during eval()
# pylint: disable-msg=W0703
def
do_py
(
self
,
args
):
"""
Evaluate a Python expression.
Node names may be used, e.g.: h1.cmd(
'
ls
'
)
"""
try
:
result
=
eval
(
args
,
globals
(),
self
.
nodemap
)
if
not
result
:
return
elif
isinstance
(
result
,
str
):
info
(
result
+
'
\n
'
)
else
:
info
(
repr
(
result
)
+
'
\n
'
)
except
Exception
,
e
:
info
(
str
(
e
)
+
'
\n
'
)
# pylint: enable-msg=W0703
def
do_pingall
(
self
,
args
):
"
Ping between all hosts.
"
self
.
mn
.
pingAll
()
...
...
@@ -119,7 +138,8 @@ def do_iperfudp( self, args ):
def
do_intfs
(
self
,
args
):
"
List interfaces.
"
for
node
in
self
.
nodelist
:
info
(
'
%s: %s
\n
'
%
(
node
.
name
,
'
'
.
join
(
node
.
intfs
)
)
)
info
(
'
%s: %s
\n
'
%
(
node
.
name
,
'
'
.
join
(
sorted
(
node
.
intfs
.
values
()
)
)
)
)
def
do_dump
(
self
,
args
):
"
Dump node info.
"
...
...
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