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
8a7d42db
Commit
8a7d42db
authored
13 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Update OVS switch to use ovs-vsctl rather than deprecated ovs-openflowd.
parent
daa576c4
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/node.py
+58
-3
58 additions, 3 deletions
mininet/node.py
with
58 additions
and
3 deletions
mininet/node.py
+
58
−
3
View file @
8a7d42db
...
...
@@ -49,7 +49,7 @@
from
time
import
sleep
from
mininet.log
import
info
,
error
,
debug
from
mininet.util
import
quietRun
,
makeIntfPair
,
moveIntf
,
isShellBuiltin
from
mininet.util
import
quietRun
,
errRun
,
makeIntfPair
,
moveIntf
,
isShellBuiltin
from
mininet.moduledeps
import
moduleDeps
,
pathCheck
,
OVS_KMOD
,
OF_KMOD
,
TUN
SWITCH_PORT_BASE
=
1
# For OF > 0.9, switch ports start at 1 rather than zero
...
...
@@ -558,8 +558,8 @@ def stop( self ):
self
.
deleteIntfs
()
class
OVSKernelSwitch
(
Switch
):
"""
Open VSwitch kernel-space switch.
class
OVS
Legacy
KernelSwitch
(
Switch
):
"""
Open VSwitch
legacy
kernel-space switch
using ovs-openflowd
.
Currently only works in the root namespace.
"""
def
__init__
(
self
,
name
,
dp
=
None
,
**
kwargs
):
...
...
@@ -617,6 +617,61 @@ def stop( self ):
self
.
deleteIntfs
()
class
OVSSwitch
(
Switch
):
"
Open vSwitch switch. Depends on ovs-vsctl.
"
def
__init__
(
self
,
name
,
dp
=
None
,
**
kwargs
):
"""
Init.
name: name for switch
dp: netlink id (0, 1, 2, ...)
defaultMAC: default MAC as unsigned int; random value if None
"""
Switch
.
__init__
(
self
,
name
,
**
kwargs
)
self
.
dp
=
'
dp%i
'
%
dp
@staticmethod
def
setup
():
"
Make sure Open vSwitch is installed and working
"
pathCheck
(
'
ovs-vsctl
'
,
moduleName
=
'
Open vSwitch (openvswitch.org)
'
)
moduleDeps
(
subtract
=
OF_KMOD
,
add
=
OVS_KMOD
)
out
,
err
,
exitcode
=
errRun
(
'
ovs-vsctl -t 1 show
'
)
if
exitcode
:
error
(
out
+
err
+
'
ovs-vsctl exited with code %d
\n
'
%
exitcode
+
'
*** Error connecting to ovs-db with ovs-vsctl
\n
'
'
Make sure that Open vSwitch is installed,
'
'
that ovsdb-server is running, and that
\n
'
'"
ovs-vsctl show
"
works correctly.
\n
'
'
You may wish to try
"
service openvswitch-switch start
"
.
\n
'
)
exit
(
1
)
def
start
(
self
,
controllers
):
"
Start up a new OVS OpenFlow switch using ovs-vsctl
"
# Annoyingly, --if-exists option seems not to work
self
.
cmd
(
'
ovs-vsctl del-br
'
,
self
.
dp
)
self
.
cmd
(
'
ovs-vsctl add-br
'
,
self
.
dp
)
self
.
cmd
(
'
ovs-vsctl set-fail-mode
'
,
self
.
dp
,
'
secure
'
)
# Add ports
ports
=
sorted
(
self
.
ports
.
values
()
)
intfs
=
[
self
.
intfs
[
port
]
for
port
in
ports
]
# XXX: Ugly check - we should probably fix this!
if
ports
and
(
len
(
ports
)
!=
ports
[
-
1
]
+
1
-
self
.
portBase
):
raise
Exception
(
'
only contiguous, one-indexed port ranges
'
'
supported: %s
'
%
self
.
intfs
)
for
intf
in
intfs
:
self
.
cmd
(
'
ovs-vsctl add-port
'
,
self
.
dp
,
intf
)
self
.
cmd
(
'
ifconfig
'
,
intf
,
'
up
'
)
# Add controllers
clist
=
'
,
'
.
join
(
[
'
tcp:%s:%d
'
%
(
c
.
IP
(),
c
.
port
)
for
c
in
controllers
]
)
self
.
cmd
(
'
ovs-vsctl set-controller
'
,
self
.
dp
,
clist
)
def
stop
(
self
):
"
Terminate OVS switch.
"
self
.
cmd
(
'
ovs-vsctl del-br
'
,
self
.
dp
)
OVSKernelSwitch
=
OVSSwitch
class
Controller
(
Node
):
"""
A Controller is a Node that is running (or has execed?) an
OpenFlow controller.
"""
...
...
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