blob: be3db6e685a7f8545a14d0100af5c4370f353725 [file] [log] [blame]
Kyle Mesteryd44517d2014-01-28 20:29:18 +00001# 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
24XTRACE=$(set +o | grep xtrace)
25set +o xtrace
26
27
28# For OVS_BRIDGE and PUBLIC_BRIDGE
29source $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=
36ODL_MGR_IP=${ODL_MGR_IP:-$SERVICE_HOST}
37
Simon Pasquiercfc9ebb2014-04-08 09:34:44 +020038# The ODL endpoint URL
39ODL_ENDPOINT=${ODL_ENDPOINT:-http://${ODL_MGR_IP}:8080/controller/nb/v2/neutron}
40
41# The ODL username
42ODL_USERNAME=${ODL_USERNAME:-admin}
43
44# The ODL password
45ODL_PASSWORD=${ODL_PASSWORD:-admin}
46
Kyle Mesteryd44517d2014-01-28 20:29:18 +000047# <define global variables here that belong to this project>
48ODL_DIR=$DEST/opendaylight
49
50# The OpenDaylight Package, currently using 'Hydrogen' release
51ODL_PKG=${ODL_PKG:-distributions-virtualization-0.1.1-osgipackage.zip}
52
53# The OpenDaylight URL
54ODL_URL=${ODL_URL:-https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/integration/distributions-virtualization/0.1.1}
55
56# Default arguments for OpenDaylight. This is typically used to set
57# Java memory options.
58# ODL_ARGS=Xmx1024m -XX:MaxPermSize=512m
59ODL_ARGS=${ODL_ARGS:-"-XX:MaxPermSize=384m"}
60
61# How long to pause after ODL starts to let it complete booting
62ODL_BOOT_WAIT=${ODL_BOOT_WAIT:-60}
63
64# Set up default directories
65
66
67# Entry Points
68# ------------
69
70# Test if OpenDaylight is enabled
71# is_opendaylight_enabled
72function is_opendaylight_enabled {
73 [[ ,${ENABLED_SERVICES} =~ ,"odl-" ]] && return 0
74 return 1
75}
76
77# cleanup_opendaylight() - Remove residual data files, anything left over from previous
78# runs that a clean run would need to clean up
79function cleanup_opendaylight {
80 :
81}
82
83# configure_opendaylight() - Set config files, create data dirs, etc
84function configure_opendaylight {
85 # Remove simple forwarder
86 rm -f $ODL_DIR/opendaylight/plugins/org.opendaylight.controller.samples.simpleforwarding*
87
88 # Configure OpenFlow 1.3
89 echo "ovsdb.of.version=1.3" >> $ODL_DIR/opendaylight/configuration/config.ini
90}
91
Simon Pasquiercfc9ebb2014-04-08 09:34:44 +020092function configure_ml2_odl {
93 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_odl url=$ODL_ENDPOINT
94 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_odl username=$ODL_USERNAME
95 populate_ml2_config /$Q_PLUGIN_CONF_FILE ml2_odl password=$ODL_PASSWORD
96}
97
Kyle Mesteryd44517d2014-01-28 20:29:18 +000098# init_opendaylight() - Initialize databases, etc.
99function init_opendaylight {
100 # clean up from previous (possibly aborted) runs
101 # create required data files
102 :
103}
104
105# install_opendaylight() - Collect source and prepare
106function install_opendaylight {
107 local _pwd=$(pwd)
108
109 if is_ubuntu; then
110 install_package maven openjdk-7-jre openjdk-7-jdk
111 else
112 yum_install maven java-1.7.0-openjdk
113 fi
114
115 # Download OpenDaylight
116 mkdir -p $ODL_DIR
117 cd $ODL_DIR
118 wget -N $ODL_URL/$ODL_PKG
119 unzip -u $ODL_PKG
120}
121
122# install_opendaylight-compute - Make sure OVS is install
123function install_opendaylight-compute {
124 local kernel_version
125 # Install deps
126 # FIXME add to ``files/apts/neutron``, but don't install if not needed!
127 if is_ubuntu; then
128 kernel_version=`cat /proc/version | cut -d " " -f3`
129 install_package make fakeroot dkms openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version
130 elif is_fedora; then
131 install_package openvswitch
132 # Ensure that the service is started
133 restart_service openvswitch
134 elif is_suse; then
Ralf Haferkampce03d102014-04-07 17:01:53 +0200135 install_package openvswitch-switch
Kyle Mesteryd44517d2014-01-28 20:29:18 +0000136 restart_service openvswitch-switch
Kyle Mesteryd44517d2014-01-28 20:29:18 +0000137 fi
138}
139
140# start_opendaylight() - Start running processes, including screen
141function start_opendaylight {
142 if is_ubuntu; then
143 JHOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
144 else
145 JHOME=/usr/lib/jvm/java-1.7.0-openjdk
146 fi
147
148 # The flags to ODL have the following meaning:
149 # -of13: runs ODL using OpenFlow 1.3 protocol support.
150 # -virt ovsdb: Runs ODL in "virtualization" mode with OVSDB support
fujioka yuuichi41ca6dc2014-03-20 03:03:26 +0000151 screen_it odl-server "cd $ODL_DIR/opendaylight && JAVA_HOME=$JHOME ./run.sh $ODL_ARGS -of13 -virt ovsdb"
Kyle Mesteryd44517d2014-01-28 20:29:18 +0000152
153 # Sleep a bit to let OpenDaylight finish starting up
154 sleep $ODL_BOOT_WAIT
155}
156
157# stop_opendaylight() - Stop running processes (non-screen)
158function stop_opendaylight {
159 screen_stop odl-server
160}
161
162# stop_opendaylight-compute() - Remove OVS bridges
163function stop_opendaylight-compute {
164 # remove all OVS ports that look like Neutron created ports
165 for port in $(sudo ovs-vsctl list port | grep -o -e tap[0-9a-f\-]* -e q[rg]-[0-9a-f\-]*); do
166 sudo ovs-vsctl del-port ${port}
167 done
168
169 # remove all OVS bridges created by Neutron
170 for bridge in $(sudo ovs-vsctl list-br | grep -o -e ${OVS_BRIDGE} -e ${PUBLIC_BRIDGE}); do
171 sudo ovs-vsctl del-br ${bridge}
172 done
173}
174
175# Restore xtrace
176$XTRACE
177
178# Tell emacs to use shell-script-mode
179## Local variables:
180## mode: shell-script
181## End: