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
e935da46
Commit
e935da46
authored
11 years ago
by
Brian O'Connor
Browse files
Options
Downloads
Patches
Plain Diff
added comments and cleaned up controlnet.py
parent
92bf2cf1
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/controlnet.py
+16
-6
16 additions, 6 deletions
examples/controlnet.py
with
16 additions
and
6 deletions
examples/controlnet.py
+
16
−
6
View file @
e935da46
...
...
@@ -10,8 +10,8 @@
Since we
'
re using UserSwitch on the data network,
it should correctly fail over to a backup controller.
We also
hack/subclass the CLI slightly so it can talk to
both the
control and data networks.
We also
use a Mininet Facade to talk to both the
control and data networks
from a single CLI
.
"""
from
mininet.net
import
Mininet
...
...
@@ -31,19 +31,25 @@ def checkListening( self ):
pass
class
MininetFacade
(
object
):
"
TODO: CLI that can talk to two or more networks
"
"""
Mininet object facade that allows a single CLI to
talk to one or more networks
"""
def
__init__
(
self
,
net
,
*
args
,
**
kwargs
):
"""
Create MininetFacade object.
net: Primary Mininet object
args: unnamed networks passed as arguments
kwargs: named networks passed as arguments
"""
self
.
net
=
net
self
.
nets
=
[
net
]
+
list
(
args
)
+
kwargs
.
values
()
self
.
nameToNet
=
kwargs
self
.
nameToNet
[
'
net
'
]
=
net
# default is first net
def
__getattr__
(
self
,
name
):
"
returns attribute from Primary Mininet object
"
return
getattr
(
self
.
net
,
name
)
def
__getitem__
(
self
,
key
):
"
returns primary/named networks or node from any net
"
#search kwargs for net named key
if
key
in
self
.
nameToNet
:
return
self
.
nameToNet
[
key
]
...
...
@@ -53,26 +59,32 @@ def __getitem__( self, key ):
return
net
[
key
]
def
__iter__
(
self
):
"
Iterate through all nodes in all Mininet objects
"
for
net
in
self
.
nets
:
for
node
in
net
:
yield
node
def
__len__
(
self
):
"
returns aggregate number of nodes in all nets
"
count
=
0
for
net
in
self
.
nets
:
count
+=
len
(
net
)
return
count
def
__contains__
(
self
,
key
):
"
returns True if node is a member of any net
"
return
key
in
self
.
keys
()
def
keys
(
self
):
"
returns a list of all node names in all networks
"
return
list
(
self
)
def
values
(
self
):
"
returns a list of all nodes in all networks
"
return
[
self
[
key
]
for
key
in
self
]
def
items
(
self
):
"
returns (key,value) tuple list for every node in all networks
"
return
zip
(
self
.
keys
(),
self
.
values
()
)
# A real control network!
...
...
@@ -126,8 +138,6 @@ def run():
net
.
stop
()
info
(
'
* Stopping Control Network
\n
'
)
# dataControllers have already been stopped -- now terminate is idempotent
#cnet.hosts = list( set( cnet.hosts ) - set( dataControllers ) )
cnet
.
stop
()
if
__name__
==
'
__main__
'
:
...
...
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