blob: cf99950e1848f28b7806b9ec45b711398e8eb660 [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**,
Nikhil Manchanda0cccad42012-12-03 18:15:09 -07005# **Glance**, **Heat**, **Horizon**, **Keystone**, **Nova**, **Neutron**,
Dean Troyerfc744f92014-01-27 13:45:21 -06006# and **Swift**
Jesse Andrewsba23cc72011-09-11 03:22:13 -07007
Brett Campbell27f29442014-02-19 18:23:16 -08008# This script's options can be changed by setting appropriate environment
9# variables. You can configure things like which git repositories to use,
10# services to enable, OS images to use, etc. Default values are located in the
11# ``stackrc`` file. If you are crafty you can run the script on multiple nodes
12# using shared settings for common resources (eg., mysql or rabbitmq) and build
13# a multi-node developer install.
Jesse Andrews782b9912011-10-02 16:53:21 -040014
Dean Troyer4a43b7b2012-08-28 17:43:40 -050015# To keep this script simple we assume you are running on a recent **Ubuntu**
Martin Falatic5bee0cd2015-01-23 14:10:33 -080016# (14.04 Trusty or newer), **Fedora** (F20 or newer), or **CentOS/RHEL**
17# (7 or newer) machine. (It may work on other platforms but support for those
18# platforms is left to those who added them to DevStack.) It should work in
19# a VM or physical server. Additionally, we maintain a list of ``apt`` and
20# ``rpm`` dependencies and other configuration files in this repo.
Jesse Andrews24859062011-09-15 21:28:23 -070021
Jesse Andrews0e7e8972011-10-02 16:36:54 -040022# Learn more and get the most recent version at http://devstack.org
Jesse Andrews6edd17f2011-09-15 22:19:42 -070023
Jason Dunsmore4e971112013-04-10 10:17:40 -050024# Make sure custom grep options don't get in the way
25unset GREP_OPTIONS
26
YAMAMOTO Takashib4a215c2014-01-10 16:39:32 +090027# Sanitize language settings to avoid commands bailing out
28# with "unsupported locale setting" errors.
29unset LANG
30unset LANGUAGE
31LC_ALL=C
32export LC_ALL
33
Brett Campbell27f29442014-02-19 18:23:16 -080034# Make sure umask is sane
35umask 022
36
Angus Lees7df9d1b2014-07-21 15:35:34 +100037# Not all distros have sbin in PATH for regular users.
38PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
39
Dean Troyerc6c1d432012-03-27 20:59:22 -050040# Keep track of the devstack directory
Jesse Andrews51fb22e2011-10-19 09:24:17 -070041TOP_DIR=$(cd $(dirname "$0") && pwd)
42
Sean Dague53753292014-12-04 19:38:15 -050043# Check for uninitialized variables, a big cause of bugs
44NOUNSET=${NOUNSET:-}
45if [[ -n "$NOUNSET" ]]; then
46 set -o nounset
47fi
48
Dean Troyerd3bf9bd2014-07-25 10:20:19 -050049# Sanity Checks
50# -------------
51
52# Clean up last environment var cache
53if [[ -r $TOP_DIR/.stackenv ]]; then
54 rm $TOP_DIR/.stackenv
55fi
56
57# ``stack.sh`` keeps the list of ``apt`` and ``rpm`` dependencies and config
58# templates and other useful files in the ``files`` subdirectory
59FILES=$TOP_DIR/files
60if [ ! -d $FILES ]; then
61 die $LINENO "missing devstack/files"
62fi
63
64# ``stack.sh`` keeps function libraries here
65# Make sure ``$TOP_DIR/lib`` directory is present
66if [ ! -d $TOP_DIR/lib ]; then
67 die $LINENO "missing devstack/lib"
68fi
69
70# Check if run as root
71# OpenStack is designed to be run as a non-root user; Horizon will fail to run
72# as **root** since Apache will not serve content from **root** user).
73# ``stack.sh`` must not be run as **root**. It aborts and suggests one course of
74# action to create a suitable user account.
75
76if [[ $EUID -eq 0 ]]; then
77 echo "You are running this script as root."
78 echo "Cut it out."
79 echo "Really."
Shuichiro MAKIGAKI3710eec2014-08-28 19:07:09 +090080 echo "If you need an account to run DevStack, do this (as root, heh) to create a non-root account:"
Dean Troyerd3bf9bd2014-07-25 10:20:19 -050081 echo "$TOP_DIR/tools/create-stack-user.sh"
82 exit 1
83fi
84
Dean Troyerd3bf9bd2014-07-25 10:20:19 -050085# Prepare the environment
86# -----------------------
87
Sean Dague53753292014-12-04 19:38:15 -050088# Initialize variables:
89LAST_SPINNER_PID=""
90
Dean Troyer6563a3c2012-01-31 12:11:56 -060091# Import common functions
Dean Troyerc6c1d432012-03-27 20:59:22 -050092source $TOP_DIR/functions
Dean Troyer6563a3c2012-01-31 12:11:56 -060093
Dean Troyer893e6632013-09-13 15:05:51 -050094# Import config functions
95source $TOP_DIR/lib/config
96
Dean Troyer8c2ce6e2015-02-18 14:47:54 -060097# Import 'public' stack.sh functions
98source $TOP_DIR/lib/stack
99
Dean Troyerc6c1d432012-03-27 20:59:22 -0500100# Determine what system we are running on. This provides ``os_VENDOR``,
101# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
Dean Troyera9e0a482012-07-09 14:07:23 -0500102# and ``DISTRO``
103GetDistro
Jesse Andrews6edd17f2011-09-15 22:19:42 -0700104
Dean Troyer48352ee2012-12-12 12:50:38 -0600105# Global Settings
Dean Troyer0e8dced2014-07-25 10:33:21 -0500106# ---------------
Scott Moserf9da5082011-10-07 21:28:00 -0400107
Dean Troyer893e6632013-09-13 15:05:51 -0500108# Check for a ``localrc`` section embedded in ``local.conf`` and extract if
109# ``localrc`` does not already exist
110
111# Phase: local
112rm -f $TOP_DIR/.localrc.auto
113if [[ -r $TOP_DIR/local.conf ]]; then
114 LRC=$(get_meta_section_files $TOP_DIR/local.conf local)
115 for lfile in $LRC; do
116 if [[ "$lfile" == "localrc" ]]; then
117 if [[ -r $TOP_DIR/localrc ]]; then
118 warn $LINENO "localrc and local.conf:[[local]] both exist, using localrc"
119 else
Dean Troyerb8dd27b2013-10-17 12:03:55 -0500120 echo "# Generated file, do not edit" >$TOP_DIR/.localrc.auto
Dean Troyer893e6632013-09-13 15:05:51 -0500121 get_meta_section $TOP_DIR/local.conf local $lfile >>$TOP_DIR/.localrc.auto
122 fi
123 fi
124 done
125fi
126
Shuichiro MAKIGAKI3710eec2014-08-28 19:07:09 +0900127
Dean Troyer1a6d4492013-06-03 16:47:36 -0500128# ``stack.sh`` is customizable by setting environment variables. Override a
129# default setting via export::
Scott Moserf9da5082011-10-07 21:28:00 -0400130#
Terry Wilson428af5a2012-11-01 16:12:39 -0400131# export DATABASE_PASSWORD=anothersecret
Scott Moserf9da5082011-10-07 21:28:00 -0400132# ./stack.sh
133#
Dean Troyer1a6d4492013-06-03 16:47:36 -0500134# or by setting the variable on the command line::
Scott Moserf9da5082011-10-07 21:28:00 -0400135#
Dean Troyer1a6d4492013-06-03 16:47:36 -0500136# DATABASE_PASSWORD=simple ./stack.sh
137#
138# Persistent variables can be placed in a ``localrc`` file::
Scott Moserf9da5082011-10-07 21:28:00 -0400139#
Terry Wilson428af5a2012-11-01 16:12:39 -0400140# DATABASE_PASSWORD=anothersecret
141# DATABASE_USER=hellaroot
Scott Moserf9da5082011-10-07 21:28:00 -0400142#
143# We try to have sensible defaults, so you should be able to run ``./stack.sh``
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500144# in most cases. ``localrc`` is not distributed with DevStack and will never
145# be overwritten by a DevStack update.
Scott Moserf9da5082011-10-07 21:28:00 -0400146#
Dean Troyerdf0972c2012-03-07 17:31:03 -0600147# DevStack distributes ``stackrc`` which contains locations for the OpenStack
Dean Troyercc6b4432013-04-08 15:38:03 -0500148# repositories, branches to configure, and other configuration defaults.
149# ``stackrc`` sources ``localrc`` to allow you to safely override those settings.
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500150
Dean Troyerbbafb1b2012-06-11 16:51:39 -0500151if [[ ! -r $TOP_DIR/stackrc ]]; then
Dean Troyer14fd9792014-07-25 10:34:11 -0500152 die $LINENO "missing $TOP_DIR/stackrc - did you grab more than just stack.sh?"
Dean Troyerbbafb1b2012-06-11 16:51:39 -0500153fi
154source $TOP_DIR/stackrc
Dean Troyerdf0972c2012-03-07 17:31:03 -0600155
Ian Wienandc973e6c2014-11-05 09:52:27 +1100156# Warn users who aren't on an explicitly supported distro, but allow them to
157# override check and attempt installation with ``FORCE=yes ./stack``
Attila Fazekas1f316be2015-01-26 16:39:57 +0100158if [[ ! ${DISTRO} =~ (precise|trusty|7.0|wheezy|sid|testing|jessie|f20|f21|rhel7) ]]; then
Ian Wienandc973e6c2014-11-05 09:52:27 +1100159 echo "WARNING: this script has not been tested on $DISTRO"
160 if [[ "$FORCE" != "yes" ]]; then
161 die $LINENO "If you wish to run this script anyway run with FORCE=yes"
162 fi
163fi
164
Shuichiro MAKIGAKI3710eec2014-08-28 19:07:09 +0900165# Check to see if we are already running DevStack
166# Note that this may fail if USE_SCREEN=False
167if type -p screen > /dev/null && screen -ls | egrep -q "[0-9]\.$SCREEN_NAME"; then
168 echo "You are already running a stack.sh session."
169 echo "To rejoin this session type 'screen -x stack'."
170 echo "To destroy this session, type './unstack.sh'."
171 exit 1
172fi
173
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500174
Dean Troyer48352ee2012-12-12 12:50:38 -0600175# Local Settings
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500176# --------------
177
Dean Troyer48352ee2012-12-12 12:50:38 -0600178# Make sure the proxy config is visible to sub-processes
179export_proxy_variables
Scott Moserf9da5082011-10-07 21:28:00 -0400180
Doug Hellmannf04178f2012-07-05 17:10:03 -0400181# Remove services which were negated in ENABLED_SERVICES
Joe Gordon6fd28112012-11-13 16:55:41 -0800182# using the "-" prefix (e.g., "-rabbit") instead of
Doug Hellmannf04178f2012-07-05 17:10:03 -0400183# calling disable_service().
184disable_negated_services
Chmouel Boudjnahc4cd4142012-06-27 11:01:40 +0200185
Dean Troyera79617c2014-04-13 18:16:54 -0500186# Look for obsolete stuff
Sean Dague53753292014-12-04 19:38:15 -0500187# if [[ ,${ENABLED_SERVICES}, =~ ,"swift", ]]; then
188# echo "FATAL: 'swift' is not supported as a service name"
189# echo "FATAL: Use the actual swift service names to enable them as required:"
190# echo "FATAL: s-proxy s-object s-container s-account"
191# exit 1
192# fi
Dean Troyera79617c2014-04-13 18:16:54 -0500193
Dean Troyerd3bf9bd2014-07-25 10:20:19 -0500194# Configure sudo
195# --------------
Dean Troyer9122e7b2011-10-17 14:07:11 -0500196
Dean Troyer23f69d82013-10-04 12:35:24 -0500197# We're not **root**, make sure ``sudo`` is available
198is_package_installed sudo || install_package sudo
199
200# UEC images ``/etc/sudoers`` does not have a ``#includedir``, add one
201sudo grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers ||
202 echo "#includedir /etc/sudoers.d" | sudo tee -a /etc/sudoers
203
204# Set up devstack sudoers
205TEMPFILE=`mktemp`
206echo "$STACK_USER ALL=(root) NOPASSWD:ALL" >$TEMPFILE
207# Some binaries might be under /sbin or /usr/sbin, so make sure sudo will
208# see them by forcing PATH
209echo "Defaults:$STACK_USER secure_path=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin" >> $TEMPFILE
Adam Gandelmanea2fcb52014-03-17 16:37:56 -0700210echo "Defaults:$STACK_USER !requiretty" >> $TEMPFILE
Dean Troyer23f69d82013-10-04 12:35:24 -0500211chmod 0440 $TEMPFILE
212sudo chown root:root $TEMPFILE
213sudo mv $TEMPFILE /etc/sudoers.d/50_stack_sh
214
Dean Troyer0e8dced2014-07-25 10:33:21 -0500215
216# Configure Distro Repositories
217# -----------------------------
Ian Wienand531aeb72014-02-28 11:24:29 +1100218
Sean Daguee83f7782014-06-23 08:11:05 -0400219# For debian/ubuntu make apt attempt to retry network ops on it's own
220if is_ubuntu; then
Chmouel Boudjnah9246d962014-06-30 12:52:51 +0000221 echo 'APT::Acquire::Retries "20";' | sudo tee /etc/apt/apt.conf.d/80retry >/dev/null
Sean Daguee83f7782014-06-23 08:11:05 -0400222fi
223
Ian Wienand531aeb72014-02-28 11:24:29 +1100224# Some distros need to add repos beyond the defaults provided by the vendor
225# to pick up required packages.
226
Attila Fazekas1f316be2015-01-26 16:39:57 +0100227if is_fedora && [[ $DISTRO == "rhel7" ]]; then
Attila Fazekas6d227a42014-04-09 14:42:42 +0200228 # RHEL requires EPEL for many Open Stack dependencies
Ian Wienand3682b6d2014-10-08 15:37:23 +1100229
Ian Wienanded077b22014-10-22 11:35:29 +1100230 # note we always remove and install latest -- some environments
231 # use snapshot images, and if EPEL version updates they break
232 # unless we update them to latest version.
233 if sudo yum repolist enabled epel | grep -q 'epel'; then
234 uninstall_package epel-release || true
235 fi
236
237 # This trick installs the latest epel-release from a bootstrap
238 # repo, then removes itself (as epel-release installed the
239 # "real" repo).
240 #
241 # you would think that rather than this, you could use
242 # $releasever directly in .repo file we create below. However
243 # RHEL gives a $releasever of "6Server" which breaks the path;
244 # see https://bugzilla.redhat.com/show_bug.cgi?id=1150759
Ian Wienanded077b22014-10-22 11:35:29 +1100245 cat <<EOF | sudo tee /etc/yum.repos.d/epel-bootstrap.repo
246[epel-bootstrap]
Ian Wienand3682b6d2014-10-08 15:37:23 +1100247name=Bootstrap EPEL
Attila Fazekas1f316be2015-01-26 16:39:57 +0100248mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-7&arch=\$basearch
Ian Wienand3682b6d2014-10-08 15:37:23 +1100249failovermethod=priority
250enabled=0
251gpgcheck=0
252EOF
Ian Wienanded077b22014-10-22 11:35:29 +1100253 # bare yum call due to --enablerepo
254 sudo yum --enablerepo=epel-bootstrap -y install epel-release || \
255 die $LINENO "Error installing EPEL repo, cannot continue"
256 # epel rpm has installed it's version
257 sudo rm -f /etc/yum.repos.d/epel-bootstrap.repo
Ian Wienand531aeb72014-02-28 11:24:29 +1100258
259 # ... and also optional to be enabled
260 is_package_installed yum-utils || install_package yum-utils
Attila Fazekas1f316be2015-01-26 16:39:57 +0100261 sudo yum-config-manager --enable rhel-7-server-optional-rpms
Zhang Jinnanfc994262014-12-14 19:19:53 -0500262
Attila Fazekas1f316be2015-01-26 16:39:57 +0100263 RHEL_RDO_REPO_RPM=${RHEL7_RDO_REPO_RPM:-"https://repos.fedorapeople.org/repos/openstack/openstack-juno/rdo-release-juno-1.noarch.rpm"}
264 RHEL_RDO_REPO_ID=${RHEL7_RDO_REPO_ID:-"openstack-juno"}
Zhang Jinnanfc994262014-12-14 19:19:53 -0500265
266 if ! sudo yum repolist enabled $RHEL_RDO_REPO_ID | grep -q $RHEL_RDO_REPO_ID; then
267 echo "RDO repo not detected; installing"
268 yum_install $RHEL_RDO_REPO_RPM || \
269 die $LINENO "Error installing RDO repo, cannot continue"
270 fi
271
Ian Wienand531aeb72014-02-28 11:24:29 +1100272fi
273
Dean Troyer0e8dced2014-07-25 10:33:21 -0500274
275# Configure Target Directories
276# ----------------------------
277
278# Destination path for installation ``DEST``
279DEST=${DEST:-/opt/stack}
Dean Troyer23f69d82013-10-04 12:35:24 -0500280
Dean Troyere26232b2012-06-27 17:55:15 -0500281# Create the destination directory and ensure it is writable by the user
Bob Ball376b6312013-07-29 13:10:25 +0100282# and read/executable by everybody for daemons (e.g. apache run for horizon)
Dean Troyere26232b2012-06-27 17:55:15 -0500283sudo mkdir -p $DEST
Doug Hellmanne7002672013-09-05 08:10:07 -0400284safe_chown -R $STACK_USER $DEST
285safe_chmod 0755 $DEST
Dean Troyere26232b2012-06-27 17:55:15 -0500286
Ian Wienand0488edd2013-04-11 12:04:36 +1000287# a basic test for $DEST path permissions (fatal on error unless skipped)
288check_path_perm_sanity ${DEST}
289
Dean Troyer0e8dced2014-07-25 10:33:21 -0500290# Destination path for service data
291DATA_DIR=${DATA_DIR:-${DEST}/data}
292sudo mkdir -p $DATA_DIR
293safe_chown -R $STACK_USER $DATA_DIR
294
295# Configure proper hostname
Ben Nemec3ee52c82013-12-12 19:26:12 +0000296# Certain services such as rabbitmq require that the local hostname resolves
297# correctly. Make sure it exists in /etc/hosts so that is always true.
298LOCAL_HOSTNAME=`hostname -s`
299if [ -z "`grep ^127.0.0.1 /etc/hosts | grep $LOCAL_HOSTNAME`" ]; then
300 sudo sed -i "s/\(^127.0.0.1.*\)/\1 $LOCAL_HOSTNAME/" /etc/hosts
301fi
302
Ian Wienand531aeb72014-02-28 11:24:29 +1100303
Dean Troyerffd17682014-08-02 16:07:03 -0500304# Configure Logging
305# -----------------
306
307# Set up logging level
Sean Dague53753292014-12-04 19:38:15 -0500308VERBOSE=$(trueorfalse True VERBOSE)
Dean Troyerffd17682014-08-02 16:07:03 -0500309
310# Draw a spinner so the user knows something is happening
311function spinner {
312 local delay=0.75
313 local spinstr='/-\|'
314 printf "..." >&3
315 while [ true ]; do
316 local temp=${spinstr#?}
317 printf "[%c]" "$spinstr" >&3
318 local spinstr=$temp${spinstr%"$temp"}
319 sleep $delay
320 printf "\b\b\b" >&3
321 done
322}
323
324function kill_spinner {
325 if [ ! -z "$LAST_SPINNER_PID" ]; then
326 kill >/dev/null 2>&1 $LAST_SPINNER_PID
327 printf "\b\b\bdone\n" >&3
328 fi
329}
330
331# Echo text to the log file, summary log file and stdout
332# echo_summary "something to say"
333function echo_summary {
334 if [[ -t 3 && "$VERBOSE" != "True" ]]; then
335 kill_spinner
336 echo -n -e $@ >&6
337 spinner &
338 LAST_SPINNER_PID=$!
339 else
340 echo -e $@ >&6
341 fi
342}
343
344# Echo text only to stdout, no log files
345# echo_nolog "something not for the logs"
346function echo_nolog {
347 echo $@ >&3
348}
349
Dean Troyerffd17682014-08-02 16:07:03 -0500350# Set up logging for ``stack.sh``
351# Set ``LOGFILE`` to turn on logging
352# Append '.xxxxxxxx' to the given name to maintain history
353# where 'xxxxxxxx' is a representation of the date the file was created
354TIMESTAMP_FORMAT=${TIMESTAMP_FORMAT:-"%F-%H%M%S"}
Dean Troyerdde41d02014-12-09 17:47:57 -0600355LOGDAYS=${LOGDAYS:-7}
356CURRENT_LOG_TIME=$(date "+$TIMESTAMP_FORMAT")
Dean Troyerffd17682014-08-02 16:07:03 -0500357
Dean Troyerb43b3592015-01-29 12:05:43 -0600358if [[ -n ${LOGDIR:-} ]]; then
359 mkdir -p $LOGDIR
360fi
361
Dean Troyerffd17682014-08-02 16:07:03 -0500362if [[ -n "$LOGFILE" ]]; then
Dean Troyerad5cc982014-12-10 16:35:32 -0600363 # Clean up old log files. Append '.*' to the user-specified
364 # ``LOGFILE`` to match the date in the search template.
Mikhail S Medvedevfc9cc962015-01-20 11:04:48 -0600365 LOGFILE_DIR="${LOGFILE%/*}" # dirname
366 LOGFILE_NAME="${LOGFILE##*/}" # basename
367 mkdir -p $LOGFILE_DIR
368 find $LOGFILE_DIR -maxdepth 1 -name $LOGFILE_NAME.\* -mtime +$LOGDAYS -exec rm {} \;
Dean Troyerffd17682014-08-02 16:07:03 -0500369 LOGFILE=$LOGFILE.${CURRENT_LOG_TIME}
Dean Troyerad5cc982014-12-10 16:35:32 -0600370 SUMFILE=$LOGFILE.summary.${CURRENT_LOG_TIME}
Dean Troyerffd17682014-08-02 16:07:03 -0500371
372 # Redirect output according to config
373
374 # Set fd 3 to a copy of stdout. So we can set fd 1 without losing
375 # stdout later.
376 exec 3>&1
377 if [[ "$VERBOSE" == "True" ]]; then
378 # Set fd 1 and 2 to write the log file
379 exec 1> >( $TOP_DIR/tools/outfilter.py -v -o "${LOGFILE}" ) 2>&1
380 # Set fd 6 to summary log file
381 exec 6> >( $TOP_DIR/tools/outfilter.py -o "${SUMFILE}" )
382 else
383 # Set fd 1 and 2 to primary logfile
384 exec 1> >( $TOP_DIR/tools/outfilter.py -o "${LOGFILE}" ) 2>&1
385 # Set fd 6 to summary logfile and stdout
386 exec 6> >( $TOP_DIR/tools/outfilter.py -v -o "${SUMFILE}" >&3 )
387 fi
388
389 echo_summary "stack.sh log $LOGFILE"
390 # Specified logfile name always links to the most recent log
Mikhail S Medvedevfc9cc962015-01-20 11:04:48 -0600391 ln -sf $LOGFILE $LOGFILE_DIR/$LOGFILE_NAME
392 ln -sf $SUMFILE $LOGFILE_DIR/$LOGFILE_NAME.summary
Dean Troyerffd17682014-08-02 16:07:03 -0500393else
394 # Set up output redirection without log files
395 # Set fd 3 to a copy of stdout. So we can set fd 1 without losing
396 # stdout later.
397 exec 3>&1
398 if [[ "$VERBOSE" != "True" ]]; then
399 # Throw away stdout and stderr
400 exec 1>/dev/null 2>&1
401 fi
402 # Always send summary fd to original stdout
403 exec 6> >( $TOP_DIR/tools/outfilter.py -v >&3 )
404fi
405
406# Set up logging of screen windows
407# Set ``SCREEN_LOGDIR`` to turn on logging of screen windows to the
408# directory specified in ``SCREEN_LOGDIR``, we will log to the the file
409# ``screen-$SERVICE_NAME-$TIMESTAMP.log`` in that dir and have a link
410# ``screen-$SERVICE_NAME.log`` to the latest log file.
411# Logs are kept for as long specified in ``LOGDAYS``.
Dean Troyerdde41d02014-12-09 17:47:57 -0600412# This is deprecated....logs go in ``LOGDIR``, only symlinks will be here now.
Dean Troyerffd17682014-08-02 16:07:03 -0500413if [[ -n "$SCREEN_LOGDIR" ]]; then
414
415 # We make sure the directory is created.
416 if [[ -d "$SCREEN_LOGDIR" ]]; then
417 # We cleanup the old logs
418 find $SCREEN_LOGDIR -maxdepth 1 -name screen-\*.log -mtime +$LOGDAYS -exec rm {} \;
419 else
420 mkdir -p $SCREEN_LOGDIR
421 fi
422fi
423
424
425# Configure Error Traps
426# ---------------------
427
428# Kill background processes on exit
429trap exit_trap EXIT
430function exit_trap {
431 local r=$?
432 jobs=$(jobs -p)
433 # Only do the kill when we're logging through a process substitution,
434 # which currently is only to verbose logfile
435 if [[ -n $jobs && -n "$LOGFILE" && "$VERBOSE" == "True" ]]; then
436 echo "exit_trap: cleaning up child processes"
437 kill 2>&1 $jobs
438 fi
439
440 # Kill the last spinner process
441 kill_spinner
442
443 if [[ $r -ne 0 ]]; then
444 echo "Error on exit"
445 if [[ -z $LOGDIR ]]; then
446 $TOP_DIR/tools/worlddump.py
447 else
448 $TOP_DIR/tools/worlddump.py -d $LOGDIR
449 fi
450 fi
451
452 exit $r
453}
454
455# Exit on any errors so that errors don't compound
456trap err_trap ERR
457function err_trap {
458 local r=$?
459 set +o xtrace
460 if [[ -n "$LOGFILE" ]]; then
461 echo "${0##*/} failed: full log in $LOGFILE"
462 else
463 echo "${0##*/} failed"
464 fi
465 exit $r
466}
467
468# Begin trapping error exit codes
469set -o errexit
470
471# Print the commands being run so that we can see the command that triggers
472# an error. It is also useful for following along as the install occurs.
473set -o xtrace
474
Jamie Lennoxbd24a8d2013-09-20 16:26:42 +1000475# Reset the bundle of CA certificates
476SSL_BUNDLE_FILE="$DATA_DIR/ca-bundle.pem"
477rm -f $SSL_BUNDLE_FILE
478
Dean Troyer0e8dced2014-07-25 10:33:21 -0500479# Import common services (database, message queue) configuration
480source $TOP_DIR/lib/database
481source $TOP_DIR/lib/rpc_backend
482
483# Make sure we only have one rpc backend enabled,
484# and the specified rpc backend is available on your platform.
485check_rpc_backend
486
Rob Crittenden18d47782014-03-19 17:47:42 -0400487# Service to enable with SSL if USE_SSL is True
488SSL_ENABLED_SERVICES="key,nova,cinder,glance,s-proxy,neutron"
489
490if is_service_enabled tls-proxy && [ "$USE_SSL" == "True" ]; then
491 die $LINENO "tls-proxy and SSL are mutually exclusive"
492fi
Dean Troyerd81a0272012-08-31 18:04:55 -0500493
494# Configure Projects
495# ==================
496
Brant Knudson0049c0c2014-01-16 18:16:48 -0600497# Import apache functions
zhang-hared98a5d02013-06-21 18:18:02 +0800498source $TOP_DIR/lib/apache
Brant Knudson0049c0c2014-01-16 18:16:48 -0600499
500# Import TLS functions
Dean Troyerc83a7e12012-11-29 11:47:58 -0600501source $TOP_DIR/lib/tls
Brant Knudson0049c0c2014-01-16 18:16:48 -0600502
503# Source project function libraries
Sean Dague0392a102013-07-31 13:07:45 -0400504source $TOP_DIR/lib/infra
Sean Dague1b6b5312013-07-31 06:46:34 -0400505source $TOP_DIR/lib/oslo
Daniel Genind4708672014-10-31 15:01:29 -0400506source $TOP_DIR/lib/lvm
Sean Dagueb562e6a2012-11-19 16:00:01 -0500507source $TOP_DIR/lib/horizon
Dean Troyerd81a0272012-08-31 18:04:55 -0500508source $TOP_DIR/lib/keystone
Dean Troyer73f6f252012-09-17 11:22:21 -0500509source $TOP_DIR/lib/glance
Dean Troyerbf67c192012-09-21 15:09:37 -0500510source $TOP_DIR/lib/nova
Dean Troyerd81a0272012-08-31 18:04:55 -0500511source $TOP_DIR/lib/cinder
Attila Fazekasece6a332012-11-29 14:19:41 +0100512source $TOP_DIR/lib/swift
Dean Troyerd81a0272012-08-31 18:04:55 -0500513source $TOP_DIR/lib/ceilometer
514source $TOP_DIR/lib/heat
Mark McClainb05c8762013-07-06 23:29:39 -0400515source $TOP_DIR/lib/neutron
Brad Topolf127e2f2013-01-22 10:17:50 -0600516source $TOP_DIR/lib/ldap
Joe Gordone0b08d02014-08-20 00:34:55 -0700517source $TOP_DIR/lib/dstat
Dean Troyerd81a0272012-08-31 18:04:55 -0500518
Sean Dague2c65e712014-12-18 09:44:56 -0500519# Clone all external plugins
520fetch_plugins
521
Dean Troyercdf3d762013-10-15 09:42:43 -0500522# Extras Source
523# --------------
524
525# Phase: source
Sean Dague2c65e712014-12-18 09:44:56 -0500526run_phase source
Dean Troyercdf3d762013-10-15 09:42:43 -0500527
Dean Troyerb7490da2013-03-18 16:07:56 -0500528# Interactive Configuration
529# -------------------------
530
531# Do all interactive config up front before the logging spew begins
James E. Blair213c4162012-11-06 09:38:36 +0100532
Anthony Young7a549f42011-10-12 07:13:13 +0000533# Generic helper to configure passwords
534function read_password {
Dean Troyer7903b792012-09-13 17:16:12 -0500535 XTRACE=$(set +o | grep xtrace)
Anthony Young7a549f42011-10-12 07:13:13 +0000536 set +o xtrace
537 var=$1; msg=$2
538 pw=${!var}
539
Sahid Orentino Ferdjaoui9e032c22014-02-10 11:36:25 +0100540 if [[ -f $RC_DIR/localrc ]]; then
541 localrc=$TOP_DIR/localrc
542 else
543 localrc=$TOP_DIR/.localrc.auto
544 fi
Anthony Young6015c822011-10-12 07:17:11 +0000545
Anthony Young7a549f42011-10-12 07:13:13 +0000546 # If the password is not defined yet, proceed to prompt user for a password.
547 if [ ! $pw ]; then
548 # If there is no localrc file, create one
Anthony Youngb4db2252011-10-12 14:08:08 -0700549 if [ ! -e $localrc ]; then
550 touch $localrc
Anthony Young7a549f42011-10-12 07:13:13 +0000551 fi
552
Vishvananda Ishaya9b353672011-10-20 10:07:10 -0700553 # Presumably if we got this far it can only be that our localrc is missing
Anthony Young7a549f42011-10-12 07:13:13 +0000554 # the required password. Prompt user for a password and write to localrc.
Anthony Youngb4db2252011-10-12 14:08:08 -0700555 echo ''
556 echo '################################################################################'
557 echo $msg
558 echo '################################################################################'
Dean Troyer4e6a2b72011-12-29 17:27:45 -0600559 echo "This value will be written to your localrc file so you don't have to enter it "
560 echo "again. Use only alphanumeric characters."
Anthony Youngb4db2252011-10-12 14:08:08 -0700561 echo "If you leave this blank, a random default value will be used."
Dean Troyer4e6a2b72011-12-29 17:27:45 -0600562 pw=" "
563 while true; do
564 echo "Enter a password now:"
565 read -e $var
566 pw=${!var}
567 [[ "$pw" = "`echo $pw | tr -cd [:alnum:]`" ]] && break
568 echo "Invalid chars in password. Try again:"
569 done
Anthony Youngb4db2252011-10-12 14:08:08 -0700570 if [ ! $pw ]; then
Attila Fazekasf71b5002014-05-28 09:52:22 +0200571 pw=$(generate_hex_string 10)
Anthony Young7a549f42011-10-12 07:13:13 +0000572 fi
Anthony Youngb4db2252011-10-12 14:08:08 -0700573 eval "$var=$pw"
574 echo "$var=$pw" >> $localrc
Anthony Young7a549f42011-10-12 07:13:13 +0000575 fi
Dean Troyer7903b792012-09-13 17:16:12 -0500576 $XTRACE
Anthony Young7a549f42011-10-12 07:13:13 +0000577}
578
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500579
Dean Troyerb9182d62012-11-07 12:31:34 -0600580# Database Configuration
Dean Troyerb9182d62012-11-07 12:31:34 -0600581
Dean Troyerafc29fe2013-02-07 15:56:24 -0600582# To select between database backends, add the following to ``localrc``:
Terry Wilson428af5a2012-11-01 16:12:39 -0400583#
Dean Troyerafc29fe2013-02-07 15:56:24 -0600584# disable_service mysql
585# enable_service postgresql
Terry Wilson428af5a2012-11-01 16:12:39 -0400586#
Dean Troyerafc29fe2013-02-07 15:56:24 -0600587# The available database backends are listed in ``DATABASE_BACKENDS`` after
588# ``lib/database`` is sourced. ``mysql`` is the default.
Terry Wilson428af5a2012-11-01 16:12:39 -0400589
Daniel P. Berrangea99e5c92015-02-11 17:25:32 +0000590initialize_database_backends && echo "Using $DATABASE_TYPE database backend" || echo "No database enabled"
Terry Wilson428af5a2012-11-01 16:12:39 -0400591
Dean Troyerb9182d62012-11-07 12:31:34 -0600592
Dean Troyerb7490da2013-03-18 16:07:56 -0500593# Queue Configuration
Jesse Andrews782b9912011-10-02 16:53:21 -0400594
Anthony Younga8416442011-09-13 20:07:44 -0700595# Rabbit connection info
Joe Gordonf6287c22014-12-16 13:32:41 -0800596# In multi node devstack, second node needs RABBIT_USERID, but rabbit
597# isn't enabled.
598RABBIT_USERID=${RABBIT_USERID:-stackrabbit}
Russell Bryant4a221452012-03-13 13:44:12 -0400599if is_service_enabled rabbit; then
Bob Balle309e5a2014-04-01 16:28:36 +0100600 RABBIT_HOST=${RABBIT_HOST:-$SERVICE_HOST}
Russell Bryant4a221452012-03-13 13:44:12 -0400601 read_password RABBIT_PASSWORD "ENTER A PASSWORD TO USE FOR RABBIT."
602fi
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700603
Dean Troyerb7490da2013-03-18 16:07:56 -0500604
605# Keystone
606
Dean Troyer5ce44cd2015-02-12 22:18:33 -0600607if is_service_enabled keystone; then
Dean Troyerb7490da2013-03-18 16:07:56 -0500608 # The ``SERVICE_TOKEN`` is used to bootstrap the Keystone database. It is
609 # just a string and is not a 'real' Keystone token.
610 read_password SERVICE_TOKEN "ENTER A SERVICE_TOKEN TO USE FOR THE SERVICE ADMIN TOKEN."
611 # Services authenticate to Identity with servicename/``SERVICE_PASSWORD``
612 read_password SERVICE_PASSWORD "ENTER A SERVICE_PASSWORD TO USE FOR THE SERVICE AUTHENTICATION."
613 # Horizon currently truncates usernames and passwords at 20 characters
614 read_password ADMIN_PASSWORD "ENTER A PASSWORD TO USE FOR HORIZON AND KEYSTONE (20 CHARS OR LESS)."
615
616 # Keystone can now optionally install OpenLDAP by enabling the ``ldap``
617 # service in ``localrc`` (e.g. ``enable_service ldap``).
618 # To clean out the Keystone contents in OpenLDAP set ``KEYSTONE_CLEAR_LDAP``
619 # to ``yes`` (e.g. ``KEYSTONE_CLEAR_LDAP=yes``) in ``localrc``. To enable the
620 # Keystone Identity Driver (``keystone.identity.backends.ldap.Identity``)
621 # set ``KEYSTONE_IDENTITY_BACKEND`` to ``ldap`` (e.g.
622 # ``KEYSTONE_IDENTITY_BACKEND=ldap``) in ``localrc``.
623
624 # only request ldap password if the service is enabled
625 if is_service_enabled ldap; then
626 read_password LDAP_PASSWORD "ENTER A PASSWORD TO USE FOR LDAP"
Chmouel Boudjnah6ae9ea52012-07-05 06:50:51 +0000627 fi
Dean Troyerb7490da2013-03-18 16:07:56 -0500628fi
629
630
631# Swift
632
633if is_service_enabled s-proxy; then
Chmouel Boudjnah77b0e1d2012-02-29 16:55:43 +0000634 # We only ask for Swift Hash if we have enabled swift service.
Dean Troyerb9182d62012-11-07 12:31:34 -0600635 # ``SWIFT_HASH`` is a random unique string for a swift cluster that
Chmouel Boudjnahb2857e42011-11-03 16:19:14 +0100636 # can never change.
637 read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH."
Jim Rollenhagenabbb0e92014-08-05 18:01:48 +0000638
639 if [[ -z "$SWIFT_TEMPURL_KEY" ]] && [[ "$SWIFT_ENABLE_TEMPURLS" == "True" ]]; then
640 read_password SWIFT_TEMPURL_KEY "ENTER A KEY FOR SWIFT TEMPURLS."
641 fi
Chmouel Boudjnahb2857e42011-11-03 16:19:14 +0100642fi
Vishvananda Ishaya5f039322011-11-05 16:12:20 -0700643
Dean Troyerdf0972c2012-03-07 17:31:03 -0600644
Jesse Andrews30f68e92011-09-13 00:59:54 -0700645# Install Packages
Jesse Andrewsd74257d2011-09-13 01:24:50 -0700646# ================
Dean Troyer7d28a0e2012-06-27 17:55:52 -0500647
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500648# OpenStack uses a fair number of other projects.
Jesse Andrews30f68e92011-09-13 00:59:54 -0700649
Dean Troyer7d28a0e2012-06-27 17:55:52 -0500650# Install package requirements
Dean Troyer48352ee2012-12-12 12:50:38 -0600651# Source it so the entire environment is available
Dean Troyer7903b792012-09-13 17:16:12 -0500652echo_summary "Installing package prerequisites"
Dean Troyer48352ee2012-12-12 12:50:38 -0600653source $TOP_DIR/tools/install_prereqs.sh
Monty Taylor47f02062012-07-26 11:09:24 -0500654
Dean Troyer62d1d692013-08-01 17:40:40 -0500655# Configure an appropriate python environment
Arata Notsu8b5d3cf2013-10-17 21:42:49 +0900656if [[ "$OFFLINE" != "True" ]]; then
Sean Dague53753292014-12-04 19:38:15 -0500657 PYPI_ALTERNATIVE_URL=${PYPI_ALTERNATIVE_URL:-""} $TOP_DIR/tools/install_pip.sh
Arata Notsu8b5d3cf2013-10-17 21:42:49 +0900658fi
Dean Troyer1a6d4492013-06-03 16:47:36 -0500659
Joe Gordon981ed292014-12-15 21:11:20 -0800660TRACK_DEPENDS=${TRACK_DEPENDS:-False}
661
662# Install python packages into a virtualenv so that we can track them
663if [[ $TRACK_DEPENDS = True ]]; then
664 echo_summary "Installing Python packages into a virtualenv $DEST/.venv"
665 pip_install -U virtualenv
666
667 rm -rf $DEST/.venv
668 virtualenv --system-site-packages $DEST/.venv
669 source $DEST/.venv/bin/activate
670 $DEST/.venv/bin/pip freeze > $DEST/requires-pre-pip
671fi
672
Gael Chamoulaudd3121f62014-07-24 23:53:02 +0200673# Do the ugly hacks for broken packages and distros
Dean Troyer04a35112014-08-15 14:03:52 -0500674source $TOP_DIR/tools/fixup_stuff.sh
Dean Troyer9acc12a2013-08-09 15:09:31 -0500675
Dean Troyer5c3a63e2014-07-09 11:27:42 -0500676
Dean Troyerb1d8e8e2015-02-16 13:58:35 -0600677# Virtual Environment
678# -------------------
679
680# Temporary hack for testing
681# This belongs in d-g functions.sh setup_host() or devstack-vm-gate.sh
682if [[ -d /var/cache/pip ]]; then
683 sudo chown -R $STACK_USER:$STACK_USER /var/cache/pip
684fi
685
686# Pre-build some problematic wheels
687if [[ ! -d ${WHEELHOUSE:-} ]]; then
688 source tools/build_wheels.sh
689fi
690
691
Dean Troyer5c3a63e2014-07-09 11:27:42 -0500692# Extras Pre-install
693# ------------------
694
695# Phase: pre-install
Sean Dague2c65e712014-12-18 09:44:56 -0500696run_phase stack pre-install
Dean Troyer5c3a63e2014-07-09 11:27:42 -0500697
Dean Troyer62d1d692013-08-01 17:40:40 -0500698install_rpc_backend
699
700if is_service_enabled $DATABASE_BACKENDS; then
701 install_database
702fi
703
704if is_service_enabled neutron; then
705 install_neutron_agent_packages
706fi
707
Dean Troyerfe51a902013-04-01 15:48:44 -0500708# Check Out and Install Source
709# ----------------------------
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500710
Dean Troyer7903b792012-09-13 17:16:12 -0500711echo_summary "Installing OpenStack project source"
712
Sean Dague0392a102013-07-31 13:07:45 -0400713# Install required infra support libraries
714install_infra
Monty Taylor5e159492013-05-08 14:29:52 -0400715
Sean Dague1b6b5312013-07-31 06:46:34 -0400716# Install oslo libraries that have graduated
717install_oslo
718
Dean Troyerfe51a902013-04-01 15:48:44 -0500719# Install clients libraries
Dean Troyerd81a0272012-08-31 18:04:55 -0500720install_keystoneclient
Dean Troyer73f6f252012-09-17 11:22:21 -0500721install_glanceclient
Dean Troyer253a1a32013-04-01 18:23:22 -0500722install_cinderclient
Dean Troyerbf67c192012-09-21 15:09:37 -0500723install_novaclient
Sean Dague75195b52013-07-25 15:38:09 -0400724if is_service_enabled swift glance horizon; then
Dean Troyerfe51a902013-04-01 15:48:44 -0500725 install_swiftclient
726fi
Sean Dague75195b52013-07-25 15:38:09 -0400727if is_service_enabled neutron nova horizon; then
Mark McClainb05c8762013-07-06 23:29:39 -0400728 install_neutronclient
Dean Troyerfe51a902013-04-01 15:48:44 -0500729fi
Sean Dague75195b52013-07-25 15:38:09 -0400730if is_service_enabled heat horizon; then
731 install_heatclient
732fi
Dean Troyerfe51a902013-04-01 15:48:44 -0500733
Morgan Fainberg58936fd2014-06-24 12:26:07 -0700734# Install middleware
735install_keystonemiddleware
736
Dean Troyer9f61d292012-11-26 18:56:20 +0000737
Dean Troyer5ce44cd2015-02-12 22:18:33 -0600738if is_service_enabled keystone; then
Bartosz Górski0abde392014-02-28 14:15:19 +0100739 if [ "$KEYSTONE_AUTH_HOST" == "$SERVICE_HOST" ]; then
Dean Troyer8c2ce6e2015-02-18 14:47:54 -0600740 stack_install_service keystone
Bartosz Górski0abde392014-02-28 14:15:19 +0100741 configure_keystone
742 fi
Jesse Andrews38df1222011-11-20 09:55:44 -0800743fi
Attila Fazekasece6a332012-11-29 14:19:41 +0100744
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100745if is_service_enabled s-proxy; then
Dean Troyer8c2ce6e2015-02-18 14:47:54 -0600746 stack_install_service swift
Dean Troyerfe51a902013-04-01 15:48:44 -0500747 configure_swift
748
rahmu9d2647a2013-04-24 10:40:07 +0200749 # swift3 middleware to provide S3 emulation to Swift
Chmouel Boudjnah6ae9ea52012-07-05 06:50:51 +0000750 if is_service_enabled swift3; then
rahmu9d2647a2013-04-24 10:40:07 +0200751 # replace the nova-objectstore port by the swift port
752 S3_SERVICE_PORT=8080
Chmouel Boudjnah6ae9ea52012-07-05 06:50:51 +0000753 git_clone $SWIFT3_REPO $SWIFT3_DIR $SWIFT3_BRANCH
Dean Troyerfe51a902013-04-01 15:48:44 -0500754 setup_develop $SWIFT3_DIR
Chmouel Boudjnah6ae9ea52012-07-05 06:50:51 +0000755 fi
James E. Blaire7ce24f2011-11-10 13:05:13 -0800756fi
Attila Fazekasece6a332012-11-29 14:19:41 +0100757
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000758if is_service_enabled g-api n-api; then
James E. Blaire7ce24f2011-11-10 13:05:13 -0800759 # image catalog service
Dean Troyer8c2ce6e2015-02-18 14:47:54 -0600760 stack_install_service glance
Dean Troyerfe51a902013-04-01 15:48:44 -0500761 configure_glance
James E. Blaire7ce24f2011-11-10 13:05:13 -0800762fi
Dean Troyerfe51a902013-04-01 15:48:44 -0500763
764if is_service_enabled cinder; then
Dean Troyer8c2ce6e2015-02-18 14:47:54 -0600765 stack_install_service cinder
Dean Troyerfe51a902013-04-01 15:48:44 -0500766 configure_cinder
767fi
768
Mark McClainb05c8762013-07-06 23:29:39 -0400769if is_service_enabled neutron; then
Dean Troyer8c2ce6e2015-02-18 14:47:54 -0600770 stack_install_service neutron
Mark McClainb05c8762013-07-06 23:29:39 -0400771 install_neutron_third_party
Dean Troyerfe51a902013-04-01 15:48:44 -0500772fi
773
Dean Troyerbf67c192012-09-21 15:09:37 -0500774if is_service_enabled nova; then
775 # compute service
Dean Troyer8c2ce6e2015-02-18 14:47:54 -0600776 stack_install_service nova
Dean Troyerfe51a902013-04-01 15:48:44 -0500777 cleanup_nova
778 configure_nova
Dean Troyerbf67c192012-09-21 15:09:37 -0500779fi
Dean Troyerfe51a902013-04-01 15:48:44 -0500780
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +0000781if is_service_enabled horizon; then
Zhenguo Niue385d1e2014-03-12 16:58:12 +0800782 # django openstack_auth
783 install_django_openstack_auth
Sean Dagueb562e6a2012-11-19 16:00:01 -0500784 # dashboard
Dean Troyer8c2ce6e2015-02-18 14:47:54 -0600785 stack_install_service horizon
Dean Troyerfe51a902013-04-01 15:48:44 -0500786 configure_horizon
James E. Blaire7ce24f2011-11-10 13:05:13 -0800787fi
Dean Troyerfe51a902013-04-01 15:48:44 -0500788
John H. Tran93361642012-07-26 11:22:05 -0700789if is_service_enabled ceilometer; then
Yunhong, Jiange583d9b2013-01-09 09:33:07 +0800790 install_ceilometerclient
Dean Troyer8c2ce6e2015-02-18 14:47:54 -0600791 stack_install_service ceilometer
Attila Fazekas12bb53b2013-07-25 23:02:48 +0200792 echo_summary "Configuring Ceilometer"
793 configure_ceilometer
John H. Tran93361642012-07-26 11:22:05 -0700794fi
Dean Troyer4a43b7b2012-08-28 17:43:40 -0500795
Steve Bakerbfdad752012-08-18 09:00:42 +1200796if is_service_enabled heat; then
Dean Troyer8c2ce6e2015-02-18 14:47:54 -0600797 stack_install_service heat
Steve Baker315971d2014-05-27 12:24:18 +1200798 install_heat_other
Steve Bakerc3249082013-04-09 13:41:47 +1200799 cleanup_heat
Steve Bakerbfdad752012-08-18 09:00:42 +1200800 configure_heat
801fi
Dean Troyerb7490da2013-03-18 16:07:56 -0500802
Rob Crittenden18d47782014-03-19 17:47:42 -0400803if is_service_enabled tls-proxy || [ "$USE_SSL" == "True" ]; then
Dean Troyerfe51a902013-04-01 15:48:44 -0500804 configure_CA
805 init_CA
806 init_cert
807 # Add name to /etc/hosts
808 # don't be naive and add to existing line!
Dean Troyer67787e62012-05-02 11:48:15 -0500809fi
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700810
Dean Troyercdf3d762013-10-15 09:42:43 -0500811# Extras Install
812# --------------
813
814# Phase: install
Sean Dague2c65e712014-12-18 09:44:56 -0500815run_phase stack install
Dean Troyercdf3d762013-10-15 09:42:43 -0500816
Ihar Hrachyshka1ffa3322015-02-20 16:23:15 +0100817
818# install the OpenStack client, needed for most setup commands
819if use_library_from_git "python-openstackclient"; then
820 git_clone_by_name "python-openstackclient"
821 setup_dev_lib "python-openstackclient"
822else
823 pip_install 'python-openstackclient>=1.0.2'
824fi
825
826
Dean Troyercc6b4432013-04-08 15:38:03 -0500827if [[ $TRACK_DEPENDS = True ]]; then
Monty Taylor47f02062012-07-26 11:09:24 -0500828 $DEST/.venv/bin/pip freeze > $DEST/requires-post-pip
Dean Troyercc6b4432013-04-08 15:38:03 -0500829 if ! diff -Nru $DEST/requires-pre-pip $DEST/requires-post-pip > $DEST/requires.diff; then
DennyZhange8fa8532013-11-03 12:22:04 -0600830 echo "Detect some changes for installed packages of pip, in depend tracking mode"
Monty Taylor47f02062012-07-26 11:09:24 -0500831 cat $DEST/requires.diff
832 fi
833 echo "Ran stack.sh in depend tracking mode, bailing out now"
834 exit 0
835fi
Dean Troyerdf0972c2012-03-07 17:31:03 -0600836
Dean Troyerb7490da2013-03-18 16:07:56 -0500837
Dean Troyerff603ef2011-11-22 17:48:10 -0600838# Syslog
Dean Troyerdf0972c2012-03-07 17:31:03 -0600839# ------
Dean Troyerff603ef2011-11-22 17:48:10 -0600840
841if [[ $SYSLOG != "False" ]]; then
Dean Troyerff603ef2011-11-22 17:48:10 -0600842 if [[ "$SYSLOG_HOST" = "$HOST_IP" ]]; then
843 # Configure the master host to receive
844 cat <<EOF >/tmp/90-stack-m.conf
845\$ModLoad imrelp
846\$InputRELPServerRun $SYSLOG_PORT
847EOF
848 sudo mv /tmp/90-stack-m.conf /etc/rsyslog.d
849 else
850 # Set rsyslog to send to remote host
851 cat <<EOF >/tmp/90-stack-s.conf
852*.* :omrelp:$SYSLOG_HOST:$SYSLOG_PORT
853EOF
854 sudo mv /tmp/90-stack-s.conf /etc/rsyslog.d
855 fi
cloudnulle4859f02013-05-28 14:10:58 -0500856
857 RSYSLOGCONF="/etc/rsyslog.conf"
858 if [ -f $RSYSLOGCONF ]; then
859 sudo cp -b $RSYSLOGCONF $RSYSLOGCONF.bak
860 if [[ $(grep '$SystemLogRateLimitBurst' $RSYSLOGCONF) ]]; then
861 sudo sed -i 's/$SystemLogRateLimitBurst\ .*/$SystemLogRateLimitBurst\ 0/' $RSYSLOGCONF
862 else
863 sudo sed -i '$ i $SystemLogRateLimitBurst\ 0' $RSYSLOGCONF
864 fi
865 if [[ $(grep '$SystemLogRateLimitInterval' $RSYSLOGCONF) ]]; then
866 sudo sed -i 's/$SystemLogRateLimitInterval\ .*/$SystemLogRateLimitInterval\ 0/' $RSYSLOGCONF
867 else
868 sudo sed -i '$ i $SystemLogRateLimitInterval\ 0' $RSYSLOGCONF
869 fi
870 fi
871
Dean Troyer7903b792012-09-13 17:16:12 -0500872 echo_summary "Starting rsyslog"
Dean Troyer13dc5cc2012-03-27 14:50:45 -0500873 restart_service rsyslog
Dean Troyerff603ef2011-11-22 17:48:10 -0600874fi
875
Dean Troyerdf0972c2012-03-07 17:31:03 -0600876
Joe Gordone5d92382012-09-13 17:19:03 -0700877# Finalize queue installation
878# ----------------------------
Akihiro MOTOKIb0f1c382013-01-13 17:58:12 +0900879restart_rpc_backend
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700880
Dean Troyerdf0972c2012-03-07 17:31:03 -0600881
Jamie Lennoxbd24a8d2013-09-20 16:26:42 +1000882# Export Certicate Authority Bundle
883# ---------------------------------
884
885# If certificates were used and written to the SSL bundle file then these
886# should be exported so clients can validate their connections.
887
888if [ -f $SSL_BUNDLE_FILE ]; then
889 export OS_CACERT=$SSL_BUNDLE_FILE
890fi
891
892
Terry Wilson428af5a2012-11-01 16:12:39 -0400893# Configure database
894# ------------------
Dean Troyerb9182d62012-11-07 12:31:34 -0600895
Terry Wilson428af5a2012-11-01 16:12:39 -0400896if is_service_enabled $DATABASE_BACKENDS; then
897 configure_database
Jesse Andrews24859062011-09-15 21:28:23 -0700898fi
899
Dean Troyerb9182d62012-11-07 12:31:34 -0600900
901# Configure screen
902# ----------------
903
Sean Dague53753292014-12-04 19:38:15 -0500904USE_SCREEN=$(trueorfalse True USE_SCREEN)
Dean Troyer681f3fd2013-02-27 19:00:39 -0600905if [[ "$USE_SCREEN" == "True" ]]; then
906 # Create a new named screen to run processes in
907 screen -d -m -S $SCREEN_NAME -t shell -s /bin/bash
908 sleep 1
909
910 # Set a reasonable status bar
Ed Cranfordff72c502015-01-21 16:42:42 -0600911 SCREEN_HARDSTATUS=${SCREEN_HARDSTATUS:-}
Dean Troyer681f3fd2013-02-27 19:00:39 -0600912 if [ -z "$SCREEN_HARDSTATUS" ]; then
913 SCREEN_HARDSTATUS='%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})'
914 fi
915 screen -r $SCREEN_NAME -X hardstatus alwayslastline "$SCREEN_HARDSTATUS"
Steven Dake30396572013-06-30 16:11:54 -0700916 screen -r $SCREEN_NAME -X setenv PROMPT_COMMAND /bin/true
Josh Kearney0a7a41e2012-04-04 17:47:56 -0500917fi
918
Jiajun Liu61bb2c12012-10-19 09:48:30 +0800919# Clear screen rc file
920SCREENRC=$TOP_DIR/$SCREEN_NAME-screenrc
921if [[ -e $SCREENRC ]]; then
Jiajun Liu8e58c072013-07-17 06:41:50 +0000922 rm -f $SCREENRC
Jiajun Liu61bb2c12012-10-19 09:48:30 +0800923fi
Dean Troyerb9182d62012-11-07 12:31:34 -0600924
jiajun xua9414242012-12-06 16:30:57 +0800925# Initialize the directory for service status check
926init_service_check
Dean Troyer7d28a0e2012-06-27 17:55:52 -0500927
Sean Dague78096b52014-02-25 10:23:04 -0500928# Dstat
Dean Troyer1a6d4492013-06-03 16:47:36 -0500929# -------
930
Sean Daguef1eb0472014-02-11 17:28:56 -0500931# A better kind of sysstat, with the top process per time slice
Joe Gordone0b08d02014-08-20 00:34:55 -0700932start_dstat
Sean Dague062cdaf2014-02-10 22:24:49 -0500933
Dean Troyer893e6632013-09-13 15:05:51 -0500934# Start Services
935# ==============
936
Dean Troyerd81a0272012-08-31 18:04:55 -0500937# Keystone
938# --------
939
Dean Troyer5ce44cd2015-02-12 22:18:33 -0600940if is_service_enabled keystone; then
Dean Troyer7903b792012-09-13 17:16:12 -0500941 echo_summary "Starting Keystone"
Bartosz Górski0abde392014-02-28 14:15:19 +0100942
943 if [ "$KEYSTONE_AUTH_HOST" == "$SERVICE_HOST" ]; then
944 init_keystone
945 start_keystone
946 fi
Dean Troyerd81a0272012-08-31 18:04:55 -0500947
Dean Troyerd835de82012-11-29 17:11:35 -0600948 # Set up a temporary admin URI for Keystone
Jamie Lennox3561d7f2014-05-21 17:18:43 +1000949 SERVICE_ENDPOINT=$KEYSTONE_AUTH_URI/v2.0
Dean Troyerc83a7e12012-11-29 11:47:58 -0600950
951 if is_service_enabled tls-proxy; then
952 export OS_CACERT=$INT_CA_DIR/ca-chain.pem
953 # Until the client support is fixed, just use the internal endpoint
954 SERVICE_ENDPOINT=http://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT_INT/v2.0
955 fi
Dean Troyerd81a0272012-08-31 18:04:55 -0500956
Dean Troyer42a59c22014-03-03 14:31:29 -0600957 # Setup OpenStackclient token-flow auth
Steve Martinelli19685422014-01-24 13:02:26 -0600958 export OS_TOKEN=$SERVICE_TOKEN
959 export OS_URL=$SERVICE_ENDPOINT
Dean Troyer42a59c22014-03-03 14:31:29 -0600960
Dean Troyerd835de82012-11-29 17:11:35 -0600961 create_keystone_accounts
Dean Troyera0dce262012-12-11 16:52:37 -0600962 create_nova_accounts
Dean Troyer42a59c22014-03-03 14:31:29 -0600963 create_glance_accounts
Dean Troyer671c16e2012-12-13 16:22:38 -0600964 create_cinder_accounts
Mark McClainb05c8762013-07-06 23:29:39 -0400965 create_neutron_accounts
Dean Troyerd835de82012-11-29 17:11:35 -0600966
Dirk Muellerfa5ccff2014-01-09 13:27:35 +0100967 if is_service_enabled ceilometer; then
968 create_ceilometer_accounts
969 fi
970
Dean Troyer42a59c22014-03-03 14:31:29 -0600971 if is_service_enabled swift; then
Ian Wienand0ff314c2013-07-17 16:30:19 +1000972 create_swift_accounts
973 fi
974
Steve Bakere389aed2014-09-23 17:10:39 +1200975 if is_service_enabled heat && [[ "$HEAT_STANDALONE" != "True" ]]; then
Steven Hardy33d1f862014-02-13 15:00:33 +0000976 create_heat_accounts
977 fi
978
Dean Troyer42a59c22014-03-03 14:31:29 -0600979 # Begone token-flow auth
Steve Martinelli19685422014-01-24 13:02:26 -0600980 unset OS_TOKEN OS_URL
Dean Troyer42a59c22014-03-03 14:31:29 -0600981
982 # Set up password-flow auth creds now that keystone is bootstrapped
Dean Troyerd81a0272012-08-31 18:04:55 -0500983 export OS_AUTH_URL=$SERVICE_ENDPOINT
984 export OS_TENANT_NAME=admin
985 export OS_USERNAME=admin
986 export OS_PASSWORD=$ADMIN_PASSWORD
Bartosz Górski0abde392014-02-28 14:15:19 +0100987 export OS_REGION_NAME=$REGION_NAME
Dean Troyerd81a0272012-08-31 18:04:55 -0500988fi
989
990
Li Ma26ac3d72014-12-21 23:41:07 -0800991# ZeroMQ
992# ------
993if is_service_enabled zeromq; then
994 echo_summary "Starting zeromq receiver"
995 run_process zeromq "$OSLO_BIN_DIR/oslo-messaging-zmq-receiver"
996fi
997
998
Tres Henryca85b792011-10-28 14:00:21 -0700999# Horizon
Dean Troyerdf0972c2012-03-07 17:31:03 -06001000# -------
Jesse Andrewscbe98d52011-10-02 17:47:32 -04001001
Dean Troyer7d28a0e2012-06-27 17:55:52 -05001002# Set up the django horizon application to serve via apache/wsgi
Jesse Andrews75a37652011-09-12 17:09:08 -07001003
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +00001004if is_service_enabled horizon; then
Dean Troyer7903b792012-09-13 17:16:12 -05001005 echo_summary "Configuring and starting Horizon"
Sean Dagueb562e6a2012-11-19 16:00:01 -05001006 init_horizon
1007 start_horizon
Anthony Young70dc5e02011-09-15 16:52:43 -07001008fi
Jesse Andrews75a37652011-09-12 17:09:08 -07001009
Anthony Young3859f732011-09-14 02:33:43 -07001010
Jesse Andrewsd74257d2011-09-13 01:24:50 -07001011# Glance
1012# ------
1013
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +00001014if is_service_enabled g-reg; then
Dean Troyer7903b792012-09-13 17:16:12 -05001015 echo_summary "Configuring Glance"
Dean Troyer73f6f252012-09-17 11:22:21 -05001016 init_glance
Anthony Young70dc5e02011-09-15 16:52:43 -07001017fi
Jesse Andrews75a37652011-09-12 17:09:08 -07001018
Dean Troyer8c032d12013-09-23 13:53:13 -05001019
Mark McClainb05c8762013-07-06 23:29:39 -04001020# Neutron
Anthony Young60df29a2012-03-28 09:40:17 -07001021# -------
Dean Troyer7d28a0e2012-06-27 17:55:52 -05001022
Mark McClainb05c8762013-07-06 23:29:39 -04001023if is_service_enabled neutron; then
1024 echo_summary "Configuring Neutron"
Dean Troyerb9182d62012-11-07 12:31:34 -06001025
Mark McClainb05c8762013-07-06 23:29:39 -04001026 configure_neutron
Salvatore Orlandodd649882013-08-05 08:56:17 -07001027 # Run init_neutron only on the node hosting the neutron API server
1028 if is_service_enabled $DATABASE_BACKENDS && is_service_enabled q-svc; then
1029 init_neutron
1030 fi
Dan Wendlandt0007f3a2012-05-18 13:37:47 -07001031fi
1032
Mark McClainb05c8762013-07-06 23:29:39 -04001033# Some Neutron plugins require network controllers which are not
Akihiro MOTOKI66afb472012-12-21 15:34:13 +09001034# a part of the OpenStack project. Configure and start them.
Mark McClainb05c8762013-07-06 23:29:39 -04001035if is_service_enabled neutron; then
1036 configure_neutron_third_party
1037 init_neutron_third_party
1038 start_neutron_third_party
Gary Kotton396a0142012-07-29 04:28:47 -04001039fi
1040
Dean Troyerb9182d62012-11-07 12:31:34 -06001041
Jesse Andrewsd74257d2011-09-13 01:24:50 -07001042# Nova
1043# ----
Dean Troyerbd13b702012-02-13 11:22:36 -06001044
Isaku Yamahata6f85ab32012-08-06 16:56:10 +09001045if is_service_enabled n-net q-dhcp; then
Anthony Young55458452011-12-17 00:21:49 +00001046 # Delete traces of nova networks from prior runs
Davanum Srinivasd71d6e72013-01-28 19:15:57 -05001047 # Do not kill any dnsmasq instance spawned by NetworkManager
1048 netman_pid=$(pidof NetworkManager || true)
1049 if [ -z "$netman_pid" ]; then
1050 sudo killall dnsmasq || true
1051 else
1052 sudo ps h -o pid,ppid -C dnsmasq | grep -v $netman_pid | awk '{print $1}' | sudo xargs kill || true
1053 fi
1054
Anthony Young55458452011-12-17 00:21:49 +00001055 clean_iptables
Christian Berendt7a7fb492014-04-07 13:31:07 +00001056
1057 if is_service_enabled n-net; then
1058 rm -rf ${NOVA_STATE_PATH}/networks
1059 sudo mkdir -p ${NOVA_STATE_PATH}/networks
Chris Denta0ced4d2014-05-27 22:08:46 +01001060 safe_chown -R ${STACK_USER} ${NOVA_STATE_PATH}/networks
Christian Berendt7a7fb492014-04-07 13:31:07 +00001061 fi
1062
Dean Troyer1a6d4492013-06-03 16:47:36 -05001063 # Force IP forwarding on, just in case
Dean Troyer0b31e862012-03-07 16:47:56 -06001064 sudo sysctl -w net.ipv4.ip_forward=1
Anthony Young70dc5e02011-09-15 16:52:43 -07001065fi
Jesse Andrews75a37652011-09-12 17:09:08 -07001066
Dean Troyer7d28a0e2012-06-27 17:55:52 -05001067
Chmouel Boudjnah28fa4e82011-11-01 12:30:55 +01001068# Storage Service
Dean Troyer7d28a0e2012-06-27 17:55:52 -05001069# ---------------
1070
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +01001071if is_service_enabled s-proxy; then
Dean Troyer7903b792012-09-13 17:16:12 -05001072 echo_summary "Configuring Swift"
Attila Fazekasece6a332012-11-29 14:19:41 +01001073 init_swift
Chmouel Boudjnah28fa4e82011-11-01 12:30:55 +01001074fi
1075
Dean Troyerdf0972c2012-03-07 17:31:03 -06001076
Anthony Youngacff87a2011-10-20 10:12:58 -07001077# Volume Service
1078# --------------
1079
Dean Troyer67787e62012-05-02 11:48:15 -05001080if is_service_enabled cinder; then
Dean Troyer7903b792012-09-13 17:16:12 -05001081 echo_summary "Configuring Cinder"
Dean Troyer67787e62012-05-02 11:48:15 -05001082 init_cinder
Anthony Youngacff87a2011-10-20 10:12:58 -07001083fi
1084
Dean Troyer2aa2a892013-08-04 19:53:19 -05001085
1086# Compute Service
1087# ---------------
1088
Dean Troyerbf67c192012-09-21 15:09:37 -05001089if is_service_enabled nova; then
1090 echo_summary "Configuring Nova"
1091 init_nova
Jesse Andrewsd1879c52011-09-16 16:28:13 -07001092
Dean Troyer86a79692012-10-22 15:24:46 -05001093 # Additional Nova configuration that is dependent on other services
Mark McClainb05c8762013-07-06 23:29:39 -04001094 if is_service_enabled neutron; then
1095 create_nova_conf_neutron
Dean Troyer86a79692012-10-22 15:24:46 -05001096 elif is_service_enabled n-net; then
Akihiro MOTOKI66afb472012-12-21 15:34:13 +09001097 create_nova_conf_nova_network
Brad Hall1bfa3d52011-10-27 18:18:20 -07001098 fi
Dean Troyerdf0972c2012-03-07 17:31:03 -06001099
Kieran Spearfb2a3ae2013-03-11 23:55:49 +00001100 init_nova_cells
Anthony Youngb62b4ca2011-10-26 22:29:08 -07001101fi
1102
Dean Troyercdf3d762013-10-15 09:42:43 -05001103# Extras Configuration
1104# ====================
1105
1106# Phase: post-config
Sean Dague2c65e712014-12-18 09:44:56 -05001107run_phase stack post-config
Dean Troyercdf3d762013-10-15 09:42:43 -05001108
1109
Dean Troyer893e6632013-09-13 15:05:51 -05001110# Local Configuration
1111# ===================
1112
1113# Apply configuration from local.conf if it exists for layer 2 services
1114# Phase: post-config
1115merge_config_group $TOP_DIR/local.conf post-config
1116
1117
Jesse Andrewsd74257d2011-09-13 01:24:50 -07001118# Launch Services
1119# ===============
Jesse Andrews30f68e92011-09-13 00:59:54 -07001120
Jesse Andrewsdfcd2002011-09-13 13:17:22 -07001121# Only run the services specified in ``ENABLED_SERVICES``
1122
Attila Fazekasece6a332012-11-29 14:19:41 +01001123# Launch Swift Services
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +01001124if is_service_enabled s-proxy; then
Attila Fazekasece6a332012-11-29 14:19:41 +01001125 echo_summary "Starting Swift"
1126 start_swift
1127fi
1128
Dean Troyer73f6f252012-09-17 11:22:21 -05001129# Launch the Glance services
Dean Troyere4fa7212014-01-15 15:04:49 -06001130if is_service_enabled glance; then
Dean Troyer7903b792012-09-13 17:16:12 -05001131 echo_summary "Starting Glance"
Dean Troyer73f6f252012-09-17 11:22:21 -05001132 start_glance
Anthony Youngd000b222011-09-19 14:46:53 -07001133fi
1134
Eric Windisch0b9776d2014-01-28 11:20:53 -05001135# Install Images
1136# ==============
1137
1138# Upload an image to glance.
1139#
1140# The default image is cirros, a small testing image which lets you login as **root**
1141# cirros has a ``cloud-init`` analog supporting login via keypair and sending
1142# scripts as userdata.
1143# See https://help.ubuntu.com/community/CloudInit for more on cloud-init
1144#
1145# Override ``IMAGE_URLS`` with a comma-separated list of UEC images.
1146# * **precise**: http://uec-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64.tar.gz
1147
1148if is_service_enabled g-reg; then
1149 TOKEN=$(keystone token-get | grep ' id ' | get_field 2)
1150 die_if_not_set $LINENO TOKEN "Keystone fail to get token"
1151
Sean Dague2f8e08b2014-12-05 08:31:16 -05001152 echo_summary "Uploading images"
Eric Windisch0b9776d2014-01-28 11:20:53 -05001153
Sean Dague2f8e08b2014-12-05 08:31:16 -05001154 # Option to upload legacy ami-tty, which works with xenserver
1155 if [[ -n "$UPLOAD_LEGACY_TTY" ]]; then
1156 IMAGE_URLS="${IMAGE_URLS:+${IMAGE_URLS},}https://github.com/downloads/citrix-openstack/warehouse/tty.tgz"
Eric Windisch0b9776d2014-01-28 11:20:53 -05001157 fi
Sean Dague2f8e08b2014-12-05 08:31:16 -05001158
1159 for image_url in ${IMAGE_URLS//,/ }; do
1160 upload_image $image_url $TOKEN
1161 done
Eric Windisch0b9776d2014-01-28 11:20:53 -05001162fi
1163
Dean Troyerd81a0272012-08-31 18:04:55 -05001164# Create an access key and secret key for nova ec2 register image
Dean Troyer5ce44cd2015-02-12 22:18:33 -06001165if is_service_enabled keystone && is_service_enabled swift3 && is_service_enabled nova; then
Steve Martinellidf6793a2014-03-13 23:38:11 -05001166 eval $(openstack ec2 credentials create --user nova --project $SERVICE_TENANT_NAME -f shell -c access -c secret)
1167 iniset $NOVA_CONF DEFAULT s3_access_key "$access"
1168 iniset $NOVA_CONF DEFAULT s3_secret_key "$secret"
Devananda van der Veen9bc47db2012-12-12 16:52:55 -08001169 iniset $NOVA_CONF DEFAULT s3_affix_tenant "True"
Anthony Youngd000b222011-09-19 14:46:53 -07001170fi
1171
Kaitlin Farrdef4c142014-01-06 08:52:49 -05001172# Create a randomized default value for the keymgr's fixed_key
1173if is_service_enabled nova; then
Attila Fazekasf71b5002014-05-28 09:52:22 +02001174 iniset $NOVA_CONF keymgr fixed_key $(generate_hex_string 32)
Kaitlin Farrdef4c142014-01-06 08:52:49 -05001175fi
1176
Dean Troyer7d28a0e2012-06-27 17:55:52 -05001177# Launch the nova-api and wait for it to answer before continuing
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +00001178if is_service_enabled n-api; then
Dean Troyer7903b792012-09-13 17:16:12 -05001179 echo_summary "Starting Nova API"
Dean Troyer3a3a2ba2012-12-11 15:26:24 -06001180 start_nova_api
Anthony Youngd000b222011-09-19 14:46:53 -07001181fi
Brad Hall1bfa3d52011-10-27 18:18:20 -07001182
Gary Kotton37dda8d2012-08-08 03:46:33 -04001183if is_service_enabled q-svc; then
Mark McClainb05c8762013-07-06 23:29:39 -04001184 echo_summary "Starting Neutron"
Mark McClainb05c8762013-07-06 23:29:39 -04001185 start_neutron_service_and_check
armando-migliaccioef1e0802014-01-02 16:33:53 -08001186 check_neutron_third_party_integration
Aaron Rosen8ec719b2012-10-30 12:57:47 -07001187elif is_service_enabled $DATABASE_BACKENDS && is_service_enabled n-net; then
Kieran Spearfb2a3ae2013-03-11 23:55:49 +00001188 NM_CONF=${NOVA_CONF}
1189 if is_service_enabled n-cell; then
1190 NM_CONF=${NOVA_CELLS_CONF}
1191 fi
1192
Gary Kotton37dda8d2012-08-08 03:46:33 -04001193 # Create a small network
Kieran Spearfb2a3ae2013-03-11 23:55:49 +00001194 $NOVA_BIN_DIR/nova-manage --config-file $NM_CONF network create "$PRIVATE_NETWORK_NAME" $FIXED_RANGE 1 $FIXED_NETWORK_SIZE $NETWORK_CREATE_ARGS
Dean Troyer696ad332012-01-10 15:34:34 -06001195
Gary Kotton37dda8d2012-08-08 03:46:33 -04001196 # Create some floating ips
Kieran Spearfb2a3ae2013-03-11 23:55:49 +00001197 $NOVA_BIN_DIR/nova-manage --config-file $NM_CONF floating create $FLOATING_RANGE --pool=$PUBLIC_NETWORK_NAME
Aaron Rosen9313dfa2012-07-06 16:08:49 -04001198
Gary Kotton37dda8d2012-08-08 03:46:33 -04001199 # Create a second pool
Kieran Spearfb2a3ae2013-03-11 23:55:49 +00001200 $NOVA_BIN_DIR/nova-manage --config-file $NM_CONF floating create --ip_range=$TEST_FLOATING_RANGE --pool=$TEST_FLOATING_POOL
Brad Hall1bfa3d52011-10-27 18:18:20 -07001201fi
1202
Mark McClainb05c8762013-07-06 23:29:39 -04001203if is_service_enabled neutron; then
1204 start_neutron_agents
Akihiro MOTOKI66afb472012-12-21 15:34:13 +09001205fi
Salvatore Orlando6fbb28d2013-12-22 07:59:37 -08001206# Once neutron agents are started setup initial network elements
Edgar Magana7bce8fa2014-11-04 17:32:54 +01001207if is_service_enabled q-svc && [[ "$NEUTRON_CREATE_INITIAL_NETWORKS" == "True" ]]; then
Salvatore Orlando6fbb28d2013-12-22 07:59:37 -08001208 echo_summary "Creating initial neutron network elements"
1209 create_neutron_initial_network
1210 setup_neutron_debug
1211fi
Dean Troyerbf67c192012-09-21 15:09:37 -05001212if is_service_enabled nova; then
1213 echo_summary "Starting Nova"
1214 start_nova
1215fi
Dean Troyer67787e62012-05-02 11:48:15 -05001216if is_service_enabled cinder; then
Dean Troyer7903b792012-09-13 17:16:12 -05001217 echo_summary "Starting Cinder"
Dean Troyer67787e62012-05-02 11:48:15 -05001218 start_cinder
Dean Troyer09718332014-07-03 10:46:57 -05001219 create_volume_types
Dean Troyer67787e62012-05-02 11:48:15 -05001220fi
John H. Tran93361642012-07-26 11:22:05 -07001221if is_service_enabled ceilometer; then
Doug Hellmannc5259b42012-09-22 10:52:31 -04001222 echo_summary "Starting Ceilometer"
Lianhao Lu8c548492013-01-09 10:41:54 +08001223 init_ceilometer
John H. Tran93361642012-07-26 11:22:05 -07001224 start_ceilometer
1225fi
Sean Dagueb562e6a2012-11-19 16:00:01 -05001226
Steve Bakerbad9d892012-10-25 14:49:47 +13001227# Configure and launch heat engine, api and metadata
Steve Bakerbfdad752012-08-18 09:00:42 +12001228if is_service_enabled heat; then
Steven Hardy1bcd2802014-02-13 15:14:41 +00001229 # Initialize heat
Steve Bakerbad9d892012-10-25 14:49:47 +13001230 echo_summary "Configuring Heat"
1231 init_heat
Dean Troyer7903b792012-09-13 17:16:12 -05001232 echo_summary "Starting Heat"
Steve Bakerbfdad752012-08-18 09:00:42 +12001233 start_heat
Steve Baker2a6009c2014-05-05 16:13:39 +12001234 if [ "$HEAT_CREATE_TEST_IMAGE" = "True" ]; then
1235 echo_summary "Building Heat functional test image"
1236 build_heat_functional_test_image
1237 fi
Steve Bakerbfdad752012-08-18 09:00:42 +12001238fi
Dean Troyer7d28a0e2012-06-27 17:55:52 -05001239
Jamie Lennoxbd24a8d2013-09-20 16:26:42 +10001240
Attila Fazekas22ef5732012-12-16 14:03:06 +01001241# Create account rc files
1242# =======================
1243
1244# Creates source able script files for easier user switching.
1245# This step also creates certificates for tenants and users,
1246# which is helpful in image bundle steps.
1247
Dean Troyer5ce44cd2015-02-12 22:18:33 -06001248if is_service_enabled nova && is_service_enabled keystone; then
Jamie Lennoxbd24a8d2013-09-20 16:26:42 +10001249 USERRC_PARAMS="-PA --target-dir $TOP_DIR/accrc"
1250
1251 if [ -f $SSL_BUNDLE_FILE ]; then
1252 USERRC_PARAMS="$USERRC_PARAMS --os-cacert $SSL_BUNDLE_FILE"
1253 fi
1254
Steve Bakere389aed2014-09-23 17:10:39 +12001255 if [[ "$HEAT_STANDALONE" = "True" ]]; then
1256 USERRC_PARAMS="$USERRC_PARAMS --heat-url http://$HEAT_API_HOST:$HEAT_API_PORT/v1"
1257 fi
1258
Jamie Lennoxbd24a8d2013-09-20 16:26:42 +10001259 $TOP_DIR/tools/create_userrc.sh $USERRC_PARAMS
Attila Fazekas22ef5732012-12-16 14:03:06 +01001260fi
1261
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001262
Dean Troyer33cb4302012-12-10 16:47:36 -06001263# Save some values we generated for later use
1264CURRENT_RUN_TIME=$(date "+$TIMESTAMP_FORMAT")
1265echo "# $CURRENT_RUN_TIME" >$TOP_DIR/.stackenv
1266for i in BASE_SQL_CONN ENABLED_SERVICES HOST_IP LOGFILE \
Jamie Lennoxbd24a8d2013-09-20 16:26:42 +10001267 SERVICE_HOST SERVICE_PROTOCOL STACK_USER TLS_IP KEYSTONE_AUTH_PROTOCOL OS_CACERT; do
Dean Troyer33cb4302012-12-10 16:47:36 -06001268 echo $i=${!i} >>$TOP_DIR/.stackenv
1269done
1270
Maru Newbyec086512012-11-01 23:44:57 +00001271
Dean Troyer893e6632013-09-13 15:05:51 -05001272# Local Configuration
1273# ===================
1274
1275# Apply configuration from local.conf if it exists for layer 2 services
1276# Phase: extra
1277merge_config_group $TOP_DIR/local.conf extra
1278
1279
Dean Troyer768295e2013-01-09 13:42:03 -06001280# Run extras
1281# ==========
1282
Dean Troyercdf3d762013-10-15 09:42:43 -05001283# Phase: extra
Sean Dague2c65e712014-12-18 09:44:56 -05001284run_phase stack extra
Dean Troyer768295e2013-01-09 13:42:03 -06001285
Ryan Hsufeb28832013-11-07 12:12:35 -08001286# Local Configuration
1287# ===================
1288
1289# Apply configuration from local.conf if it exists for layer 2 services
1290# Phase: post-extra
1291merge_config_group $TOP_DIR/local.conf post-extra
1292
Dean Troyer768295e2013-01-09 13:42:03 -06001293
Dean Troyerf5633dd2012-03-28 11:21:40 -05001294# Run local script
1295# ================
1296
1297# Run ``local.sh`` if it exists to perform user-managed tasks
1298if [[ -x $TOP_DIR/local.sh ]]; then
1299 echo "Running user script $TOP_DIR/local.sh"
1300 $TOP_DIR/local.sh
1301fi
1302
jiajun xua9414242012-12-06 16:30:57 +08001303# Check the status of running services
1304service_check
Dean Troyerf5633dd2012-03-28 11:21:40 -05001305
Dean Troyerb7490da2013-03-18 16:07:56 -05001306
Scott Moserb94f4bf2011-10-07 14:51:07 +00001307# Fin
1308# ===
1309
Dean Troyer471de7a2011-12-27 11:45:55 -06001310set +o xtrace
Scott Moserb94f4bf2011-10-07 14:51:07 +00001311
Dean Troyer7903b792012-09-13 17:16:12 -05001312if [[ -n "$LOGFILE" ]]; then
1313 exec 1>&3
1314 # Force all output to stdout and logs now
Dean Troyerbaa8b422012-09-24 15:02:05 -05001315 exec 1> >( tee -a "${LOGFILE}" ) 2>&1
Dean Troyer7903b792012-09-13 17:16:12 -05001316else
1317 # Force all output to stdout now
1318 exec 1>&3
1319fi
1320
Dean Troyerdf0972c2012-03-07 17:31:03 -06001321
Jesse Andrews24859062011-09-15 21:28:23 -07001322# Using the cloud
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001323# ---------------
Jesse Andrews24859062011-09-15 21:28:23 -07001324
Jesse Andrewse19d8842011-11-01 20:06:55 -07001325echo ""
1326echo ""
1327echo ""
1328
Dean Troyerdf0972c2012-03-07 17:31:03 -06001329# If you installed Horizon on this server you should be able
root40a37002011-09-20 18:06:14 +00001330# to access the site using your browser.
Chmouel Boudjnaha6651e92012-02-16 10:16:52 +00001331if is_service_enabled horizon; then
Dean Troyerdf0972c2012-03-07 17:31:03 -06001332 echo "Horizon is now available at http://$SERVICE_HOST/"
Jesse Andrews24859062011-09-15 21:28:23 -07001333fi
1334
Dean Troyerdf0972c2012-03-07 17:31:03 -06001335# If Keystone is present you can point ``nova`` cli to this server
Dean Troyer5ce44cd2015-02-12 22:18:33 -06001336if is_service_enabled keystone; then
Jamie Lennox3561d7f2014-05-21 17:18:43 +10001337 echo "Keystone is serving at $KEYSTONE_SERVICE_URI/v2.0/"
Dean Troyerdf0972c2012-03-07 17:31:03 -06001338 echo "Examples on using novaclient command line is in exercise.sh"
1339 echo "The default users are: admin and demo"
1340 echo "The password: $ADMIN_PASSWORD"
Jesse Andrews24859062011-09-15 21:28:23 -07001341fi
termie523c4052011-09-28 19:49:40 -05001342
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001343# Echo ``HOST_IP`` - useful for ``build_uec.sh``, which uses dhcp to give the instance an address
Anthony Young1097c7c2011-12-27 23:22:14 -08001344echo "This is your host ip: $HOST_IP"
1345
Dean Troyerafc29fe2013-02-07 15:56:24 -06001346# Warn that a deprecated feature was used
1347if [[ -n "$DEPRECATED_TEXT" ]]; then
1348 echo_summary "WARNING: $DEPRECATED_TEXT"
Dean Troyerced65172012-03-02 16:36:16 -06001349fi
1350
Dean Troyer4a43b7b2012-08-28 17:43:40 -05001351# Indicate how long this took to run (bash maintained variable ``SECONDS``)
Dean Troyer7903b792012-09-13 17:16:12 -05001352echo_summary "stack.sh completed in $SECONDS seconds."
Dean Troyer80684552014-03-05 11:50:23 -06001353
1354# Restore/close logging file descriptors
1355exec 1>&3
1356exec 2>&3
1357exec 3>&-
1358exec 6>&-