added new OVS service file

This commit is contained in:
cspiker 2017-06-07 12:41:52 -07:00
parent 97f3c3a070
commit b37d1d52fa
6 changed files with 660 additions and 0 deletions

View file

@ -0,0 +1,113 @@
#
# CORE
# Copyright (c)2010-2012 the Boeing Company.
# See the LICENSE file included in this distribution.
#
''' Sample user-defined service.
'''
import os
import re
from core.service import CoreService, addservice
class OvsService(CoreService):
''' This is a sample user-defined service.
'''
# a unique name is required, without spaces
_name = "OvsService"
# you can create your own group here
_group = "SDN"
# list of other services this service depends on
_depends = ()
# per-node directories
_dirs = ("/etc/openvswitch", "/var/run/openvswitch", "/var/log/openvswitch")
# generated files (without a full path this file goes in the node's dir,
# e.g. /tmp/pycore.12345/n1.conf/)
_configs = ('OvsService.sh', )
# this controls the starting order vs other enabled services
_startindex = 50
# list of startup commands, also may be generated during startup
_startup = ('sh OvsService.sh',)
# list of shutdown commands
_shutdown = ('killall ovs-vswitchd','killall ovsdb-server')
@classmethod
def generateconfig(cls, node, filename, services):
''' Return a string that will be written to filename, or sent to the
GUI for user customization.
'''
# Check whether the node is running zebra
has_zebra = 0
for s in services:
if s._name == "zebra":
has_zebra = 1
# Check whether the node is running an SDN controller
has_sdn_ctrlr = 0
for s in services:
if s._name == "ryuService":
has_sdn_ctrlr = 1
cfg = "#!/bin/sh\n"
cfg += "# auto-generated by OvsService (OvsService.py)\n"
cfg += "/etc/init.d/openvswitch-switch start < /dev/null\n"
cfg += "ovs-vsctl add-br ovsbr0\n"
cfg += "ifconfig ovsbr0 up\n"
for ifc in node.netifs():
if hasattr(ifc, 'control') and ifc.control == True:
continue
ifnumstr = re.findall(r"\d+", ifc.name)
ifnum = ifnumstr[0]
# create virtual interfaces
cfg += "ip link add rtr%s type veth peer name sw%s\n" % (ifnum, ifnum)
cfg += "ifconfig rtr%s up\n" % ifnum
cfg += "ifconfig sw%s up\n" % ifnum
# remove ip address of eths because quagga/zebra will assign same IPs to rtr interfaces
# or assign them manually to rtr interfaces if zebra is not running
for ifcaddr in ifc.addrlist:
if ifcaddr.find(".") >= 0:
cfg += "ip addr del %s dev %s\n" % (ifcaddr, ifc.name)
if has_zebra == 0:
cfg += "ip addr add %s dev rtr%s\n" % (ifcaddr, ifnum)
elif ifcaddr.find(":") >= 0:
cfg += "ip -6 addr del %s dev %s\n" % (ifcaddr, ifc.name)
if has_zebra == 0:
cfg += "ip -6 addr add %s dev rtr%s\n" % (ifcaddr, ifnum)
else:
raise Value, "invalid address: %s", x
# add interfaces to bridge
cfg += "ovs-vsctl add-port ovsbr0 eth%s\n" % ifnum
cfg += "ovs-vsctl add-port ovsbr0 sw%s\n" % ifnum
#if has_sdn_ctrlr == 1: #TODO- even if the controller is not local, it finds it
# Add rule for default controller if there is one local
cfg += "ovs-vsctl set-controller ovsbr0 tcp:127.0.0.1:6633\n"
#else:
# Delete flows otherwise
#cfg += "ovs-ofctl del-flows ovsbr0\n"
# Setup default flows
portnum = 1
for ifc in node.netifs():
if hasattr(ifc, 'control') and ifc.control == True:
continue
cfg += "ovs-ofctl add-flow ovsbr0 priority=1000,in_port=%d,action=output:%d\n" % (portnum, portnum+1)
cfg += "ovs-ofctl add-flow ovsbr0 priority=1000,in_port=%d,action=output:%d\n" % (portnum+1, portnum)
portnum += 2
return cfg
@staticmethod
def subnetentry(x):
# TODO - Maybe move default flow rules to here?
return
# this line is required to add the above class to the list of available services
addservice(OvsService)

