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
538a856c
Commit
538a856c
authored
11 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Add Switch.connected() and OVSSwitch.controllerUUIDs()
parent
877e7efb
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
+33
-12
33 additions, 12 deletions
mininet/node.py
with
33 additions
and
12 deletions
mininet/node.py
+
33
−
12
View file @
538a856c
...
@@ -49,6 +49,7 @@
...
@@ -49,6 +49,7 @@
import
signal
import
signal
import
select
import
select
from
subprocess
import
Popen
,
PIPE
,
STDOUT
from
subprocess
import
Popen
,
PIPE
,
STDOUT
from
operator
import
or_
from
mininet.log
import
info
,
error
,
warn
,
debug
from
mininet.log
import
info
,
error
,
warn
,
debug
from
mininet.util
import
(
quietRun
,
errRun
,
errFail
,
moveIntf
,
isShellBuiltin
,
from
mininet.util
import
(
quietRun
,
errRun
,
errFail
,
moveIntf
,
isShellBuiltin
,
...
@@ -784,6 +785,10 @@ def sendCmd( self, *cmd, **kwargs ):
...
@@ -784,6 +785,10 @@ def sendCmd( self, *cmd, **kwargs ):
error
(
'
*** Error: %s has execed and cannot accept commands
'
%
error
(
'
*** Error: %s has execed and cannot accept commands
'
%
self
.
name
)
self
.
name
)
def
connected
(
self
):
"
Is the switch connected to a controller? (override this method)
"
return
False
def
__repr__
(
self
):
def
__repr__
(
self
):
"
More informative string representation
"
"
More informative string representation
"
intfs
=
(
'
,
'
.
join
(
[
'
%s:%s
'
%
(
i
.
name
,
i
.
IP
()
)
intfs
=
(
'
,
'
.
join
(
[
'
%s:%s
'
%
(
i
.
name
,
i
.
IP
()
)
...
@@ -819,6 +824,10 @@ def dpctl( self, *args ):
...
@@ -819,6 +824,10 @@ def dpctl( self, *args ):
return
self
.
cmd
(
'
dpctl
'
+
'
'
.
join
(
args
)
+
return
self
.
cmd
(
'
dpctl
'
+
'
'
.
join
(
args
)
+
'
tcp:127.0.0.1:%i
'
%
self
.
listenPort
)
'
tcp:127.0.0.1:%i
'
%
self
.
listenPort
)
def
connected
(
self
):
"
Is the switch connected to a controller?
"
return
'
remote.is-connected=true
'
in
self
.
dpctl
(
'
status
'
)
def
start
(
self
,
controllers
):
def
start
(
self
,
controllers
):
"""
Start OpenFlow reference user datapath.
"""
Start OpenFlow reference user datapath.
Log to /tmp/sN-{ofd,ofp}.log.
Log to /tmp/sN-{ofd,ofp}.log.
...
@@ -950,6 +959,23 @@ def detach( self, intf ):
...
@@ -950,6 +959,23 @@ def detach( self, intf ):
"
Disconnect a data port
"
"
Disconnect a data port
"
self
.
cmd
(
'
ovs-vsctl del-port
'
,
self
,
intf
)
self
.
cmd
(
'
ovs-vsctl del-port
'
,
self
,
intf
)
def
controllerUUIDs
(
self
):
"
Return ovsdb UUIDs for our controllers
"
uuids
=
[]
controllers
=
self
.
cmd
(
'
ovs-vsctl -- get Bridge
'
,
self
,
'
Controller
'
).
strip
()
if
controllers
.
startswith
(
'
[
'
)
and
controllers
.
endswith
(
'
]
'
):
controllers
=
controllers
[
1
:
-
1
]
uuids
=
[
c
.
strip
()
for
c
in
controllers
.
split
(
'
,
'
)
]
return
uuids
def
connected
(
self
):
"
Are we connected to at least one of our controllers?
"
results
=
[
'
true
'
in
self
.
cmd
(
'
ovs-vsctl -- get Controller
'
,
uuid
,
'
is_connected
'
)
for
uuid
in
self
.
controllerUUIDs
()
]
return
reduce
(
or_
,
results
,
False
)
def
start
(
self
,
controllers
):
def
start
(
self
,
controllers
):
"
Start up a new OVS OpenFlow switch using ovs-vsctl
"
"
Start up a new OVS OpenFlow switch using ovs-vsctl
"
if
self
.
inNamespace
:
if
self
.
inNamespace
:
...
@@ -976,18 +1002,13 @@ def start( self, controllers ):
...
@@ -976,18 +1002,13 @@ def start( self, controllers ):
clist
+=
'
ptcp:%s
'
%
self
.
listenPort
clist
+=
'
ptcp:%s
'
%
self
.
listenPort
self
.
cmd
(
'
ovs-vsctl set-controller
'
,
self
,
clist
)
self
.
cmd
(
'
ovs-vsctl set-controller
'
,
self
,
clist
)
# Reconnect quickly to controllers (1s vs. 15s max_backoff)
# Reconnect quickly to controllers (1s vs. 15s max_backoff)
controllers
=
self
.
cmd
(
'
ovs-vsctl -- get Bridge
'
,
self
,
for
uuid
in
self
.
controllerUUIDs
():
'
Controller
'
).
strip
()
if
uuid
.
count
(
'
-
'
)
!=
4
:
if
controllers
.
startswith
(
'
[
'
)
and
controllers
.
endswith
(
'
]
'
):
# Doesn't look like a UUID
controllers
=
controllers
[
1
:
-
1
]
continue
uuids
=
[
c
.
strip
()
for
c
in
controllers
.
split
(
'
,
'
)
]
uuid
=
uuid
.
strip
()
for
uuid
in
uuids
:
self
.
cmd
(
'
ovs-vsctl set Controller
'
,
uuid
,
if
uuid
.
count
(
'
-
'
)
!=
4
:
'
max_backoff=1000
'
)
# Doesn't look like a UUID
continue
uuid
=
uuid
.
strip
()
self
.
cmd
(
'
ovs-vsctl set Controller
'
,
uuid
,
'
max_backoff=1000
'
)
def
stop
(
self
):
def
stop
(
self
):
"
Terminate OVS switch.
"
"
Terminate OVS switch.
"
...
...
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