Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
tom
2014-09-12 18:23:20 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e2918e623ddcea922219849d933f4cf15359cbbd
e2918e62
1 parent
4009d2c5
Added a solar test topology.
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
0 deletions
tools/test/topos/sol.py
tools/test/topos/solar.py
tools/test/topos/sol.py
0 → 100644
View file @
e2918e6
#!/usr/bin/python
import
sys
,
solar
topo
=
solar
.
Solar
(
cip
=
sys
.
argv
[
1
])
topo
.
run
()
tools/test/topos/solar.py
0 → 100644
View file @
e2918e6
#!/usr/bin/env python
from
mininet.cli
import
CLI
from
mininet.net
import
Mininet
from
mininet.node
import
RemoteController
,
OVSKernelSwitch
MAC
=
12
DPID
=
16
class
CustomCLI
(
CLI
):
"""Custom CLI to allow us to add our own commands."""
def
__init__
(
self
,
net
):
"""Init method for our custom CLI."""
self
.
net
=
net
CLI
.
__init__
(
self
,
net
)
class
Solar
(
object
):
""" Create a tiered topology from semi-scratch in Mininet """
def
__init__
(
self
,
cname
=
'onos'
,
cip
=
'192.168.56.1'
,
islands
=
3
,
edges
=
2
,
hosts
=
2
,
proto
=
None
):
"""Create tower topology for mininet"""
# We are creating the controller with local-loopback on purpose to avoid
# having the switches connect immediately. Instead, we'll set controller
# explicitly for each switch after configuring it as we want.
self
.
flare
=
RemoteController
(
cname
,
cip
,
6633
)
self
.
net
=
Mininet
(
controller
=
self
.
flare
,
switch
=
OVSKernelSwitch
,
build
=
False
)
self
.
cip
=
cip
self
.
spines
=
[]
self
.
leaves
=
[]
self
.
hosts
=
[]
self
.
proto
=
proto
# Create the two core switches and links between them
c1
=
self
.
net
.
addSwitch
(
'c1'
,
dpid
=
'1111000000000000'
)
c2
=
self
.
net
.
addSwitch
(
'c2'
,
dpid
=
'2222000000000000'
)
self
.
spines
.
append
(
c1
)
self
.
spines
.
append
(
c2
)
self
.
net
.
addLink
(
c1
,
c2
)
self
.
net
.
addLink
(
c2
,
c1
)
for
i
in
range
(
1
,
islands
+
1
):
sc
=
self
.
createSpineClump
(
i
,
edges
,
hosts
)
self
.
net
.
addLink
(
c1
,
sc
[
0
])
self
.
net
.
addLink
(
c2
,
sc
[
0
])
self
.
net
.
addLink
(
c1
,
sc
[
1
])
self
.
net
.
addLink
(
c2
,
sc
[
1
])
def
createSpineClump
(
self
,
island
,
edges
,
hosts
):
""" Creates a clump of spine and edge switches with hosts"""
s1
=
self
.
net
.
addSwitch
(
's
%1
d1'
%
island
,
dpid
=
'00000
%1
d0100000000'
%
island
)
s2
=
self
.
net
.
addSwitch
(
's
%1
d2'
%
island
,
dpid
=
'00000
%1
d0200000000'
%
island
)
self
.
net
.
addLink
(
s1
,
s2
)
self
.
net
.
addLink
(
s2
,
s1
)
for
i
in
range
(
1
,
edges
+
1
):
es
=
self
.
createEdgeSwitch
(
island
,
i
,
hosts
)
self
.
net
.
addLink
(
es
,
s1
)
self
.
net
.
addLink
(
es
,
s2
)
self
.
spines
.
append
(
s1
)
self
.
spines
.
append
(
s2
)
clump
=
[]
clump
.
append
(
s1
)
clump
.
append
(
s2
)
return
clump
def
createEdgeSwitch
(
self
,
island
,
index
,
hosts
):
""" Creates an edge switch in an island and ads hosts to it"""
sw
=
self
.
net
.
addSwitch
(
'e
%1
d
%1
d'
%
(
island
,
index
),
dpid
=
'0000000
%1
d0000000
%1
d'
%
(
island
,
index
))
self
.
leaves
.
append
(
sw
)
for
j
in
range
(
1
,
hosts
+
1
):
host
=
self
.
net
.
addHost
(
'h
%
d
%
d
%
d'
%
(
island
,
index
,
j
),
ip
=
'10.
%
d.
%
d.
%
d'
%
(
island
,
index
,
j
))
self
.
net
.
addLink
(
host
,
sw
)
self
.
hosts
.
append
(
host
)
return
sw
def
run
(
self
):
""" Runs the created network topology and launches mininet cli"""
self
.
run_silent
()
CustomCLI
(
self
.
net
)
self
.
net
.
stop
()
def
run_silent
(
self
):
""" Runs silently - for unit testing """
self
.
net
.
build
()
# Start the switches, configure them with desired protocols and only
# then set the controller
for
sw
in
self
.
spines
:
sw
.
start
([
self
.
flare
])
if
self
.
proto
:
sw
.
cmd
(
'ovs-vsctl set bridge
%(sw)
s protocols=
%(proto)
s'
%
\
{
'sw'
:
sw
.
name
,
'proto'
:
self
.
proto
})
sw
.
cmdPrint
(
'ovs-vsctl set-controller
%(sw)
s tcp:
%(ctl)
s:6633'
%
\
{
'sw'
:
sw
.
name
,
'ctl'
:
self
.
cip
})
for
sw
in
self
.
leaves
:
sw
.
start
([
self
.
flare
])
sw
.
cmdPrint
(
'ovs-vsctl set-controller
%(sw)
s tcp:
%(ctl)
s:6633'
%
\
{
'sw'
:
sw
.
name
,
'ctl'
:
self
.
cip
})
def
pingAll
(
self
):
""" PingAll to create flows - for unit testing """
self
.
net
.
pingAll
()
def
stop
(
self
):
"Stops the topology. You should call this after run_silent"
self
.
net
.
stop
()
Please
register
or
login
to post a comment