View file

@ -0,0 +1,66 @@
#
# CORE
# Copyright (c)2010-2012 the Boeing Company.
# See the LICENSE file included in this distribution.
#
''' Ryu SDN controller user-defined service.
'''
import os
from core.service import CoreService, addservice
from core.misc.ipaddr import IPv4Prefix, IPv6Prefix
class ryuService(CoreService):
''' This is a ryu user-defined service.
'''
# a unique name is required, without spaces
_name = "ryuService"
# you can create your own group here
_group = "SDN"
# list of other services this service depends on
_depends = ()
# per-node directories
_dirs = ()
# generated files (without a full path this file goes in the node's dir,
# e.g. /tmp/pycore.12345/n1.conf/)
_configs = ('ryuService.sh', )
# this controls the starting order vs other enabled services
_startindex = 50
# list of startup commands, also may be generated during startup
_startup = ('sh ryuService.sh',)
# list of shutdown commands
_shutdown = ('killall ryu-manager')
@classmethod
def generateconfig(cls, node, filename, services):
''' Return a string that will be written to filename, or sent to the
GUI for user customization.
'''
app_path = "/usr/local/lib/python2.7/dist-packages/ryu/app"
cfg = "#!/bin/sh\n"
cfg += "# auto-generated by ryuService (ryuService.py)\n"
cfg += '/usr/local/bin/ryu-manager --observe-links %s/ofctl_rest.py %s/rest_topology.py' % (app_path, app_path)
#for ifc in node.netifs():
# cfg += 'echo "Node %s has interface %s"\n' % (node.name, ifc.name)
# # here we do something interesting
# cfg += "\n".join(map(cls.subnetentry, ifc.addrlist))
# break
return cfg
@staticmethod
def subnetentry(x):
''' Generate a subnet declaration block given an IPv4 prefix string
for inclusion in the config file.
'''
if x.find(":") >= 0:
# this is an IPv6 address
return ""
else:
net = IPv4Prefix(x)
return 'echo " network %s"' % (net)
# this line is required to add the above class to the list of available services
addservice(ryuService)

View file

