Skip to content

Commit d44517d

Browse files
committed
Add support for configuring OVS to work with OpenDaylight
This adds support for running OpenDaylight as an OpenStack Neutron plugin under devstack. This entails downloading the latest version of OpenDaylight, configuring it, and running it as a service under devstack. This code also includes pieces which configure Open vSwitch on each devstack node to point at OpenDaylight as their OpenFlow and OVSDB control interface. This is required for compute hosts, which will not be running any Neutron software on them at all. This post-devstack configuration is handled in the extras directory because of the fact there is no Neutron code running on the compute hosts themselves. Closes-bug: #1273917 Change-Id: I696e7c7fe63c835f90c56105775def305a702877
1 parent c880fb4 commit d44517d

File tree

5 files changed

+241
-0
lines changed

5 files changed

+241
-0
lines changed

extras.d/80-opendaylight.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# opendaylight.sh - DevStack extras script
2+
3+
# Need this first to get the is_***_enabled for ODL
4+
source $TOP_DIR/lib/opendaylight
5+
6+
if is_service_enabled odl-server; then
7+
if [[ "$1" == "source" ]]; then
8+
# no-op
9+
:
10+
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
11+
install_opendaylight
12+
configure_opendaylight
13+
init_opendaylight
14+
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
15+
# This has to start before Neutron
16+
start_opendaylight
17+
elif [[ "$1" == "stack" && "$2" == "post-extra" ]]; then
18+
# no-op
19+
:
20+
fi
21+
22+
if [[ "$1" == "unstack" ]]; then
23+
stop_opendaylight
24+
cleanup_opendaylight
25+
fi
26+
27+
if [[ "$1" == "clean" ]]; then
28+
# no-op
29+
:
30+
fi
31+
fi
32+
33+
if is_service_enabled odl-compute; then
34+
if [[ "$1" == "source" ]]; then
35+
# no-op
36+
:
37+
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
38+
install_opendaylight-compute
39+
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
40+
create_nova_conf_neutron
41+
elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
42+
echo_summary "Initializing OpenDaylight"
43+
ODL_LOCAL_IP=${ODL_LOCAL_IP:-$HOST_IP}
44+
ODL_MGR_PORT=${ODL_MGR_PORT:-6640}
45+
read ovstbl <<< $(sudo ovs-vsctl get Open_vSwitch . _uuid)
46+
sudo ovs-vsctl set-manager tcp:$ODL_MGR_IP:$ODL_MGR_PORT
47+
sudo ovs-vsctl set Open_vSwitch $ovstbl other_config={"local_ip"="$ODL_LOCAL_IP"}
48+
elif [[ "$1" == "stack" && "$2" == "post-extra" ]]; then
49+
# no-op
50+
:
51+
fi
52+
53+
if [[ "$1" == "unstack" ]]; then
54+
sudo ovs-vsctl del-manager
55+
BRIDGES=$(sudo ovs-vsctl list-br)
56+
for bridge in $BRIDGES ; do
57+
sudo ovs-vsctl del-controller $bridge
58+
done
59+
60+
stop_opendaylight-compute
61+
fi
62+
63+
if [[ "$1" == "clean" ]]; then
64+
# no-op
65+
:
66+
fi
67+
fi

files/apts/opendaylight

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
openvswitch-datapath-dkms # NOPRIME
2+
openvswitch-switch # NOPRIME

files/rpms-suse/opendaylight

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
openvswitch # NOPRIME
2+
openvswitch-controller # NOPRIME
3+
openvswitch-switch # NOPRIME
4+

files/rpms/opendaylight

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
openvswitch # NOPRIME

