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
bd558875
Commit
bd558875
authored
12 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Add net['h1'] and for node in net support
thanks to Brian O'Connor for reminder + suggestion closes #114
parent
31fe4f1b
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/net.py
+12
-2
12 additions, 2 deletions
mininet/net.py
with
12 additions
and
2 deletions
mininet/net.py
+
12
−
2
View file @
bd558875
...
...
@@ -91,6 +91,7 @@
import
select
import
signal
from
time
import
sleep
from
itertools
import
chain
from
mininet.cli
import
CLI
from
mininet.log
import
info
,
error
,
debug
,
output
...
...
@@ -216,8 +217,8 @@ def addController( self, name='c0', controller=None, **params ):
self
.
nameToNode
[
name
]
=
controller_new
return
controller_new
# BL:
is this better than just using nameToNode[] ?
#
Should it have a better name?
# BL:
We now have four ways to look up nodes
#
This may (should?) be cleaned up in the future.
def
getNodeByName
(
self
,
*
args
):
"
Return node(s) with given name(s)
"
if
len
(
args
)
==
1
:
...
...
@@ -228,6 +229,15 @@ def get( self, *args ):
"
Convenience alias for getNodeByName
"
return
self
.
getNodeByName
(
*
args
)
# Even more convenient syntax for node lookup and iteration
def
__getitem__
(
self
,
*
args
):
"""
net [ name ] operator: Return node(s) with given name(s)
"""
return
self
.
getNodeByName
(
*
args
)
def
__iter__
(
self
):
"
return iterator over nodes
"
return
chain
(
self
.
hosts
,
self
.
switches
,
self
.
controllers
)
def
addLink
(
self
,
node1
,
node2
,
port1
=
None
,
port2
=
None
,
cls
=
None
,
**
params
):
""""
Add a link from node1 to node2
...
...
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