@ -0,0 +1,291 @@
node n1 {
type router
model host
network-config {
hostname ryu1
!
interface eth1
ip address 10.0.5.10/24
ipv6 address 2001:5::10/64
!
interface eth0
ip address 10.0.4.10/24
ipv6 address 2001:4::10/64
!
}
canvas c1
iconcoords {203.0 65.0}
labelcoords {203.0 97.0}
interface-peer {eth0 n2}
interface-peer {eth1 n3}
}
node n2 {
type router
model OVS
network-config {
hostname ovs1
!
interface eth2
ip address 10.0.4.1/24
ipv6 address 2001:4::1/64
!
interface eth1
ip address 10.0.1.1/24
ipv6 address 2001:1::1/64
!
interface eth0
ip address 10.0.0.1/24
ipv6 address 2001:0::1/64
!
}
canvas c1
iconcoords {124.0 213.0}
labelcoords {124.0 245.0}
interface-peer {eth0 n6}
interface-peer {eth1 n4}
interface-peer {eth2 n1}
}
node n3 {
type router
model OVS
network-config {
hostname ovs2
!
interface eth2
ip address 10.0.5.1/24
ipv6 address 2001:5::1/64
!
interface eth1
ip address 10.0.3.1/24
ipv6 address 2001:3::1/64
!
interface eth0
ip address 10.0.2.1/24
ipv6 address 2001:2::1/64
!
}
canvas c1
iconcoords {299.0 220.0}
labelcoords {299.0 252.0}
interface-peer {eth0 n7}
interface-peer {eth1 n5}
interface-peer {eth2 n1}
}
node n4 {
type router
model host
network-config {
hostname n4
!
interface eth0
ip address 10.0.1.10/24
ipv6 address 2001:1::10/64
!
}
canvas c1
iconcoords {39.0 313.0}
labelcoords {39.0 345.0}
interface-peer {eth0 n2}
}
node n5 {
type router
model host
network-config {
hostname n5
!
interface eth0
ip address 10.0.3.10/24
ipv6 address 2001:3::10/64
!
}
canvas c1
iconcoords {286.0 327.0}
labelcoords {286.0 359.0}
interface-peer {eth0 n3}
}
node n6 {
type router
model host
network-config {
hostname n6
!
interface eth0
ip address 10.0.0.10/24
ipv6 address 2001:0::10/64
!
}
canvas c1
iconcoords {131.0 322.0}
labelcoords {131.0 354.0}
interface-peer {eth0 n2}
}
node n7 {
type router
model host
network-config {
hostname n7
!
interface eth0
ip address 10.0.2.10/24
ipv6 address 2001:2::10/64
!
}
canvas c1
iconcoords {373.0 328.0}
labelcoords {373.0 360.0}
interface-peer {eth0 n3}
}
node n8 {
type router
model mdr
network-config {
hostname n8
!
interface eth0
ip address 10.0.6.1/32
ipv6 address 2001:6::1/128
!
}
canvas c1
iconcoords {579.0 102.0}
labelcoords {579.0 134.0}
interface-peer {eth0 n11}
}
node n9 {
type router
model mdr
network-config {
hostname n9
!
interface eth0
ip address 10.0.6.2/32
ipv6 address 2001:6::2/128
!
}
canvas c1
iconcoords {493.0 212.0}
labelcoords {493.0 244.0}
interface-peer {eth0 n11}
}
node n10 {
type router
model mdr
network-config {
hostname n10
!
interface eth0
ip address 10.0.6.3/32
ipv6 address 2001:6::3/128
!
}
canvas c1
iconcoords {674.0 225.0}
labelcoords {674.0 257.0}
interface-peer {eth0 n11}
}
node n11 {
type wlan
network-config {
hostname mobile-sdn
!
interface wireless
ip address 10.0.6.0/32
ipv6 address 2001:6::0/128
!
mobmodel
coreapi
basic_range
!
}
custom-config {
custom-config-id basic_range
custom-command {3 3 9 9 9}
config {
range=275
bandwidth=54000000
jitter=0
delay=20000
error=0
}
}
canvas c1
iconcoords {683.0 127.0}
labelcoords {683.0 159.0}
interface-peer {e0 n8}
interface-peer {e1 n9}
interface-peer {e2 n10}
}
link l1 {
nodes {n2 n6}
bandwidth 0
}
link l2 {
nodes {n2 n4}
bandwidth 0
}
link l3 {
nodes {n3 n7}
bandwidth 0
}
link l4 {
nodes {n3 n5}
bandwidth 0
}
link l5 {
nodes {n1 n2}
bandwidth 0
}
link l6 {
nodes {n1 n3}
bandwidth 0
}
link l7 {
nodes {n11 n8}
}
link l8 {
nodes {n11 n9}
}
link l9 {
nodes {n11 n10}
}
canvas c1 {
name {Canvas1}
}
option global {
interface_names no
ip_addresses yes
ipv6_addresses no
node_labels yes
link_labels yes
show_api no
background_images no
annotations yes
grid yes
traffic_start 0
mac_address_start 80
}
option session {
}

BIN
gui/icons/normal/OVS.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

190
gui/icons/svg/OVS.svg Executable file
View file