lib/opendaylight

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# lib/opendaylight
2+
# Functions to control the configuration and operation of the opendaylight service
3+
4+
# Dependencies:
5+
#
6+
# - ``functions`` file
7+
# # ``DEST`` must be defined
8+
# # ``STACK_USER`` must be defined
9+
10+
# ``stack.sh`` calls the entry points in this order:
11+
#
12+
# - is_opendaylight_enabled
13+
# - is_opendaylight-compute_enabled
14+
# - install_opendaylight
15+
# - install_opendaylight-compute
16+
# - configure_opendaylight
17+
# - init_opendaylight
18+
# - start_opendaylight
19+
# - stop_opendaylight-compute
20+
# - stop_opendaylight
21+
# - cleanup_opendaylight
22+
23+
# Save trace setting
24+
XTRACE=$(set +o | grep xtrace)
25+
set +o xtrace
26+
27+
28+
# For OVS_BRIDGE and PUBLIC_BRIDGE
29+
source $TOP_DIR/lib/neutron_plugins/ovs_base
30+
31+
# Defaults
32+
# --------
33+
34+
# The IP address of ODL. Set this in local.conf.
35+
# ODL_MGR_IP=
36+
ODL_MGR_IP=${ODL_MGR_IP:-$SERVICE_HOST}
37+
38+
# <define global variables here that belong to this project>
39+
ODL_DIR=$DEST/opendaylight
40+
41+
# The OpenDaylight Package, currently using 'Hydrogen' release
42+
ODL_PKG=${ODL_PKG:-distributions-virtualization-0.1.1-osgipackage.zip}
43+
44+
# The OpenDaylight URL
45+
ODL_URL=${ODL_URL:-https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/distributions-virtualization/0.1.1}
46+
47+
# Default arguments for OpenDaylight. This is typically used to set
48+
# Java memory options.
49+
# ODL_ARGS=Xmx1024m -XX:MaxPermSize=512m
50+
ODL_ARGS=${ODL_ARGS:-"-XX:MaxPermSize=384m"}
51+
52+
# How long to pause after ODL starts to let it complete booting
53+
ODL_BOOT_WAIT=${ODL_BOOT_WAIT:-60}
54+
55+
# Set up default directories
56+
57+
58+
# Entry Points
59+
# ------------
60+
61+
# Test if OpenDaylight is enabled
62+
# is_opendaylight_enabled
63+
function is_opendaylight_enabled {
64+
[[ ,${ENABLED_SERVICES} =~ ,"odl-" ]] && return 0
65+
return 1
66+
}
67+
68+
# cleanup_opendaylight() - Remove residual data files, anything left over from previous
69+
# runs that a clean run would need to clean up
70+
function cleanup_opendaylight {
71+
:
72+
}
73+
74+
# configure_opendaylight() - Set config files, create data dirs, etc
75+
function configure_opendaylight {
76+
# Remove simple forwarder
77+
rm -f $ODL_DIR/opendaylight/plugins/org.opendaylight.controller.samples.simpleforwarding*
78+
79+
# Configure OpenFlow 1.3
80+
echo "ovsdb.of.version=1.3" >> $ODL_DIR/opendaylight/configuration/config.ini
81+
}
82+
83+
# init_opendaylight() - Initialize databases, etc.
84+
function init_opendaylight {
85+
# clean up from previous (possibly aborted) runs
86+
# create required data files
87+
:
88+
}
89+
90+
# install_opendaylight() - Collect source and prepare
91+
function install_opendaylight {
92+
local _pwd=$(pwd)
93+
94+
if is_ubuntu; then
95+
install_package maven openjdk-7-jre openjdk-7-jdk
96+
else
97+
yum_install maven java-1.7.0-openjdk
98+
fi
99+
100+
# Download OpenDaylight
101+
mkdir -p $ODL_DIR
102+
cd $ODL_DIR
103+
wget -N $ODL_URL/$ODL_PKG
104+
unzip -u $ODL_PKG
105+
}
106+
107+
# install_opendaylight-compute - Make sure OVS is install
108+
function install_opendaylight-compute {
109+
local kernel_version
110+
# Install deps
111+
# FIXME add to ``files/apts/neutron``, but don't install if not needed!
112+
if is_ubuntu; then
113+
kernel_version=`cat /proc/version | cut -d " " -f3`
114+
install_package make fakeroot dkms openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version
115+
elif is_fedora; then
116+
install_package openvswitch
117+
# Ensure that the service is started
118+
restart_service openvswitch
119+
elif is_suse; then
120+
install_package openvswitch
121+
restart_service openvswitch-switch
122+
restart_service openvswitch-controller
123+
fi
124+
}
125+
126+
# start_opendaylight() - Start running processes, including screen
127+
function start_opendaylight {
128+
if is_ubuntu; then
129+
JHOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
130+
else
131+
JHOME=/usr/lib/jvm/java-1.7.0-openjdk
132+
fi
133+
134+
# The flags to ODL have the following meaning:
135+
# -of13: runs ODL using OpenFlow 1.3 protocol support.
136+
# -virt ovsdb: Runs ODL in "virtualization" mode with OVSDB support
137+
screen_it odl-server "cd $ODL_DIR/opendaylight && JAVE_HOME=$JHOME ./run.sh $ODL_ARGS -of13 -virt ovsdb"
138+
139+
# Sleep a bit to let OpenDaylight finish starting up
140+
sleep $ODL_BOOT_WAIT
141+
}
142+
143+
# stop_opendaylight() - Stop running processes (non-screen)
144+
function stop_opendaylight {
145+
screen_stop odl-server
146+
}
147+
148+
# stop_opendaylight-compute() - Remove OVS bridges
149+
function stop_opendaylight-compute {
150+
# remove all OVS ports that look like Neutron created ports
151+
for port in $(sudo ovs-vsctl list port | grep -o -e tap[0-9a-f\-]* -e q[rg]-[0-9a-f\-]*); do
152+
sudo ovs-vsctl del-port ${port}
153+
done
154+
155+
# remove all OVS bridges created by Neutron
156+
for bridge in $(sudo ovs-vsctl list-br | grep -o -e ${OVS_BRIDGE} -e ${PUBLIC_BRIDGE}); do
157+
sudo ovs-vsctl del-br ${bridge}
158+
done
159+
}
160+
161+
# Restore xtrace
162+
$XTRACE
163+
164+
# Tell emacs to use shell-script-mode
165+
## Local variables:
166+
## mode: shell-script
167+
## End:

0 commit comments

Comments
 (0)