blob: 26376b6383f2ae5e7d7b856556d825882a126491 [file] [log] [blame]
Jesse Andrewsba23cc72011-09-11 03:22:13 -07001#!/usr/bin/env bash
2
Dean Troyerc6c1d432012-03-27 20:59:22 -05003# ``stack.sh`` is an opinionated OpenStack developer installation. It
Dean Troyer4a43b7b2012-08-28 17:43:40 -05004# installs and configures various combinations of **Ceilometer**, **Cinder**,
5# **Glance**, **Heat**, **Horizon**, **Keystone**, **Nova**, **Quantum**
6# and **Swift**
Jesse Andrewsba23cc72011-09-11 03:22:13 -07007
Vishvananda Ishaya9b353672011-10-20 10:07:10 -07008# This script allows you to specify configuration options of what git
Jesse Andrews5372f432011-10-03 01:08:24 -04009# repositories to use, enabled services, network configuration and various
10# passwords. If you are crafty you can run the script on multiple nodes using
11# shared settings for common resources (mysql, rabbitmq) and build a multi-node
12# developer install.
Jesse Andrews782b9912011-10-02 16:53:21 -040013
Dean Troyer4a43b7b2012-08-28 17:43:40 -050014# To keep this script simple we assume you are running on a recent **Ubuntu**
Dean Troyerb9182d62012-11-07 12:31:34 -060015# (11.10 Oneiric or newer) or **Fedora** (F16 or newer) machine. It
Dean Troyer4a43b7b2012-08-28 17:43:40 -050016# should work in a VM or physical server. Additionally we put the list of
17# ``apt`` and ``rpm`` dependencies and other configuration files in this repo.
Jesse Andrews24859062011-09-15 21:28:23 -070018
Jesse Andrews0e7e8972011-10-02 16:36:54 -040019# Learn more and get the most recent version at http://devstack.org
Jesse Andrews6edd17f2011-09-15 22:19:42 -070020
Dean Troyerc6c1d432012-03-27 20:59:22 -050021# Keep track of the devstack directory
Jesse Andrews51fb22e2011-10-19 09:24:17 -070022TOP_DIR=$(cd $(dirname "$0") && pwd)
23
Dean Troyer6563a3c2012-01-31 12:11:56 -060024# Import common functions
Dean Troyerc6c1d432012-03-27 20:59:22 -050025source $TOP_DIR/functions
Dean Troyer6563a3c2012-01-31 12:11:56 -060026
Dean Troyerc6c1d432012-03-27 20:59:22 -050027# Determine what system we are running on. This provides ``os_VENDOR``,
28# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
Dean Troyera9e0a482012-07-09 14:07:23 -050029# and ``DISTRO``
30GetDistro
Jesse Andrews6edd17f2011-09-15 22:19:42 -070031
Anthony Young6015c822011-10-12 07:17:11 +000032
Dean Troyerb9182d62012-11-07 12:31:34 -060033
Scott Moserf9da5082011-10-07 21:28:00 -040034# Settings
35# ========
36
Dean Troyerdf0972c2012-03-07 17:31:03 -060037# ``stack.sh`` is customizable through setting environment variables. If you
38# want to override a setting you can set and export it::
Scott Moserf9da5082011-10-07 21:28:00 -040039#
Terry Wilson428af5a2012-11-01 16:12:39 -040040# export DATABASE_PASSWORD=anothersecret
Scott Moserf9da5082011-10-07 21:28:00 -040041# ./stack.sh
42#
Terry Wilson428af5a2012-11-01 16:12:39 -040043# You can also pass options on a single line ``DATABASE_PASSWORD=simple ./stack.sh``
Scott Moserf9da5082011-10-07 21:28:00 -040044#
Dean Troyerdf0972c2012-03-07 17:31:03 -060045# Additionally, you can put any local variables into a ``localrc`` file::
Scott Moserf9da5082011-10-07 21:28:00 -040046#
Terry Wilson428af5a2012-11-01 16:12:39 -040047# DATABASE_PASSWORD=anothersecret
48# DATABASE_USER=hellaroot
Scott Moserf9da5082011-10-07 21:28:00 -040049#
50# We try to have sensible defaults, so you should be able to run ``./stack.sh``
Dean Troyer4a43b7b2012-08-28 17:43:40 -050051# in most cases. ``localrc`` is not distributed with DevStack and will never
52# be overwritten by a DevStack update.
Scott Moserf9da5082011-10-07 21:28:00 -040053#
Dean Troyerdf0972c2012-03-07 17:31:03 -060054# DevStack distributes ``stackrc`` which contains locations for the OpenStack
55# repositories and branches to configure. ``stackrc`` sources ``localrc`` to
Dean Troyer4a43b7b2012-08-28 17:43:40 -050056# allow you to safely override those settings.
57
Dean Troyerbbafb1b2012-06-11 16:51:39 -050058if [[ ! -r $TOP_DIR/stackrc ]]; then
59 echo "ERROR: missing $TOP_DIR/stackrc - did you grab more than just stack.sh?"
60 exit 1
61fi
62source $TOP_DIR/stackrc
Dean Troyerdf0972c2012-03-07 17:31:03 -060063
Dean Troyer4a43b7b2012-08-28 17:43:40 -050064
65# Proxy Settings
66# --------------
67
68# HTTP and HTTPS proxy servers are supported via the usual environment variables [1]
69# ``http_proxy``, ``https_proxy`` and ``no_proxy``. They can be set in
70# ``localrc`` if necessary or on the command line::
71#
72# [1] http://www.w3.org/Daemon/User/Proxies/ProxyClients.html
Dean Troyerc727aa82012-01-13 12:13:59 -060073#
Osamu Habuka7abe4f22012-07-25 12:39:32 +090074# http_proxy=http://proxy.example.com:3128/ no_proxy=repo.example.net ./stack.sh
Dean Troyer4a43b7b2012-08-28 17:43:40 -050075
Dean Troyerbbafb1b2012-06-11 16:51:39 -050076if [[ -n "$http_proxy" ]]; then
77 export http_proxy=$http_proxy
Dean Troyerc6c1d432012-03-27 20:59:22 -050078fi
Dean Troyerbbafb1b2012-06-11 16:51:39 -050079if [[ -n "$https_proxy" ]]; then
80 export https_proxy=$https_proxy
81fi
Osamu Habuka7abe4f22012-07-25 12:39:32 +090082if [[ -n "$no_proxy" ]]; then
83 export no_proxy=$no_proxy
84fi
Scott Moserf9da5082011-10-07 21:28:00 -040085
Jesse Andrews6edd17f2011-09-15 22:19:42 -070086# Destination path for installation ``DEST``
Anthony Younge8fed482011-09-26 19:50:43 -070087DEST=${DEST:-/opt/stack}
Jesse Andrewsba23cc72011-09-11 03:22:13 -070088
Dean Troyerc6c1d432012-03-27 20:59:22 -050089
90# Sanity Check
91# ============
92
Dean Troyer33cb4302012-12-10 16:47:36 -060093# Clean up last environment var cache
94if [[ -r $TOP_DIR/.stackenv ]]; then
95 rm $TOP_DIR/.stackenv
96fi
97
Dean Troyerc1b486a2012-11-05 14:26:09 -060098# Import database configuration
99source $TOP_DIR/lib/database
100
101# Validate database selection
102# Since DATABASE_BACKENDS is now set, this also gets ENABLED_SERVICES
103# properly configured for the database selection.
104use_database $DATABASE_TYPE || echo "Invalid database '$DATABASE_TYPE'"
105
Doug Hellmannf04178f2012-07-05 17:10:03 -0400106# Remove services which were negated in ENABLED_SERVICES
Joe Gordon6fd28112012-11-13 16:55:41 -0800107# using the "-" prefix (e.g., "-rabbit") instead of
Doug Hellmannf04178f2012-07-05 17:10:03 -0400108# calling disable_service().
109disable_negated_services
Chmouel Boudjnahc4cd4142012-06-27 11:01:40 +0200110
Dean Troyerc6c1d432012-03-27 20:59:22 -0500111# Warn users who aren't on an explicitly supported distro, but allow them to
112# override check and attempt installation with ``FORCE=yes ./stack``
Attila Fazekasece6a332012-11-29 14:19:41 +0100113if [[ ! ${DISTRO} =~ (oneiric|precise|quantal|raring|f16|f17|f18) ]]; then
Dean Troyer4a1f5a72012-06-21 09:57:43 -0500114 echo "WARNING: this script has not been tested on $DISTRO"
Dean Troyerc6c1d432012-03-27 20:59:22 -0500115 if [[ "$FORCE" != "yes" ]]; then
116 echo "If you wish to run this script anyway run with FORCE=yes"
117 exit 1
118 fi
119fi
120
Vincent Untz856a11e2012-11-21 16:04:12 +0100121if is_service_enabled qpid && ! qpid_is_supported; then
122 echo "Qpid support is not available for this version of your distribution."
Russell Bryant4a221452012-03-13 13:44:12 -0400123 exit 1
124fi
125
Dean Troyer67787e62012-05-02 11:48:15 -0500126# ``stack.sh`` keeps function libraries here
127# Make sure ``$TOP_DIR/lib`` directory is present
128if [ ! -d $TOP_DIR/lib ]; then
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500129 echo "ERROR: missing devstack/lib"
Dean Troyer67787e62012-05-02 11:48:15 -0500130 exit 1
131fi
132
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500133# ``stack.sh`` keeps the list of ``apt`` and ``rpm`` dependencies and config
134# templates and other useful files in the ``files`` subdirectory
Dean Troyerc6c1d432012-03-27 20:59:22 -0500135FILES=$TOP_DIR/files
136if [ ! -d $FILES ]; then
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500137 echo "ERROR: missing devstack/files"
Dean Troyerc6c1d432012-03-27 20:59:22 -0500138 exit 1
139fi
140
Dean Troyer15733352012-09-06 11:51:30 -0500141SCREEN_NAME=${SCREEN_NAME:-stack}
Dean Troyerc6c1d432012-03-27 20:59:22 -0500142# Check to see if we are already running DevStack
Dean Troyer15733352012-09-06 11:51:30 -0500143if type -p screen >/dev/null && screen -ls | egrep -q "[0-9].$SCREEN_NAME"; then
Anthony Young55458452011-12-17 00:21:49 +0000144 echo "You are already running a stack.sh session."
145 echo "To rejoin this session type 'screen -x stack'."
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500146 echo "To destroy this session, type './unstack.sh'."
Anthony Young55458452011-12-17 00:21:49 +0000147 exit 1
148fi
Todd Willey0a161452011-10-28 02:34:19 -0400149
ewindisch3bae7c22012-01-18 11:18:35 -0500150# Make sure we only have one rpc backend enabled.
151rpc_backend_cnt=0
152for svc in qpid zeromq rabbit; do
153 is_service_enabled $svc &&
154 ((rpc_backend_cnt++))
155done
156if [ "$rpc_backend_cnt" -gt 1 ]; then
157 echo "ERROR: only one rpc backend may be enabled,"
158 echo " set only one of 'rabbit', 'qpid', 'zeromq'"
159 echo " via ENABLED_SERVICES."
160elif [ "$rpc_backend_cnt" == 0 ]; then
161 echo "ERROR: at least one rpc backend must be enabled,"
162 echo " set one of 'rabbit', 'qpid', 'zeromq'"
163 echo " via ENABLED_SERVICES."
164fi
165unset rpc_backend_cnt
166
Dean Troyer7903b792012-09-13 17:16:12 -0500167# Set up logging level
168VERBOSE=$(trueorfalse True $VERBOSE)
169
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500170
171# root Access
172# -----------
173
174# OpenStack is designed to be run as a non-root user; Horizon will fail to run
175# as **root** since Apache will not serve content from **root** user). If
Dean Troyerdf0972c2012-03-07 17:31:03 -0600176# ``stack.sh`` is run as **root**, it automatically creates a **stack** user with
Dean Troyer9122e7b2011-10-17 14:07:11 -0500177# sudo privileges and runs as that user.
178
179if [[ $EUID -eq 0 ]]; then
James E. Blair92e81992011-10-11 09:26:29 -0500180 ROOTSLEEP=${ROOTSLEEP:-10}
Dean Troyer9122e7b2011-10-17 14:07:11 -0500181 echo "You are running this script as root."
James E. Blair92e81992011-10-11 09:26:29 -0500182 echo "In $ROOTSLEEP seconds, we will create a user 'stack' and run as that user"
183 sleep $ROOTSLEEP
Dean Troyer9122e7b2011-10-17 14:07:11 -0500184
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500185 # Give the non-root user the ability to run as **root** via ``sudo``
Vincent Untz71ebc6f2012-06-12 13:45:15 +0200186 is_package_installed sudo || install_package sudo
Vincent Untze29b94e2012-06-12 14:21:18 +0200187 if ! getent group stack >/dev/null; then
188 echo "Creating a group called stack"
189 groupadd stack
190 fi
Dean Troyer9122e7b2011-10-17 14:07:11 -0500191 if ! getent passwd stack >/dev/null; then
192 echo "Creating a user called stack"
Vincent Untze29b94e2012-06-12 14:21:18 +0200193 useradd -g stack -s /bin/bash -d $DEST -m stack
Dean Troyer9122e7b2011-10-17 14:07:11 -0500194 fi
195
Joe Gordone5d92382012-09-13 17:19:03 -0700196 echo "Giving stack user passwordless sudo privileges"
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500197 # UEC images ``/etc/sudoers`` does not have a ``#includedir``, add one
Dean Troyer9122e7b2011-10-17 14:07:11 -0500198 grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers ||
199 echo "#includedir /etc/sudoers.d" >> /etc/sudoers
200 ( umask 226 && echo "stack ALL=(ALL) NOPASSWD:ALL" \
201 > /etc/sudoers.d/50_stack_sh )
202
203 echo "Copying files to stack user"
Sean Gallagher8f393df2012-12-03 00:17:38 -0800204 STACK_DIR="$DEST/${TOP_DIR##*/}"
205 cp -r -f -T "$TOP_DIR" "$STACK_DIR"
Jesse Andrews5f4ae102011-11-06 07:47:09 -0800206 chown -R stack "$STACK_DIR"
Dean Troyer9122e7b2011-10-17 14:07:11 -0500207 if [[ "$SHELL_AFTER_RUN" != "no" ]]; then
208 exec su -c "set -e; cd $STACK_DIR; bash stack.sh; bash" stack
209 else
210 exec su -c "set -e; cd $STACK_DIR; bash stack.sh" stack
211 fi
212 exit 1
Jesse Andrews509992f2011-10-27 11:18:09 -0700213else
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500214 # We're not **root**, make sure ``sudo`` is available
Vincent Untz71ebc6f2012-06-12 13:45:15 +0200215 is_package_installed sudo || die "Sudo is required. Re-run stack.sh as root ONE TIME ONLY to set up sudo."
Dean Troyere0d677c2012-03-07 14:11:33 -0600216
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500217 # UEC images ``/etc/sudoers`` does not have a ``#includedir``, add one
Jesse Andrews84a399b2011-10-27 11:20:38 -0700218 sudo grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers ||
219 echo "#includedir /etc/sudoers.d" | sudo tee -a /etc/sudoers
Dean Troyere0d677c2012-03-07 14:11:33 -0600220
221 # Set up devstack sudoers
Todd Willey0a161452011-10-28 02:34:19 -0400222 TEMPFILE=`mktemp`
Dean Troyere0d677c2012-03-07 14:11:33 -0600223 echo "`whoami` ALL=(root) NOPASSWD:ALL" >$TEMPFILE
Vincent Untzf2a25b72012-06-13 17:45:43 +0200224 # Some binaries might be under /sbin or /usr/sbin, so make sure sudo will
225 # see them by forcing PATH
226 echo "Defaults:`whoami` secure_path=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin" >> $TEMPFILE
Todd Willey0a161452011-10-28 02:34:19 -0400227 chmod 0440 $TEMPFILE
228 sudo chown root:root $TEMPFILE
Dean Troyere0d677c2012-03-07 14:11:33 -0600229 sudo mv $TEMPFILE /etc/sudoers.d/50_stack_sh
230
Dean Troyere0d677c2012-03-07 14:11:33 -0600231 # Remove old file
232 sudo rm -f /etc/sudoers.d/stack_sh_nova
Dean Troyer9122e7b2011-10-17 14:07:11 -0500233fi
234
Dean Troyere26232b2012-06-27 17:55:15 -0500235# Create the destination directory and ensure it is writable by the user
236sudo mkdir -p $DEST
237if [ ! -w $DEST ]; then
238 sudo chown `whoami` $DEST
239fi
240
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500241# Set ``OFFLINE`` to ``True`` to configure ``stack.sh`` to run cleanly without
242# Internet access. ``stack.sh`` must have been previously run with Internet
243# access to install prerequisites and fetch repositories.
Dean Troyer25dab662011-12-16 22:40:46 -0600244OFFLINE=`trueorfalse False $OFFLINE`
245
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500246# Set ``ERROR_ON_CLONE`` to ``True`` to configure ``stack.sh`` to exit if
247# the destination git repository does not exist during the ``git_clone``
248# operation.
James E. Blair94cb9602012-06-22 15:28:29 -0700249ERROR_ON_CLONE=`trueorfalse False $ERROR_ON_CLONE`
250
Dean Troyer67787e62012-05-02 11:48:15 -0500251# Destination path for service data
252DATA_DIR=${DATA_DIR:-${DEST}/data}
253sudo mkdir -p $DATA_DIR
254sudo chown `whoami` $DATA_DIR
255
256
Dean Troyerd81a0272012-08-31 18:04:55 -0500257# Common Configuration
258# ====================
Jesse Andrews782b9912011-10-02 16:53:21 -0400259
Vishvananda Ishayac9ad14b2012-07-03 20:29:01 +0000260# Set fixed and floating range here so we can make sure not to use addresses
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500261# from either range when attempting to guess the IP to use for the host.
262# Note that setting FIXED_RANGE may be necessary when running DevStack
Dean Troyerd81a0272012-08-31 18:04:55 -0500263# in an OpenStack cloud that uses either of these address ranges internally.
Vishvananda Ishayac9ad14b2012-07-03 20:29:01 +0000264FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.224/28}
Dean Troyerd81a0272012-08-31 18:04:55 -0500265FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
266FIXED_NETWORK_SIZE=${FIXED_NETWORK_SIZE:-256}
267NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1}
Vishvananda Ishayac9ad14b2012-07-03 20:29:01 +0000268
269# Find the interface used for the default route
270HOST_IP_IFACE=${HOST_IP_IFACE:-$(ip route | sed -n '/^default/{ s/.*dev \(\w\+\)\s\+.*/\1/; p; }')}
271# Search for an IP unless an explicit is set by ``HOST_IP`` environment variable
rootb1153412012-01-19 13:28:21 -0800272if [ -z "$HOST_IP" -o "$HOST_IP" == "dhcp" ]; then
Vishvananda Ishayac9ad14b2012-07-03 20:29:01 +0000273 HOST_IP=""
274 HOST_IPS=`LC_ALL=C ip -f inet addr show ${HOST_IP_IFACE} | awk '/inet/ {split($2,parts,"/"); print parts[1]}'`
275 for IP in $HOST_IPS; do
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500276 # Attempt to filter out IP addresses that are part of the fixed and
277 # floating range. Note that this method only works if the ``netaddr``
Vishvananda Ishayac9ad14b2012-07-03 20:29:01 +0000278 # python library is installed. If it is not installed, an error
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500279 # will be printed and the first IP from the interface will be used.
280 # If that is not correct set ``HOST_IP`` in ``localrc`` to the correct
281 # address.
Vishvananda Ishayac9ad14b2012-07-03 20:29:01 +0000282 if ! (address_in_net $IP $FIXED_RANGE || address_in_net $IP $FLOATING_RANGE); then
283 HOST_IP=$IP
284 break;
285 fi
286 done
287 if [ "$HOST_IP" == "" ]; then
Anthony Young857035d2011-11-07 14:02:13 -0600288 echo "Could not determine host ip address."
Vishvananda Ishayac9ad14b2012-07-03 20:29:01 +0000289 echo "Either localrc specified dhcp on ${HOST_IP_IFACE} or defaulted"
Anthony Young7c259ce2011-11-07 13:18:28 -0600290 exit 1
291 fi
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700292fi
293
Anthony Young1097c7c2011-12-27 23:22:14 -0800294# Allow the use of an alternate hostname (such as localhost/127.0.0.1) for service endpoints.
295SERVICE_HOST=${SERVICE_HOST:-$HOST_IP}
Dean Troyerc83a7e12012-11-29 11:47:58 -0600296SERVICE_PROTOCOL=${SERVICE_PROTOCOL:-http}
Anthony Young1097c7c2011-12-27 23:22:14 -0800297
Dean Troyerdf0972c2012-03-07 17:31:03 -0600298# Configure services to use syslog instead of writing to individual log files
Dean Troyerff603ef2011-11-22 17:48:10 -0600299SYSLOG=`trueorfalse False $SYSLOG`
300SYSLOG_HOST=${SYSLOG_HOST:-$HOST_IP}
301SYSLOG_PORT=${SYSLOG_PORT:-516}
302
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500303# Use color for logging output (only available if syslog is not used)
Vishvananda Ishaya6f13ba32012-06-01 23:17:38 +0000304LOG_COLOR=`trueorfalse True $LOG_COLOR`
305
Dean Troyer2bbcd682011-11-05 16:19:03 -0500306# Service startup timeout
307SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}
308
Dean Troyerd81a0272012-08-31 18:04:55 -0500309
310# Configure Projects
311# ==================
312
313# Get project function libraries
Dean Troyerc83a7e12012-11-29 11:47:58 -0600314source $TOP_DIR/lib/tls
Sean Dagueb562e6a2012-11-19 16:00:01 -0500315source $TOP_DIR/lib/horizon
Dean Troyerd81a0272012-08-31 18:04:55 -0500316source $TOP_DIR/lib/keystone
Dean Troyer73f6f252012-09-17 11:22:21 -0500317source $TOP_DIR/lib/glance
Dean Troyerbf67c192012-09-21 15:09:37 -0500318source $TOP_DIR/lib/nova
Dean Troyerd81a0272012-08-31 18:04:55 -0500319source $TOP_DIR/lib/cinder
Attila Fazekasece6a332012-11-29 14:19:41 +0100320source $TOP_DIR/lib/swift
Dean Troyerd81a0272012-08-31 18:04:55 -0500321source $TOP_DIR/lib/ceilometer
322source $TOP_DIR/lib/heat
323source $TOP_DIR/lib/quantum
Sean Dagued0931212012-10-04 16:06:44 -0400324source $TOP_DIR/lib/tempest
Dean Troyerd81a0272012-08-31 18:04:55 -0500325
326# Set the destination directories for OpenStack projects
Dean Troyerd81a0272012-08-31 18:04:55 -0500327HORIZON_DIR=$DEST/horizon
Dean Troyer9f61d292012-11-26 18:56:20 +0000328OPENSTACKCLIENT_DIR=$DEST/python-openstackclient
Dean Troyerd81a0272012-08-31 18:04:55 -0500329NOVNC_DIR=$DEST/noVNC
Dean Troyerd81a0272012-08-31 18:04:55 -0500330SWIFT3_DIR=$DEST/swift3
Dean Troyerd81a0272012-08-31 18:04:55 -0500331
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000332RYU_DIR=$DEST/ryu
333# Ryu API Host
334RYU_API_HOST=${RYU_API_HOST:-127.0.0.1}
335# Ryu API Port
336RYU_API_PORT=${RYU_API_PORT:-8080}
337# Ryu OFP Host
338RYU_OFP_HOST=${RYU_OFP_HOST:-127.0.0.1}
339# Ryu OFP Port
340RYU_OFP_PORT=${RYU_OFP_PORT:-6633}
341# Ryu Applications
342RYU_APPS=${RYU_APPS:-ryu.app.simple_isolation,ryu.app.rest}
343
James E. Blair213c4162012-11-06 09:38:36 +0100344# Should cinder perform secure deletion of volumes?
345# Defaults to true, can be set to False to avoid this bug when testing:
346# https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1023755
347CINDER_SECURE_DELETE=`trueorfalse True $CINDER_SECURE_DELETE`
348
Dean Troyerd81a0272012-08-31 18:04:55 -0500349# Name of the LVM volume group to use/create for iscsi volumes
350VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes}
351VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-}
352INSTANCE_NAME_PREFIX=${INSTANCE_NAME_PREFIX:-instance-}
353
Anthony Young7a549f42011-10-12 07:13:13 +0000354# Generic helper to configure passwords
355function read_password {
Dean Troyer7903b792012-09-13 17:16:12 -0500356 XTRACE=$(set +o | grep xtrace)
Anthony Young7a549f42011-10-12 07:13:13 +0000357 set +o xtrace
358 var=$1; msg=$2
359 pw=${!var}
360
Anthony Youngb4db2252011-10-12 14:08:08 -0700361 localrc=$TOP_DIR/localrc
Anthony Young6015c822011-10-12 07:17:11 +0000362
Anthony Young7a549f42011-10-12 07:13:13 +0000363 # If the password is not defined yet, proceed to prompt user for a password.
364 if [ ! $pw ]; then
365 # If there is no localrc file, create one
Anthony Youngb4db2252011-10-12 14:08:08 -0700366 if [ ! -e $localrc ]; then
367 touch $localrc
Anthony Young7a549f42011-10-12 07:13:13 +0000368 fi
369
Vishvananda Ishaya9b353672011-10-20 10:07:10 -0700370 # Presumably if we got this far it can only be that our localrc is missing
Anthony Young7a549f42011-10-12 07:13:13 +0000371 # the required password. Prompt user for a password and write to localrc.
Anthony Youngb4db2252011-10-12 14:08:08 -0700372 echo ''
373 echo '################################################################################'
374 echo $msg
375 echo '################################################################################'
Dean Troyer4e6a2b72011-12-29 17:27:45 -0600376 echo "This value will be written to your localrc file so you don't have to enter it "
377 echo "again. Use only alphanumeric characters."
Anthony Youngb4db2252011-10-12 14:08:08 -0700378 echo "If you leave this blank, a random default value will be used."
Dean Troyer4e6a2b72011-12-29 17:27:45 -0600379 pw=" "
380 while true; do
381 echo "Enter a password now:"
382 read -e $var
383 pw=${!var}
384 [[ "$pw" = "`echo $pw | tr -cd [:alnum:]`" ]] && break
385 echo "Invalid chars in password. Try again:"
386 done
Anthony Youngb4db2252011-10-12 14:08:08 -0700387 if [ ! $pw ]; then
388 pw=`openssl rand -hex 10`
Anthony Young7a549f42011-10-12 07:13:13 +0000389 fi
Anthony Youngb4db2252011-10-12 14:08:08 -0700390 eval "$var=$pw"
391 echo "$var=$pw" >> $localrc
Anthony Young7a549f42011-10-12 07:13:13 +0000392 fi
Dean Troyer7903b792012-09-13 17:16:12 -0500393 $XTRACE
Anthony Young7a549f42011-10-12 07:13:13 +0000394}
395
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500396
Jesse Andrews782b9912011-10-02 16:53:21 -0400397# Nova Network Configuration
398# --------------------------
399
Dean Troyerdf0972c2012-03-07 17:31:03 -0600400# FIXME: more documentation about why these are important options. Also
401# we should make sure we use the same variable names as the option names.
Jesse Andrews5372f432011-10-03 01:08:24 -0400402
John Garbutt8e2cffd2012-03-02 16:22:07 +0000403if [ "$VIRT_DRIVER" = 'xenserver' ]; then
404 PUBLIC_INTERFACE_DEFAULT=eth3
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500405 # Allow ``build_domU.sh`` to specify the flat network bridge via kernel args
Renuka Apte0af143b2012-04-02 15:46:53 -0700406 FLAT_NETWORK_BRIDGE_DEFAULT=$(grep -o 'flat_network_bridge=[[:alnum:]]*' /proc/cmdline | cut -d= -f 2 | sort -u)
John Garbutt8e2cffd2012-03-02 16:22:07 +0000407 GUEST_INTERFACE_DEFAULT=eth1
408else
409 PUBLIC_INTERFACE_DEFAULT=br100
410 FLAT_NETWORK_BRIDGE_DEFAULT=br100
411 GUEST_INTERFACE_DEFAULT=eth0
412fi
413
414PUBLIC_INTERFACE=${PUBLIC_INTERFACE:-$PUBLIC_INTERFACE_DEFAULT}
Jesse Andrewsa72f7ad2011-09-25 13:41:22 -0700415NET_MAN=${NET_MAN:-FlatDHCPManager}
Anthony Young1097c7c2011-12-27 23:22:14 -0800416EC2_DMZ_HOST=${EC2_DMZ_HOST:-$SERVICE_HOST}
John Garbutt8e2cffd2012-03-02 16:22:07 +0000417FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-$FLAT_NETWORK_BRIDGE_DEFAULT}
418VLAN_INTERFACE=${VLAN_INTERFACE:-$GUEST_INTERFACE_DEFAULT}
Jesse Andrewscbe98d52011-10-02 17:47:32 -0400419
Dean Troyer696ad332012-01-10 15:34:34 -0600420# Test floating pool and range are used for testing. They are defined
421# here until the admin APIs can replace nova-manage
422TEST_FLOATING_POOL=${TEST_FLOATING_POOL:-test}
423TEST_FLOATING_RANGE=${TEST_FLOATING_RANGE:-192.168.253.0/29}
424
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500425# ``MULTI_HOST`` is a mode where each compute node runs its own network node. This
Jesse Andrewscbe98d52011-10-02 17:47:32 -0400426# allows network operations and routing for a VM to occur on the server that is
427# running the VM - removing a SPOF and bandwidth bottleneck.
Armando Migliaccio7d13f302012-04-19 22:26:16 +0100428MULTI_HOST=`trueorfalse False $MULTI_HOST`
Jesse Andrews30f68e92011-09-13 00:59:54 -0700429
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500430# If you are using the FlatDHCP network mode on multiple hosts, set the
431# ``FLAT_INTERFACE`` variable but make sure that the interface doesn't already
432# have an IP or you risk breaking things.
Jesse Andrews5372f432011-10-03 01:08:24 -0400433#
Vishvananda Ishaya9b353672011-10-20 10:07:10 -0700434# **DHCP Warning**: If your flat interface device uses DHCP, there will be a
435# hiccup while the network is moved from the flat interface to the flat network
436# bridge. This will happen when you launch your first instance. Upon launch
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500437# you will lose all connectivity to the node, and the VM launch will probably
Jesse Andrews5372f432011-10-03 01:08:24 -0400438# fail.
Vishvananda Ishaya9b353672011-10-20 10:07:10 -0700439#
440# If you are running on a single node and don't need to access the VMs from
Dean Troyerb9182d62012-11-07 12:31:34 -0600441# devices other than that node, you can set ``FLAT_INTERFACE=``
442# This will stop nova from bridging any interfaces into ``FLAT_NETWORK_BRIDGE``.
Vishvananda Ishaya3a19d182012-09-08 23:16:40 -0700443FLAT_INTERFACE=${FLAT_INTERFACE-$GUEST_INTERFACE_DEFAULT}
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700444
Jesse Andrewscbe98d52011-10-02 17:47:32 -0400445## FIXME(ja): should/can we check that FLAT_INTERFACE is sane?
446
Dean Troyerb9182d62012-11-07 12:31:34 -0600447
Dean Troyerb9182d62012-11-07 12:31:34 -0600448# Database Configuration
Terry Wilson428af5a2012-11-01 16:12:39 -0400449# ----------------------
Dean Troyerb9182d62012-11-07 12:31:34 -0600450
Terry Wilson428af5a2012-11-01 16:12:39 -0400451# To select between database backends, add a line to localrc like:
452#
453# use_database postgresql
454#
Dean Troyerb9182d62012-11-07 12:31:34 -0600455# The available database backends are defined in the ``DATABASE_BACKENDS``
Terry Wilson428af5a2012-11-01 16:12:39 -0400456# variable defined in stackrc. By default, MySQL is enabled as the database
457# backend.
458
459initialize_database_backends && echo "Using $DATABASE_TYPE database backend" || echo "No database enabled"
460
Dean Troyerb9182d62012-11-07 12:31:34 -0600461
Terry Wilson428af5a2012-11-01 16:12:39 -0400462# RabbitMQ or Qpid
Russell Bryant4a221452012-03-13 13:44:12 -0400463# --------------------------
Jesse Andrews782b9912011-10-02 16:53:21 -0400464
Anthony Younga8416442011-09-13 20:07:44 -0700465# Rabbit connection info
Russell Bryant4a221452012-03-13 13:44:12 -0400466if is_service_enabled rabbit; then
467 RABBIT_HOST=${RABBIT_HOST:-localhost}
468 read_password RABBIT_PASSWORD "ENTER A PASSWORD TO USE FOR RABBIT."
469fi
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700470
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000471if is_service_enabled swift; then
Chmouel Boudjnah6ae9ea52012-07-05 06:50:51 +0000472 # If we are using swift3, we can default the s3 port to swift instead
Chmouel Boudjnah77b0e1d2012-02-29 16:55:43 +0000473 # of nova-objectstore
Chmouel Boudjnah6ae9ea52012-07-05 06:50:51 +0000474 if is_service_enabled swift3;then
475 S3_SERVICE_PORT=${S3_SERVICE_PORT:-8080}
476 fi
Chmouel Boudjnah77b0e1d2012-02-29 16:55:43 +0000477 # We only ask for Swift Hash if we have enabled swift service.
Dean Troyerb9182d62012-11-07 12:31:34 -0600478 # ``SWIFT_HASH`` is a random unique string for a swift cluster that
Chmouel Boudjnahb2857e42011-11-03 16:19:14 +0100479 # can never change.
480 read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH."
481fi
Vishvananda Ishaya5f039322011-11-05 16:12:20 -0700482
Chmouel Boudjnah77b0e1d2012-02-29 16:55:43 +0000483# Set default port for nova-objectstore
484S3_SERVICE_PORT=${S3_SERVICE_PORT:-3333}
Dean Troyerdf0972c2012-03-07 17:31:03 -0600485
Dean Troyer7d28a0e2012-06-27 17:55:52 -0500486
Jesse Andrews782b9912011-10-02 16:53:21 -0400487# Keystone
488# --------
489
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500490# The ``SERVICE_TOKEN`` is used to bootstrap the Keystone database. It is
491# just a string and is not a 'real' Keystone token.
Anthony Young7a549f42011-10-12 07:13:13 +0000492read_password SERVICE_TOKEN "ENTER A SERVICE_TOKEN TO USE FOR THE SERVICE ADMIN TOKEN."
Dean Troyerb9182d62012-11-07 12:31:34 -0600493# Services authenticate to Identity with servicename/``SERVICE_PASSWORD``
Dean Troyerb3288382012-02-28 16:41:10 -0600494read_password SERVICE_PASSWORD "ENTER A SERVICE_PASSWORD TO USE FOR THE SERVICE AUTHENTICATION."
Tres Henryca85b792011-10-28 14:00:21 -0700495# Horizon currently truncates usernames and passwords at 20 characters
496read_password ADMIN_PASSWORD "ENTER A PASSWORD TO USE FOR HORIZON AND KEYSTONE (20 CHARS OR LESS)."
Jesse Andrewsb96871e2011-10-02 09:02:46 -0700497
Dean Troyerb3288382012-02-28 16:41:10 -0600498# Set the tenant for service accounts in Keystone
499SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service}
500
Dean Troyer6577b462012-01-16 22:27:20 -0600501
Dean Troyer471de7a2011-12-27 11:45:55 -0600502# Log files
503# ---------
504
Vishvananda Ishaya7879a3c2012-09-21 15:36:06 -0700505# Draw a spinner so the user knows something is happening
Dean Troyerb9182d62012-11-07 12:31:34 -0600506function spinner() {
Vishvananda Ishaya7879a3c2012-09-21 15:36:06 -0700507 local delay=0.75
Dean Troyerb9182d62012-11-07 12:31:34 -0600508 local spinstr='/-\|'
Vishvananda Ishaya7879a3c2012-09-21 15:36:06 -0700509 printf "..." >&3
510 while [ true ]; do
511 local temp=${spinstr#?}
512 printf "[%c]" "$spinstr" >&3
513 local spinstr=$temp${spinstr%"$temp"}
514 sleep $delay
515 printf "\b\b\b" >&3
516 done
517}
518
Dean Troyer7903b792012-09-13 17:16:12 -0500519# Echo text to the log file, summary log file and stdout
520# echo_summary "something to say"
521function echo_summary() {
Vishvananda Ishaya7879a3c2012-09-21 15:36:06 -0700522 if [[ -t 3 && "$VERBOSE" != "True" ]]; then
523 kill >/dev/null 2>&1 $LAST_SPINNER_PID
524 if [ ! -z "$LAST_SPINNER_PID" ]; then
525 printf "\b\b\bdone\n" >&3
526 fi
527 echo -n $@ >&6
528 spinner &
529 LAST_SPINNER_PID=$!
530 else
531 echo $@ >&6
532 fi
Dean Troyer7903b792012-09-13 17:16:12 -0500533}
534
535# Echo text only to stdout, no log files
536# echo_nolog "something not for the logs"
537function echo_nolog() {
538 echo $@ >&3
539}
540
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500541# Set up logging for ``stack.sh``
542# Set ``LOGFILE`` to turn on logging
543# Append '.xxxxxxxx' to the given name to maintain history
544# where 'xxxxxxxx' is a representation of the date the file was created
Dean Troyer33cb4302012-12-10 16:47:36 -0600545TIMESTAMP_FORMAT=${TIMESTAMP_FORMAT:-"%F-%H%M%S"}
Chmouel Boudjnahd966ed22012-03-05 12:42:48 +0000546if [[ -n "$LOGFILE" || -n "$SCREEN_LOGDIR" ]]; then
547 LOGDAYS=${LOGDAYS:-7}
Chmouel Boudjnahd966ed22012-03-05 12:42:48 +0000548 CURRENT_LOG_TIME=$(date "+$TIMESTAMP_FORMAT")
549fi
550
Dean Troyer471de7a2011-12-27 11:45:55 -0600551if [[ -n "$LOGFILE" ]]; then
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500552 # First clean up old log files. Use the user-specified ``LOGFILE``
Dean Troyer471de7a2011-12-27 11:45:55 -0600553 # as the template to search for, appending '.*' to match the date
554 # we added on earlier runs.
Dean Troyer471de7a2011-12-27 11:45:55 -0600555 LOGDIR=$(dirname "$LOGFILE")
556 LOGNAME=$(basename "$LOGFILE")
Chmouel Boudjnahfff6fec2012-03-09 15:37:56 +0000557 mkdir -p $LOGDIR
Dean Troyer471de7a2011-12-27 11:45:55 -0600558 find $LOGDIR -maxdepth 1 -name $LOGNAME.\* -mtime +$LOGDAYS -exec rm {} \;
Chmouel Boudjnahd966ed22012-03-05 12:42:48 +0000559 LOGFILE=$LOGFILE.${CURRENT_LOG_TIME}
Dean Troyer7903b792012-09-13 17:16:12 -0500560 SUMFILE=$LOGFILE.${CURRENT_LOG_TIME}.summary
561
562 # Redirect output according to config
Dean Troyerb9182d62012-11-07 12:31:34 -0600563
Dean Troyer7903b792012-09-13 17:16:12 -0500564 # Copy stdout to fd 3
565 exec 3>&1
566 if [[ "$VERBOSE" == "True" ]]; then
567 # Redirect stdout/stderr to tee to write the log file
Davanum Srinivase5eee582012-12-06 09:47:53 -0500568 exec 1> >( awk '
569 {
570 cmd ="date +\"%Y-%m-%d %H:%M:%S \""
571 cmd | getline now
572 close("date +\"%Y-%m-%d %H:%M:%S \"")
573 sub(/^/, now)
574 print
575 fflush()
576 }' | tee "${LOGFILE}" ) 2>&1
Dean Troyer7903b792012-09-13 17:16:12 -0500577 # Set up a second fd for output
578 exec 6> >( tee "${SUMFILE}" )
579 else
580 # Set fd 1 and 2 to primary logfile
581 exec 1> "${LOGFILE}" 2>&1
582 # Set fd 6 to summary logfile and stdout
583 exec 6> >( tee "${SUMFILE}" /dev/fd/3 )
584 fi
585
586 echo_summary "stack.sh log $LOGFILE"
Dean Troyer471de7a2011-12-27 11:45:55 -0600587 # Specified logfile name always links to the most recent log
588 ln -sf $LOGFILE $LOGDIR/$LOGNAME
Dean Troyer7903b792012-09-13 17:16:12 -0500589 ln -sf $SUMFILE $LOGDIR/$LOGNAME.summary
590else
591 # Set up output redirection without log files
592 # Copy stdout to fd 3
593 exec 3>&1
Eric Windischefdf3ff2012-09-24 12:47:44 -0400594 if [[ "$VERBOSE" != "True" ]]; then
Dean Troyer7903b792012-09-13 17:16:12 -0500595 # Throw away stdout and stderr
596 exec 1>/dev/null 2>&1
597 fi
598 # Always send summary fd to original stdout
599 exec 6>&3
Dean Troyer471de7a2011-12-27 11:45:55 -0600600fi
601
Chmouel Boudjnahd966ed22012-03-05 12:42:48 +0000602# Set up logging of screen windows
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500603# Set ``SCREEN_LOGDIR`` to turn on logging of screen windows to the
604# directory specified in ``SCREEN_LOGDIR``, we will log to the the file
605# ``screen-$SERVICE_NAME-$TIMESTAMP.log`` in that dir and have a link
606# ``screen-$SERVICE_NAME.log`` to the latest log file.
607# Logs are kept for as long specified in ``LOGDAYS``.
Chmouel Boudjnahd966ed22012-03-05 12:42:48 +0000608if [[ -n "$SCREEN_LOGDIR" ]]; then
609
610 # We make sure the directory is created.
611 if [[ -d "$SCREEN_LOGDIR" ]]; then
612 # We cleanup the old logs
613 find $SCREEN_LOGDIR -maxdepth 1 -name screen-\*.log -mtime +$LOGDAYS -exec rm {} \;
614 else
615 mkdir -p $SCREEN_LOGDIR
616 fi
617fi
618
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500619
620# Set Up Script Execution
621# -----------------------
622
Vishvananda Ishaya7879a3c2012-09-21 15:36:06 -0700623# Kill background processes on exit
624trap clean EXIT
625clean() {
626 local r=$?
627 kill >/dev/null 2>&1 $(jobs -p)
628 exit $r
629}
630
631
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500632# Exit on any errors so that errors don't compound
Scott Moserf9da5082011-10-07 21:28:00 -0400633trap failed ERR
634failed() {
635 local r=$?
Vishvananda Ishaya7879a3c2012-09-21 15:36:06 -0700636 kill >/dev/null 2>&1 $(jobs -p)
Scott Moserf9da5082011-10-07 21:28:00 -0400637 set +o xtrace
638 [ -n "$LOGFILE" ] && echo "${0##*/} failed: full log in $LOGFILE"
639 exit $r
640}
641
642# Print the commands being run so that we can see the command that triggers
643# an error. It is also useful for following along as the install occurs.
644set -o xtrace
645
Dean Troyerdf0972c2012-03-07 17:31:03 -0600646
Jesse Andrews30f68e92011-09-13 00:59:54 -0700647# Install Packages
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700648# ================
Dean Troyer7d28a0e2012-06-27 17:55:52 -0500649
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500650# OpenStack uses a fair number of other projects.
Jesse Andrews30f68e92011-09-13 00:59:54 -0700651
Dean Troyer7d28a0e2012-06-27 17:55:52 -0500652# Install package requirements
Dean Troyer7903b792012-09-13 17:16:12 -0500653echo_summary "Installing package prerequisites"
Vincent Untzc18b9652012-12-04 12:36:34 +0100654if is_ubuntu; then
Dean Troyer5218d452012-02-04 02:13:23 -0600655 install_package $(get_packages $FILES/apts)
Vincent Untz00011c02012-12-06 09:56:32 +0100656elif is_fedora; then
657 install_package $(get_packages $FILES/rpms)
Vincent Untzca5c4712012-11-21 17:45:49 +0100658elif is_suse; then
659 install_package $(get_packages $FILES/rpms-suse)
Dean Troyer5218d452012-02-04 02:13:23 -0600660else
Vincent Untz00011c02012-12-06 09:56:32 +0100661 exit_distro_not_supported "list of packages"
Dean Troyer5218d452012-02-04 02:13:23 -0600662fi
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700663
Monty Taylor47f02062012-07-26 11:09:24 -0500664if [[ $SYSLOG != "False" ]]; then
Vincent Untz00011c02012-12-06 09:56:32 +0100665 if is_ubuntu || is_fedora; then
666 install_package rsyslog-relp
667 elif is_suse; then
Vincent Untzca5c4712012-11-21 17:45:49 +0100668 install_package rsyslog-module-relp
669 else
Vincent Untz00011c02012-12-06 09:56:32 +0100670 exit_distro_not_supported "rsyslog-relp installation"
Vincent Untzca5c4712012-11-21 17:45:49 +0100671 fi
Monty Taylor47f02062012-07-26 11:09:24 -0500672fi
673
674if is_service_enabled rabbit; then
675 # Install rabbitmq-server
676 # the temp file is necessary due to LP: #878600
677 tfile=$(mktemp)
678 install_package rabbitmq-server > "$tfile" 2>&1
679 cat "$tfile"
680 rm -f "$tfile"
681elif is_service_enabled qpid; then
Vincent Untz00011c02012-12-06 09:56:32 +0100682 if is_fedora; then
Nikola Dipanov20df2a82012-09-08 18:36:35 +0200683 install_package qpid-cpp-server-daemon
Vincent Untz00011c02012-12-06 09:56:32 +0100684 elif is_ubuntu; then
Monty Taylor47f02062012-07-26 11:09:24 -0500685 install_package qpidd
Vincent Untz00011c02012-12-06 09:56:32 +0100686 else
687 exit_distro_not_supported "qpid installation"
Monty Taylor47f02062012-07-26 11:09:24 -0500688 fi
ewindisch3bae7c22012-01-18 11:18:35 -0500689elif is_service_enabled zeromq; then
Vincent Untz00011c02012-12-06 09:56:32 +0100690 if is_fedora; then
691 install_package zeromq python-zmq
692 elif is_ubuntu; then
ewindisch3bae7c22012-01-18 11:18:35 -0500693 install_package libzmq1 python-zmq
Vincent Untz00011c02012-12-06 09:56:32 +0100694 elif is_suse; then
695 install_package libzmq1 python-pyzmq
696 else
697 exit_distro_not_supported "zeromq installation"
ewindisch3bae7c22012-01-18 11:18:35 -0500698 fi
Monty Taylor47f02062012-07-26 11:09:24 -0500699fi
700
Terry Wilson428af5a2012-11-01 16:12:39 -0400701if is_service_enabled $DATABASE_BACKENDS; then
702 install_database
Monty Taylor47f02062012-07-26 11:09:24 -0500703fi
704
Monty Taylor47f02062012-07-26 11:09:24 -0500705if is_service_enabled q-agt; then
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000706 if is_quantum_ovs_base_plugin "$Q_PLUGIN"; then
Monty Taylor47f02062012-07-26 11:09:24 -0500707 # Install deps
Dean Troyerb9182d62012-11-07 12:31:34 -0600708 # FIXME add to ``files/apts/quantum``, but don't install if not needed!
Vincent Untzc18b9652012-12-04 12:36:34 +0100709 if is_ubuntu; then
Monty Taylor47f02062012-07-26 11:09:24 -0500710 kernel_version=`cat /proc/version | cut -d " " -f3`
711 install_package make fakeroot dkms openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version
712 else
713 ### FIXME(dtroyer): Find RPMs for OpenVSwitch
714 echo "OpenVSwitch packages need to be located"
John Dunningb782a2c2012-09-11 16:13:37 -0400715 # Fedora does not started OVS by default
716 restart_service openvswitch
Monty Taylor47f02062012-07-26 11:09:24 -0500717 fi
718 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
719 install_package bridge-utils
720 fi
721fi
722
Monty Taylor47f02062012-07-26 11:09:24 -0500723TRACK_DEPENDS=${TRACK_DEPENDS:-False}
724
725# Install python packages into a virtualenv so that we can track them
726if [[ $TRACK_DEPENDS = True ]] ; then
Dean Troyer7903b792012-09-13 17:16:12 -0500727 echo_summary "Installing Python packages into a virtualenv $DEST/.venv"
Monty Taylor47f02062012-07-26 11:09:24 -0500728 install_package python-virtualenv
729
730 rm -rf $DEST/.venv
731 virtualenv --system-site-packages $DEST/.venv
732 source $DEST/.venv/bin/activate
733 $DEST/.venv/bin/pip freeze > $DEST/requires-pre-pip
734fi
735
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500736
737# Check Out Source
738# ----------------
739
Dean Troyer7903b792012-09-13 17:16:12 -0500740echo_summary "Installing OpenStack project source"
741
Dean Troyerb9182d62012-11-07 12:31:34 -0600742# Grab clients first
Dean Troyerd81a0272012-08-31 18:04:55 -0500743install_keystoneclient
Dean Troyer73f6f252012-09-17 11:22:21 -0500744install_glanceclient
Dean Troyerbf67c192012-09-21 15:09:37 -0500745install_novaclient
Dean Troyer9f61d292012-11-26 18:56:20 +0000746# Check out the client libs that are used most
747git_clone $OPENSTACKCLIENT_REPO $OPENSTACKCLIENT_DIR $OPENSTACKCLIENT_BRANCH
748
Jesse Andrews38df1222011-11-20 09:55:44 -0800749# glance, swift middleware and nova api needs keystone middleware
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000750if is_service_enabled key g-api n-api swift; then
Jesse Andrews38df1222011-11-20 09:55:44 -0800751 # unified auth system (manages accounts/tokens)
Dean Troyerd81a0272012-08-31 18:04:55 -0500752 install_keystone
Jesse Andrews38df1222011-11-20 09:55:44 -0800753fi
Attila Fazekasece6a332012-11-29 14:19:41 +0100754
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000755if is_service_enabled swift; then
Attila Fazekasece6a332012-11-29 14:19:41 +0100756 install_swiftclient
757 install_swift
Chmouel Boudjnah6ae9ea52012-07-05 06:50:51 +0000758 if is_service_enabled swift3; then
759 # swift3 middleware to provide S3 emulation to Swift
760 git_clone $SWIFT3_REPO $SWIFT3_DIR $SWIFT3_BRANCH
761 fi
James E. Blaire7ce24f2011-11-10 13:05:13 -0800762fi
Attila Fazekasece6a332012-11-29 14:19:41 +0100763
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000764if is_service_enabled g-api n-api; then
James E. Blaire7ce24f2011-11-10 13:05:13 -0800765 # image catalog service
Dean Troyer73f6f252012-09-17 11:22:21 -0500766 install_glance
James E. Blaire7ce24f2011-11-10 13:05:13 -0800767fi
Dean Troyerbf67c192012-09-21 15:09:37 -0500768if is_service_enabled nova; then
769 # compute service
770 install_nova
771fi
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000772if is_service_enabled n-novnc; then
James E. Blaire7ce24f2011-11-10 13:05:13 -0800773 # a websockets/html5 or flash powered VNC console for vm instances
774 git_clone $NOVNC_REPO $NOVNC_DIR $NOVNC_BRANCH
775fi
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000776if is_service_enabled horizon; then
Sean Dagueb562e6a2012-11-19 16:00:01 -0500777 # dashboard
778 install_horizon
James E. Blaire7ce24f2011-11-10 13:05:13 -0800779fi
Monty Taylor5440ac02012-03-23 11:32:29 -0700780if is_service_enabled quantum; then
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600781 git_clone $QUANTUMCLIENT_REPO $QUANTUMCLIENT_DIR $QUANTUMCLIENT_BRANCH
Monty Taylor5440ac02012-03-23 11:32:29 -0700782fi
Dan Wendlandt0007f3a2012-05-18 13:37:47 -0700783if is_service_enabled quantum; then
James E. Blaire7ce24f2011-11-10 13:05:13 -0800784 # quantum
785 git_clone $QUANTUM_REPO $QUANTUM_DIR $QUANTUM_BRANCH
Deepak Garg1e98bdc2012-02-22 12:15:26 +0530786fi
Steve Bakerbfdad752012-08-18 09:00:42 +1200787if is_service_enabled heat; then
788 install_heat
Steve Baker32761a42012-11-05 09:57:57 +1300789 install_heatclient
Steve Bakerbfdad752012-08-18 09:00:42 +1200790fi
Dean Troyer67787e62012-05-02 11:48:15 -0500791if is_service_enabled cinder; then
792 install_cinder
793fi
John H. Tran93361642012-07-26 11:22:05 -0700794if is_service_enabled ceilometer; then
795 install_ceilometer
796fi
Sean Dagued0931212012-10-04 16:06:44 -0400797if is_service_enabled tempest; then
798 install_tempest
799fi
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000800if is_service_enabled ryu || (is_service_enabled quantum && [[ "$Q_PLUGIN" = "ryu" ]]); then
801 git_clone $RYU_REPO $RYU_DIR $RYU_BRANCH
802fi
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500803
Dean Troyerb9182d62012-11-07 12:31:34 -0600804
Jesse Andrews30f68e92011-09-13 00:59:54 -0700805# Initialization
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700806# ==============
Jesse Andrews30f68e92011-09-13 00:59:54 -0700807
Dean Troyer7903b792012-09-13 17:16:12 -0500808echo_summary "Configuring OpenStack projects"
809
Dean Troyer7d28a0e2012-06-27 17:55:52 -0500810# Set up our checkouts so they are installed into python path
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700811# allowing ``import nova`` or ``import glance.client``
Dean Troyerd81a0272012-08-31 18:04:55 -0500812configure_keystoneclient
Dean Troyerbf67c192012-09-21 15:09:37 -0500813configure_novaclient
Dean Troyer9f61d292012-11-26 18:56:20 +0000814setup_develop $OPENSTACKCLIENT_DIR
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000815if is_service_enabled key g-api n-api swift; then
Dean Troyerd81a0272012-08-31 18:04:55 -0500816 configure_keystone
James E. Blaire7ce24f2011-11-10 13:05:13 -0800817fi
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000818if is_service_enabled swift; then
Attila Fazekasece6a332012-11-29 14:19:41 +0100819 configure_swift
820 configure_swiftclient
821 if is_service_enabled swift3; then
822 setup_develop $SWIFT3_DIR
823 fi
James E. Blaire7ce24f2011-11-10 13:05:13 -0800824fi
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000825if is_service_enabled g-api n-api; then
Dean Troyer73f6f252012-09-17 11:22:21 -0500826 configure_glance
James E. Blaire7ce24f2011-11-10 13:05:13 -0800827fi
Dean Troyera34961b2012-06-26 13:05:33 -0500828
829# Do this _after_ glance is installed to override the old binary
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500830# TODO(dtroyer): figure out when this is no longer necessary
Dean Troyer73f6f252012-09-17 11:22:21 -0500831configure_glanceclient
Dean Troyera34961b2012-06-26 13:05:33 -0500832
Dean Troyerbf67c192012-09-21 15:09:37 -0500833if is_service_enabled nova; then
834 configure_nova
835fi
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000836if is_service_enabled horizon; then
Sean Dagueb562e6a2012-11-19 16:00:01 -0500837 configure_horizon
James E. Blaire7ce24f2011-11-10 13:05:13 -0800838fi
Anthony Young84a03e02012-03-15 11:27:13 -0700839if is_service_enabled quantum; then
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600840 setup_develop $QUANTUMCLIENT_DIR
Dean Troyerbbafb1b2012-06-11 16:51:39 -0500841 setup_develop $QUANTUM_DIR
Monty Taylor5440ac02012-03-23 11:32:29 -0700842fi
Steve Bakerbfdad752012-08-18 09:00:42 +1200843if is_service_enabled heat; then
844 configure_heat
Steve Baker32761a42012-11-05 09:57:57 +1300845 configure_heatclient
Steve Bakerbfdad752012-08-18 09:00:42 +1200846fi
Dean Troyer67787e62012-05-02 11:48:15 -0500847if is_service_enabled cinder; then
848 configure_cinder
849fi
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000850if is_service_enabled ryu || (is_service_enabled quantum && [[ "$Q_PLUGIN" = "ryu" ]]); then
851 setup_develop $RYU_DIR
852fi
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700853
Monty Taylor47f02062012-07-26 11:09:24 -0500854if [[ $TRACK_DEPENDS = True ]] ; then
855 $DEST/.venv/bin/pip freeze > $DEST/requires-post-pip
856 if ! diff -Nru $DEST/requires-pre-pip $DEST/requires-post-pip > $DEST/requires.diff ; then
857 cat $DEST/requires.diff
858 fi
859 echo "Ran stack.sh in depend tracking mode, bailing out now"
860 exit 0
861fi
Dean Troyerdf0972c2012-03-07 17:31:03 -0600862
Dean Troyerc83a7e12012-11-29 11:47:58 -0600863if is_service_enabled tls-proxy; then
864 configure_CA
865 init_CA
866 # Add name to /etc/hosts
867 # don't be naive and add to existing line!
868fi
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500869
Dean Troyerff603ef2011-11-22 17:48:10 -0600870# Syslog
Dean Troyerdf0972c2012-03-07 17:31:03 -0600871# ------
Dean Troyerff603ef2011-11-22 17:48:10 -0600872
873if [[ $SYSLOG != "False" ]]; then
Dean Troyerff603ef2011-11-22 17:48:10 -0600874 if [[ "$SYSLOG_HOST" = "$HOST_IP" ]]; then
875 # Configure the master host to receive
876 cat <<EOF >/tmp/90-stack-m.conf
877\$ModLoad imrelp
878\$InputRELPServerRun $SYSLOG_PORT
879EOF
880 sudo mv /tmp/90-stack-m.conf /etc/rsyslog.d
881 else
882 # Set rsyslog to send to remote host
883 cat <<EOF >/tmp/90-stack-s.conf
884*.* :omrelp:$SYSLOG_HOST:$SYSLOG_PORT
885EOF
886 sudo mv /tmp/90-stack-s.conf /etc/rsyslog.d
887 fi
Dean Troyer7903b792012-09-13 17:16:12 -0500888 echo_summary "Starting rsyslog"
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500889 restart_service rsyslog
Dean Troyerff603ef2011-11-22 17:48:10 -0600890fi
891
Dean Troyerdf0972c2012-03-07 17:31:03 -0600892
Joe Gordone5d92382012-09-13 17:19:03 -0700893# Finalize queue installation
894# ----------------------------
Jesse Andrewscbe98d52011-10-02 17:47:32 -0400895
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000896if is_service_enabled rabbit; then
Monty Taylor47f02062012-07-26 11:09:24 -0500897 # Start rabbitmq-server
Dean Troyer7903b792012-09-13 17:16:12 -0500898 echo_summary "Starting RabbitMQ"
Vincent Untz00011c02012-12-06 09:56:32 +0100899 if is_fedora || is_suse; then
900 # service is not started by default
Dean Troyer5218d452012-02-04 02:13:23 -0600901 restart_service rabbitmq-server
902 fi
Jesse Andrews53ed3872011-10-02 14:28:17 -0400903 # change the rabbit password since the default is "guest"
904 sudo rabbitmqctl change_password guest $RABBIT_PASSWORD
Russell Bryant4a221452012-03-13 13:44:12 -0400905elif is_service_enabled qpid; then
Dean Troyer7903b792012-09-13 17:16:12 -0500906 echo_summary "Starting qpid"
Monty Taylor47f02062012-07-26 11:09:24 -0500907 restart_service qpidd
Anthony Younga09ae2f2011-09-15 23:11:29 -0700908fi
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700909
Dean Troyerdf0972c2012-03-07 17:31:03 -0600910
Terry Wilson428af5a2012-11-01 16:12:39 -0400911# Configure database
912# ------------------
Dean Troyerb9182d62012-11-07 12:31:34 -0600913
Terry Wilson428af5a2012-11-01 16:12:39 -0400914if is_service_enabled $DATABASE_BACKENDS; then
915 configure_database
Jesse Andrews24859062011-09-15 21:28:23 -0700916fi
917
Dean Troyerb9182d62012-11-07 12:31:34 -0600918
919# Configure screen
920# ----------------
921
Josh Kearney0a7a41e2012-04-04 17:47:56 -0500922if [ -z "$SCREEN_HARDSTATUS" ]; then
923 SCREEN_HARDSTATUS='%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})'
924fi
925
Jiajun Liu61bb2c12012-10-19 09:48:30 +0800926# Clear screen rc file
927SCREENRC=$TOP_DIR/$SCREEN_NAME-screenrc
928if [[ -e $SCREENRC ]]; then
929 echo -n > $SCREENRC
930fi
Dean Troyerb9182d62012-11-07 12:31:34 -0600931
Dean Troyer7d28a0e2012-06-27 17:55:52 -0500932# Create a new named screen to run processes in
Dean Troyer15733352012-09-06 11:51:30 -0500933screen -d -m -S $SCREEN_NAME -t shell -s /bin/bash
Anthony Young60df29a2012-03-28 09:40:17 -0700934sleep 1
Dean Troyerb9182d62012-11-07 12:31:34 -0600935
Joe Gordone5d92382012-09-13 17:19:03 -0700936# Set a reasonable status bar
Dean Troyer15733352012-09-06 11:51:30 -0500937screen -r $SCREEN_NAME -X hardstatus alwayslastline "$SCREEN_HARDSTATUS"
Jesse Andrews24859062011-09-15 21:28:23 -0700938
jiajun xua9414242012-12-06 16:30:57 +0800939# Initialize the directory for service status check
940init_service_check
Dean Troyer7d28a0e2012-06-27 17:55:52 -0500941
Dean Troyerd81a0272012-08-31 18:04:55 -0500942# Keystone
943# --------
944
945if is_service_enabled key; then
Dean Troyer7903b792012-09-13 17:16:12 -0500946 echo_summary "Starting Keystone"
Dean Troyerd81a0272012-08-31 18:04:55 -0500947 init_keystone
948 start_keystone
Dean Troyerd81a0272012-08-31 18:04:55 -0500949
Dean Troyerd835de82012-11-29 17:11:35 -0600950 # Set up a temporary admin URI for Keystone
Dean Troyerc83a7e12012-11-29 11:47:58 -0600951 SERVICE_ENDPOINT=$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0
952
953 if is_service_enabled tls-proxy; then
954 export OS_CACERT=$INT_CA_DIR/ca-chain.pem
955 # Until the client support is fixed, just use the internal endpoint
956 SERVICE_ENDPOINT=http://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT_INT/v2.0
957 fi
Dean Troyerd81a0272012-08-31 18:04:55 -0500958
Dean Troyerd835de82012-11-29 17:11:35 -0600959 # Do the keystone-specific bits from keystone_data.sh
960 export OS_SERVICE_TOKEN=$SERVICE_TOKEN
961 export OS_SERVICE_ENDPOINT=$SERVICE_ENDPOINT
962 create_keystone_accounts
Dean Troyera0dce262012-12-11 16:52:37 -0600963 create_nova_accounts
Dean Troyer671c16e2012-12-13 16:22:38 -0600964 create_cinder_accounts
Dean Troyerd835de82012-11-29 17:11:35 -0600965
966 # ``keystone_data.sh`` creates services, admin and demo users, and roles.
Dean Troyerd81a0272012-08-31 18:04:55 -0500967 ADMIN_PASSWORD=$ADMIN_PASSWORD SERVICE_TENANT_NAME=$SERVICE_TENANT_NAME SERVICE_PASSWORD=$SERVICE_PASSWORD \
968 SERVICE_TOKEN=$SERVICE_TOKEN SERVICE_ENDPOINT=$SERVICE_ENDPOINT SERVICE_HOST=$SERVICE_HOST \
969 S3_SERVICE_PORT=$S3_SERVICE_PORT KEYSTONE_CATALOG_BACKEND=$KEYSTONE_CATALOG_BACKEND \
Angus Salkelde2790212012-09-11 11:24:09 +1000970 DEVSTACK_DIR=$TOP_DIR ENABLED_SERVICES=$ENABLED_SERVICES HEAT_API_CFN_PORT=$HEAT_API_CFN_PORT \
Steve Bakerbb421be2012-10-10 13:19:10 +1300971 HEAT_API_PORT=$HEAT_API_PORT \
Dean Troyerd81a0272012-08-31 18:04:55 -0500972 bash -x $FILES/keystone_data.sh
973
974 # Set up auth creds now that keystone is bootstrapped
975 export OS_AUTH_URL=$SERVICE_ENDPOINT
976 export OS_TENANT_NAME=admin
977 export OS_USERNAME=admin
978 export OS_PASSWORD=$ADMIN_PASSWORD
Dean Troyerd835de82012-11-29 17:11:35 -0600979 unset OS_SERVICE_TOKEN OS_SERVICE_ENDPOINT
Dean Troyerd81a0272012-08-31 18:04:55 -0500980fi
981
982
Tres Henryca85b792011-10-28 14:00:21 -0700983# Horizon
Dean Troyerdf0972c2012-03-07 17:31:03 -0600984# -------
Jesse Andrewscbe98d52011-10-02 17:47:32 -0400985
Dean Troyer7d28a0e2012-06-27 17:55:52 -0500986# Set up the django horizon application to serve via apache/wsgi
Jesse Andrews75a37652011-09-12 17:09:08 -0700987
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000988if is_service_enabled horizon; then
Dean Troyer7903b792012-09-13 17:16:12 -0500989 echo_summary "Configuring and starting Horizon"
Sean Dagueb562e6a2012-11-19 16:00:01 -0500990 init_horizon
991 start_horizon
Anthony Young70dc5e02011-09-15 16:52:43 -0700992fi
Jesse Andrews75a37652011-09-12 17:09:08 -0700993
Anthony Young3859f732011-09-14 02:33:43 -0700994
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700995# Glance
996# ------
997
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000998if is_service_enabled g-reg; then
Dean Troyer7903b792012-09-13 17:16:12 -0500999 echo_summary "Configuring Glance"
1000
Dean Troyer73f6f252012-09-17 11:22:21 -05001001 init_glance
Dean Troyer6577b462012-01-16 22:27:20 -06001002
Chmouel Boudjnahee76d262012-05-09 17:19:09 +01001003 # Store the images in swift if enabled.
1004 if is_service_enabled swift; then
1005 iniset $GLANCE_API_CONF DEFAULT default_store swift
1006 iniset $GLANCE_API_CONF DEFAULT swift_store_auth_address $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/
1007 iniset $GLANCE_API_CONF DEFAULT swift_store_user $SERVICE_TENANT_NAME:glance
1008 iniset $GLANCE_API_CONF DEFAULT swift_store_key $SERVICE_PASSWORD
1009 iniset $GLANCE_API_CONF DEFAULT swift_store_create_container_on_put True
1010 fi
Anthony Young70dc5e02011-09-15 16:52:43 -07001011fi
Jesse Andrews75a37652011-09-12 17:09:08 -07001012
Dean Troyer7d28a0e2012-06-27 17:55:52 -05001013
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +00001014# Ryu
1015# ---
Dean Troyerb9182d62012-11-07 12:31:34 -06001016
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +00001017# Ryu is not a part of OpenStack project. Please ignore following block if
1018# you are not interested in Ryu.
1019# launch ryu manager
1020if is_service_enabled ryu; then
1021 RYU_CONF_DIR=/etc/ryu
1022 if [[ ! -d $RYU_CONF_DIR ]]; then
1023 sudo mkdir -p $RYU_CONF_DIR
1024 fi
1025 sudo chown `whoami` $RYU_CONF_DIR
1026 RYU_CONF=$RYU_CONF_DIR/ryu.conf
1027 sudo rm -rf $RYU_CONF
1028
1029 cat <<EOF > $RYU_CONF
1030--app_lists=$RYU_APPS
1031--wsapi_host=$RYU_API_HOST
1032--wsapi_port=$RYU_API_PORT
1033--ofp_listen_host=$RYU_OFP_HOST
1034--ofp_tcp_listen_port=$RYU_OFP_PORT
1035EOF
1036 screen_it ryu "cd $RYU_DIR && $RYU_DIR/bin/ryu-manager --flagfile $RYU_CONF"
1037fi
1038
1039
Dean Troyer7d28a0e2012-06-27 17:55:52 -05001040# Quantum
Anthony Young60df29a2012-03-28 09:40:17 -07001041# -------
Dean Troyer7d28a0e2012-06-27 17:55:52 -05001042
Dean Troyerb9182d62012-11-07 12:31:34 -06001043# Quantum Network Configuration
Shweta P4dc53aa2012-04-04 16:17:40 -04001044if is_service_enabled quantum; then
Dean Troyer7903b792012-09-13 17:16:12 -05001045 echo_summary "Configuring Quantum"
Dean Troyerb9182d62012-11-07 12:31:34 -06001046
Bob Kukura6e771632012-09-05 15:07:15 -04001047 # The following variables control the Quantum openvswitch and
1048 # linuxbridge plugins' allocation of tenant networks and
1049 # availability of provider networks. If these are not configured
1050 # in localrc, tenant networks will be local to the host (with no
1051 # remote connectivity), and no physical resources will be
1052 # available for the allocation of provider networks.
1053
1054 # To use GRE tunnels for tenant networks, set to True in
1055 # localrc. GRE tunnels are only supported by the openvswitch
1056 # plugin, and currently only on Ubuntu.
1057 ENABLE_TENANT_TUNNELS=${ENABLE_TENANT_TUNNELS:-False}
1058
1059 # If using GRE tunnels for tenant networks, specify the range of
1060 # tunnel IDs from which tenant networks are allocated. Can be
1061 # overriden in localrc in necesssary.
1062 TENANT_TUNNEL_RANGES=${TENANT_TUNNEL_RANGE:-1:1000}
1063
1064 # To use VLANs for tenant networks, set to True in localrc. VLANs
1065 # are supported by the openvswitch and linuxbridge plugins, each
1066 # requiring additional configuration described below.
1067 ENABLE_TENANT_VLANS=${ENABLE_TENANT_VLANS:-False}
1068
1069 # If using VLANs for tenant networks, set in localrc to specify
1070 # the range of VLAN VIDs from which tenant networks are
1071 # allocated. An external network switch must be configured to
1072 # trunk these VLANs between hosts for multi-host connectivity.
1073 #
Dean Troyerb9182d62012-11-07 12:31:34 -06001074 # Example: ``TENANT_VLAN_RANGE=1000:1999``
Bob Kukura6e771632012-09-05 15:07:15 -04001075 TENANT_VLAN_RANGE=${TENANT_VLAN_RANGE:-}
1076
1077 # If using VLANs for tenant networks, or if using flat or VLAN
1078 # provider networks, set in localrc to the name of the physical
1079 # network, and also configure OVS_PHYSICAL_BRIDGE for the
1080 # openvswitch agent or LB_PHYSICAL_INTERFACE for the linuxbridge
1081 # agent, as described below.
1082 #
Dean Troyerb9182d62012-11-07 12:31:34 -06001083 # Example: ``PHYSICAL_NETWORK=default``
Bob Kukura6e771632012-09-05 15:07:15 -04001084 PHYSICAL_NETWORK=${PHYSICAL_NETWORK:-}
1085
1086 # With the openvswitch plugin, if using VLANs for tenant networks,
1087 # or if using flat or VLAN provider networks, set in localrc to
1088 # the name of the OVS bridge to use for the physical network. The
1089 # bridge will be created if it does not already exist, but a
1090 # physical interface must be manually added to the bridge as a
1091 # port for external connectivity.
1092 #
Dean Troyerb9182d62012-11-07 12:31:34 -06001093 # Example: ``OVS_PHYSICAL_BRIDGE=br-eth1``
Bob Kukura6e771632012-09-05 15:07:15 -04001094 OVS_PHYSICAL_BRIDGE=${OVS_PHYSICAL_BRIDGE:-}
1095
1096 # With the linuxbridge plugin, if using VLANs for tenant networks,
1097 # or if using flat or VLAN provider networks, set in localrc to
1098 # the name of the network interface to use for the physical
1099 # network.
1100 #
Dean Troyerb9182d62012-11-07 12:31:34 -06001101 # Example: ``LB_PHYSICAL_INTERFACE=eth1``
Bob Kukura6e771632012-09-05 15:07:15 -04001102 LB_PHYSICAL_INTERFACE=${LB_PHYSICAL_INTERFACE:-}
1103
Bob Kukurafddd8f82012-09-10 00:59:24 -04001104 # With the openvswitch plugin, set to True in localrc to enable
Dean Troyerb9182d62012-11-07 12:31:34 -06001105 # provider GRE tunnels when ``ENABLE_TENANT_TUNNELS`` is False.
Bob Kukurafddd8f82012-09-10 00:59:24 -04001106 #
Dean Troyerb9182d62012-11-07 12:31:34 -06001107 # Example: ``OVS_ENABLE_TUNNELING=True``
Bob Kukurafddd8f82012-09-10 00:59:24 -04001108 OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-$ENABLE_TENANT_TUNNELS}
1109
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001110 # Put config files in ``QUANTUM_CONF_DIR`` for everyone to find
1111 if [[ ! -d $QUANTUM_CONF_DIR ]]; then
1112 sudo mkdir -p $QUANTUM_CONF_DIR
Anthony Young60df29a2012-03-28 09:40:17 -07001113 fi
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001114 sudo chown `whoami` $QUANTUM_CONF_DIR
Shweta P4dc53aa2012-04-04 16:17:40 -04001115
Anthony Young60df29a2012-03-28 09:40:17 -07001116 if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
Dan Wendlandt0007f3a2012-05-18 13:37:47 -07001117 Q_PLUGIN_CONF_PATH=etc/quantum/plugins/openvswitch
1118 Q_PLUGIN_CONF_FILENAME=ovs_quantum_plugin.ini
1119 Q_DB_NAME="ovs_quantum"
Gary Kotton37dda8d2012-08-08 03:46:33 -04001120 Q_PLUGIN_CLASS="quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2"
Shweta P4dc53aa2012-04-04 16:17:40 -04001121 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
Dan Wendlandt0007f3a2012-05-18 13:37:47 -07001122 Q_PLUGIN_CONF_PATH=etc/quantum/plugins/linuxbridge
1123 Q_PLUGIN_CONF_FILENAME=linuxbridge_conf.ini
1124 Q_DB_NAME="quantum_linux_bridge"
Gary Kotton37dda8d2012-08-08 03:46:33 -04001125 Q_PLUGIN_CLASS="quantum.plugins.linuxbridge.lb_quantum_plugin.LinuxBridgePluginV2"
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +00001126 elif [[ "$Q_PLUGIN" = "ryu" ]]; then
1127 Q_PLUGIN_CONF_PATH=etc/quantum/plugins/ryu
1128 Q_PLUGIN_CONF_FILENAME=ryu.ini
1129 Q_DB_NAME="ovs_quantum"
1130 Q_PLUGIN_CLASS="quantum.plugins.ryu.ryu_quantum_plugin.RyuQuantumPluginV2"
Takaaki Suzukib4907b22012-10-25 14:23:58 +09001131 fi
1132
1133 if [[ $Q_PLUGIN_CONF_PATH == '' || $Q_PLUGIN_CONF_FILENAME == '' || $Q_PLUGIN_CLASS == '' ]]; then
1134 echo "Quantum plugin not set.. exiting"
Dan Wendlandt0007f3a2012-05-18 13:37:47 -07001135 exit 1
1136 fi
1137
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001138 # If needed, move config file from ``$QUANTUM_DIR/etc/quantum`` to ``QUANTUM_CONF_DIR``
Dan Wendlandt0007f3a2012-05-18 13:37:47 -07001139 mkdir -p /$Q_PLUGIN_CONF_PATH
1140 Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME
Gary Kotton8301f142012-07-25 03:26:23 -04001141 cp $QUANTUM_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE
1142
Terry Wilson428af5a2012-11-01 16:12:39 -04001143 database_connection_url dburl $Q_DB_NAME
1144 iniset /$Q_PLUGIN_CONF_FILE DATABASE sql_connection $dburl
1145 unset dburl
Dan Wendlandt0007f3a2012-05-18 13:37:47 -07001146
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001147 cp $QUANTUM_DIR/etc/quantum.conf $QUANTUM_CONF
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -08001148 configure_quantum_rootwrap
Dan Wendlandt0007f3a2012-05-18 13:37:47 -07001149fi
1150
1151# Quantum service (for controller node)
1152if is_service_enabled q-svc; then
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001153 Q_API_PASTE_FILE=$QUANTUM_CONF_DIR/api-paste.ini
1154 Q_POLICY_FILE=$QUANTUM_CONF_DIR/policy.json
Dan Wendlandt0007f3a2012-05-18 13:37:47 -07001155
Akihiro MOTOKI1a4166c2012-07-25 17:53:40 +09001156 cp $QUANTUM_DIR/etc/api-paste.ini $Q_API_PASTE_FILE
1157 cp $QUANTUM_DIR/etc/policy.json $Q_POLICY_FILE
Aaron Rosen4402d6e2012-06-19 16:09:40 -07001158
Terry Wilson428af5a2012-11-01 16:12:39 -04001159 if is_service_enabled $DATABASE_BACKENDS; then
1160 recreate_database $Q_DB_NAME utf8
1161 else
1162 echo "A database must be enabled in order to use the $Q_PLUGIN Quantum plugin."
1163 exit 1
Anthony Young60df29a2012-03-28 09:40:17 -07001164 fi
Dan Wendlandt0007f3a2012-05-18 13:37:47 -07001165
Aaron Rosen4402d6e2012-06-19 16:09:40 -07001166 # Update either configuration file with plugin
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001167 iniset $QUANTUM_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS
Akihiro MOTOKI1a4166c2012-07-25 17:53:40 +09001168
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001169 iniset $QUANTUM_CONF DEFAULT auth_strategy $Q_AUTH_STRATEGY
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001170 quantum_setup_keystone $Q_API_PASTE_FILE filter:authtoken
Bob Kukura6e771632012-09-05 15:07:15 -04001171
1172 # Configure plugin
1173 if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
1174 if [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
1175 iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type gre
1176 iniset /$Q_PLUGIN_CONF_FILE OVS tunnel_id_ranges $TENANT_TUNNEL_RANGES
1177 elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
1178 iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type vlan
1179 else
1180 echo "WARNING - The openvswitch plugin is using local tenant networks, with no connectivity between hosts."
1181 fi
1182
Dean Troyerb9182d62012-11-07 12:31:34 -06001183 # Override ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc``
Bob Kukura6e771632012-09-05 15:07:15 -04001184 # for more complex physical network configurations.
1185 if [[ "$OVS_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
1186 OVS_VLAN_RANGES=$PHYSICAL_NETWORK
1187 if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
1188 OVS_VLAN_RANGES=$OVS_VLAN_RANGES:$TENANT_VLAN_RANGE
1189 fi
1190 fi
1191 if [[ "$OVS_VLAN_RANGES" != "" ]]; then
1192 iniset /$Q_PLUGIN_CONF_FILE OVS network_vlan_ranges $OVS_VLAN_RANGES
1193 fi
Bob Kukurafddd8f82012-09-10 00:59:24 -04001194
1195 # Enable tunnel networks if selected
1196 if [[ $OVS_ENABLE_TUNNELING = "True" ]]; then
1197 iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
1198 fi
Bob Kukura6e771632012-09-05 15:07:15 -04001199 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
1200 if [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
1201 iniset /$Q_PLUGIN_CONF_FILE VLANS tenant_network_type vlan
1202 else
1203 echo "WARNING - The linuxbridge plugin is using local tenant networks, with no connectivity between hosts."
1204 fi
1205
Dean Troyerb9182d62012-11-07 12:31:34 -06001206 # Override ``LB_VLAN_RANGES`` and ``LB_INTERFACE_MAPPINGS`` in ``localrc``
Bob Kukura6e771632012-09-05 15:07:15 -04001207 # for more complex physical network configurations.
1208 if [[ "$LB_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
1209 LB_VLAN_RANGES=$PHYSICAL_NETWORK
1210 if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
1211 LB_VLAN_RANGES=$LB_VLAN_RANGES:$TENANT_VLAN_RANGE
1212 fi
1213 fi
1214 if [[ "$LB_VLAN_RANGES" != "" ]]; then
1215 iniset /$Q_PLUGIN_CONF_FILE VLANS network_vlan_ranges $LB_VLAN_RANGES
1216 fi
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +00001217 elif [[ "$Q_PLUGIN" = "ryu" ]]; then
1218 iniset /$Q_PLUGIN_CONF_FILE OVS openflow_controller $RYU_OFP_HOST:$RYU_OFP_PORT
1219 iniset /$Q_PLUGIN_CONF_FILE OVS openflow_rest_api $RYU_API_HOST:$RYU_API_PORT
Bob Kukura6e771632012-09-05 15:07:15 -04001220 fi
Anthony Young60df29a2012-03-28 09:40:17 -07001221fi
1222
1223# Quantum agent (for compute nodes)
1224if is_service_enabled q-agt; then
Bob Kukura6e771632012-09-05 15:07:15 -04001225 # Configure agent for plugin
Anthony Young60df29a2012-03-28 09:40:17 -07001226 if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
Bob Kukura6e771632012-09-05 15:07:15 -04001227 # Setup integration bridge
Anthony Young60df29a2012-03-28 09:40:17 -07001228 OVS_BRIDGE=${OVS_BRIDGE:-br-int}
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001229 quantum_setup_ovs_bridge $OVS_BRIDGE
Bob Kukura6e771632012-09-05 15:07:15 -04001230
1231 # Setup agent for tunneling
Bob Kukurafddd8f82012-09-10 00:59:24 -04001232 if [[ "$OVS_ENABLE_TUNNELING" = "True" ]]; then
Bob Kukura6e771632012-09-05 15:07:15 -04001233 # Verify tunnels are supported
1234 # REVISIT - also check kernel module support for GRE and patch ports
1235 OVS_VERSION=`ovs-vsctl --version | head -n 1 | awk '{print $4;}'`
1236 if [ $OVS_VERSION \< "1.4" ] && ! is_service_enabled q-svc ; then
1237 echo "You are running OVS version $OVS_VERSION."
1238 echo "OVS 1.4+ is required for tunneling between multiple hosts."
1239 exit 1
1240 fi
Bob Kukurafddd8f82012-09-10 00:59:24 -04001241 iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
Bob Kukurab26a27a2012-08-27 01:53:11 -04001242 iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP
Bob Kukurab26a27a2012-08-27 01:53:11 -04001243 fi
Bob Kukura6e771632012-09-05 15:07:15 -04001244
1245 # Setup physical network bridge mappings. Override
Dean Troyerb9182d62012-11-07 12:31:34 -06001246 # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more
Bob Kukura6e771632012-09-05 15:07:15 -04001247 # complex physical network configurations.
1248 if [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
1249 OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
1250
Bob Kukurab26a27a2012-08-27 01:53:11 -04001251 # Configure bridge manually with physical interface as port for multi-node
Bob Kukura6e771632012-09-05 15:07:15 -04001252 sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE
Bob Kukurab26a27a2012-08-27 01:53:11 -04001253 fi
Bob Kukura6e771632012-09-05 15:07:15 -04001254 if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
1255 iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS
1256 fi
Gary Kottoncea6c512012-08-20 09:09:25 -04001257 AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent"
Shweta P4dc53aa2012-04-04 16:17:40 -04001258 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
Bob Kukura6e771632012-09-05 15:07:15 -04001259 # Setup physical network interface mappings. Override
Dean Troyerb9182d62012-11-07 12:31:34 -06001260 # ``LB_VLAN_RANGES`` and ``LB_INTERFACE_MAPPINGS`` in ``localrc`` for more
Bob Kukura6e771632012-09-05 15:07:15 -04001261 # complex physical network configurations.
1262 if [[ "$LB_INTERFACE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$LB_PHYSICAL_INTERFACE" != "" ]]; then
1263 LB_INTERFACE_MAPPINGS=$PHYSICAL_NETWORK:$LB_PHYSICAL_INTERFACE
1264 fi
1265 if [[ "$LB_INTERFACE_MAPPINGS" != "" ]]; then
1266 iniset /$Q_PLUGIN_CONF_FILE LINUX_BRIDGE physical_interface_mappings $LB_INTERFACE_MAPPINGS
1267 fi
Gary Kottoncea6c512012-08-20 09:09:25 -04001268 AGENT_BINARY="$QUANTUM_DIR/bin/quantum-linuxbridge-agent"
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +00001269 elif [[ "$Q_PLUGIN" = "ryu" ]]; then
1270 # Set up integration bridge
1271 OVS_BRIDGE=${OVS_BRIDGE:-br-int}
1272 quantum_setup_ovs_bridge $OVS_BRIDGE
1273 if [ -n "$RYU_INTERNAL_INTERFACE" ]; then
1274 sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_BRIDGE $RYU_INTERNAL_INTERFACE
1275 fi
1276 AGENT_BINARY="$QUANTUM_DIR/quantum/plugins/ryu/agent/ryu_quantum_agent.py"
Anthony Young60df29a2012-03-28 09:40:17 -07001277 fi
Gary Kottoncbeeccb2012-09-23 08:18:10 +00001278 # Update config w/rootwrap
1279 iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
Anthony Young60df29a2012-03-28 09:40:17 -07001280fi
1281
Gary Kottonbff593d2012-07-16 18:02:37 -04001282# Quantum DHCP
1283if is_service_enabled q-dhcp; then
1284 AGENT_DHCP_BINARY="$QUANTUM_DIR/bin/quantum-dhcp-agent"
1285
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001286 Q_DHCP_CONF_FILE=$QUANTUM_CONF_DIR/dhcp_agent.ini
Gary Kottonbff593d2012-07-16 18:02:37 -04001287
Gary Kotton396a0142012-07-29 04:28:47 -04001288 cp $QUANTUM_DIR/etc/dhcp_agent.ini $Q_DHCP_CONF_FILE
Gary Kottonbff593d2012-07-16 18:02:37 -04001289
1290 # Set verbose
1291 iniset $Q_DHCP_CONF_FILE DEFAULT verbose True
1292 # Set debug
1293 iniset $Q_DHCP_CONF_FILE DEFAULT debug True
Dan Wendlandtea23e682012-08-22 05:53:17 -07001294 iniset $Q_DHCP_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
Dean Troyer13314452012-10-23 15:09:50 -05001295 iniset $Q_DHCP_CONF_FILE DEFAULT state_path $DATA_DIR/quantum
Gary Kottonbff593d2012-07-16 18:02:37 -04001296
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001297 quantum_setup_keystone $Q_DHCP_CONF_FILE DEFAULT set_auth_url
Gary Kottonbff593d2012-07-16 18:02:37 -04001298
John Dunningb782a2c2012-09-11 16:13:37 -04001299 # Update config w/rootwrap
Gary Kottoncbeeccb2012-09-23 08:18:10 +00001300 iniset $Q_DHCP_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
John Dunningb782a2c2012-09-11 16:13:37 -04001301
Gary Kottonbff593d2012-07-16 18:02:37 -04001302 if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
1303 iniset $Q_DHCP_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
1304 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
1305 iniset $Q_DHCP_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +00001306 elif [[ "$Q_PLUGIN" = "ryu" ]]; then
1307 iniset $Q_DHCP_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.RyuInterfaceDriver
1308 iniset $Q_DHCP_CONF_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
Gary Kottonbff593d2012-07-16 18:02:37 -04001309 fi
Gary Kottonbff593d2012-07-16 18:02:37 -04001310fi
1311
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001312# Quantum L3
1313if is_service_enabled q-l3; then
1314 AGENT_L3_BINARY="$QUANTUM_DIR/bin/quantum-l3-agent"
1315 PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex}
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001316 Q_L3_CONF_FILE=$QUANTUM_CONF_DIR/l3_agent.ini
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001317
1318 cp $QUANTUM_DIR/etc/l3_agent.ini $Q_L3_CONF_FILE
1319
1320 # Set verbose
1321 iniset $Q_L3_CONF_FILE DEFAULT verbose True
1322 # Set debug
1323 iniset $Q_L3_CONF_FILE DEFAULT debug True
1324
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001325 iniset $Q_L3_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001326
Mark McClain205bc492012-11-16 00:15:28 -05001327 iniset $Q_L3_CONF_FILE DEFAULT state_path $DATA_DIR/quantum
1328
Gary Kottoncbeeccb2012-09-23 08:18:10 +00001329 iniset $Q_L3_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
1330
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001331 quantum_setup_keystone $Q_L3_CONF_FILE DEFAULT set_auth_url
1332 if [[ "$Q_PLUGIN" == "openvswitch" ]]; then
1333 iniset $Q_L3_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
Gary Kottoncea6c512012-08-20 09:09:25 -04001334 iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001335 # Set up external bridge
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +00001336 quantum_setup_external_bridge $PUBLIC_BRIDGE
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001337 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
1338 iniset $Q_L3_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver
Gary Kottoncea6c512012-08-20 09:09:25 -04001339 iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge ''
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +00001340 elif [[ "$Q_PLUGIN" = "ryu" ]]; then
1341 iniset $Q_L3_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.RyuInterfaceDriver
1342 iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
1343 iniset $Q_L3_CONF_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
1344 # Set up external bridge
1345 quantum_setup_external_bridge $PUBLIC_BRIDGE
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001346 fi
1347fi
1348
Mark McClain205bc492012-11-16 00:15:28 -05001349#Quantum Metadata
1350if is_service_enabled q-meta; then
1351 AGENT_META_BINARY="$QUANTUM_DIR/bin/quantum-metadata-agent"
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001352 Q_META_CONF_FILE=$QUANTUM_CONF_DIR/metadata_agent.ini
Mark McClain205bc492012-11-16 00:15:28 -05001353
1354 cp $QUANTUM_DIR/etc/metadata_agent.ini $Q_META_CONF_FILE
1355
1356 # Set verbose
1357 iniset $Q_META_CONF_FILE DEFAULT verbose True
1358 # Set debug
1359 iniset $Q_META_CONF_FILE DEFAULT debug True
1360
1361 iniset $Q_META_CONF_FILE DEFAULT state_path $DATA_DIR/quantum
1362
1363 iniset $Q_META_CONF_FILE DEFAULT nova_metadata_ip $Q_META_DATA_IP
1364
1365 iniset $Q_META_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
1366
1367 quantum_setup_keystone $Q_META_CONF_FILE DEFAULT set_auth_url
1368fi
1369
Gary Kotton396a0142012-07-29 04:28:47 -04001370# Quantum RPC support - must be updated prior to starting any of the services
1371if is_service_enabled quantum; then
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001372 iniset $QUANTUM_CONF DEFAULT control_exchange quantum
Gary Kotton396a0142012-07-29 04:28:47 -04001373 if is_service_enabled qpid ; then
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001374 iniset $QUANTUM_CONF DEFAULT rpc_backend quantum.openstack.common.rpc.impl_qpid
ewindisch3bae7c22012-01-18 11:18:35 -05001375 elif is_service_enabled zeromq; then
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001376 iniset $QUANTUM_CONF DEFAULT rpc_backend quantum.openstack.common.rpc.impl_zmq
Gary Kotton396a0142012-07-29 04:28:47 -04001377 elif [ -n "$RABBIT_HOST" ] && [ -n "$RABBIT_PASSWORD" ]; then
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001378 iniset $QUANTUM_CONF DEFAULT rabbit_host $RABBIT_HOST
1379 iniset $QUANTUM_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
Gary Kotton396a0142012-07-29 04:28:47 -04001380 fi
Nachi Ueno5db5bfa2012-10-29 11:25:29 -07001381 if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
Nachi Ueno8bc21f62012-11-19 22:04:28 -08001382 cp $QUANTUM_DIR/etc/l3_agent.ini $QUANTUM_TEST_CONFIG_FILE
1383 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT verbose False
1384 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT debug False
1385 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
Nachi Ueno3c6a57a2012-12-08 22:07:11 -08001386 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT root_helper "$Q_RR_COMMAND"
Nachi Ueno8bc21f62012-11-19 22:04:28 -08001387 quantum_setup_keystone $QUANTUM_TEST_CONFIG_FILE DEFAULT set_auth_url
1388 if [[ "$Q_PLUGIN" == "openvswitch" ]]; then
1389 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
1390 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
1391 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
1392 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver
1393 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge ''
1394 elif [[ "$Q_PLUGIN" = "ryu" ]]; then
1395 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT interface_driver quantum.agent.linux.interface.RyuInterfaceDriver
1396 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
1397 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
1398 fi
Nachi Ueno5db5bfa2012-10-29 11:25:29 -07001399 fi
Gary Kotton396a0142012-07-29 04:28:47 -04001400fi
1401
Dean Troyerb9182d62012-11-07 12:31:34 -06001402
Jesse Andrewsd74257d2011-09-13 01:24:50 -07001403# Nova
1404# ----
Dean Troyerbd13b702012-02-13 11:22:36 -06001405
Dean Troyerbf67c192012-09-21 15:09:37 -05001406if is_service_enabled nova; then
1407 echo_summary "Configuring Nova"
1408 configure_nova
Jesse Andrewsdfcd2002011-09-13 13:17:22 -07001409fi
1410
Isaku Yamahata6f85ab32012-08-06 16:56:10 +09001411if is_service_enabled n-net q-dhcp; then
Anthony Young55458452011-12-17 00:21:49 +00001412 # Delete traces of nova networks from prior runs
Anthony Young09fde812011-09-20 02:23:54 -07001413 sudo killall dnsmasq || true
Anthony Young55458452011-12-17 00:21:49 +00001414 clean_iptables
Dean Troyer50ac7922012-09-13 14:02:01 -05001415 rm -rf $NOVA_STATE_PATH/networks
1416 mkdir -p $NOVA_STATE_PATH/networks
Dean Troyer0b31e862012-03-07 16:47:56 -06001417
1418 # Force IP forwarding on, just on case
1419 sudo sysctl -w net.ipv4.ip_forward=1
Anthony Young70dc5e02011-09-15 16:52:43 -07001420fi
Jesse Andrews75a37652011-09-12 17:09:08 -07001421
Dean Troyer7d28a0e2012-06-27 17:55:52 -05001422
Chmouel Boudjnah28fa4e82011-11-01 12:30:55 +01001423# Storage Service
Dean Troyer7d28a0e2012-06-27 17:55:52 -05001424# ---------------
1425
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +00001426if is_service_enabled swift; then
Dean Troyer7903b792012-09-13 17:16:12 -05001427 echo_summary "Configuring Swift"
Attila Fazekasece6a332012-11-29 14:19:41 +01001428 init_swift
Chmouel Boudjnah28fa4e82011-11-01 12:30:55 +01001429fi
1430
Dean Troyerdf0972c2012-03-07 17:31:03 -06001431
Anthony Youngacff87a2011-10-20 10:12:58 -07001432# Volume Service
1433# --------------
1434
Dean Troyer67787e62012-05-02 11:48:15 -05001435if is_service_enabled cinder; then
Dean Troyer7903b792012-09-13 17:16:12 -05001436 echo_summary "Configuring Cinder"
Dean Troyer67787e62012-05-02 11:48:15 -05001437 init_cinder
Anthony Youngacff87a2011-10-20 10:12:58 -07001438fi
1439
Dean Troyerbf67c192012-09-21 15:09:37 -05001440if is_service_enabled nova; then
1441 echo_summary "Configuring Nova"
Dean Troyerda7b8092012-10-08 18:12:14 -05001442 # Rebuild the config file from scratch
1443 create_nova_conf
Dean Troyerbf67c192012-09-21 15:09:37 -05001444 init_nova
Jesse Andrewsd1879c52011-09-16 16:28:13 -07001445
Dean Troyer86a79692012-10-22 15:24:46 -05001446 # Additional Nova configuration that is dependent on other services
1447 if is_service_enabled quantum; then
1448 add_nova_opt "network_api_class=nova.network.quantumv2.api.API"
1449 add_nova_opt "quantum_admin_username=$Q_ADMIN_USERNAME"
1450 add_nova_opt "quantum_admin_password=$SERVICE_PASSWORD"
1451 add_nova_opt "quantum_admin_auth_url=$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v2.0"
1452 add_nova_opt "quantum_auth_strategy=$Q_AUTH_STRATEGY"
1453 add_nova_opt "quantum_admin_tenant_name=$SERVICE_TENANT_NAME"
1454 add_nova_opt "quantum_url=http://$Q_HOST:$Q_PORT"
Dan Wendlandt0007f3a2012-05-18 13:37:47 -07001455
Dean Troyer86a79692012-10-22 15:24:46 -05001456 if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
Robert Collins443ac482012-11-19 18:59:04 +13001457 NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"}
Dean Troyer86a79692012-10-22 15:24:46 -05001458 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
Robert Collins443ac482012-11-19 18:59:04 +13001459 NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver"}
Dean Troyer86a79692012-10-22 15:24:46 -05001460 elif [[ "$Q_PLUGIN" = "ryu" ]]; then
Robert Collins443ac482012-11-19 18:59:04 +13001461 NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"quantum.plugins.ryu.nova.vif.LibvirtOpenVswitchOFPRyuDriver"}
Dean Troyer86a79692012-10-22 15:24:46 -05001462 add_nova_opt "libvirt_ovs_integration_bridge=$OVS_BRIDGE"
1463 add_nova_opt "linuxnet_ovs_ryu_api_host=$RYU_API_HOST:$RYU_API_PORT"
1464 add_nova_opt "libvirt_ovs_ryu_api_host=$RYU_API_HOST:$RYU_API_PORT"
1465 fi
1466 add_nova_opt "libvirt_vif_driver=$NOVA_VIF_DRIVER"
1467 add_nova_opt "linuxnet_interface_driver=$LINUXNET_VIF_DRIVER"
Mark McClain205bc492012-11-16 00:15:28 -05001468 if is_service_enabled q-meta; then
1469 add_nova_opt "service_quantum_metadata_proxy=True"
1470 fi
Dean Troyer86a79692012-10-22 15:24:46 -05001471 elif is_service_enabled n-net; then
1472 add_nova_opt "network_manager=nova.network.manager.$NET_MAN"
1473 add_nova_opt "public_interface=$PUBLIC_INTERFACE"
1474 add_nova_opt "vlan_interface=$VLAN_INTERFACE"
1475 add_nova_opt "flat_network_bridge=$FLAT_NETWORK_BRIDGE"
1476 if [ -n "$FLAT_INTERFACE" ]; then
1477 add_nova_opt "flat_interface=$FLAT_INTERFACE"
1478 fi
Brad Hall1bfa3d52011-10-27 18:18:20 -07001479 fi
Dean Troyer86a79692012-10-22 15:24:46 -05001480 # All nova-compute workers need to know the vnc configuration options
1481 # These settings don't hurt anything if n-xvnc and n-novnc are disabled
1482 if is_service_enabled n-cpu; then
1483 NOVNCPROXY_URL=${NOVNCPROXY_URL:-"http://$SERVICE_HOST:6080/vnc_auto.html"}
1484 add_nova_opt "novncproxy_base_url=$NOVNCPROXY_URL"
1485 XVPVNCPROXY_URL=${XVPVNCPROXY_URL:-"http://$SERVICE_HOST:6081/console"}
1486 add_nova_opt "xvpvncproxy_base_url=$XVPVNCPROXY_URL"
Gary Kottoncea6c512012-08-20 09:09:25 -04001487 fi
Dean Troyer86a79692012-10-22 15:24:46 -05001488 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
1489 VNCSERVER_PROXYCLIENT_ADDRESS=${VNCSERVER_PROXYCLIENT_ADDRESS=169.254.0.1}
1490 else
1491 VNCSERVER_PROXYCLIENT_ADDRESS=${VNCSERVER_PROXYCLIENT_ADDRESS=127.0.0.1}
1492 fi
1493 # Address on which instance vncservers will listen on compute hosts.
1494 # For multi-host, this should be the management ip of the compute host.
1495 VNCSERVER_LISTEN=${VNCSERVER_LISTEN=127.0.0.1}
1496 add_nova_opt "vncserver_listen=$VNCSERVER_LISTEN"
1497 add_nova_opt "vncserver_proxyclient_address=$VNCSERVER_PROXYCLIENT_ADDRESS"
1498 add_nova_opt "ec2_dmz_host=$EC2_DMZ_HOST"
1499 if is_service_enabled zeromq; then
1500 add_nova_opt "rpc_backend=nova.openstack.common.rpc.impl_zmq"
1501 elif is_service_enabled qpid; then
1502 add_nova_opt "rpc_backend=nova.rpc.impl_qpid"
1503 elif [ -n "$RABBIT_HOST" ] && [ -n "$RABBIT_PASSWORD" ]; then
1504 add_nova_opt "rabbit_host=$RABBIT_HOST"
1505 add_nova_opt "rabbit_password=$RABBIT_PASSWORD"
1506 fi
1507 add_nova_opt "glance_api_servers=$GLANCE_HOSTPORT"
Dean Troyerdf0972c2012-03-07 17:31:03 -06001508
Dean Troyerb9182d62012-11-07 12:31:34 -06001509
Dean Troyer86a79692012-10-22 15:24:46 -05001510 # XenServer
1511 # ---------
Anthony Youngb62b4ca2011-10-26 22:29:08 -07001512
Dean Troyer86a79692012-10-22 15:24:46 -05001513 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
1514 echo_summary "Using XenServer virtualization driver"
1515 read_password XENAPI_PASSWORD "ENTER A PASSWORD TO USE FOR XEN."
1516 add_nova_opt "compute_driver=xenapi.XenAPIDriver"
1517 XENAPI_CONNECTION_URL=${XENAPI_CONNECTION_URL:-"http://169.254.0.1"}
1518 XENAPI_USER=${XENAPI_USER:-"root"}
1519 add_nova_opt "xenapi_connection_url=$XENAPI_CONNECTION_URL"
1520 add_nova_opt "xenapi_connection_username=$XENAPI_USER"
1521 add_nova_opt "xenapi_connection_password=$XENAPI_PASSWORD"
1522 add_nova_opt "flat_injected=False"
1523 # Need to avoid crash due to new firewall support
1524 XEN_FIREWALL_DRIVER=${XEN_FIREWALL_DRIVER:-"nova.virt.firewall.IptablesFirewallDriver"}
1525 add_nova_opt "firewall_driver=$XEN_FIREWALL_DRIVER"
1526 elif [ "$VIRT_DRIVER" = 'openvz' ]; then
1527 echo_summary "Using OpenVZ virtualization driver"
1528 # TODO(deva): OpenVZ driver does not yet work if compute_driver is set here.
1529 # Replace connection_type when this is fixed.
1530 # add_nova_opt "compute_driver=openvz.connection.OpenVzConnection"
1531 add_nova_opt "connection_type=openvz"
1532 LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.libvirt.firewall.IptablesFirewallDriver"}
1533 add_nova_opt "firewall_driver=$LIBVIRT_FIREWALL_DRIVER"
1534 else
1535 echo_summary "Using libvirt virtualization driver"
1536 add_nova_opt "compute_driver=libvirt.LibvirtDriver"
1537 LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.libvirt.firewall.IptablesFirewallDriver"}
1538 add_nova_opt "firewall_driver=$LIBVIRT_FIREWALL_DRIVER"
1539 fi
Anthony Youngb62b4ca2011-10-26 22:29:08 -07001540fi
1541
Dean Troyerdf0972c2012-03-07 17:31:03 -06001542
Jesse Andrewsd74257d2011-09-13 01:24:50 -07001543# Launch Services
1544# ===============
Jesse Andrews30f68e92011-09-13 00:59:54 -07001545
Jesse Andrewsdfcd2002011-09-13 13:17:22 -07001546# Only run the services specified in ``ENABLED_SERVICES``
1547
Attila Fazekasece6a332012-11-29 14:19:41 +01001548# Launch Swift Services
1549if is_service_enabled swift; then
1550 echo_summary "Starting Swift"
1551 start_swift
1552fi
1553
Dean Troyer73f6f252012-09-17 11:22:21 -05001554# Launch the Glance services
1555if is_service_enabled g-api g-reg; then
Dean Troyer7903b792012-09-13 17:16:12 -05001556 echo_summary "Starting Glance"
Dean Troyer73f6f252012-09-17 11:22:21 -05001557 start_glance
Anthony Youngd000b222011-09-19 14:46:53 -07001558fi
1559
Dean Troyerd81a0272012-08-31 18:04:55 -05001560# Create an access key and secret key for nova ec2 register image
1561if is_service_enabled key && is_service_enabled swift3 && is_service_enabled nova; then
1562 NOVA_USER_ID=$(keystone user-list | grep ' nova ' | get_field 1)
1563 NOVA_TENANT_ID=$(keystone tenant-list | grep " $SERVICE_TENANT_NAME " | get_field 1)
1564 CREDS=$(keystone ec2-credentials-create --user_id $NOVA_USER_ID --tenant_id $NOVA_TENANT_ID)
1565 ACCESS_KEY=$(echo "$CREDS" | awk '/ access / { print $4 }')
1566 SECRET_KEY=$(echo "$CREDS" | awk '/ secret / { print $4 }')
1567 add_nova_opt "s3_access_key=$ACCESS_KEY"
1568 add_nova_opt "s3_secret_key=$SECRET_KEY"
1569 add_nova_opt "s3_affix_tenant=True"
Anthony Youngd000b222011-09-19 14:46:53 -07001570fi
1571
Monty Taylor99fcd812012-12-02 13:07:39 -08001572screen_it zeromq "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-rpc-zmq-receiver"
ewindisch3bae7c22012-01-18 11:18:35 -05001573
Dean Troyer7d28a0e2012-06-27 17:55:52 -05001574# Launch the nova-api and wait for it to answer before continuing
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +00001575if is_service_enabled n-api; then
Dean Troyer7903b792012-09-13 17:16:12 -05001576 echo_summary "Starting Nova API"
Monty Taylor9fbeedd2012-08-17 12:52:27 -04001577 screen_it n-api "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-api"
James E. Blair92e81992011-10-11 09:26:29 -05001578 echo "Waiting for nova-api to start..."
Dean Troyerc727aa82012-01-13 12:13:59 -06001579 if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://127.0.0.1:8774; do sleep 1; done"; then
James E. Blair92e81992011-10-11 09:26:29 -05001580 echo "nova-api did not start"
1581 exit 1
1582 fi
Anthony Youngd000b222011-09-19 14:46:53 -07001583fi
Brad Hall1bfa3d52011-10-27 18:18:20 -07001584
Gary Kotton37dda8d2012-08-08 03:46:33 -04001585if is_service_enabled q-svc; then
Dean Troyer7903b792012-09-13 17:16:12 -05001586 echo_summary "Starting Quantum"
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001587 # Start the Quantum service
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001588 screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server --config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE"
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001589 echo "Waiting for Quantum to start..."
1590 if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://127.0.0.1:9696; do sleep 1; done"; then
1591 echo "Quantum did not start"
1592 exit 1
1593 fi
1594
1595 # Configure Quantum elements
1596 # Configure internal network & subnet
1597
Gary Kotton37dda8d2012-08-08 03:46:33 -04001598 TENANT_ID=$(keystone tenant-list | grep " demo " | get_field 1)
Brad Hall1bfa3d52011-10-27 18:18:20 -07001599
Gary Kotton37dda8d2012-08-08 03:46:33 -04001600 # Create a small network
1601 # Since quantum command is executed in admin context at this point,
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001602 # ``--tenant_id`` needs to be specified.
Nachi Uenofda946e2012-10-24 17:26:02 -07001603 NET_ID=$(quantum net-create --tenant_id $TENANT_ID "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2)
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001604 SUBNET_ID=$(quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
1605 if is_service_enabled q-l3; then
1606 # Create a router, and add the private subnet as one of its interfaces
1607 ROUTER_ID=$(quantum router-create --tenant_id $TENANT_ID router1 | grep ' id ' | get_field 2)
1608 quantum router-interface-add $ROUTER_ID $SUBNET_ID
1609 # Create an external network, and a subnet. Configure the external network as router gw
Nachi Uenofda946e2012-10-24 17:26:02 -07001610 EXT_NET_ID=$(quantum net-create "$PUBLIC_NETWORK_NAME" -- --router:external=True | grep ' id ' | get_field 2)
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001611 EXT_GW_IP=$(quantum subnet-create --ip_version 4 $EXT_NET_ID $FLOATING_RANGE -- --enable_dhcp=False | grep 'gateway_ip' | get_field 2)
1612 quantum router-gateway-set $ROUTER_ID $EXT_NET_ID
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +00001613 if is_quantum_ovs_base_plugin "$Q_PLUGIN" && [[ "$Q_USE_NAMESPACE" = "True" ]]; then
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001614 CIDR_LEN=${FLOATING_RANGE#*/}
1615 sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE
1616 sudo ip link set $PUBLIC_BRIDGE up
Dan Wendlandtc8dc1f32012-09-26 01:04:55 -07001617 ROUTER_GW_IP=`quantum port-list -c fixed_ips -c device_owner | grep router_gateway | awk -F '"' '{ print $8; }'`
1618 sudo route add -net $FIXED_RANGE gw $ROUTER_GW_IP
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001619 fi
1620 if [[ "$Q_USE_NAMESPACE" == "False" ]]; then
1621 # Explicitly set router id in l3 agent configuration
1622 iniset $Q_L3_CONF_FILE DEFAULT router_id $ROUTER_ID
1623 fi
1624 fi
Nachi Ueno8bc21f62012-11-19 22:04:28 -08001625 if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
1626 setup_quantum
1627 fi
Aaron Rosen8ec719b2012-10-30 12:57:47 -07001628elif is_service_enabled $DATABASE_BACKENDS && is_service_enabled n-net; then
Gary Kotton37dda8d2012-08-08 03:46:33 -04001629 # Create a small network
Nachi Uenofda946e2012-10-24 17:26:02 -07001630 $NOVA_BIN_DIR/nova-manage network create "$PRIVATE_NETWORK_NAME" $FIXED_RANGE 1 $FIXED_NETWORK_SIZE $NETWORK_CREATE_ARGS
Dean Troyer696ad332012-01-10 15:34:34 -06001631
Gary Kotton37dda8d2012-08-08 03:46:33 -04001632 # Create some floating ips
Nachi Uenofda946e2012-10-24 17:26:02 -07001633 $NOVA_BIN_DIR/nova-manage floating create $FLOATING_RANGE --pool=$PUBLIC_NETWORK
Aaron Rosen9313dfa2012-07-06 16:08:49 -04001634
Gary Kotton37dda8d2012-08-08 03:46:33 -04001635 # Create a second pool
Monty Taylor9fbeedd2012-08-17 12:52:27 -04001636 $NOVA_BIN_DIR/nova-manage floating create --ip_range=$TEST_FLOATING_RANGE --pool=$TEST_FLOATING_POOL
Brad Hall1bfa3d52011-10-27 18:18:20 -07001637fi
1638
Bob Kukura6e771632012-09-05 15:07:15 -04001639# Start up the quantum agents if enabled
Dean Troyer60e9c0a2012-12-06 15:52:52 -06001640screen_it q-agt "python $AGENT_BINARY --config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE"
1641screen_it q-dhcp "python $AGENT_DHCP_BINARY --config-file $QUANTUM_CONF --config-file=$Q_DHCP_CONF_FILE"
1642screen_it q-meta "python $AGENT_META_BINARY --config-file $QUANTUM_CONF --config-file=$Q_META_CONF_FILE"
1643screen_it q-l3 "python $AGENT_L3_BINARY --config-file $QUANTUM_CONF --config-file=$Q_L3_CONF_FILE"
Bob Kukura6e771632012-09-05 15:07:15 -04001644
Dean Troyerbf67c192012-09-21 15:09:37 -05001645if is_service_enabled nova; then
1646 echo_summary "Starting Nova"
1647 start_nova
1648fi
Dean Troyer67787e62012-05-02 11:48:15 -05001649if is_service_enabled cinder; then
Dean Troyer7903b792012-09-13 17:16:12 -05001650 echo_summary "Starting Cinder"
Dean Troyer67787e62012-05-02 11:48:15 -05001651 start_cinder
1652fi
John H. Tran93361642012-07-26 11:22:05 -07001653if is_service_enabled ceilometer; then
Doug Hellmannc5259b42012-09-22 10:52:31 -04001654 echo_summary "Configuring Ceilometer"
John H. Tran93361642012-07-26 11:22:05 -07001655 configure_ceilometer
Doug Hellmannc5259b42012-09-22 10:52:31 -04001656 echo_summary "Starting Ceilometer"
John H. Tran93361642012-07-26 11:22:05 -07001657 start_ceilometer
1658fi
Sean Dagueb562e6a2012-11-19 16:00:01 -05001659
Chmouel Boudjnah6ae9ea52012-07-05 06:50:51 +00001660# Starting the nova-objectstore only if swift3 service is not enabled.
Chmouel Boudjnahe347b992012-03-16 17:38:49 +00001661# Swift will act as s3 objectstore.
Chmouel Boudjnah6ae9ea52012-07-05 06:50:51 +00001662is_service_enabled swift3 || \
Monty Taylor9fbeedd2012-08-17 12:52:27 -04001663 screen_it n-obj "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-objectstore"
Dean Troyerdf0972c2012-03-07 17:31:03 -06001664
Steve Bakerbad9d892012-10-25 14:49:47 +13001665
1666# Configure and launch heat engine, api and metadata
Steve Bakerbfdad752012-08-18 09:00:42 +12001667if is_service_enabled heat; then
Steve Bakerbad9d892012-10-25 14:49:47 +13001668 # Initialize heat, including replacing nova flavors
1669 echo_summary "Configuring Heat"
1670 init_heat
Dean Troyer7903b792012-09-13 17:16:12 -05001671 echo_summary "Starting Heat"
Steve Bakerbfdad752012-08-18 09:00:42 +12001672 start_heat
1673fi
Dean Troyer7d28a0e2012-06-27 17:55:52 -05001674
Attila Fazekas22ef5732012-12-16 14:03:06 +01001675# Create account rc files
1676# =======================
1677
1678# Creates source able script files for easier user switching.
1679# This step also creates certificates for tenants and users,
1680# which is helpful in image bundle steps.
1681
1682if is_service_enabled nova && is_service_enabled key; then
1683 $TOP_DIR/tools/create_userrc.sh -PA --target-dir $TOP_DIR/accrc
1684fi
1685
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001686
Jesse Andrewsd74257d2011-09-13 01:24:50 -07001687# Install Images
1688# ==============
Jesse Andrewse49b8bd2011-09-12 18:08:04 -07001689
Anthony Young0ab1d462011-10-13 23:03:23 -07001690# Upload an image to glance.
Jesse Andrews5372f432011-10-03 01:08:24 -04001691#
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001692# The default image is cirros, a small testing image which lets you login as **root**
Dean Troyerca0e3d02012-04-13 15:58:37 -05001693# cirros also uses ``cloud-init``, supporting login via keypair and sending scripts as
Anthony Young0ab1d462011-10-13 23:03:23 -07001694# userdata. See https://help.ubuntu.com/community/CloudInit for more on cloud-init
1695#
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001696# Override ``IMAGE_URLS`` with a comma-separated list of UEC images.
Jesse Andrewsaab7eae2011-10-19 10:30:19 -07001697# * **oneiric**: http://uec-images.ubuntu.com/oneiric/current/oneiric-server-cloudimg-amd64.tar.gz
Dean Troyerca0e3d02012-04-13 15:58:37 -05001698# * **precise**: http://uec-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64.tar.gz
Jesse Andrews08e8b742011-10-02 23:42:56 -04001699
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +00001700if is_service_enabled g-reg; then
Dean Troyer7903b792012-09-13 17:16:12 -05001701 echo_summary "Uploading images"
Dean Troyerbc071bc2012-10-01 14:06:44 -05001702 TOKEN=$(keystone token-get | grep ' id ' | get_field 2)
termie747ee332012-01-11 22:31:59 +00001703
Anthony Youngb62b4ca2011-10-26 22:29:08 -07001704 # Option to upload legacy ami-tty, which works with xenserver
Dean Troyer314da5a2012-03-28 19:15:48 -05001705 if [[ -n "$UPLOAD_LEGACY_TTY" ]]; then
Mate Lakatda339822012-11-14 12:45:10 +00001706 IMAGE_URLS="${IMAGE_URLS:+${IMAGE_URLS},}https://github.com/downloads/citrix-openstack/warehouse/tty.tgz"
Anthony Youngb62b4ca2011-10-26 22:29:08 -07001707 fi
1708
Anthony Young120f4862011-10-14 09:31:09 -07001709 for image_url in ${IMAGE_URLS//,/ }; do
Dean Troyerca0e3d02012-04-13 15:58:37 -05001710 upload_image $image_url $TOKEN
Anthony Young120f4862011-10-14 09:31:09 -07001711 done
Jesse Andrewse49b8bd2011-09-12 18:08:04 -07001712fi
Jesse Andrews24859062011-09-15 21:28:23 -07001713
Dean Troyerdf0972c2012-03-07 17:31:03 -06001714
Maru Newbyec086512012-11-01 23:44:57 +00001715# Configure Tempest last to ensure that the runtime configuration of
1716# the various OpenStack services can be queried.
1717if is_service_enabled tempest; then
Attila Fazekas2aa35172012-12-05 20:03:40 +01001718 echo_summary "Configuring Tempest"
Maru Newbyec086512012-11-01 23:44:57 +00001719 configure_tempest
Attila Fazekas2aa35172012-12-05 20:03:40 +01001720 echo '**************************************************'
1721 echo_summary "Finished Configuring Tempest"
1722 echo '**************************************************'
Maru Newbyec086512012-11-01 23:44:57 +00001723fi
1724
Dean Troyer33cb4302012-12-10 16:47:36 -06001725# Save some values we generated for later use
1726CURRENT_RUN_TIME=$(date "+$TIMESTAMP_FORMAT")
1727echo "# $CURRENT_RUN_TIME" >$TOP_DIR/.stackenv
1728for i in BASE_SQL_CONN ENABLED_SERVICES HOST_IP LOGFILE \
1729 SERVICE_HOST SERVICE_PROTOCOL TLS_IP; do
1730 echo $i=${!i} >>$TOP_DIR/.stackenv
1731done
1732
Maru Newbyec086512012-11-01 23:44:57 +00001733
Dean Troyerf5633dd2012-03-28 11:21:40 -05001734# Run local script
1735# ================
1736
1737# Run ``local.sh`` if it exists to perform user-managed tasks
1738if [[ -x $TOP_DIR/local.sh ]]; then
1739 echo "Running user script $TOP_DIR/local.sh"
1740 $TOP_DIR/local.sh
1741fi
1742
jiajun xua9414242012-12-06 16:30:57 +08001743# Check the status of running services
1744service_check
Dean Troyerf5633dd2012-03-28 11:21:40 -05001745
Scott Moserb94f4bf2011-10-07 14:51:07 +00001746# Fin
1747# ===
1748
Dean Troyer471de7a2011-12-27 11:45:55 -06001749set +o xtrace
Scott Moserb94f4bf2011-10-07 14:51:07 +00001750
Dean Troyer7903b792012-09-13 17:16:12 -05001751if [[ -n "$LOGFILE" ]]; then
1752 exec 1>&3
1753 # Force all output to stdout and logs now
Dean Troyerbaa8b422012-09-24 15:02:05 -05001754 exec 1> >( tee -a "${LOGFILE}" ) 2>&1
Dean Troyer7903b792012-09-13 17:16:12 -05001755else
1756 # Force all output to stdout now
1757 exec 1>&3
1758fi
1759
Dean Troyerdf0972c2012-03-07 17:31:03 -06001760
Jesse Andrews24859062011-09-15 21:28:23 -07001761# Using the cloud
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001762# ---------------
Jesse Andrews24859062011-09-15 21:28:23 -07001763
Jesse Andrewse19d8842011-11-01 20:06:55 -07001764echo ""
1765echo ""
1766echo ""
1767
Dean Troyerdf0972c2012-03-07 17:31:03 -06001768# If you installed Horizon on this server you should be able
root40a37002011-09-20 18:06:14 +00001769# to access the site using your browser.
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +00001770if is_service_enabled horizon; then
Dean Troyerdf0972c2012-03-07 17:31:03 -06001771 echo "Horizon is now available at http://$SERVICE_HOST/"
Jesse Andrews24859062011-09-15 21:28:23 -07001772fi
1773
Steve Bakerbad9d892012-10-25 14:49:47 +13001774# Warn that the default flavors have been changed by Heat
1775if is_service_enabled heat; then
1776 echo "Heat has replaced the default flavors. View by running: nova flavor-list"
1777fi
1778
Dean Troyerdf0972c2012-03-07 17:31:03 -06001779# If Keystone is present you can point ``nova`` cli to this server
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +00001780if is_service_enabled key; then
Dean Troyerd835de82012-11-29 17:11:35 -06001781 echo "Keystone is serving at $KEYSTONE_AUTH_PROTOCOL://$SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/"
Dean Troyerdf0972c2012-03-07 17:31:03 -06001782 echo "Examples on using novaclient command line is in exercise.sh"
1783 echo "The default users are: admin and demo"
1784 echo "The password: $ADMIN_PASSWORD"
Jesse Andrews24859062011-09-15 21:28:23 -07001785fi
termie523c4052011-09-28 19:49:40 -05001786
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001787# Echo ``HOST_IP`` - useful for ``build_uec.sh``, which uses dhcp to give the instance an address
Anthony Young1097c7c2011-12-27 23:22:14 -08001788echo "This is your host ip: $HOST_IP"
1789
Dean Troyerdf0972c2012-03-07 17:31:03 -06001790# Warn that ``EXTRA_FLAGS`` needs to be converted to ``EXTRA_OPTS``
Dean Troyerced65172012-03-02 16:36:16 -06001791if [[ -n "$EXTRA_FLAGS" ]]; then
Dean Troyer7903b792012-09-13 17:16:12 -05001792 echo_summary "WARNING: EXTRA_FLAGS is defined and may need to be converted to EXTRA_OPTS"
Dean Troyerced65172012-03-02 16:36:16 -06001793fi
1794
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001795# Indicate how long this took to run (bash maintained variable ``SECONDS``)
Dean Troyer7903b792012-09-13 17:16:12 -05001796echo_summary "stack.sh completed in $SECONDS seconds."