@ -0,0 +1,190 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="146"
height="100"
id="svg3868"
version="1.1"
inkscape:version="0.47 r22583"
sodipodi:docname="switch.svg">
<defs
id="defs3870">
<linearGradient
id="linearGradient5149">
<stop
id="stop5151"
offset="0"
style="stop-color:#5dacd1;stop-opacity:1;" />
<stop
id="stop5153"
offset="1"
style="stop-color:#1b4a78;stop-opacity:1;" />
</linearGradient>
<linearGradient
id="linearGradient4902">
<stop
style="stop-color:#484848;stop-opacity:1;"
offset="0"
id="stop4904" />
<stop
style="stop-color:#8f8f90;stop-opacity:0;"
offset="1"
id="stop4906" />
</linearGradient>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective3876" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient12001"
id="linearGradient4908"
x1="5.8083773"
y1="68.180191"
x2="84.600281"
y2="68.180191"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.269166,0,0,1.2912385,-2.3717949,931.82545)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient12001"
id="linearGradient5039"
x1="105"
y1="55"
x2="140"
y2="55"
gradientUnits="userSpaceOnUse" />
<inkscape:perspective
id="perspective5049"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient12001"
id="linearGradient3844"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.471308,0,0,0.471308,9.3066001,-238.48173)"
x1="175.71875"
y1="737.01562"
x2="470.00089"
y2="737.01562" />
<linearGradient
id="linearGradient12001">
<stop
style="stop-color:#1b4a78;stop-opacity:1;"
offset="0"
id="stop12003" />
<stop
style="stop-color:#5dacd1;stop-opacity:1;"
offset="1"
id="stop12005" />
</linearGradient>
<inkscape:perspective
id="perspective5135"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective5165"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8284271"
inkscape:cx="91.162404"
inkscape:cy="35.126778"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="809"
inkscape:window-height="852"
inkscape:window-x="605"
inkscape:window-y="185"
inkscape:window-maximized="0">
<inkscape:grid
type="xygrid"
id="grid4935"
empspacing="5"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
<metadata
id="metadata3873">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-952.36218)">
<rect
style="fill:url(#linearGradient4908);fill-opacity:1.0;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none"
id="rect4390"
width="100"
height="45"
x="5"
y="997.36218" />
<path
style="fill:url(#linearGradient5039);stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;fill-opacity:1.0"
d="m 105,45 35,-40 0,45 -35,40 0,-45 z"
id="path5031"
transform="translate(0,952.36218)"
sodipodi:nodetypes="ccccc" />
<path
style="fill:#3a78a0;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
d="M 105,45 5,45 40,5 140,5 105,45 z"
id="path5079"
transform="translate(0,952.36218)" />
<path
style="fill:#f2fdff;fill-opacity:0.71171169;stroke:none"
d="m 63.720704,982.3378 12.656877,-3.10116 12.656905,-3.10105 -3.523923,3.28427 18.978167,0.15164 -6.571234,6.1243 -18.978156,-0.15164 -3.523925,3.28426 -5.843452,-3.24896 -5.851259,-3.24166 z"
id="path13511" />
<path
style="fill:#f2fdff;fill-opacity:0.71171169;stroke:none"
d="M 80.174263,970.7443 74.367199,967.43074 68.560125,964.11719 65,967.36218 46.024691,967.0001 l -6.638732,6.05106 18.975309,0.36208 -3.560123,3.24499 12.690524,-2.96052 12.682595,-2.95341 z"
id="path13513" />
<path
id="path5195"
d="M 65.174263,985.7443 59.367199,982.43074 53.560125,979.11719 50,982.36218 31.024691,982.0001 l -6.638732,6.05106 18.975309,0.36208 -3.560123,3.24499 12.690524,-2.96052 12.682595,-2.95341 z"
style="fill:#f2fdff;fill-opacity:0.71171169;stroke:none" />
<path
id="path5209"
d="m 78.9675,967.75499 12.656877,-3.10116 12.656903,-3.10105 -3.52392,3.28427 18.97816,0.15164 -6.57123,6.1243 -18.978154,-0.15164 -3.523925,3.28426 -5.843452,-3.24896 -5.851259,-3.24166 z"
style="fill:#f2fdff;fill-opacity:0.71171169;stroke:none" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
gui/icons/tiny/OVS.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B