Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Dean Troyer | c6c1d43 | 2012-03-27 20:59:22 -0500 | [diff] [blame] | 3 | # ``stack.sh`` is an opinionated OpenStack developer installation. It |
| 4 | # installs and configures various combinations of **Glance**, **Horizon**, |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 5 | # **Keystone**, **Nova**, **Quantum**, **Heat** and **Swift** |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 6 | |
Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 7 | # This script allows you to specify configuration options of what git |
Jesse Andrews | 5372f43 | 2011-10-03 01:08:24 -0400 | [diff] [blame] | 8 | # repositories to use, enabled services, network configuration and various |
| 9 | # passwords. If you are crafty you can run the script on multiple nodes using |
| 10 | # shared settings for common resources (mysql, rabbitmq) and build a multi-node |
| 11 | # developer install. |
Jesse Andrews | 782b991 | 2011-10-02 16:53:21 -0400 | [diff] [blame] | 12 | |
Jesse Andrews | 38df122 | 2011-11-20 09:55:44 -0800 | [diff] [blame] | 13 | # To keep this script simple we assume you are running on an **Ubuntu 11.10 |
Dean Troyer | c6c1d43 | 2012-03-27 20:59:22 -0500 | [diff] [blame] | 14 | # Oneiric** or **Ubuntu 12.04 Precise** machine. It should work in a VM or |
| 15 | # physical server. Additionally we put the list of ``apt`` and ``pip`` |
| 16 | # dependencies and other configuration files in this repo. So start by |
| 17 | # grabbing this script and the dependencies. |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 18 | |
Jesse Andrews | 0e7e897 | 2011-10-02 16:36:54 -0400 | [diff] [blame] | 19 | # Learn more and get the most recent version at http://devstack.org |
Jesse Andrews | 6edd17f | 2011-09-15 22:19:42 -0700 | [diff] [blame] | 20 | |
Dean Troyer | c6c1d43 | 2012-03-27 20:59:22 -0500 | [diff] [blame] | 21 | # Keep track of the devstack directory |
Jesse Andrews | 51fb22e | 2011-10-19 09:24:17 -0700 | [diff] [blame] | 22 | TOP_DIR=$(cd $(dirname "$0") && pwd) |
| 23 | |
Dean Troyer | 6563a3c | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 24 | # Import common functions |
Dean Troyer | c6c1d43 | 2012-03-27 20:59:22 -0500 | [diff] [blame] | 25 | source $TOP_DIR/functions |
Dean Troyer | 6563a3c | 2012-01-31 12:11:56 -0600 | [diff] [blame] | 26 | |
Dean Troyer | c6c1d43 | 2012-03-27 20:59:22 -0500 | [diff] [blame] | 27 | # Determine what system we are running on. This provides ``os_VENDOR``, |
| 28 | # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` |
Dean Troyer | a9e0a48 | 2012-07-09 14:07:23 -0500 | [diff] [blame] | 29 | # and ``DISTRO`` |
| 30 | GetDistro |
Jesse Andrews | 6edd17f | 2011-09-15 22:19:42 -0700 | [diff] [blame] | 31 | |
Anthony Young | 6015c82 | 2011-10-12 07:17:11 +0000 | [diff] [blame] | 32 | |
Scott Moser | f9da508 | 2011-10-07 21:28:00 -0400 | [diff] [blame] | 33 | # Settings |
| 34 | # ======== |
| 35 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 36 | # ``stack.sh`` is customizable through setting environment variables. If you |
| 37 | # want to override a setting you can set and export it:: |
Scott Moser | f9da508 | 2011-10-07 21:28:00 -0400 | [diff] [blame] | 38 | # |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 39 | # export MYSQL_PASSWORD=anothersecret |
Scott Moser | f9da508 | 2011-10-07 21:28:00 -0400 | [diff] [blame] | 40 | # ./stack.sh |
| 41 | # |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 42 | # You can also pass options on a single line ``MYSQL_PASSWORD=simple ./stack.sh`` |
Scott Moser | f9da508 | 2011-10-07 21:28:00 -0400 | [diff] [blame] | 43 | # |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 44 | # Additionally, you can put any local variables into a ``localrc`` file:: |
Scott Moser | f9da508 | 2011-10-07 21:28:00 -0400 | [diff] [blame] | 45 | # |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 46 | # MYSQL_PASSWORD=anothersecret |
Scott Moser | f9da508 | 2011-10-07 21:28:00 -0400 | [diff] [blame] | 47 | # MYSQL_USER=hellaroot |
| 48 | # |
| 49 | # We try to have sensible defaults, so you should be able to run ``./stack.sh`` |
| 50 | # in most cases. |
| 51 | # |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 52 | # DevStack distributes ``stackrc`` which contains locations for the OpenStack |
| 53 | # repositories and branches to configure. ``stackrc`` sources ``localrc`` to |
Dean Troyer | c6c1d43 | 2012-03-27 20:59:22 -0500 | [diff] [blame] | 54 | # allow you to safely override those settings without being overwritten |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 55 | # when updating DevStack. |
Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 56 | if [[ ! -r $TOP_DIR/stackrc ]]; then |
| 57 | echo "ERROR: missing $TOP_DIR/stackrc - did you grab more than just stack.sh?" |
| 58 | exit 1 |
| 59 | fi |
| 60 | source $TOP_DIR/stackrc |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 61 | |
Dean Troyer | c6c1d43 | 2012-03-27 20:59:22 -0500 | [diff] [blame] | 62 | # HTTP and HTTPS proxy servers are supported via the usual environment variables |
Osamu Habuka | 7abe4f2 | 2012-07-25 12:39:32 +0900 | [diff] [blame] | 63 | # ``http_proxy`` and ``https_proxy``. Additionally if you would like to access |
| 64 | # to specific server directly and not through the proxy server, you can use |
| 65 | # ``no_proxy`` environment variable. They can be set in ``localrc`` if necessary |
Dean Troyer | c6c1d43 | 2012-03-27 20:59:22 -0500 | [diff] [blame] | 66 | # or on the command line:: |
Dean Troyer | c727aa8 | 2012-01-13 12:13:59 -0600 | [diff] [blame] | 67 | # |
Osamu Habuka | 7abe4f2 | 2012-07-25 12:39:32 +0900 | [diff] [blame] | 68 | # http_proxy=http://proxy.example.com:3128/ no_proxy=repo.example.net ./stack.sh |
Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 69 | if [[ -n "$http_proxy" ]]; then |
| 70 | export http_proxy=$http_proxy |
Dean Troyer | c6c1d43 | 2012-03-27 20:59:22 -0500 | [diff] [blame] | 71 | fi |
Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 72 | if [[ -n "$https_proxy" ]]; then |
| 73 | export https_proxy=$https_proxy |
| 74 | fi |
Osamu Habuka | 7abe4f2 | 2012-07-25 12:39:32 +0900 | [diff] [blame] | 75 | if [[ -n "$no_proxy" ]]; then |
| 76 | export no_proxy=$no_proxy |
| 77 | fi |
Scott Moser | f9da508 | 2011-10-07 21:28:00 -0400 | [diff] [blame] | 78 | |
Jesse Andrews | 6edd17f | 2011-09-15 22:19:42 -0700 | [diff] [blame] | 79 | # Destination path for installation ``DEST`` |
Anthony Young | e8fed48 | 2011-09-26 19:50:43 -0700 | [diff] [blame] | 80 | DEST=${DEST:-/opt/stack} |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 81 | |
Dean Troyer | c6c1d43 | 2012-03-27 20:59:22 -0500 | [diff] [blame] | 82 | |
| 83 | # Sanity Check |
| 84 | # ============ |
| 85 | |
Doug Hellmann | f04178f | 2012-07-05 17:10:03 -0400 | [diff] [blame] | 86 | # Remove services which were negated in ENABLED_SERVICES |
| 87 | # using the "-" prefix (e.g., "-n-vol") instead of |
| 88 | # calling disable_service(). |
| 89 | disable_negated_services |
Chmouel Boudjnah | c4cd414 | 2012-06-27 11:01:40 +0200 | [diff] [blame] | 90 | |
Dean Troyer | c6c1d43 | 2012-03-27 20:59:22 -0500 | [diff] [blame] | 91 | # Warn users who aren't on an explicitly supported distro, but allow them to |
| 92 | # override check and attempt installation with ``FORCE=yes ./stack`` |
Dean Troyer | 4a1f5a7 | 2012-06-21 09:57:43 -0500 | [diff] [blame] | 93 | if [[ ! ${DISTRO} =~ (oneiric|precise|quantal|f16|f17) ]]; then |
| 94 | echo "WARNING: this script has not been tested on $DISTRO" |
Dean Troyer | c6c1d43 | 2012-03-27 20:59:22 -0500 | [diff] [blame] | 95 | if [[ "$FORCE" != "yes" ]]; then |
| 96 | echo "If you wish to run this script anyway run with FORCE=yes" |
| 97 | exit 1 |
| 98 | fi |
| 99 | fi |
| 100 | |
Russell Bryant | 4a22145 | 2012-03-13 13:44:12 -0400 | [diff] [blame] | 101 | if [ "${DISTRO}" = "oneiric" ] && is_service_enabled qpid ; then |
| 102 | # Qpid was introduced in precise |
| 103 | echo "You must use Ubuntu Precise or newer for Qpid support." |
| 104 | exit 1 |
| 105 | fi |
| 106 | |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 107 | # Set the paths of certain binaries |
| 108 | if [[ "$os_PACKAGE" = "deb" ]]; then |
| 109 | NOVA_ROOTWRAP=/usr/local/bin/nova-rootwrap |
| 110 | else |
| 111 | NOVA_ROOTWRAP=/usr/bin/nova-rootwrap |
| 112 | fi |
| 113 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 114 | # ``stack.sh`` keeps function libraries here |
| 115 | # Make sure ``$TOP_DIR/lib`` directory is present |
| 116 | if [ ! -d $TOP_DIR/lib ]; then |
| 117 | echo "ERROR: missing devstack/lib - did you grab more than just stack.sh?" |
| 118 | exit 1 |
| 119 | fi |
| 120 | |
Dean Troyer | c6c1d43 | 2012-03-27 20:59:22 -0500 | [diff] [blame] | 121 | # stack.sh keeps the list of ``apt`` and ``pip`` dependencies in external |
| 122 | # files, along with config templates and other useful files. You can find these |
| 123 | # in the ``files`` directory (next to this script). We will reference this |
| 124 | # directory using the ``FILES`` variable in this script. |
| 125 | FILES=$TOP_DIR/files |
| 126 | if [ ! -d $FILES ]; then |
| 127 | echo "ERROR: missing devstack/files - did you grab more than just stack.sh?" |
| 128 | exit 1 |
| 129 | fi |
| 130 | |
| 131 | # Check to see if we are already running DevStack |
Chmouel Boudjnah | 44b5736 | 2012-02-07 18:13:44 +0100 | [diff] [blame] | 132 | if type -p screen >/dev/null && screen -ls | egrep -q "[0-9].stack"; then |
Anthony Young | 5545845 | 2011-12-17 00:21:49 +0000 | [diff] [blame] | 133 | echo "You are already running a stack.sh session." |
| 134 | echo "To rejoin this session type 'screen -x stack'." |
| 135 | echo "To destroy this session, kill the running screen." |
| 136 | exit 1 |
| 137 | fi |
Todd Willey | 0a16145 | 2011-10-28 02:34:19 -0400 | [diff] [blame] | 138 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 139 | # Make sure we only have one volume service enabled. |
| 140 | if is_service_enabled cinder && is_service_enabled n-vol; then |
| 141 | echo "ERROR: n-vol and cinder must not be enabled at the same time" |
| 142 | exit 1 |
| 143 | fi |
| 144 | |
Tres Henry | ca85b79 | 2011-10-28 14:00:21 -0700 | [diff] [blame] | 145 | # OpenStack is designed to be run as a regular user (Horizon will fail to run |
Dean Troyer | 9122e7b | 2011-10-17 14:07:11 -0500 | [diff] [blame] | 146 | # as root, since apache refused to startup serve content from root user). If |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 147 | # ``stack.sh`` is run as **root**, it automatically creates a **stack** user with |
Dean Troyer | 9122e7b | 2011-10-17 14:07:11 -0500 | [diff] [blame] | 148 | # sudo privileges and runs as that user. |
| 149 | |
| 150 | if [[ $EUID -eq 0 ]]; then |
James E. Blair | 92e8199 | 2011-10-11 09:26:29 -0500 | [diff] [blame] | 151 | ROOTSLEEP=${ROOTSLEEP:-10} |
Dean Troyer | 9122e7b | 2011-10-17 14:07:11 -0500 | [diff] [blame] | 152 | echo "You are running this script as root." |
James E. Blair | 92e8199 | 2011-10-11 09:26:29 -0500 | [diff] [blame] | 153 | echo "In $ROOTSLEEP seconds, we will create a user 'stack' and run as that user" |
| 154 | sleep $ROOTSLEEP |
Dean Troyer | 9122e7b | 2011-10-17 14:07:11 -0500 | [diff] [blame] | 155 | |
| 156 | # since this script runs as a normal user, we need to give that user |
| 157 | # ability to run sudo |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 158 | if [[ "$os_PACKAGE" = "deb" ]]; then |
| 159 | dpkg -l sudo || apt_get update && install_package sudo |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 160 | else |
| 161 | rpm -qa | grep sudo || install_package sudo |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 162 | fi |
Vincent Untz | e29b94e | 2012-06-12 14:21:18 +0200 | [diff] [blame] | 163 | if ! getent group stack >/dev/null; then |
| 164 | echo "Creating a group called stack" |
| 165 | groupadd stack |
| 166 | fi |
Dean Troyer | 9122e7b | 2011-10-17 14:07:11 -0500 | [diff] [blame] | 167 | if ! getent passwd stack >/dev/null; then |
| 168 | echo "Creating a user called stack" |
Vincent Untz | e29b94e | 2012-06-12 14:21:18 +0200 | [diff] [blame] | 169 | useradd -g stack -s /bin/bash -d $DEST -m stack |
Dean Troyer | 9122e7b | 2011-10-17 14:07:11 -0500 | [diff] [blame] | 170 | fi |
| 171 | |
| 172 | echo "Giving stack user passwordless sudo priviledges" |
Jesse Andrews | 38df122 | 2011-11-20 09:55:44 -0800 | [diff] [blame] | 173 | # some uec images sudoers does not have a '#includedir'. add one. |
Dean Troyer | 9122e7b | 2011-10-17 14:07:11 -0500 | [diff] [blame] | 174 | grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers || |
| 175 | echo "#includedir /etc/sudoers.d" >> /etc/sudoers |
| 176 | ( umask 226 && echo "stack ALL=(ALL) NOPASSWD:ALL" \ |
| 177 | > /etc/sudoers.d/50_stack_sh ) |
| 178 | |
| 179 | echo "Copying files to stack user" |
| 180 | STACK_DIR="$DEST/${PWD##*/}" |
Dean Troyer | 0c3db25 | 2011-12-15 12:00:31 -0600 | [diff] [blame] | 181 | cp -r -f -T "$PWD" "$STACK_DIR" |
Jesse Andrews | 5f4ae10 | 2011-11-06 07:47:09 -0800 | [diff] [blame] | 182 | chown -R stack "$STACK_DIR" |
Dean Troyer | 9122e7b | 2011-10-17 14:07:11 -0500 | [diff] [blame] | 183 | if [[ "$SHELL_AFTER_RUN" != "no" ]]; then |
| 184 | exec su -c "set -e; cd $STACK_DIR; bash stack.sh; bash" stack |
| 185 | else |
| 186 | exec su -c "set -e; cd $STACK_DIR; bash stack.sh" stack |
| 187 | fi |
| 188 | exit 1 |
Jesse Andrews | 509992f | 2011-10-27 11:18:09 -0700 | [diff] [blame] | 189 | else |
Dean Troyer | e0d677c | 2012-03-07 14:11:33 -0600 | [diff] [blame] | 190 | # We're not root, make sure sudo is available |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 191 | if [[ "$os_PACKAGE" = "deb" ]]; then |
| 192 | CHECK_SUDO_CMD="dpkg -l sudo" |
| 193 | else |
| 194 | CHECK_SUDO_CMD="rpm -q sudo" |
| 195 | fi |
| 196 | $CHECK_SUDO_CMD || die "Sudo is required. Re-run stack.sh as root ONE TIME ONLY to set up sudo." |
Dean Troyer | e0d677c | 2012-03-07 14:11:33 -0600 | [diff] [blame] | 197 | |
| 198 | # UEC images /etc/sudoers does not have a '#includedir'. add one. |
Jesse Andrews | 84a399b | 2011-10-27 11:20:38 -0700 | [diff] [blame] | 199 | sudo grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers || |
| 200 | echo "#includedir /etc/sudoers.d" | sudo tee -a /etc/sudoers |
Dean Troyer | e0d677c | 2012-03-07 14:11:33 -0600 | [diff] [blame] | 201 | |
| 202 | # Set up devstack sudoers |
Todd Willey | 0a16145 | 2011-10-28 02:34:19 -0400 | [diff] [blame] | 203 | TEMPFILE=`mktemp` |
Dean Troyer | e0d677c | 2012-03-07 14:11:33 -0600 | [diff] [blame] | 204 | echo "`whoami` ALL=(root) NOPASSWD:ALL" >$TEMPFILE |
Vincent Untz | f2a25b7 | 2012-06-13 17:45:43 +0200 | [diff] [blame] | 205 | # Some binaries might be under /sbin or /usr/sbin, so make sure sudo will |
| 206 | # see them by forcing PATH |
| 207 | echo "Defaults:`whoami` secure_path=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin" >> $TEMPFILE |
Todd Willey | 0a16145 | 2011-10-28 02:34:19 -0400 | [diff] [blame] | 208 | chmod 0440 $TEMPFILE |
| 209 | sudo chown root:root $TEMPFILE |
Dean Troyer | e0d677c | 2012-03-07 14:11:33 -0600 | [diff] [blame] | 210 | sudo mv $TEMPFILE /etc/sudoers.d/50_stack_sh |
| 211 | |
Dean Troyer | e0d677c | 2012-03-07 14:11:33 -0600 | [diff] [blame] | 212 | # Remove old file |
| 213 | sudo rm -f /etc/sudoers.d/stack_sh_nova |
Dean Troyer | 9122e7b | 2011-10-17 14:07:11 -0500 | [diff] [blame] | 214 | fi |
| 215 | |
Dean Troyer | e26232b | 2012-06-27 17:55:15 -0500 | [diff] [blame] | 216 | # Create the destination directory and ensure it is writable by the user |
| 217 | sudo mkdir -p $DEST |
| 218 | if [ ! -w $DEST ]; then |
| 219 | sudo chown `whoami` $DEST |
| 220 | fi |
| 221 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 222 | # Set True to configure ``stack.sh`` to run cleanly without Internet access. |
| 223 | # ``stack.sh`` must have been previously run with Internet access to install |
| 224 | # prerequisites and initialize ``$DEST``. |
Dean Troyer | 25dab66 | 2011-12-16 22:40:46 -0600 | [diff] [blame] | 225 | OFFLINE=`trueorfalse False $OFFLINE` |
| 226 | |
James E. Blair | 94cb960 | 2012-06-22 15:28:29 -0700 | [diff] [blame] | 227 | # Set True to configure ``stack.sh`` to exit with an error code if it is asked |
| 228 | # to clone any git repositories. If devstack is used in a testing environment, |
| 229 | # this may be used to ensure that the correct code is being tested. |
| 230 | ERROR_ON_CLONE=`trueorfalse False $ERROR_ON_CLONE` |
| 231 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 232 | # Destination path for service data |
| 233 | DATA_DIR=${DATA_DIR:-${DEST}/data} |
| 234 | sudo mkdir -p $DATA_DIR |
| 235 | sudo chown `whoami` $DATA_DIR |
| 236 | |
| 237 | |
| 238 | # Projects |
| 239 | # -------- |
| 240 | |
| 241 | # Get project function libraries |
| 242 | source $TOP_DIR/lib/cinder |
John H. Tran | 9336164 | 2012-07-26 11:22:05 -0700 | [diff] [blame] | 243 | source $TOP_DIR/lib/ceilometer |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 244 | source $TOP_DIR/lib/heat |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 245 | |
Jesse Andrews | 6f3baaf | 2011-09-12 11:59:38 -0700 | [diff] [blame] | 246 | # Set the destination directories for openstack projects |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 247 | NOVA_DIR=$DEST/nova |
Tres Henry | ca85b79 | 2011-10-28 14:00:21 -0700 | [diff] [blame] | 248 | HORIZON_DIR=$DEST/horizon |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 249 | GLANCE_DIR=$DEST/glance |
Dean Troyer | 4549525 | 2012-04-13 13:16:38 -0500 | [diff] [blame] | 250 | GLANCECLIENT_DIR=$DEST/python-glanceclient |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 251 | KEYSTONE_DIR=$DEST/keystone |
| 252 | NOVACLIENT_DIR=$DEST/python-novaclient |
Anthony Young | 52e631d | 2011-12-27 22:22:14 -0800 | [diff] [blame] | 253 | KEYSTONECLIENT_DIR=$DEST/python-keystoneclient |
Andrew Bogott | 77a4e3a | 2012-05-01 00:07:29 -0500 | [diff] [blame] | 254 | OPENSTACKCLIENT_DIR=$DEST/python-openstackclient |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 255 | NOVNC_DIR=$DEST/noVNC |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 256 | SWIFT_DIR=$DEST/swift |
Joe Gordon | 42b1aa9 | 2012-05-24 14:11:01 -0700 | [diff] [blame] | 257 | SWIFT3_DIR=$DEST/swift3 |
Chmouel Boudjnah | fda9df8 | 2012-05-22 10:27:08 +0000 | [diff] [blame] | 258 | SWIFTCLIENT_DIR=$DEST/python-swiftclient |
Brad Hall | 1bfa3d5 | 2011-10-27 18:18:20 -0700 | [diff] [blame] | 259 | QUANTUM_DIR=$DEST/quantum |
Dave Lapsley | 5a09c92 | 2012-01-25 17:22:15 -0500 | [diff] [blame] | 260 | QUANTUM_CLIENT_DIR=$DEST/python-quantumclient |
Brad Hall | 1bfa3d5 | 2011-10-27 18:18:20 -0700 | [diff] [blame] | 261 | |
| 262 | # Default Quantum Plugin |
| 263 | Q_PLUGIN=${Q_PLUGIN:-openvswitch} |
Brad Hall | f1f3a8f | 2011-12-12 23:04:58 +0000 | [diff] [blame] | 264 | # Default Quantum Port |
| 265 | Q_PORT=${Q_PORT:-9696} |
| 266 | # Default Quantum Host |
| 267 | Q_HOST=${Q_HOST:-localhost} |
Aaron Rosen | 9313dfa | 2012-07-06 16:08:49 -0400 | [diff] [blame] | 268 | # Which Quantum API nova should use |
Aaron Rosen | 9313dfa | 2012-07-06 16:08:49 -0400 | [diff] [blame] | 269 | # Default admin username |
| 270 | Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-quantum} |
| 271 | # Default auth strategy |
| 272 | Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone} |
Dan Wendlandt | ea23e68 | 2012-08-22 05:53:17 -0700 | [diff] [blame] | 273 | # Use namespace or not |
| 274 | Q_USE_NAMESPACE=${Q_USE_NAMESPACE:-True} |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 275 | |
Jesse Andrews | d02b7b7 | 2011-11-14 08:59:05 -0800 | [diff] [blame] | 276 | # Name of the lvm volume group to use/create for iscsi volumes |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 277 | VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes} |
Dean Troyer | 2229a6e | 2011-12-01 17:02:07 -0600 | [diff] [blame] | 278 | VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-} |
Anthony Young | 5545845 | 2011-12-17 00:21:49 +0000 | [diff] [blame] | 279 | INSTANCE_NAME_PREFIX=${INSTANCE_NAME_PREFIX:-instance-} |
Jesse Andrews | d02b7b7 | 2011-11-14 08:59:05 -0800 | [diff] [blame] | 280 | |
Vishvananda Ishaya | 51aa401 | 2012-03-06 12:45:19 -0800 | [diff] [blame] | 281 | # Nova supports pluggable schedulers. ``FilterScheduler`` should work in most |
| 282 | # cases. |
| 283 | SCHEDULER=${SCHEDULER:-nova.scheduler.filter_scheduler.FilterScheduler} |
Jesse Andrews | 782b991 | 2011-10-02 16:53:21 -0400 | [diff] [blame] | 284 | |
Vishvananda Ishaya | c9ad14b | 2012-07-03 20:29:01 +0000 | [diff] [blame] | 285 | # Set fixed and floating range here so we can make sure not to use addresses |
| 286 | # from either range when attempting to guess the ip to use for the host |
| 287 | FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24} |
| 288 | FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.224/28} |
| 289 | |
| 290 | # Find the interface used for the default route |
| 291 | HOST_IP_IFACE=${HOST_IP_IFACE:-$(ip route | sed -n '/^default/{ s/.*dev \(\w\+\)\s\+.*/\1/; p; }')} |
| 292 | # Search for an IP unless an explicit is set by ``HOST_IP`` environment variable |
root | b115341 | 2012-01-19 13:28:21 -0800 | [diff] [blame] | 293 | if [ -z "$HOST_IP" -o "$HOST_IP" == "dhcp" ]; then |
Vishvananda Ishaya | c9ad14b | 2012-07-03 20:29:01 +0000 | [diff] [blame] | 294 | HOST_IP="" |
| 295 | HOST_IPS=`LC_ALL=C ip -f inet addr show ${HOST_IP_IFACE} | awk '/inet/ {split($2,parts,"/"); print parts[1]}'` |
| 296 | for IP in $HOST_IPS; do |
| 297 | # Attempt to filter out ip addresses that are part of the fixed and |
| 298 | # floating range. Note that this method only works if the 'netaddr' |
| 299 | # python library is installed. If it is not installed, an error |
| 300 | # will be printed and the first ip from the interface will be used. |
| 301 | if ! (address_in_net $IP $FIXED_RANGE || address_in_net $IP $FLOATING_RANGE); then |
| 302 | HOST_IP=$IP |
| 303 | break; |
| 304 | fi |
| 305 | done |
| 306 | if [ "$HOST_IP" == "" ]; then |
Anthony Young | 857035d | 2011-11-07 14:02:13 -0600 | [diff] [blame] | 307 | echo "Could not determine host ip address." |
Vishvananda Ishaya | c9ad14b | 2012-07-03 20:29:01 +0000 | [diff] [blame] | 308 | echo "Either localrc specified dhcp on ${HOST_IP_IFACE} or defaulted" |
Anthony Young | 7c259ce | 2011-11-07 13:18:28 -0600 | [diff] [blame] | 309 | exit 1 |
| 310 | fi |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 311 | fi |
| 312 | |
Anthony Young | 1097c7c | 2011-12-27 23:22:14 -0800 | [diff] [blame] | 313 | # Allow the use of an alternate hostname (such as localhost/127.0.0.1) for service endpoints. |
| 314 | SERVICE_HOST=${SERVICE_HOST:-$HOST_IP} |
| 315 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 316 | # Configure services to use syslog instead of writing to individual log files |
Dean Troyer | ff603ef | 2011-11-22 17:48:10 -0600 | [diff] [blame] | 317 | SYSLOG=`trueorfalse False $SYSLOG` |
| 318 | SYSLOG_HOST=${SYSLOG_HOST:-$HOST_IP} |
| 319 | SYSLOG_PORT=${SYSLOG_PORT:-516} |
| 320 | |
Vishvananda Ishaya | 6f13ba3 | 2012-06-01 23:17:38 +0000 | [diff] [blame] | 321 | # Use color for logging output |
| 322 | LOG_COLOR=`trueorfalse True $LOG_COLOR` |
| 323 | |
Dean Troyer | 2bbcd68 | 2011-11-05 16:19:03 -0500 | [diff] [blame] | 324 | # Service startup timeout |
| 325 | SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60} |
| 326 | |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 327 | # Generic helper to configure passwords |
| 328 | function read_password { |
| 329 | set +o xtrace |
| 330 | var=$1; msg=$2 |
| 331 | pw=${!var} |
| 332 | |
Anthony Young | b4db225 | 2011-10-12 14:08:08 -0700 | [diff] [blame] | 333 | localrc=$TOP_DIR/localrc |
Anthony Young | 6015c82 | 2011-10-12 07:17:11 +0000 | [diff] [blame] | 334 | |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 335 | # If the password is not defined yet, proceed to prompt user for a password. |
| 336 | if [ ! $pw ]; then |
| 337 | # If there is no localrc file, create one |
Anthony Young | b4db225 | 2011-10-12 14:08:08 -0700 | [diff] [blame] | 338 | if [ ! -e $localrc ]; then |
| 339 | touch $localrc |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 340 | fi |
| 341 | |
Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 342 | # Presumably if we got this far it can only be that our localrc is missing |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 343 | # the required password. Prompt user for a password and write to localrc. |
Anthony Young | b4db225 | 2011-10-12 14:08:08 -0700 | [diff] [blame] | 344 | echo '' |
| 345 | echo '################################################################################' |
| 346 | echo $msg |
| 347 | echo '################################################################################' |
Dean Troyer | 4e6a2b7 | 2011-12-29 17:27:45 -0600 | [diff] [blame] | 348 | echo "This value will be written to your localrc file so you don't have to enter it " |
| 349 | echo "again. Use only alphanumeric characters." |
Anthony Young | b4db225 | 2011-10-12 14:08:08 -0700 | [diff] [blame] | 350 | echo "If you leave this blank, a random default value will be used." |
Dean Troyer | 4e6a2b7 | 2011-12-29 17:27:45 -0600 | [diff] [blame] | 351 | pw=" " |
| 352 | while true; do |
| 353 | echo "Enter a password now:" |
| 354 | read -e $var |
| 355 | pw=${!var} |
| 356 | [[ "$pw" = "`echo $pw | tr -cd [:alnum:]`" ]] && break |
| 357 | echo "Invalid chars in password. Try again:" |
| 358 | done |
Anthony Young | b4db225 | 2011-10-12 14:08:08 -0700 | [diff] [blame] | 359 | if [ ! $pw ]; then |
| 360 | pw=`openssl rand -hex 10` |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 361 | fi |
Anthony Young | b4db225 | 2011-10-12 14:08:08 -0700 | [diff] [blame] | 362 | eval "$var=$pw" |
| 363 | echo "$var=$pw" >> $localrc |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 364 | fi |
| 365 | set -o xtrace |
| 366 | } |
| 367 | |
Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 368 | |
Jesse Andrews | 782b991 | 2011-10-02 16:53:21 -0400 | [diff] [blame] | 369 | # Nova Network Configuration |
| 370 | # -------------------------- |
| 371 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 372 | # FIXME: more documentation about why these are important options. Also |
| 373 | # we should make sure we use the same variable names as the option names. |
Jesse Andrews | 5372f43 | 2011-10-03 01:08:24 -0400 | [diff] [blame] | 374 | |
John Garbutt | 8e2cffd | 2012-03-02 16:22:07 +0000 | [diff] [blame] | 375 | if [ "$VIRT_DRIVER" = 'xenserver' ]; then |
| 376 | PUBLIC_INTERFACE_DEFAULT=eth3 |
| 377 | # allow build_domU.sh to specify the flat network bridge via kernel args |
Renuka Apte | 0af143b | 2012-04-02 15:46:53 -0700 | [diff] [blame] | 378 | FLAT_NETWORK_BRIDGE_DEFAULT=$(grep -o 'flat_network_bridge=[[:alnum:]]*' /proc/cmdline | cut -d= -f 2 | sort -u) |
John Garbutt | 8e2cffd | 2012-03-02 16:22:07 +0000 | [diff] [blame] | 379 | GUEST_INTERFACE_DEFAULT=eth1 |
| 380 | else |
| 381 | PUBLIC_INTERFACE_DEFAULT=br100 |
| 382 | FLAT_NETWORK_BRIDGE_DEFAULT=br100 |
| 383 | GUEST_INTERFACE_DEFAULT=eth0 |
| 384 | fi |
| 385 | |
| 386 | PUBLIC_INTERFACE=${PUBLIC_INTERFACE:-$PUBLIC_INTERFACE_DEFAULT} |
Jesse Andrews | b5197e4 | 2011-09-26 12:48:31 -0700 | [diff] [blame] | 387 | FIXED_NETWORK_SIZE=${FIXED_NETWORK_SIZE:-256} |
Aaron Rosen | 9313dfa | 2012-07-06 16:08:49 -0400 | [diff] [blame] | 388 | NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1} |
Jesse Andrews | a72f7ad | 2011-09-25 13:41:22 -0700 | [diff] [blame] | 389 | NET_MAN=${NET_MAN:-FlatDHCPManager} |
Anthony Young | 1097c7c | 2011-12-27 23:22:14 -0800 | [diff] [blame] | 390 | EC2_DMZ_HOST=${EC2_DMZ_HOST:-$SERVICE_HOST} |
John Garbutt | 8e2cffd | 2012-03-02 16:22:07 +0000 | [diff] [blame] | 391 | FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-$FLAT_NETWORK_BRIDGE_DEFAULT} |
| 392 | VLAN_INTERFACE=${VLAN_INTERFACE:-$GUEST_INTERFACE_DEFAULT} |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 393 | |
Dean Troyer | 696ad33 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 394 | # Test floating pool and range are used for testing. They are defined |
| 395 | # here until the admin APIs can replace nova-manage |
| 396 | TEST_FLOATING_POOL=${TEST_FLOATING_POOL:-test} |
| 397 | TEST_FLOATING_RANGE=${TEST_FLOATING_RANGE:-192.168.253.0/29} |
| 398 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 399 | # **MULTI_HOST** is a mode where each compute node runs its own network node. This |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 400 | # allows network operations and routing for a VM to occur on the server that is |
| 401 | # running the VM - removing a SPOF and bandwidth bottleneck. |
Armando Migliaccio | 7d13f30 | 2012-04-19 22:26:16 +0100 | [diff] [blame] | 402 | MULTI_HOST=`trueorfalse False $MULTI_HOST` |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 403 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 404 | # If you are using FlatDHCP on multiple hosts, set the ``FLAT_INTERFACE`` |
| 405 | # variable but make sure that the interface doesn't already have an |
| 406 | # ip or you risk breaking things. |
Jesse Andrews | 5372f43 | 2011-10-03 01:08:24 -0400 | [diff] [blame] | 407 | # |
Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 408 | # **DHCP Warning**: If your flat interface device uses DHCP, there will be a |
| 409 | # hiccup while the network is moved from the flat interface to the flat network |
| 410 | # bridge. This will happen when you launch your first instance. Upon launch |
| 411 | # you will lose all connectivity to the node, and the vm launch will probably |
Jesse Andrews | 5372f43 | 2011-10-03 01:08:24 -0400 | [diff] [blame] | 412 | # fail. |
Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 413 | # |
| 414 | # If you are running on a single node and don't need to access the VMs from |
Jesse Andrews | 5372f43 | 2011-10-03 01:08:24 -0400 | [diff] [blame] | 415 | # devices other than that node, you can set the flat interface to the same |
Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 416 | # value as ``FLAT_NETWORK_BRIDGE``. This will stop the network hiccup from |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 417 | # occurring. |
John Garbutt | 8e2cffd | 2012-03-02 16:22:07 +0000 | [diff] [blame] | 418 | FLAT_INTERFACE=${FLAT_INTERFACE:-$GUEST_INTERFACE_DEFAULT} |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 419 | |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 420 | ## FIXME(ja): should/can we check that FLAT_INTERFACE is sane? |
| 421 | |
Brad Hall | 1bfa3d5 | 2011-10-27 18:18:20 -0700 | [diff] [blame] | 422 | # Using Quantum networking: |
| 423 | # |
Brad Hall | f1f3a8f | 2011-12-12 23:04:58 +0000 | [diff] [blame] | 424 | # Make sure that quantum is enabled in ENABLED_SERVICES. If it is the network |
| 425 | # manager will be set to the QuantumManager. If you want to run Quantum on |
| 426 | # this host, make sure that q-svc is also in ENABLED_SERVICES. |
Brad Hall | 1bfa3d5 | 2011-10-27 18:18:20 -0700 | [diff] [blame] | 427 | # |
| 428 | # If you're planning to use the Quantum openvswitch plugin, set Q_PLUGIN to |
| 429 | # "openvswitch" and make sure the q-agt service is enabled in |
| 430 | # ENABLED_SERVICES. |
| 431 | # |
| 432 | # With Quantum networking the NET_MAN variable is ignored. |
| 433 | |
Russell Bryant | 4a22145 | 2012-03-13 13:44:12 -0400 | [diff] [blame] | 434 | # MySQL & (RabbitMQ or Qpid) |
| 435 | # -------------------------- |
Jesse Andrews | 782b991 | 2011-10-02 16:53:21 -0400 | [diff] [blame] | 436 | |
Tres Henry | ca85b79 | 2011-10-28 14:00:21 -0700 | [diff] [blame] | 437 | # We configure Nova, Horizon, Glance and Keystone to use MySQL as their |
Jesse Andrews | 782b991 | 2011-10-02 16:53:21 -0400 | [diff] [blame] | 438 | # database server. While they share a single server, each has their own |
| 439 | # database and tables. |
| 440 | |
Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 441 | # By default this script will install and configure MySQL. If you want to |
Jesse Andrews | 782b991 | 2011-10-02 16:53:21 -0400 | [diff] [blame] | 442 | # use an existing server, you can pass in the user/password/host parameters. |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 443 | # You will need to send the same ``MYSQL_PASSWORD`` to every host if you are doing |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 444 | # a multi-node DevStack installation. |
Jesse Andrews | a50a346 | 2011-10-19 15:38:10 -0700 | [diff] [blame] | 445 | MYSQL_HOST=${MYSQL_HOST:-localhost} |
Anthony Young | 320412b | 2011-09-14 02:39:10 -0700 | [diff] [blame] | 446 | MYSQL_USER=${MYSQL_USER:-root} |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 447 | read_password MYSQL_PASSWORD "ENTER A PASSWORD TO USE FOR MYSQL." |
Jesse Andrews | 782b991 | 2011-10-02 16:53:21 -0400 | [diff] [blame] | 448 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 449 | # NOTE: Don't specify /db in this string so we can use it for multiple services |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 450 | BASE_SQL_CONN=${BASE_SQL_CONN:-mysql://$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST} |
Anthony Young | a841644 | 2011-09-13 20:07:44 -0700 | [diff] [blame] | 451 | |
| 452 | # Rabbit connection info |
Russell Bryant | 4a22145 | 2012-03-13 13:44:12 -0400 | [diff] [blame] | 453 | if is_service_enabled rabbit; then |
| 454 | RABBIT_HOST=${RABBIT_HOST:-localhost} |
| 455 | read_password RABBIT_PASSWORD "ENTER A PASSWORD TO USE FOR RABBIT." |
| 456 | fi |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 457 | |
Anthony Young | 377aae6 | 2011-09-14 09:55:31 -0700 | [diff] [blame] | 458 | # Glance connection info. Note the port must be specified. |
Anthony Young | 1097c7c | 2011-12-27 23:22:14 -0800 | [diff] [blame] | 459 | GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$SERVICE_HOST:9292} |
Anthony Young | 377aae6 | 2011-09-14 09:55:31 -0700 | [diff] [blame] | 460 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 461 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 462 | # Swift |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 463 | # ----- |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 464 | |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 465 | # TODO: add logging to different location. |
Chmouel Boudjnah | b93478f | 2011-11-02 16:49:56 +0100 | [diff] [blame] | 466 | |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 467 | # By default the location of swift drives and objects is located inside |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 468 | # the swift source directory. SWIFT_DATA_DIR variable allow you to redefine |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 469 | # this. |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 470 | SWIFT_DATA_DIR=${SWIFT_DATA_DIR:-${DEST}/data/swift} |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 471 | |
Chmouel Boudjnah | 3a64826 | 2011-11-03 10:43:46 +0100 | [diff] [blame] | 472 | # We are going to have the configuration files inside the source |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 473 | # directory, change SWIFT_CONFIG_DIR if you want to adjust that. |
| 474 | SWIFT_CONFIG_DIR=${SWIFT_CONFIG_DIR:-/etc/swift} |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 475 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 476 | # DevStack will create a loop-back disk formatted as XFS to store the |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 477 | # swift data. By default the disk size is 1 gigabyte. The variable |
| 478 | # SWIFT_LOOPBACK_DISK_SIZE specified in bytes allow you to change |
| 479 | # that. |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 480 | SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-1000000} |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 481 | |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 482 | # The ring uses a configurable number of bits from a path’s MD5 hash as |
| 483 | # a partition index that designates a device. The number of bits kept |
| 484 | # from the hash is known as the partition power, and 2 to the partition |
| 485 | # power indicates the partition count. Partitioning the full MD5 hash |
| 486 | # ring allows other parts of the cluster to work in batches of items at |
| 487 | # once which ends up either more efficient or at least less complex than |
| 488 | # working with each item separately or the entire cluster all at once. |
| 489 | # By default we define 9 for the partition count (which mean 512). |
Chmouel Boudjnah | a211898 | 2011-11-01 15:36:00 +0100 | [diff] [blame] | 490 | SWIFT_PARTITION_POWER_SIZE=${SWIFT_PARTITION_POWER_SIZE:-9} |
| 491 | |
Chmouel Boudjnah | a95efab | 2012-02-16 10:35:26 +0000 | [diff] [blame] | 492 | # This variable allows you to configure how many replicas you want to be |
| 493 | # configured for your Swift cluster. By default the three replicas would need a |
| 494 | # bit of IO and Memory on a VM you may want to lower that to 1 if you want to do |
| 495 | # only some quick testing. |
| 496 | SWIFT_REPLICAS=${SWIFT_REPLICAS:-3} |
| 497 | |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 498 | if is_service_enabled swift; then |
Chmouel Boudjnah | 6ae9ea5 | 2012-07-05 06:50:51 +0000 | [diff] [blame] | 499 | # If we are using swift3, we can default the s3 port to swift instead |
Chmouel Boudjnah | 77b0e1d | 2012-02-29 16:55:43 +0000 | [diff] [blame] | 500 | # of nova-objectstore |
Chmouel Boudjnah | 6ae9ea5 | 2012-07-05 06:50:51 +0000 | [diff] [blame] | 501 | if is_service_enabled swift3;then |
| 502 | S3_SERVICE_PORT=${S3_SERVICE_PORT:-8080} |
| 503 | fi |
Chmouel Boudjnah | 77b0e1d | 2012-02-29 16:55:43 +0000 | [diff] [blame] | 504 | # We only ask for Swift Hash if we have enabled swift service. |
Chmouel Boudjnah | b2857e4 | 2011-11-03 16:19:14 +0100 | [diff] [blame] | 505 | # SWIFT_HASH is a random unique string for a swift cluster that |
| 506 | # can never change. |
| 507 | read_password SWIFT_HASH "ENTER A RANDOM SWIFT HASH." |
| 508 | fi |
Vishvananda Ishaya | 5f03932 | 2011-11-05 16:12:20 -0700 | [diff] [blame] | 509 | |
Chmouel Boudjnah | 77b0e1d | 2012-02-29 16:55:43 +0000 | [diff] [blame] | 510 | # Set default port for nova-objectstore |
| 511 | S3_SERVICE_PORT=${S3_SERVICE_PORT:-3333} |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 512 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 513 | |
Jesse Andrews | 782b991 | 2011-10-02 16:53:21 -0400 | [diff] [blame] | 514 | # Keystone |
| 515 | # -------- |
| 516 | |
Jesse Andrews | b96871e | 2011-10-02 09:02:46 -0700 | [diff] [blame] | 517 | # Service Token - Openstack components need to have an admin token |
| 518 | # to validate user tokens. |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 519 | read_password SERVICE_TOKEN "ENTER A SERVICE_TOKEN TO USE FOR THE SERVICE ADMIN TOKEN." |
Dean Troyer | b328838 | 2012-02-28 16:41:10 -0600 | [diff] [blame] | 520 | # Services authenticate to Identity with servicename/SERVICE_PASSWORD |
| 521 | read_password SERVICE_PASSWORD "ENTER A SERVICE_PASSWORD TO USE FOR THE SERVICE AUTHENTICATION." |
Tres Henry | ca85b79 | 2011-10-28 14:00:21 -0700 | [diff] [blame] | 522 | # Horizon currently truncates usernames and passwords at 20 characters |
| 523 | read_password ADMIN_PASSWORD "ENTER A PASSWORD TO USE FOR HORIZON AND KEYSTONE (20 CHARS OR LESS)." |
Jesse Andrews | b96871e | 2011-10-02 09:02:46 -0700 | [diff] [blame] | 524 | |
Dean Troyer | b328838 | 2012-02-28 16:41:10 -0600 | [diff] [blame] | 525 | # Set the tenant for service accounts in Keystone |
| 526 | SERVICE_TENANT_NAME=${SERVICE_TENANT_NAME:-service} |
| 527 | |
Dean Troyer | 6577b46 | 2012-01-16 22:27:20 -0600 | [diff] [blame] | 528 | # Set Keystone interface configuration |
Dean Troyer | b328838 | 2012-02-28 16:41:10 -0600 | [diff] [blame] | 529 | KEYSTONE_API_PORT=${KEYSTONE_API_PORT:-5000} |
Dean Troyer | 6577b46 | 2012-01-16 22:27:20 -0600 | [diff] [blame] | 530 | KEYSTONE_AUTH_HOST=${KEYSTONE_AUTH_HOST:-$SERVICE_HOST} |
| 531 | KEYSTONE_AUTH_PORT=${KEYSTONE_AUTH_PORT:-35357} |
| 532 | KEYSTONE_AUTH_PROTOCOL=${KEYSTONE_AUTH_PROTOCOL:-http} |
| 533 | KEYSTONE_SERVICE_HOST=${KEYSTONE_SERVICE_HOST:-$SERVICE_HOST} |
| 534 | KEYSTONE_SERVICE_PORT=${KEYSTONE_SERVICE_PORT:-5000} |
| 535 | KEYSTONE_SERVICE_PROTOCOL=${KEYSTONE_SERVICE_PROTOCOL:-http} |
| 536 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 537 | |
Dean Troyer | 9bb84f0 | 2012-01-24 11:45:52 -0600 | [diff] [blame] | 538 | # Horizon |
| 539 | # ------- |
| 540 | |
| 541 | # Allow overriding the default Apache user and group, default both to |
| 542 | # current user. |
| 543 | APACHE_USER=${APACHE_USER:-$USER} |
| 544 | APACHE_GROUP=${APACHE_GROUP:-$APACHE_USER} |
| 545 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 546 | |
Dean Troyer | 471de7a | 2011-12-27 11:45:55 -0600 | [diff] [blame] | 547 | # Log files |
| 548 | # --------- |
| 549 | |
| 550 | # Set up logging for stack.sh |
| 551 | # Set LOGFILE to turn on logging |
| 552 | # We append '.xxxxxxxx' to the given name to maintain history |
| 553 | # where xxxxxxxx is a representation of the date the file was created |
Chmouel Boudjnah | d966ed2 | 2012-03-05 12:42:48 +0000 | [diff] [blame] | 554 | if [[ -n "$LOGFILE" || -n "$SCREEN_LOGDIR" ]]; then |
| 555 | LOGDAYS=${LOGDAYS:-7} |
| 556 | TIMESTAMP_FORMAT=${TIMESTAMP_FORMAT:-"%F-%H%M%S"} |
| 557 | CURRENT_LOG_TIME=$(date "+$TIMESTAMP_FORMAT") |
| 558 | fi |
| 559 | |
Dean Troyer | 471de7a | 2011-12-27 11:45:55 -0600 | [diff] [blame] | 560 | if [[ -n "$LOGFILE" ]]; then |
| 561 | # First clean up old log files. Use the user-specified LOGFILE |
| 562 | # as the template to search for, appending '.*' to match the date |
| 563 | # we added on earlier runs. |
Dean Troyer | 471de7a | 2011-12-27 11:45:55 -0600 | [diff] [blame] | 564 | LOGDIR=$(dirname "$LOGFILE") |
| 565 | LOGNAME=$(basename "$LOGFILE") |
Chmouel Boudjnah | fff6fec | 2012-03-09 15:37:56 +0000 | [diff] [blame] | 566 | mkdir -p $LOGDIR |
Dean Troyer | 471de7a | 2011-12-27 11:45:55 -0600 | [diff] [blame] | 567 | find $LOGDIR -maxdepth 1 -name $LOGNAME.\* -mtime +$LOGDAYS -exec rm {} \; |
| 568 | |
Chmouel Boudjnah | d966ed2 | 2012-03-05 12:42:48 +0000 | [diff] [blame] | 569 | LOGFILE=$LOGFILE.${CURRENT_LOG_TIME} |
Dean Troyer | 471de7a | 2011-12-27 11:45:55 -0600 | [diff] [blame] | 570 | # Redirect stdout/stderr to tee to write the log file |
| 571 | exec 1> >( tee "${LOGFILE}" ) 2>&1 |
| 572 | echo "stack.sh log $LOGFILE" |
| 573 | # Specified logfile name always links to the most recent log |
| 574 | ln -sf $LOGFILE $LOGDIR/$LOGNAME |
| 575 | fi |
| 576 | |
Chmouel Boudjnah | d966ed2 | 2012-03-05 12:42:48 +0000 | [diff] [blame] | 577 | # Set up logging of screen windows |
| 578 | # Set SCREEN_LOGDIR to turn on logging of screen windows to the |
| 579 | # directory specified in SCREEN_LOGDIR, we will log to the the file |
| 580 | # screen-$SERVICE_NAME-$TIMESTAMP.log in that dir and have a link |
| 581 | # screen-$SERVICE_NAME.log to the latest log file. |
| 582 | # Logs are kept for as long specified in LOGDAYS. |
| 583 | if [[ -n "$SCREEN_LOGDIR" ]]; then |
| 584 | |
| 585 | # We make sure the directory is created. |
| 586 | if [[ -d "$SCREEN_LOGDIR" ]]; then |
| 587 | # We cleanup the old logs |
| 588 | find $SCREEN_LOGDIR -maxdepth 1 -name screen-\*.log -mtime +$LOGDAYS -exec rm {} \; |
| 589 | else |
| 590 | mkdir -p $SCREEN_LOGDIR |
| 591 | fi |
| 592 | fi |
| 593 | |
Scott Moser | f9da508 | 2011-10-07 21:28:00 -0400 | [diff] [blame] | 594 | # So that errors don't compound we exit on any errors so you see only the |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 595 | # first error that occurred. |
Scott Moser | f9da508 | 2011-10-07 21:28:00 -0400 | [diff] [blame] | 596 | trap failed ERR |
| 597 | failed() { |
| 598 | local r=$? |
| 599 | set +o xtrace |
| 600 | [ -n "$LOGFILE" ] && echo "${0##*/} failed: full log in $LOGFILE" |
| 601 | exit $r |
| 602 | } |
| 603 | |
| 604 | # Print the commands being run so that we can see the command that triggers |
| 605 | # an error. It is also useful for following along as the install occurs. |
| 606 | set -o xtrace |
| 607 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 608 | |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 609 | # Install Packages |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 610 | # ================ |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 611 | |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 612 | # Openstack uses a fair number of other projects. |
| 613 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 614 | # Install package requirements |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 615 | if [[ "$os_PACKAGE" = "deb" ]]; then |
| 616 | apt_get update |
| 617 | install_package $(get_packages $FILES/apts) |
| 618 | else |
| 619 | install_package $(get_packages $FILES/rpms) |
| 620 | fi |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 621 | |
Monty Taylor | 47f0206 | 2012-07-26 11:09:24 -0500 | [diff] [blame] | 622 | if [[ $SYSLOG != "False" ]]; then |
| 623 | install_package rsyslog-relp |
| 624 | fi |
| 625 | |
| 626 | if is_service_enabled rabbit; then |
| 627 | # Install rabbitmq-server |
| 628 | # the temp file is necessary due to LP: #878600 |
| 629 | tfile=$(mktemp) |
| 630 | install_package rabbitmq-server > "$tfile" 2>&1 |
| 631 | cat "$tfile" |
| 632 | rm -f "$tfile" |
| 633 | elif is_service_enabled qpid; then |
| 634 | if [[ "$os_PACKAGE" = "rpm" ]]; then |
| 635 | install_package qpid-cpp-server |
| 636 | else |
| 637 | install_package qpidd |
| 638 | fi |
| 639 | fi |
| 640 | |
| 641 | if is_service_enabled mysql; then |
| 642 | |
| 643 | if [[ "$os_PACKAGE" = "deb" ]]; then |
| 644 | # Seed configuration with mysql password so that apt-get install doesn't |
| 645 | # prompt us for a password upon install. |
| 646 | cat <<MYSQL_PRESEED | sudo debconf-set-selections |
| 647 | mysql-server-5.1 mysql-server/root_password password $MYSQL_PASSWORD |
| 648 | mysql-server-5.1 mysql-server/root_password_again password $MYSQL_PASSWORD |
| 649 | mysql-server-5.1 mysql-server/start_on_boot boolean true |
| 650 | MYSQL_PRESEED |
| 651 | fi |
| 652 | |
| 653 | # while ``.my.cnf`` is not needed for openstack to function, it is useful |
| 654 | # as it allows you to access the mysql databases via ``mysql nova`` instead |
| 655 | # of having to specify the username/password each time. |
| 656 | if [[ ! -e $HOME/.my.cnf ]]; then |
| 657 | cat <<EOF >$HOME/.my.cnf |
| 658 | [client] |
| 659 | user=$MYSQL_USER |
| 660 | password=$MYSQL_PASSWORD |
| 661 | host=$MYSQL_HOST |
| 662 | EOF |
| 663 | chmod 0600 $HOME/.my.cnf |
| 664 | fi |
| 665 | # Install mysql-server |
| 666 | install_package mysql-server |
| 667 | fi |
| 668 | |
| 669 | if is_service_enabled quantum; then |
| 670 | if [[ "$Q_PLUGIN" = "linuxbridge" ]]; then |
| 671 | # Install deps |
| 672 | # FIXME add to files/apts/quantum, but don't install if not needed! |
| 673 | install_package python-configobj |
| 674 | fi |
| 675 | fi |
| 676 | |
| 677 | if is_service_enabled horizon; then |
| 678 | if [[ "$os_PACKAGE" = "deb" ]]; then |
| 679 | # Install apache2, which is NOPRIME'd |
| 680 | install_package apache2 libapache2-mod-wsgi |
| 681 | else |
| 682 | sudo rm -f /etc/httpd/conf.d/000-* |
| 683 | install_package httpd mod_wsgi |
| 684 | fi |
| 685 | fi |
| 686 | |
| 687 | if is_service_enabled q-agt; then |
| 688 | if [[ "$Q_PLUGIN" = "openvswitch" ]]; then |
| 689 | # Install deps |
| 690 | # FIXME add to files/apts/quantum, but don't install if not needed! |
| 691 | if [[ "$os_PACKAGE" = "deb" ]]; then |
| 692 | kernel_version=`cat /proc/version | cut -d " " -f3` |
| 693 | install_package make fakeroot dkms openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version |
| 694 | else |
| 695 | ### FIXME(dtroyer): Find RPMs for OpenVSwitch |
| 696 | echo "OpenVSwitch packages need to be located" |
| 697 | fi |
| 698 | elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then |
| 699 | install_package bridge-utils |
| 700 | fi |
| 701 | fi |
| 702 | |
| 703 | if is_service_enabled n-cpu; then |
| 704 | |
| 705 | # Virtualization Configuration |
| 706 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 707 | if [[ "$os_PACKAGE" = "deb" ]]; then |
| 708 | LIBVIRT_PKG_NAME=libvirt-bin |
| 709 | else |
| 710 | LIBVIRT_PKG_NAME=libvirt |
| 711 | fi |
| 712 | install_package $LIBVIRT_PKG_NAME |
| 713 | # Install and configure **LXC** if specified. LXC is another approach to |
| 714 | # splitting a system into many smaller parts. LXC uses cgroups and chroot |
| 715 | # to simulate multiple systems. |
| 716 | if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then |
| 717 | if [[ "$os_PACKAGE" = "deb" ]]; then |
| 718 | if [[ "$DISTRO" > natty ]]; then |
| 719 | install_package cgroup-lite |
| 720 | fi |
| 721 | else |
| 722 | ### FIXME(dtroyer): figure this out |
| 723 | echo "RPM-based cgroup not implemented yet" |
| 724 | yum_install libcgroup-tools |
| 725 | fi |
| 726 | fi |
| 727 | fi |
| 728 | |
| 729 | if is_service_enabled swift; then |
| 730 | # Install memcached for swift. |
| 731 | install_package memcached |
| 732 | fi |
| 733 | |
| 734 | TRACK_DEPENDS=${TRACK_DEPENDS:-False} |
| 735 | |
| 736 | # Install python packages into a virtualenv so that we can track them |
| 737 | if [[ $TRACK_DEPENDS = True ]] ; then |
| 738 | install_package python-virtualenv |
| 739 | |
| 740 | rm -rf $DEST/.venv |
| 741 | virtualenv --system-site-packages $DEST/.venv |
| 742 | source $DEST/.venv/bin/activate |
| 743 | $DEST/.venv/bin/pip freeze > $DEST/requires-pre-pip |
| 744 | fi |
| 745 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 746 | # Install python requirements |
Dean Troyer | d0b21e2 | 2012-03-07 14:52:25 -0600 | [diff] [blame] | 747 | pip_install $(get_packages $FILES/pips | sort -u) |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 748 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 749 | # Check out OpenStack sources |
Anthony Young | 2f14020 | 2011-09-26 13:02:40 -0700 | [diff] [blame] | 750 | git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 751 | |
| 752 | # Check out the client libs that are used most |
Andy Smith | 84c0599 | 2012-02-03 21:40:32 -0800 | [diff] [blame] | 753 | git_clone $KEYSTONECLIENT_REPO $KEYSTONECLIENT_DIR $KEYSTONECLIENT_BRANCH |
Anthony Young | 2f14020 | 2011-09-26 13:02:40 -0700 | [diff] [blame] | 754 | git_clone $NOVACLIENT_REPO $NOVACLIENT_DIR $NOVACLIENT_BRANCH |
Andrew Bogott | 77a4e3a | 2012-05-01 00:07:29 -0500 | [diff] [blame] | 755 | git_clone $OPENSTACKCLIENT_REPO $OPENSTACKCLIENT_DIR $OPENSTACKCLIENT_BRANCH |
Dean Troyer | 4549525 | 2012-04-13 13:16:38 -0500 | [diff] [blame] | 756 | git_clone $GLANCECLIENT_REPO $GLANCECLIENT_DIR $GLANCECLIENT_BRANCH |
Jesse Andrews | 38df122 | 2011-11-20 09:55:44 -0800 | [diff] [blame] | 757 | |
| 758 | # glance, swift middleware and nova api needs keystone middleware |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 759 | if is_service_enabled key g-api n-api swift; then |
Jesse Andrews | 38df122 | 2011-11-20 09:55:44 -0800 | [diff] [blame] | 760 | # unified auth system (manages accounts/tokens) |
| 761 | git_clone $KEYSTONE_REPO $KEYSTONE_DIR $KEYSTONE_BRANCH |
| 762 | fi |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 763 | if is_service_enabled swift; then |
James E. Blair | e7ce24f | 2011-11-10 13:05:13 -0800 | [diff] [blame] | 764 | # storage service |
| 765 | git_clone $SWIFT_REPO $SWIFT_DIR $SWIFT_BRANCH |
Chmouel Boudjnah | fda9df8 | 2012-05-22 10:27:08 +0000 | [diff] [blame] | 766 | # storage service client and and Library |
| 767 | git_clone $SWIFTCLIENT_REPO $SWIFTCLIENT_DIR $SWIFTCLIENT_BRANCH |
Chmouel Boudjnah | 6ae9ea5 | 2012-07-05 06:50:51 +0000 | [diff] [blame] | 768 | if is_service_enabled swift3; then |
| 769 | # swift3 middleware to provide S3 emulation to Swift |
| 770 | git_clone $SWIFT3_REPO $SWIFT3_DIR $SWIFT3_BRANCH |
| 771 | fi |
James E. Blair | e7ce24f | 2011-11-10 13:05:13 -0800 | [diff] [blame] | 772 | fi |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 773 | if is_service_enabled g-api n-api; then |
James E. Blair | e7ce24f | 2011-11-10 13:05:13 -0800 | [diff] [blame] | 774 | # image catalog service |
| 775 | git_clone $GLANCE_REPO $GLANCE_DIR $GLANCE_BRANCH |
| 776 | fi |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 777 | if is_service_enabled n-novnc; then |
James E. Blair | e7ce24f | 2011-11-10 13:05:13 -0800 | [diff] [blame] | 778 | # a websockets/html5 or flash powered VNC console for vm instances |
| 779 | git_clone $NOVNC_REPO $NOVNC_DIR $NOVNC_BRANCH |
| 780 | fi |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 781 | if is_service_enabled horizon; then |
James E. Blair | e7ce24f | 2011-11-10 13:05:13 -0800 | [diff] [blame] | 782 | # django powered web control panel for openstack |
| 783 | git_clone $HORIZON_REPO $HORIZON_DIR $HORIZON_BRANCH $HORIZON_TAG |
| 784 | fi |
Monty Taylor | 5440ac0 | 2012-03-23 11:32:29 -0700 | [diff] [blame] | 785 | if is_service_enabled quantum; then |
| 786 | git_clone $QUANTUM_CLIENT_REPO $QUANTUM_CLIENT_DIR $QUANTUM_CLIENT_BRANCH |
| 787 | fi |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 788 | if is_service_enabled quantum; then |
James E. Blair | e7ce24f | 2011-11-10 13:05:13 -0800 | [diff] [blame] | 789 | # quantum |
| 790 | git_clone $QUANTUM_REPO $QUANTUM_DIR $QUANTUM_BRANCH |
Deepak Garg | 1e98bdc | 2012-02-22 12:15:26 +0530 | [diff] [blame] | 791 | fi |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 792 | if is_service_enabled heat; then |
| 793 | install_heat |
| 794 | fi |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 795 | if is_service_enabled cinder; then |
| 796 | install_cinder |
| 797 | fi |
John H. Tran | 9336164 | 2012-07-26 11:22:05 -0700 | [diff] [blame] | 798 | if is_service_enabled ceilometer; then |
| 799 | install_ceilometer |
| 800 | fi |
Jason Kölker | 64a9066 | 2012-01-23 11:17:27 -0600 | [diff] [blame] | 801 | |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 802 | # Initialization |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 803 | # ============== |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 804 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 805 | # Set up our checkouts so they are installed into python path |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 806 | # allowing ``import nova`` or ``import glance.client`` |
Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 807 | setup_develop $KEYSTONECLIENT_DIR |
| 808 | setup_develop $NOVACLIENT_DIR |
| 809 | setup_develop $OPENSTACKCLIENT_DIR |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 810 | if is_service_enabled key g-api n-api swift; then |
Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 811 | setup_develop $KEYSTONE_DIR |
James E. Blair | e7ce24f | 2011-11-10 13:05:13 -0800 | [diff] [blame] | 812 | fi |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 813 | if is_service_enabled swift; then |
Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 814 | setup_develop $SWIFT_DIR |
| 815 | setup_develop $SWIFTCLIENT_DIR |
James E. Blair | 3b73df7 | 2012-07-16 14:28:24 -0700 | [diff] [blame] | 816 | fi |
| 817 | if is_service_enabled swift3; then |
Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 818 | setup_develop $SWIFT3_DIR |
James E. Blair | e7ce24f | 2011-11-10 13:05:13 -0800 | [diff] [blame] | 819 | fi |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 820 | if is_service_enabled g-api n-api; then |
Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 821 | setup_develop $GLANCE_DIR |
James E. Blair | e7ce24f | 2011-11-10 13:05:13 -0800 | [diff] [blame] | 822 | fi |
Dean Troyer | a34961b | 2012-06-26 13:05:33 -0500 | [diff] [blame] | 823 | |
| 824 | # Do this _after_ glance is installed to override the old binary |
| 825 | setup_develop $GLANCECLIENT_DIR |
| 826 | |
Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 827 | setup_develop $NOVA_DIR |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 828 | if is_service_enabled horizon; then |
Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 829 | setup_develop $HORIZON_DIR |
James E. Blair | e7ce24f | 2011-11-10 13:05:13 -0800 | [diff] [blame] | 830 | fi |
Anthony Young | 84a03e0 | 2012-03-15 11:27:13 -0700 | [diff] [blame] | 831 | if is_service_enabled quantum; then |
Dean Troyer | bbafb1b | 2012-06-11 16:51:39 -0500 | [diff] [blame] | 832 | setup_develop $QUANTUM_CLIENT_DIR |
| 833 | setup_develop $QUANTUM_DIR |
Monty Taylor | 5440ac0 | 2012-03-23 11:32:29 -0700 | [diff] [blame] | 834 | fi |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 835 | if is_service_enabled heat; then |
| 836 | configure_heat |
| 837 | fi |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 838 | if is_service_enabled cinder; then |
| 839 | configure_cinder |
| 840 | fi |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 841 | |
Monty Taylor | 47f0206 | 2012-07-26 11:09:24 -0500 | [diff] [blame] | 842 | if [[ $TRACK_DEPENDS = True ]] ; then |
| 843 | $DEST/.venv/bin/pip freeze > $DEST/requires-post-pip |
| 844 | if ! diff -Nru $DEST/requires-pre-pip $DEST/requires-post-pip > $DEST/requires.diff ; then |
| 845 | cat $DEST/requires.diff |
| 846 | fi |
| 847 | echo "Ran stack.sh in depend tracking mode, bailing out now" |
| 848 | exit 0 |
| 849 | fi |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 850 | |
Dean Troyer | ff603ef | 2011-11-22 17:48:10 -0600 | [diff] [blame] | 851 | # Syslog |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 852 | # ------ |
Dean Troyer | ff603ef | 2011-11-22 17:48:10 -0600 | [diff] [blame] | 853 | |
| 854 | if [[ $SYSLOG != "False" ]]; then |
Dean Troyer | ff603ef | 2011-11-22 17:48:10 -0600 | [diff] [blame] | 855 | if [[ "$SYSLOG_HOST" = "$HOST_IP" ]]; then |
| 856 | # Configure the master host to receive |
| 857 | cat <<EOF >/tmp/90-stack-m.conf |
| 858 | \$ModLoad imrelp |
| 859 | \$InputRELPServerRun $SYSLOG_PORT |
| 860 | EOF |
| 861 | sudo mv /tmp/90-stack-m.conf /etc/rsyslog.d |
| 862 | else |
| 863 | # Set rsyslog to send to remote host |
| 864 | cat <<EOF >/tmp/90-stack-s.conf |
| 865 | *.* :omrelp:$SYSLOG_HOST:$SYSLOG_PORT |
| 866 | EOF |
| 867 | sudo mv /tmp/90-stack-s.conf /etc/rsyslog.d |
| 868 | fi |
Dean Troyer | 13dc5cc | 2012-03-27 14:50:45 -0500 | [diff] [blame] | 869 | restart_service rsyslog |
Dean Troyer | ff603ef | 2011-11-22 17:48:10 -0600 | [diff] [blame] | 870 | fi |
| 871 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 872 | |
Russell Bryant | 4a22145 | 2012-03-13 13:44:12 -0400 | [diff] [blame] | 873 | # Rabbit or Qpid |
| 874 | # -------------- |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 875 | |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 876 | if is_service_enabled rabbit; then |
Monty Taylor | 47f0206 | 2012-07-26 11:09:24 -0500 | [diff] [blame] | 877 | # Start rabbitmq-server |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 878 | if [[ "$os_PACKAGE" = "rpm" ]]; then |
| 879 | # RPM doesn't start the service |
| 880 | restart_service rabbitmq-server |
| 881 | fi |
Jesse Andrews | 53ed387 | 2011-10-02 14:28:17 -0400 | [diff] [blame] | 882 | # change the rabbit password since the default is "guest" |
| 883 | sudo rabbitmqctl change_password guest $RABBIT_PASSWORD |
Russell Bryant | 4a22145 | 2012-03-13 13:44:12 -0400 | [diff] [blame] | 884 | elif is_service_enabled qpid; then |
Monty Taylor | 47f0206 | 2012-07-26 11:09:24 -0500 | [diff] [blame] | 885 | restart_service qpidd |
Anthony Young | a09ae2f | 2011-09-15 23:11:29 -0700 | [diff] [blame] | 886 | fi |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 887 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 888 | |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 889 | # Mysql |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 890 | # ----- |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 891 | |
Monty Taylor | 47f0206 | 2012-07-26 11:09:24 -0500 | [diff] [blame] | 892 | |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 893 | if is_service_enabled mysql; then |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 894 | |
Monty Taylor | 47f0206 | 2012-07-26 11:09:24 -0500 | [diff] [blame] | 895 | #start mysql-server |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 896 | if [[ "$os_PACKAGE" = "rpm" ]]; then |
| 897 | # RPM doesn't start the service |
| 898 | start_service mysqld |
| 899 | # Set the root password - only works the first time |
| 900 | sudo mysqladmin -u root password $MYSQL_PASSWORD || true |
| 901 | fi |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 902 | # Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases: |
James E. Blair | 92e8199 | 2011-10-11 09:26:29 -0500 | [diff] [blame] | 903 | sudo mysql -uroot -p$MYSQL_PASSWORD -h127.0.0.1 -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' identified by '$MYSQL_PASSWORD';" |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 904 | |
Dean Troyer | 588f406 | 2012-04-02 16:50:49 -0500 | [diff] [blame] | 905 | # Update ``my.cnf`` for some local needs and restart the mysql service |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 906 | if [[ "$os_PACKAGE" = "deb" ]]; then |
Dean Troyer | 588f406 | 2012-04-02 16:50:49 -0500 | [diff] [blame] | 907 | MY_CONF=/etc/mysql/my.cnf |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 908 | MYSQL=mysql |
| 909 | else |
Dean Troyer | 588f406 | 2012-04-02 16:50:49 -0500 | [diff] [blame] | 910 | MY_CONF=/etc/my.cnf |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 911 | MYSQL=mysqld |
| 912 | fi |
Dean Troyer | 588f406 | 2012-04-02 16:50:49 -0500 | [diff] [blame] | 913 | |
| 914 | # Change ‘bind-address’ from localhost (127.0.0.1) to any (0.0.0.0) |
| 915 | sudo sed -i '/^bind-address/s/127.0.0.1/0.0.0.0/g' $MY_CONF |
| 916 | |
| 917 | # Set default db type to InnoDB |
Vincent Untz | 4556b5d | 2012-06-14 09:20:55 +0200 | [diff] [blame] | 918 | if sudo grep -q "default-storage-engine" $MY_CONF; then |
Dean Troyer | 588f406 | 2012-04-02 16:50:49 -0500 | [diff] [blame] | 919 | # Change it |
| 920 | sudo bash -c "source $TOP_DIR/functions; iniset $MY_CONF mysqld default-storage-engine InnoDB" |
| 921 | else |
| 922 | # Add it |
| 923 | sudo sed -i -e "/^\[mysqld\]/ a \ |
| 924 | default-storage-engine = InnoDB" $MY_CONF |
| 925 | fi |
| 926 | |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 927 | restart_service $MYSQL |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 928 | fi |
| 929 | |
Josh Kearney | 0a7a41e | 2012-04-04 17:47:56 -0500 | [diff] [blame] | 930 | if [ -z "$SCREEN_HARDSTATUS" ]; then |
| 931 | SCREEN_HARDSTATUS='%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})' |
| 932 | fi |
| 933 | |
Anthony Young | 60df29a | 2012-03-28 09:40:17 -0700 | [diff] [blame] | 934 | # Our screenrc file builder |
| 935 | function screen_rc { |
| 936 | SCREENRC=$TOP_DIR/stack-screenrc |
| 937 | if [[ ! -e $SCREENRC ]]; then |
| 938 | # Name the screen session |
| 939 | echo "sessionname stack" > $SCREENRC |
| 940 | # Set a reasonable statusbar |
Josh Kearney | 076e86a | 2012-04-05 16:25:03 -0500 | [diff] [blame] | 941 | echo "hardstatus alwayslastline '$SCREEN_HARDSTATUS'" >> $SCREENRC |
Anthony Young | 60df29a | 2012-03-28 09:40:17 -0700 | [diff] [blame] | 942 | echo "screen -t stack bash" >> $SCREENRC |
| 943 | fi |
| 944 | # If this service doesn't already exist in the screenrc file |
| 945 | if ! grep $1 $SCREENRC 2>&1 > /dev/null; then |
| 946 | NL=`echo -ne '\015'` |
| 947 | echo "screen -t $1 bash" >> $SCREENRC |
| 948 | echo "stuff \"$2$NL\"" >> $SCREENRC |
| 949 | fi |
| 950 | } |
| 951 | |
| 952 | # Our screen helper to launch a service in a hidden named screen |
| 953 | function screen_it { |
| 954 | NL=`echo -ne '\015'` |
| 955 | if is_service_enabled $1; then |
| 956 | # Append the service to the screen rc file |
| 957 | screen_rc "$1" "$2" |
| 958 | |
| 959 | screen -S stack -X screen -t $1 |
| 960 | # sleep to allow bash to be ready to be send the command - we are |
| 961 | # creating a new window in screen and then sends characters, so if |
| 962 | # bash isn't running by the time we send the command, nothing happens |
| 963 | sleep 1.5 |
| 964 | |
| 965 | if [[ -n ${SCREEN_LOGDIR} ]]; then |
| 966 | screen -S stack -p $1 -X logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log |
| 967 | screen -S stack -p $1 -X log on |
| 968 | ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log |
| 969 | fi |
| 970 | screen -S stack -p $1 -X stuff "$2$NL" |
| 971 | fi |
| 972 | } |
| 973 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 974 | # Create a new named screen to run processes in |
Anthony Young | 60df29a | 2012-03-28 09:40:17 -0700 | [diff] [blame] | 975 | screen -d -m -S stack -t stack -s /bin/bash |
| 976 | sleep 1 |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 977 | # Set a reasonable statusbar |
Josh Kearney | 0a7a41e | 2012-04-04 17:47:56 -0500 | [diff] [blame] | 978 | screen -r stack -X hardstatus alwayslastline "$SCREEN_HARDSTATUS" |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 979 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 980 | |
Tres Henry | ca85b79 | 2011-10-28 14:00:21 -0700 | [diff] [blame] | 981 | # Horizon |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 982 | # ------- |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 983 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 984 | # Set up the django horizon application to serve via apache/wsgi |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 985 | |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 986 | if is_service_enabled horizon; then |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 987 | |
Anthony Young | a575d50 | 2012-01-26 12:59:26 -0800 | [diff] [blame] | 988 | # Remove stale session database. |
Gabriel Hurley | f1a11ad | 2012-02-29 01:36:53 -0800 | [diff] [blame] | 989 | rm -f $HORIZON_DIR/openstack_dashboard/local/dashboard_openstack.sqlite3 |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 990 | |
Tres Henry | ca85b79 | 2011-10-28 14:00:21 -0700 | [diff] [blame] | 991 | # ``local_settings.py`` is used to override horizon default settings. |
Gabriel Hurley | f1a11ad | 2012-02-29 01:36:53 -0800 | [diff] [blame] | 992 | local_settings=$HORIZON_DIR/openstack_dashboard/local/local_settings.py |
Jesse Andrews | 9c7c908 | 2011-11-23 10:10:53 -0800 | [diff] [blame] | 993 | cp $FILES/horizon_settings.py $local_settings |
| 994 | |
Tres Henry | ca85b79 | 2011-10-28 14:00:21 -0700 | [diff] [blame] | 995 | # Initialize the horizon database (it stores sessions and notices shown to |
Jesse Andrews | 51fb22e | 2011-10-19 09:24:17 -0700 | [diff] [blame] | 996 | # users). The user system is external (keystone). |
Gabriel Hurley | f1a11ad | 2012-02-29 01:36:53 -0800 | [diff] [blame] | 997 | cd $HORIZON_DIR |
Gabriel Hurley | 8156062 | 2012-07-08 20:03:55 -0700 | [diff] [blame] | 998 | python manage.py syncdb --noinput |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 999 | cd $TOP_DIR |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 1000 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 1001 | # Create an empty directory that apache uses as docroot |
Tres Henry | ca85b79 | 2011-10-28 14:00:21 -0700 | [diff] [blame] | 1002 | sudo mkdir -p $HORIZON_DIR/.blackhole |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 1003 | |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1004 | if [[ "$os_PACKAGE" = "deb" ]]; then |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1005 | APACHE_NAME=apache2 |
| 1006 | APACHE_CONF=sites-available/horizon |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1007 | # Clean up the old config name |
| 1008 | sudo rm -f /etc/apache2/sites-enabled/000-default |
| 1009 | # Be a good citizen and use the distro tools here |
| 1010 | sudo touch /etc/$APACHE_NAME/$APACHE_CONF |
| 1011 | sudo a2ensite horizon |
| 1012 | else |
| 1013 | # Install httpd, which is NOPRIME'd |
| 1014 | APACHE_NAME=httpd |
| 1015 | APACHE_CONF=conf.d/horizon.conf |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1016 | sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf |
| 1017 | fi |
| 1018 | ## Configure apache to run horizon |
| 1019 | sudo sh -c "sed -e \" |
Dean Troyer | 9bb84f0 | 2012-01-24 11:45:52 -0600 | [diff] [blame] | 1020 | s,%USER%,$APACHE_USER,g; |
| 1021 | s,%GROUP%,$APACHE_GROUP,g; |
| 1022 | s,%HORIZON_DIR%,$HORIZON_DIR,g; |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1023 | s,%APACHE_NAME%,$APACHE_NAME,g; |
| 1024 | s,%DEST%,$DEST,g; |
| 1025 | \" $FILES/apache-horizon.template >/etc/$APACHE_NAME/$APACHE_CONF" |
| 1026 | restart_service $APACHE_NAME |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 1027 | fi |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 1028 | |
Anthony Young | 3859f73 | 2011-09-14 02:33:43 -0700 | [diff] [blame] | 1029 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 1030 | # Glance |
| 1031 | # ------ |
| 1032 | |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 1033 | if is_service_enabled g-reg; then |
Yong Sheng Gong | 0ddcae6 | 2012-03-20 21:17:39 +0800 | [diff] [blame] | 1034 | GLANCE_CONF_DIR=/etc/glance |
| 1035 | if [[ ! -d $GLANCE_CONF_DIR ]]; then |
| 1036 | sudo mkdir -p $GLANCE_CONF_DIR |
| 1037 | fi |
| 1038 | sudo chown `whoami` $GLANCE_CONF_DIR |
Brian Waldon | ea78a6a | 2012-08-30 13:44:39 -0700 | [diff] [blame^] | 1039 | |
Anthony Young | c835762 | 2011-09-20 10:38:06 -0700 | [diff] [blame] | 1040 | GLANCE_IMAGE_DIR=$DEST/glance/images |
Anthony Young | a531b77 | 2011-09-20 09:59:54 -0700 | [diff] [blame] | 1041 | # Delete existing images |
| 1042 | rm -rf $GLANCE_IMAGE_DIR |
Anthony Young | a531b77 | 2011-09-20 09:59:54 -0700 | [diff] [blame] | 1043 | mkdir -p $GLANCE_IMAGE_DIR |
| 1044 | |
Brian Waldon | ea78a6a | 2012-08-30 13:44:39 -0700 | [diff] [blame^] | 1045 | GLANCE_CACHE_DIR=$DEST/glance/cache |
| 1046 | # Delete existing images |
| 1047 | rm -rf $GLANCE_CACHE_DIR |
| 1048 | mkdir -p $GLANCE_CACHE_DIR |
| 1049 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 1050 | # (re)create glance database |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 1051 | mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS glance;' |
Gabriel Hurley | 71f23eb | 2012-02-15 17:39:05 -0800 | [diff] [blame] | 1052 | mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE glance CHARACTER SET utf8;' |
Jesse Andrews | 51fb22e | 2011-10-19 09:24:17 -0700 | [diff] [blame] | 1053 | |
| 1054 | # Copy over our glance configurations and update them |
Yong Sheng Gong | 0ddcae6 | 2012-03-20 21:17:39 +0800 | [diff] [blame] | 1055 | GLANCE_REGISTRY_CONF=$GLANCE_CONF_DIR/glance-registry.conf |
Dean Troyer | 9bab259 | 2012-04-06 12:10:05 -0500 | [diff] [blame] | 1056 | cp $GLANCE_DIR/etc/glance-registry.conf $GLANCE_REGISTRY_CONF |
| 1057 | iniset $GLANCE_REGISTRY_CONF DEFAULT debug True |
| 1058 | inicomment $GLANCE_REGISTRY_CONF DEFAULT log_file |
| 1059 | iniset $GLANCE_REGISTRY_CONF DEFAULT sql_connection $BASE_SQL_CONN/glance?charset=utf8 |
| 1060 | iniset $GLANCE_REGISTRY_CONF DEFAULT use_syslog $SYSLOG |
| 1061 | iniset $GLANCE_REGISTRY_CONF paste_deploy flavor keystone |
Brian Waldon | 0fe0606 | 2012-08-29 13:30:03 -0700 | [diff] [blame] | 1062 | iniset $GLANCE_REGISTRY_CONF keystone_authtoken auth_host $KEYSTONE_AUTH_HOST |
| 1063 | iniset $GLANCE_REGISTRY_CONF keystone_authtoken auth_port $KEYSTONE_AUTH_PORT |
| 1064 | iniset $GLANCE_REGISTRY_CONF keystone_authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL |
| 1065 | iniset $GLANCE_REGISTRY_CONF keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/ |
| 1066 | iniset $GLANCE_REGISTRY_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME |
| 1067 | iniset $GLANCE_REGISTRY_CONF keystone_authtoken admin_user glance |
| 1068 | iniset $GLANCE_REGISTRY_CONF keystone_authtoken admin_password $SERVICE_PASSWORD |
Anthony Young | f12d3ab | 2011-09-20 00:33:51 -0700 | [diff] [blame] | 1069 | |
Yong Sheng Gong | 0ddcae6 | 2012-03-20 21:17:39 +0800 | [diff] [blame] | 1070 | GLANCE_API_CONF=$GLANCE_CONF_DIR/glance-api.conf |
Dean Troyer | 9bab259 | 2012-04-06 12:10:05 -0500 | [diff] [blame] | 1071 | cp $GLANCE_DIR/etc/glance-api.conf $GLANCE_API_CONF |
| 1072 | iniset $GLANCE_API_CONF DEFAULT debug True |
| 1073 | inicomment $GLANCE_API_CONF DEFAULT log_file |
Brian Waldon | 7f9833f | 2012-05-25 08:31:59 -0700 | [diff] [blame] | 1074 | iniset $GLANCE_API_CONF DEFAULT sql_connection $BASE_SQL_CONN/glance?charset=utf8 |
Dean Troyer | 9bab259 | 2012-04-06 12:10:05 -0500 | [diff] [blame] | 1075 | iniset $GLANCE_API_CONF DEFAULT use_syslog $SYSLOG |
| 1076 | iniset $GLANCE_API_CONF DEFAULT filesystem_store_datadir $GLANCE_IMAGE_DIR/ |
Brian Waldon | ea78a6a | 2012-08-30 13:44:39 -0700 | [diff] [blame^] | 1077 | iniset $GLANCE_API_CONF DEFAULT image_cache_dir $GLANCE_CACHE_DIR/ |
| 1078 | iniset $GLANCE_API_CONF paste_deploy flavor keystone+cachemanagement |
Brian Waldon | 0fe0606 | 2012-08-29 13:30:03 -0700 | [diff] [blame] | 1079 | iniset $GLANCE_API_CONF keystone_authtoken auth_host $KEYSTONE_AUTH_HOST |
| 1080 | iniset $GLANCE_API_CONF keystone_authtoken auth_port $KEYSTONE_AUTH_PORT |
| 1081 | iniset $GLANCE_API_CONF keystone_authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL |
| 1082 | iniset $GLANCE_API_CONF keystone_authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/ |
| 1083 | iniset $GLANCE_API_CONF keystone_authtoken admin_tenant_name $SERVICE_TENANT_NAME |
| 1084 | iniset $GLANCE_API_CONF keystone_authtoken admin_user glance |
| 1085 | iniset $GLANCE_API_CONF keystone_authtoken admin_password $SERVICE_PASSWORD |
Dean Troyer | 6577b46 | 2012-01-16 22:27:20 -0600 | [diff] [blame] | 1086 | |
Chmouel Boudjnah | ee76d26 | 2012-05-09 17:19:09 +0100 | [diff] [blame] | 1087 | # Store the images in swift if enabled. |
| 1088 | if is_service_enabled swift; then |
| 1089 | iniset $GLANCE_API_CONF DEFAULT default_store swift |
| 1090 | iniset $GLANCE_API_CONF DEFAULT swift_store_auth_address $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/v2.0/ |
| 1091 | iniset $GLANCE_API_CONF DEFAULT swift_store_user $SERVICE_TENANT_NAME:glance |
| 1092 | iniset $GLANCE_API_CONF DEFAULT swift_store_key $SERVICE_PASSWORD |
| 1093 | iniset $GLANCE_API_CONF DEFAULT swift_store_create_container_on_put True |
| 1094 | fi |
| 1095 | |
Brian Waldon | 0fe0606 | 2012-08-29 13:30:03 -0700 | [diff] [blame] | 1096 | GLANCE_REGISTRY_PASTE_INI=$GLANCE_CONF_DIR/glance-registry-paste.ini |
| 1097 | cp $GLANCE_DIR/etc/glance-registry-paste.ini $GLANCE_REGISTRY_PASTE_INI |
| 1098 | |
Dean Troyer | 9bab259 | 2012-04-06 12:10:05 -0500 | [diff] [blame] | 1099 | GLANCE_API_PASTE_INI=$GLANCE_CONF_DIR/glance-api-paste.ini |
| 1100 | cp $GLANCE_DIR/etc/glance-api-paste.ini $GLANCE_API_PASTE_INI |
Brian Waldon | e7114ca | 2012-05-04 13:42:35 -0700 | [diff] [blame] | 1101 | |
Brian Waldon | ea78a6a | 2012-08-30 13:44:39 -0700 | [diff] [blame^] | 1102 | GLANCE_CACHE_CONF=$GLANCE_CONF_DIR/glance-cache.conf |
| 1103 | cp $GLANCE_DIR/etc/glance-cache.conf $GLANCE_CACHE_CONF |
| 1104 | iniset $GLANCE_CACHE_CONF DEFAULT debug True |
| 1105 | inicomment $GLANCE_CACHE_CONF DEFAULT log_file |
| 1106 | iniset $GLANCE_CACHE_CONF DEFAULT use_syslog $SYSLOG |
| 1107 | iniset $GLANCE_CACHE_CONF DEFAULT filesystem_store_datadir $GLANCE_IMAGE_DIR/ |
| 1108 | iniset $GLANCE_CACHE_CONF DEFAULT image_cache_dir $GLANCE_CACHE_DIR/ |
| 1109 | iniuncomment $GLANCE_CACHE_CONF DEFAULT auth_url |
| 1110 | iniset $GLANCE_CACHE_CONF DEFAULT auth_url $KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0 |
| 1111 | iniuncomment $GLANCE_CACHE_CONF DEFAULT auth_tenant_name |
| 1112 | iniset $GLANCE_CACHE_CONF DEFAULT admin_tenant_name $SERVICE_TENANT_NAME |
| 1113 | iniuncomment $GLANCE_CACHE_CONF DEFAULT auth_user |
| 1114 | iniset $GLANCE_CACHE_CONF DEFAULT admin_user glance |
| 1115 | iniuncomment $GLANCE_CACHE_CONF DEFAULT auth_password |
| 1116 | iniset $GLANCE_CACHE_CONF DEFAULT admin_password $SERVICE_PASSWORD |
| 1117 | |
| 1118 | |
Brian Waldon | e7114ca | 2012-05-04 13:42:35 -0700 | [diff] [blame] | 1119 | GLANCE_POLICY_JSON=$GLANCE_CONF_DIR/policy.json |
| 1120 | cp $GLANCE_DIR/etc/policy.json $GLANCE_POLICY_JSON |
Dan Prince | 0f39c5d | 2012-06-13 15:17:19 -0400 | [diff] [blame] | 1121 | |
| 1122 | $GLANCE_DIR/bin/glance-manage db_sync |
| 1123 | |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 1124 | fi |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 1125 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 1126 | |
| 1127 | # Quantum |
Anthony Young | 60df29a | 2012-03-28 09:40:17 -0700 | [diff] [blame] | 1128 | # ------- |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 1129 | |
Shweta P | 4dc53aa | 2012-04-04 16:17:40 -0400 | [diff] [blame] | 1130 | if is_service_enabled quantum; then |
| 1131 | # Put config files in /etc/quantum for everyone to find |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1132 | if [[ ! -d /etc/quantum ]]; then |
| 1133 | sudo mkdir -p /etc/quantum |
Anthony Young | 60df29a | 2012-03-28 09:40:17 -0700 | [diff] [blame] | 1134 | fi |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1135 | sudo chown `whoami` /etc/quantum |
Shweta P | 4dc53aa | 2012-04-04 16:17:40 -0400 | [diff] [blame] | 1136 | |
Anthony Young | 60df29a | 2012-03-28 09:40:17 -0700 | [diff] [blame] | 1137 | if [[ "$Q_PLUGIN" = "openvswitch" ]]; then |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1138 | Q_PLUGIN_CONF_PATH=etc/quantum/plugins/openvswitch |
| 1139 | Q_PLUGIN_CONF_FILENAME=ovs_quantum_plugin.ini |
| 1140 | Q_DB_NAME="ovs_quantum" |
Gary Kotton | 37dda8d | 2012-08-08 03:46:33 -0400 | [diff] [blame] | 1141 | Q_PLUGIN_CLASS="quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2" |
Shweta P | 4dc53aa | 2012-04-04 16:17:40 -0400 | [diff] [blame] | 1142 | elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1143 | Q_PLUGIN_CONF_PATH=etc/quantum/plugins/linuxbridge |
| 1144 | Q_PLUGIN_CONF_FILENAME=linuxbridge_conf.ini |
| 1145 | Q_DB_NAME="quantum_linux_bridge" |
Gary Kotton | 37dda8d | 2012-08-08 03:46:33 -0400 | [diff] [blame] | 1146 | Q_PLUGIN_CLASS="quantum.plugins.linuxbridge.lb_quantum_plugin.LinuxBridgePluginV2" |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1147 | else |
| 1148 | echo "Unknown Quantum plugin '$Q_PLUGIN'.. exiting" |
| 1149 | exit 1 |
| 1150 | fi |
| 1151 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 1152 | # If needed, move config file from $QUANTUM_DIR/etc/quantum to /etc/quantum |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1153 | mkdir -p /$Q_PLUGIN_CONF_PATH |
| 1154 | Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME |
Gary Kotton | 8301f14 | 2012-07-25 03:26:23 -0400 | [diff] [blame] | 1155 | cp $QUANTUM_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE |
| 1156 | |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1157 | sudo sed -i -e "s/^sql_connection =.*$/sql_connection = mysql:\/\/$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST\/$Q_DB_NAME?charset=utf8/g" /$Q_PLUGIN_CONF_FILE |
| 1158 | |
| 1159 | OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-True} |
| 1160 | if [[ "$Q_PLUGIN" = "openvswitch" && $OVS_ENABLE_TUNNELING = "True" ]]; then |
| 1161 | OVS_VERSION=`ovs-vsctl --version | head -n 1 | awk '{print $4;}'` |
| 1162 | if [ $OVS_VERSION \< "1.4" ] && ! is_service_enabled q-svc ; then |
| 1163 | echo "You are running OVS version $OVS_VERSION." |
| 1164 | echo "OVS 1.4+ is required for tunneling between multiple hosts." |
| 1165 | exit 1 |
| 1166 | fi |
Aaron Rosen | 4402d6e | 2012-06-19 16:09:40 -0700 | [diff] [blame] | 1167 | sudo sed -i -e "s/.*enable_tunneling = .*$/enable_tunneling = $OVS_ENABLE_TUNNELING/g" /$Q_PLUGIN_CONF_FILE |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1168 | fi |
Aaron Rosen | 9313dfa | 2012-07-06 16:08:49 -0400 | [diff] [blame] | 1169 | |
Gary Kotton | 396a014 | 2012-07-29 04:28:47 -0400 | [diff] [blame] | 1170 | Q_CONF_FILE=/etc/quantum/quantum.conf |
| 1171 | cp $QUANTUM_DIR/etc/quantum.conf $Q_CONF_FILE |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1172 | fi |
| 1173 | |
| 1174 | # Quantum service (for controller node) |
| 1175 | if is_service_enabled q-svc; then |
Gary Kotton | 5f4b6de | 2012-06-05 07:05:35 -0400 | [diff] [blame] | 1176 | Q_API_PASTE_FILE=/etc/quantum/api-paste.ini |
Aaron Rosen | 4402d6e | 2012-06-19 16:09:40 -0700 | [diff] [blame] | 1177 | Q_POLICY_FILE=/etc/quantum/policy.json |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1178 | |
Akihiro MOTOKI | 1a4166c | 2012-07-25 17:53:40 +0900 | [diff] [blame] | 1179 | cp $QUANTUM_DIR/etc/api-paste.ini $Q_API_PASTE_FILE |
| 1180 | cp $QUANTUM_DIR/etc/policy.json $Q_POLICY_FILE |
Aaron Rosen | 4402d6e | 2012-06-19 16:09:40 -0700 | [diff] [blame] | 1181 | |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1182 | if is_service_enabled mysql; then |
| 1183 | mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e "DROP DATABASE IF EXISTS $Q_DB_NAME;" |
| 1184 | mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e "CREATE DATABASE IF NOT EXISTS $Q_DB_NAME CHARACTER SET utf8;" |
Shweta P | 4dc53aa | 2012-04-04 16:17:40 -0400 | [diff] [blame] | 1185 | else |
| 1186 | echo "mysql must be enabled in order to use the $Q_PLUGIN Quantum plugin." |
| 1187 | exit 1 |
Anthony Young | 60df29a | 2012-03-28 09:40:17 -0700 | [diff] [blame] | 1188 | fi |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1189 | |
Aaron Rosen | 4402d6e | 2012-06-19 16:09:40 -0700 | [diff] [blame] | 1190 | # Update either configuration file with plugin |
Akihiro MOTOKI | 1a4166c | 2012-07-25 17:53:40 +0900 | [diff] [blame] | 1191 | iniset $Q_CONF_FILE DEFAULT core_plugin $Q_PLUGIN_CLASS |
| 1192 | |
| 1193 | iniset $Q_CONF_FILE DEFAULT auth_strategy $Q_AUTH_STRATEGY |
| 1194 | iniset $Q_API_PASTE_FILE filter:authtoken auth_host $KEYSTONE_SERVICE_HOST |
| 1195 | iniset $Q_API_PASTE_FILE filter:authtoken auth_port $KEYSTONE_AUTH_PORT |
| 1196 | iniset $Q_API_PASTE_FILE filter:authtoken auth_protocol $KEYSTONE_SERVICE_PROTOCOL |
| 1197 | iniset $Q_API_PASTE_FILE filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME |
| 1198 | iniset $Q_API_PASTE_FILE filter:authtoken admin_user $Q_ADMIN_USERNAME |
| 1199 | iniset $Q_API_PASTE_FILE filter:authtoken admin_password $SERVICE_PASSWORD |
Anthony Young | 60df29a | 2012-03-28 09:40:17 -0700 | [diff] [blame] | 1200 | fi |
| 1201 | |
| 1202 | # Quantum agent (for compute nodes) |
| 1203 | if is_service_enabled q-agt; then |
| 1204 | if [[ "$Q_PLUGIN" = "openvswitch" ]]; then |
| 1205 | # Set up integration bridge |
| 1206 | OVS_BRIDGE=${OVS_BRIDGE:-br-int} |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1207 | for PORT in `sudo ovs-vsctl --no-wait list-ports $OVS_BRIDGE`; do |
| 1208 | if [[ "$PORT" =~ tap* ]]; then echo `sudo ip link delete $PORT` > /dev/null; fi |
| 1209 | sudo ovs-vsctl --no-wait del-port $OVS_BRIDGE $PORT |
| 1210 | done |
Anthony Young | 60df29a | 2012-03-28 09:40:17 -0700 | [diff] [blame] | 1211 | sudo ovs-vsctl --no-wait -- --if-exists del-br $OVS_BRIDGE |
| 1212 | sudo ovs-vsctl --no-wait add-br $OVS_BRIDGE |
| 1213 | sudo ovs-vsctl --no-wait br-set-external-id $OVS_BRIDGE bridge-id br-int |
Aaron Rosen | 4402d6e | 2012-06-19 16:09:40 -0700 | [diff] [blame] | 1214 | sudo sed -i -e "s/.*local_ip = .*/local_ip = $HOST_IP/g" /$Q_PLUGIN_CONF_FILE |
Aaron Rosen | 9313dfa | 2012-07-06 16:08:49 -0400 | [diff] [blame] | 1215 | AGENT_BINARY="$QUANTUM_DIR/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py" |
Shweta P | 4dc53aa | 2012-04-04 16:17:40 -0400 | [diff] [blame] | 1216 | elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then |
| 1217 | # Start up the quantum <-> linuxbridge agent |
Monty Taylor | 47f0206 | 2012-07-26 11:09:24 -0500 | [diff] [blame] | 1218 | # set the default network interface |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1219 | QUANTUM_LB_PRIVATE_INTERFACE=${QUANTUM_LB_PRIVATE_INTERFACE:-$GUEST_INTERFACE_DEFAULT} |
Bob Kukura | 8227a77 | 2012-08-13 02:29:54 -0400 | [diff] [blame] | 1220 | iniset /$Q_PLUGIN_CONF_FILE LINUX_BRIDGE physical_interface_mappings default:$QUANTUM_LB_PRIVATE_INTERFACE |
Aaron Rosen | 9313dfa | 2012-07-06 16:08:49 -0400 | [diff] [blame] | 1221 | AGENT_BINARY="$QUANTUM_DIR/quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py" |
Anthony Young | 60df29a | 2012-03-28 09:40:17 -0700 | [diff] [blame] | 1222 | fi |
Anthony Young | 60df29a | 2012-03-28 09:40:17 -0700 | [diff] [blame] | 1223 | fi |
| 1224 | |
Gary Kotton | bff593d | 2012-07-16 18:02:37 -0400 | [diff] [blame] | 1225 | # Quantum DHCP |
| 1226 | if is_service_enabled q-dhcp; then |
| 1227 | AGENT_DHCP_BINARY="$QUANTUM_DIR/bin/quantum-dhcp-agent" |
| 1228 | |
| 1229 | Q_DHCP_CONF_FILE=/etc/quantum/dhcp_agent.ini |
| 1230 | |
Gary Kotton | 396a014 | 2012-07-29 04:28:47 -0400 | [diff] [blame] | 1231 | cp $QUANTUM_DIR/etc/dhcp_agent.ini $Q_DHCP_CONF_FILE |
Gary Kotton | bff593d | 2012-07-16 18:02:37 -0400 | [diff] [blame] | 1232 | |
| 1233 | # Set verbose |
| 1234 | iniset $Q_DHCP_CONF_FILE DEFAULT verbose True |
| 1235 | # Set debug |
| 1236 | iniset $Q_DHCP_CONF_FILE DEFAULT debug True |
Dan Wendlandt | ea23e68 | 2012-08-22 05:53:17 -0700 | [diff] [blame] | 1237 | iniset $Q_DHCP_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE |
Gary Kotton | bff593d | 2012-07-16 18:02:37 -0400 | [diff] [blame] | 1238 | |
| 1239 | # Update database |
| 1240 | iniset $Q_DHCP_CONF_FILE DEFAULT db_connection "mysql:\/\/$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST\/$Q_DB_NAME?charset=utf8" |
| 1241 | iniset $Q_DHCP_CONF_FILE DEFAULT auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0" |
| 1242 | iniset $Q_DHCP_CONF_FILE DEFAULT admin_tenant_name $SERVICE_TENANT_NAME |
| 1243 | iniset $Q_DHCP_CONF_FILE DEFAULT admin_user $Q_ADMIN_USERNAME |
| 1244 | iniset $Q_DHCP_CONF_FILE DEFAULT admin_password $SERVICE_PASSWORD |
| 1245 | |
| 1246 | if [[ "$Q_PLUGIN" = "openvswitch" ]]; then |
| 1247 | iniset $Q_DHCP_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver |
| 1248 | elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then |
| 1249 | iniset $Q_DHCP_CONF_FILE DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver |
| 1250 | fi |
Gary Kotton | bff593d | 2012-07-16 18:02:37 -0400 | [diff] [blame] | 1251 | fi |
| 1252 | |
Gary Kotton | 396a014 | 2012-07-29 04:28:47 -0400 | [diff] [blame] | 1253 | # Quantum RPC support - must be updated prior to starting any of the services |
| 1254 | if is_service_enabled quantum; then |
| 1255 | iniset $Q_CONF_FILE DEFAULT control_exchange quantum |
| 1256 | if is_service_enabled qpid ; then |
| 1257 | iniset $Q_CONF_FILE DEFAULT rpc_backend quantum.openstack.common.rpc.impl_qpid |
| 1258 | elif [ -n "$RABBIT_HOST" ] && [ -n "$RABBIT_PASSWORD" ]; then |
| 1259 | iniset $Q_CONF_FILE DEFAULT rabbit_host $RABBIT_HOST |
| 1260 | iniset $Q_CONF_FILE DEFAULT rabbit_password $RABBIT_PASSWORD |
| 1261 | fi |
| 1262 | fi |
| 1263 | |
| 1264 | # Start the Quantum services |
| 1265 | screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server --config-file $Q_CONF_FILE --config-file /$Q_PLUGIN_CONF_FILE" |
| 1266 | |
| 1267 | # Start up the quantum agent |
| 1268 | screen_it q-agt "sudo python $AGENT_BINARY --config-file $Q_CONF_FILE --config-file /$Q_PLUGIN_CONF_FILE" |
| 1269 | |
| 1270 | # Start up the quantum agent |
Mark McClain | 2053753 | 2012-08-13 11:34:01 -0400 | [diff] [blame] | 1271 | screen_it q-dhcp "sudo python $AGENT_DHCP_BINARY --config-file $Q_CONF_FILE --config-file=$Q_DHCP_CONF_FILE" |
Gary Kotton | 396a014 | 2012-07-29 04:28:47 -0400 | [diff] [blame] | 1272 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 1273 | # Nova |
| 1274 | # ---- |
Dean Troyer | bd13b70 | 2012-02-13 11:22:36 -0600 | [diff] [blame] | 1275 | |
| 1276 | # Put config files in /etc/nova for everyone to find |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1277 | NOVA_CONF_DIR=/etc/nova |
| 1278 | if [[ ! -d $NOVA_CONF_DIR ]]; then |
| 1279 | sudo mkdir -p $NOVA_CONF_DIR |
Dean Troyer | bd13b70 | 2012-02-13 11:22:36 -0600 | [diff] [blame] | 1280 | fi |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1281 | sudo chown `whoami` $NOVA_CONF_DIR |
Dean Troyer | bd13b70 | 2012-02-13 11:22:36 -0600 | [diff] [blame] | 1282 | |
Mark McLoughlin | 27e39fd | 2012-05-10 07:12:36 +0100 | [diff] [blame] | 1283 | cp -p $NOVA_DIR/etc/nova/policy.json $NOVA_CONF_DIR |
| 1284 | |
Thierry Carrez | be5d3f2 | 2012-06-20 18:17:03 +0200 | [diff] [blame] | 1285 | # If Nova ships the new rootwrap filters files, deploy them |
Thierry Carrez | ce5b8ed | 2012-06-14 12:27:58 +0200 | [diff] [blame] | 1286 | # (owned by root) and add a parameter to $NOVA_ROOTWRAP |
| 1287 | ROOTWRAP_SUDOER_CMD="$NOVA_ROOTWRAP" |
Thierry Carrez | 76a9eaf | 2012-06-22 15:30:28 +0200 | [diff] [blame] | 1288 | if [[ -d $NOVA_DIR/etc/nova/rootwrap.d ]]; then |
Thierry Carrez | ce5b8ed | 2012-06-14 12:27:58 +0200 | [diff] [blame] | 1289 | # Wipe any existing rootwrap.d files first |
| 1290 | if [[ -d $NOVA_CONF_DIR/rootwrap.d ]]; then |
| 1291 | sudo rm -rf $NOVA_CONF_DIR/rootwrap.d |
| 1292 | fi |
Thierry Carrez | be5d3f2 | 2012-06-20 18:17:03 +0200 | [diff] [blame] | 1293 | # Deploy filters to /etc/nova/rootwrap.d |
Thierry Carrez | ce5b8ed | 2012-06-14 12:27:58 +0200 | [diff] [blame] | 1294 | sudo mkdir -m 755 $NOVA_CONF_DIR/rootwrap.d |
Thierry Carrez | 76a9eaf | 2012-06-22 15:30:28 +0200 | [diff] [blame] | 1295 | sudo cp $NOVA_DIR/etc/nova/rootwrap.d/*.filters $NOVA_CONF_DIR/rootwrap.d |
Thierry Carrez | ce5b8ed | 2012-06-14 12:27:58 +0200 | [diff] [blame] | 1296 | sudo chown -R root:root $NOVA_CONF_DIR/rootwrap.d |
| 1297 | sudo chmod 644 $NOVA_CONF_DIR/rootwrap.d/* |
Thierry Carrez | be5d3f2 | 2012-06-20 18:17:03 +0200 | [diff] [blame] | 1298 | # Set up rootwrap.conf, pointing to /etc/nova/rootwrap.d |
| 1299 | sudo cp $NOVA_DIR/etc/nova/rootwrap.conf $NOVA_CONF_DIR/ |
Thierry Carrez | 76a9eaf | 2012-06-22 15:30:28 +0200 | [diff] [blame] | 1300 | sudo sed -e "s:^filters_path=.*$:filters_path=$NOVA_CONF_DIR/rootwrap.d:" -i $NOVA_CONF_DIR/rootwrap.conf |
Thierry Carrez | be5d3f2 | 2012-06-20 18:17:03 +0200 | [diff] [blame] | 1301 | sudo chown root:root $NOVA_CONF_DIR/rootwrap.conf |
| 1302 | sudo chmod 0644 $NOVA_CONF_DIR/rootwrap.conf |
| 1303 | # Specify rootwrap.conf as first parameter to nova-rootwrap |
| 1304 | NOVA_ROOTWRAP="$NOVA_ROOTWRAP $NOVA_CONF_DIR/rootwrap.conf" |
Thierry Carrez | ce5b8ed | 2012-06-14 12:27:58 +0200 | [diff] [blame] | 1305 | ROOTWRAP_SUDOER_CMD="$NOVA_ROOTWRAP *" |
| 1306 | fi |
| 1307 | |
John Griffith | 4e823ff | 2012-07-20 13:18:17 -0600 | [diff] [blame] | 1308 | # Set up the rootwrap sudoers for nova |
Thierry Carrez | d2f8fa3 | 2012-06-11 16:45:29 +0200 | [diff] [blame] | 1309 | TEMPFILE=`mktemp` |
Thierry Carrez | ce5b8ed | 2012-06-14 12:27:58 +0200 | [diff] [blame] | 1310 | echo "$USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE |
Thierry Carrez | d2f8fa3 | 2012-06-11 16:45:29 +0200 | [diff] [blame] | 1311 | chmod 0440 $TEMPFILE |
| 1312 | sudo chown root:root $TEMPFILE |
| 1313 | sudo mv $TEMPFILE /etc/sudoers.d/nova-rootwrap |
| 1314 | |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 1315 | if is_service_enabled n-api; then |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 1316 | # Use the sample http middleware configuration supplied in the |
| 1317 | # Nova sources. This paste config adds the configuration required |
| 1318 | # for Nova to validate Keystone tokens. |
Vishvananda Ishaya | ea4a53d | 2012-01-11 11:34:13 -0800 | [diff] [blame] | 1319 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 1320 | # Allow rate limiting to be turned off for testing, like for Tempest |
Vishvananda Ishaya | ed11195 | 2012-03-20 15:08:15 -0700 | [diff] [blame] | 1321 | # NOTE: Set API_RATE_LIMIT="False" to turn OFF rate limiting |
| 1322 | API_RATE_LIMIT=${API_RATE_LIMIT:-"True"} |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 1323 | |
| 1324 | # Remove legacy paste config if present |
Vishvananda Ishaya | 7a103dd | 2012-02-23 23:35:43 +0000 | [diff] [blame] | 1325 | rm -f $NOVA_DIR/bin/nova-api-paste.ini |
| 1326 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 1327 | # Get the sample configuration file in place |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1328 | cp $NOVA_DIR/etc/nova/api-paste.ini $NOVA_CONF_DIR |
Vishvananda Ishaya | ea4a53d | 2012-01-11 11:34:13 -0800 | [diff] [blame] | 1329 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 1330 | # Rewrite the authtoken configration for our Keystone service. |
| 1331 | # This is a bit defensive to allow the sample file some varaince. |
Dean Troyer | b328838 | 2012-02-28 16:41:10 -0600 | [diff] [blame] | 1332 | sed -e " |
| 1333 | /^admin_token/i admin_tenant_name = $SERVICE_TENANT_NAME |
| 1334 | /admin_tenant_name/s/^.*$/admin_tenant_name = $SERVICE_TENANT_NAME/; |
| 1335 | /admin_user/s/^.*$/admin_user = nova/; |
| 1336 | /admin_password/s/^.*$/admin_password = $SERVICE_PASSWORD/; |
| 1337 | s,%SERVICE_TENANT_NAME%,$SERVICE_TENANT_NAME,g; |
| 1338 | s,%SERVICE_TOKEN%,$SERVICE_TOKEN,g; |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1339 | " -i $NOVA_CONF_DIR/api-paste.ini |
Jesse Andrews | f70569e | 2011-10-24 21:56:25 -0700 | [diff] [blame] | 1340 | fi |
Jesse Andrews | ba23cc7 | 2011-09-11 03:22:13 -0700 | [diff] [blame] | 1341 | |
Anthony Young | 5545845 | 2011-12-17 00:21:49 +0000 | [diff] [blame] | 1342 | # Helper to clean iptables rules |
| 1343 | function clean_iptables() { |
| 1344 | # Delete rules |
| 1345 | sudo iptables -S -v | sed "s/-c [0-9]* [0-9]* //g" | grep "nova" | grep "\-A" | sed "s/-A/-D/g" | awk '{print "sudo iptables",$0}' | bash |
| 1346 | # Delete nat rules |
| 1347 | sudo iptables -S -v -t nat | sed "s/-c [0-9]* [0-9]* //g" | grep "nova" | grep "\-A" | sed "s/-A/-D/g" | awk '{print "sudo iptables -t nat",$0}' | bash |
| 1348 | # Delete chains |
| 1349 | sudo iptables -S -v | sed "s/-c [0-9]* [0-9]* //g" | grep "nova" | grep "\-N" | sed "s/-N/-X/g" | awk '{print "sudo iptables",$0}' | bash |
| 1350 | # Delete nat chains |
| 1351 | sudo iptables -S -v -t nat | sed "s/-c [0-9]* [0-9]* //g" | grep "nova" | grep "\-N" | sed "s/-N/-X/g" | awk '{print "sudo iptables -t nat",$0}' | bash |
| 1352 | } |
| 1353 | |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 1354 | if is_service_enabled n-cpu; then |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 1355 | |
Dean Troyer | 0b31e86 | 2012-03-07 16:47:56 -0600 | [diff] [blame] | 1356 | # Force IP forwarding on, just on case |
| 1357 | sudo sysctl -w net.ipv4.ip_forward=1 |
| 1358 | |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 1359 | # attempt to load modules: network block device - used to manage qcow images |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 1360 | sudo modprobe nbd || true |
Jesse Andrews | c6d3042 | 2011-10-02 13:11:28 -0400 | [diff] [blame] | 1361 | |
Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 1362 | # Check for kvm (hardware based virtualization). If unable to initialize |
| 1363 | # kvm, we drop back to the slower emulation mode (qemu). Note: many systems |
Jesse Andrews | 51fb22e | 2011-10-19 09:24:17 -0700 | [diff] [blame] | 1364 | # come with hardware virtualization disabled in BIOS. |
Jesse Andrews | 2abbdd4 | 2011-10-03 22:48:30 -0400 | [diff] [blame] | 1365 | if [[ "$LIBVIRT_TYPE" == "kvm" ]]; then |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 1366 | sudo modprobe kvm || true |
Jesse Andrews | c6d3042 | 2011-10-02 13:11:28 -0400 | [diff] [blame] | 1367 | if [ ! -e /dev/kvm ]; then |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 1368 | echo "WARNING: Switching to QEMU" |
Jesse Andrews | c6d3042 | 2011-10-02 13:11:28 -0400 | [diff] [blame] | 1369 | LIBVIRT_TYPE=qemu |
| 1370 | fi |
Jesse Andrews | d1879c5 | 2011-09-16 16:28:13 -0700 | [diff] [blame] | 1371 | fi |
Jesse Andrews | c6d3042 | 2011-10-02 13:11:28 -0400 | [diff] [blame] | 1372 | |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 1373 | # Install and configure **LXC** if specified. LXC is another approach to |
| 1374 | # splitting a system into many smaller parts. LXC uses cgroups and chroot |
| 1375 | # to simulate multiple systems. |
Jesse Andrews | 2abbdd4 | 2011-10-03 22:48:30 -0400 | [diff] [blame] | 1376 | if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1377 | if [[ "$os_PACKAGE" = "deb" ]]; then |
Monty Taylor | 47f0206 | 2012-07-26 11:09:24 -0500 | [diff] [blame] | 1378 | if [[ ! "$DISTRO" > natty ]]; then |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1379 | cgline="none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0" |
| 1380 | sudo mkdir -p /cgroup |
| 1381 | if ! grep -q cgroup /etc/fstab; then |
| 1382 | echo "$cgline" | sudo tee -a /etc/fstab |
| 1383 | fi |
| 1384 | if ! mount -n | grep -q cgroup; then |
| 1385 | sudo mount /cgroup |
| 1386 | fi |
| 1387 | fi |
Jesse Andrews | e430423 | 2011-10-07 10:34:32 -0400 | [diff] [blame] | 1388 | fi |
Jesse Andrews | c6d3042 | 2011-10-02 13:11:28 -0400 | [diff] [blame] | 1389 | fi |
| 1390 | |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1391 | QEMU_CONF=/etc/libvirt/qemu.conf |
| 1392 | if is_service_enabled quantum && [[ $Q_PLUGIN = "openvswitch" ]] && ! sudo grep -q '^cgroup_device_acl' $QEMU_CONF ; then |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 1393 | # Add /dev/net/tun to cgroup_device_acls, needed for type=ethernet interfaces |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1394 | sudo chmod 666 $QEMU_CONF |
| 1395 | sudo cat <<EOF >> /etc/libvirt/qemu.conf |
| 1396 | cgroup_device_acl = [ |
| 1397 | "/dev/null", "/dev/full", "/dev/zero", |
| 1398 | "/dev/random", "/dev/urandom", |
| 1399 | "/dev/ptmx", "/dev/kvm", "/dev/kqemu", |
| 1400 | "/dev/rtc", "/dev/hpet","/dev/net/tun", |
| 1401 | ] |
| 1402 | EOF |
| 1403 | sudo chmod 644 $QEMU_CONF |
| 1404 | fi |
| 1405 | |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1406 | if [[ "$os_PACKAGE" = "deb" ]]; then |
| 1407 | LIBVIRT_DAEMON=libvirt-bin |
| 1408 | else |
| 1409 | # http://wiki.libvirt.org/page/SSHPolicyKitSetup |
| 1410 | if ! grep ^libvirtd: /etc/group >/dev/null; then |
| 1411 | sudo groupadd libvirtd |
| 1412 | fi |
| 1413 | sudo bash -c 'cat <<EOF >/etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla |
| 1414 | [libvirt Management Access] |
| 1415 | Identity=unix-group:libvirtd |
| 1416 | Action=org.libvirt.unix.manage |
| 1417 | ResultAny=yes |
| 1418 | ResultInactive=yes |
| 1419 | ResultActive=yes |
| 1420 | EOF' |
| 1421 | LIBVIRT_DAEMON=libvirtd |
| 1422 | fi |
Jesse Andrews | 51fb22e | 2011-10-19 09:24:17 -0700 | [diff] [blame] | 1423 | # The user that nova runs as needs to be member of libvirtd group otherwise |
| 1424 | # nova-compute will be unable to use libvirt. |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 1425 | sudo usermod -a -G libvirtd `whoami` |
Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 1426 | # libvirt detects various settings on startup, as we potentially changed |
Jesse Andrews | 51fb22e | 2011-10-19 09:24:17 -0700 | [diff] [blame] | 1427 | # the system configuration (modules, filesystems), we need to restart |
| 1428 | # libvirt to detect those changes. |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1429 | restart_service $LIBVIRT_DAEMON |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 1430 | |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 1431 | |
| 1432 | # Instance Storage |
| 1433 | # ~~~~~~~~~~~~~~~~ |
| 1434 | |
| 1435 | # Nova stores each instance in its own directory. |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 1436 | mkdir -p $NOVA_DIR/instances |
| 1437 | |
Jesse Andrews | 51fb22e | 2011-10-19 09:24:17 -0700 | [diff] [blame] | 1438 | # You can specify a different disk to be mounted and used for backing the |
Vishvananda Ishaya | 9b35367 | 2011-10-20 10:07:10 -0700 | [diff] [blame] | 1439 | # virtual machines. If there is a partition labeled nova-instances we |
Jesse Andrews | 51fb22e | 2011-10-19 09:24:17 -0700 | [diff] [blame] | 1440 | # mount it (ext filesystems can be labeled via e2label). |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 1441 | if [ -L /dev/disk/by-label/nova-instances ]; then |
Jesse Andrews | 38df122 | 2011-11-20 09:55:44 -0800 | [diff] [blame] | 1442 | if ! mount -n | grep -q $NOVA_DIR/instances; then |
Jesse Andrews | 51fb22e | 2011-10-19 09:24:17 -0700 | [diff] [blame] | 1443 | sudo mount -L nova-instances $NOVA_DIR/instances |
| 1444 | sudo chown -R `whoami` $NOVA_DIR/instances |
| 1445 | fi |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 1446 | fi |
| 1447 | |
Anthony Young | 5545845 | 2011-12-17 00:21:49 +0000 | [diff] [blame] | 1448 | # Clean iptables from previous runs |
| 1449 | clean_iptables |
| 1450 | |
| 1451 | # Destroy old instances |
Anthony Young | 1df0789 | 2012-03-15 01:08:13 -0700 | [diff] [blame] | 1452 | instances=`sudo virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"` |
Anthony Young | edef244 | 2012-01-20 12:45:32 -0800 | [diff] [blame] | 1453 | if [ ! "$instances" = "" ]; then |
Anthony Young | 1df0789 | 2012-03-15 01:08:13 -0700 | [diff] [blame] | 1454 | echo $instances | xargs -n1 sudo virsh destroy || true |
| 1455 | echo $instances | xargs -n1 sudo virsh undefine || true |
Anthony Young | 5545845 | 2011-12-17 00:21:49 +0000 | [diff] [blame] | 1456 | fi |
| 1457 | |
Anthony Young | 4f830e1 | 2012-02-11 00:17:31 -0800 | [diff] [blame] | 1458 | # Logout and delete iscsi sessions |
| 1459 | sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | xargs sudo iscsiadm --mode node --logout || true |
| 1460 | sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | sudo iscsiadm --mode node --op delete || true |
| 1461 | |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 1462 | # Clean out the instances directory. |
Jesse Andrews | 461bfdc | 2011-10-09 17:50:38 -0700 | [diff] [blame] | 1463 | sudo rm -rf $NOVA_DIR/instances/* |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 1464 | fi |
| 1465 | |
Isaku Yamahata | 6f85ab3 | 2012-08-06 16:56:10 +0900 | [diff] [blame] | 1466 | if is_service_enabled n-net q-dhcp; then |
Anthony Young | 5545845 | 2011-12-17 00:21:49 +0000 | [diff] [blame] | 1467 | # Delete traces of nova networks from prior runs |
Anthony Young | 09fde81 | 2011-09-20 02:23:54 -0700 | [diff] [blame] | 1468 | sudo killall dnsmasq || true |
Anthony Young | 5545845 | 2011-12-17 00:21:49 +0000 | [diff] [blame] | 1469 | clean_iptables |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 1470 | rm -rf $NOVA_DIR/networks |
| 1471 | mkdir -p $NOVA_DIR/networks |
Dean Troyer | 0b31e86 | 2012-03-07 16:47:56 -0600 | [diff] [blame] | 1472 | |
| 1473 | # Force IP forwarding on, just on case |
| 1474 | sudo sysctl -w net.ipv4.ip_forward=1 |
Anthony Young | 70dc5e0 | 2011-09-15 16:52:43 -0700 | [diff] [blame] | 1475 | fi |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 1476 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 1477 | |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 1478 | # Storage Service |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 1479 | # --------------- |
| 1480 | |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 1481 | if is_service_enabled swift; then |
Chmouel Boudjnah | 77b0e1d | 2012-02-29 16:55:43 +0000 | [diff] [blame] | 1482 | |
Chmouel Boudjnah | f87fd04 | 2012-06-14 13:08:24 +0000 | [diff] [blame] | 1483 | # We make sure to kill all swift processes first |
Chmouel Boudjnah | 2a5f681 | 2012-07-12 05:22:44 +0000 | [diff] [blame] | 1484 | swift-init all stop || true |
Chmouel Boudjnah | f87fd04 | 2012-06-14 13:08:24 +0000 | [diff] [blame] | 1485 | |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 1486 | # We first do a bit of setup by creating the directories and |
| 1487 | # changing the permissions so we can run it as our user. |
| 1488 | |
Chmouel Boudjnah | 067163d | 2011-11-02 14:25:06 +0100 | [diff] [blame] | 1489 | USER_GROUP=$(id -g) |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 1490 | sudo mkdir -p ${SWIFT_DATA_DIR}/drives |
| 1491 | sudo chown -R $USER:${USER_GROUP} ${SWIFT_DATA_DIR} |
Vishvananda Ishaya | 5f03932 | 2011-11-05 16:12:20 -0700 | [diff] [blame] | 1492 | |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 1493 | # We then create a loopback disk and format it to XFS. |
Dean Troyer | 00edc95 | 2012-05-17 11:10:36 -0500 | [diff] [blame] | 1494 | if [[ -e ${SWIFT_DATA_DIR}/drives/images/swift.img ]]; then |
| 1495 | if egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then |
| 1496 | sudo umount ${SWIFT_DATA_DIR}/drives/sdb1 |
| 1497 | fi |
| 1498 | else |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 1499 | mkdir -p ${SWIFT_DATA_DIR}/drives/images |
| 1500 | sudo touch ${SWIFT_DATA_DIR}/drives/images/swift.img |
| 1501 | sudo chown $USER: ${SWIFT_DATA_DIR}/drives/images/swift.img |
Vishvananda Ishaya | 5f03932 | 2011-11-05 16:12:20 -0700 | [diff] [blame] | 1502 | |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 1503 | dd if=/dev/zero of=${SWIFT_DATA_DIR}/drives/images/swift.img \ |
Chmouel Boudjnah | b93478f | 2011-11-02 16:49:56 +0100 | [diff] [blame] | 1504 | bs=1024 count=0 seek=${SWIFT_LOOPBACK_DISK_SIZE} |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 1505 | fi |
Dean Troyer | 00edc95 | 2012-05-17 11:10:36 -0500 | [diff] [blame] | 1506 | # Make a fresh XFS filesystem |
| 1507 | mkfs.xfs -f -i size=1024 ${SWIFT_DATA_DIR}/drives/images/swift.img |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 1508 | |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 1509 | # After the drive being created we mount the disk with a few mount |
| 1510 | # options to make it most efficient as possible for swift. |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 1511 | mkdir -p ${SWIFT_DATA_DIR}/drives/sdb1 |
| 1512 | if ! egrep -q ${SWIFT_DATA_DIR}/drives/sdb1 /proc/mounts; then |
Chmouel Boudjnah | b93478f | 2011-11-02 16:49:56 +0100 | [diff] [blame] | 1513 | sudo mount -t xfs -o loop,noatime,nodiratime,nobarrier,logbufs=8 \ |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 1514 | ${SWIFT_DATA_DIR}/drives/images/swift.img ${SWIFT_DATA_DIR}/drives/sdb1 |
Chmouel Boudjnah | a03f005 | 2011-11-01 13:08:29 +0000 | [diff] [blame] | 1515 | fi |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 1516 | |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 1517 | # We then create link to that mounted location so swift would know |
| 1518 | # where to go. |
Chmouel Boudjnah | a95efab | 2012-02-16 10:35:26 +0000 | [diff] [blame] | 1519 | for x in $(seq ${SWIFT_REPLICAS}); do |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 1520 | sudo ln -sf ${SWIFT_DATA_DIR}/drives/sdb1/$x ${SWIFT_DATA_DIR}/$x; done |
Vishvananda Ishaya | 5f03932 | 2011-11-05 16:12:20 -0700 | [diff] [blame] | 1521 | |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 1522 | # We now have to emulate a few different servers into one we |
Vishvananda Ishaya | 5f03932 | 2011-11-05 16:12:20 -0700 | [diff] [blame] | 1523 | # create all the directories needed for swift |
Chmouel Boudjnah | a95efab | 2012-02-16 10:35:26 +0000 | [diff] [blame] | 1524 | for x in $(seq ${SWIFT_REPLICAS}); do |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 1525 | drive=${SWIFT_DATA_DIR}/drives/sdb1/${x} |
| 1526 | node=${SWIFT_DATA_DIR}/${x}/node |
Chmouel Boudjnah | a95efab | 2012-02-16 10:35:26 +0000 | [diff] [blame] | 1527 | node_device=${node}/sdb1 |
| 1528 | [[ -d $node ]] && continue |
| 1529 | [[ -d $drive ]] && continue |
| 1530 | sudo install -o ${USER} -g $USER_GROUP -d $drive |
| 1531 | sudo install -o ${USER} -g $USER_GROUP -d $node_device |
| 1532 | sudo chown -R $USER: ${node} |
Chmouel Boudjnah | e1d2bcb | 2011-11-01 17:32:11 +0100 | [diff] [blame] | 1533 | done |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 1534 | |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 1535 | sudo mkdir -p ${SWIFT_CONFIG_DIR}/{object,container,account}-server /var/run/swift |
| 1536 | sudo chown -R $USER: ${SWIFT_CONFIG_DIR} /var/run/swift |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 1537 | |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 1538 | if [[ "$SWIFT_CONFIG_DIR" != "/etc/swift" ]]; then |
| 1539 | # Some swift tools are hard-coded to use /etc/swift and are apparenty not going to be fixed. |
| 1540 | # Create a symlink if the config dir is moved |
| 1541 | sudo ln -sf ${SWIFT_CONFIG_DIR} /etc/swift |
| 1542 | fi |
Vishvananda Ishaya | 5f03932 | 2011-11-05 16:12:20 -0700 | [diff] [blame] | 1543 | |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 1544 | # Swift use rsync to syncronize between all the different |
| 1545 | # partitions (which make more sense when you have a multi-node |
| 1546 | # setup) we configure it with our version of rsync. |
| 1547 | sed -e " |
| 1548 | s/%GROUP%/${USER_GROUP}/; |
| 1549 | s/%USER%/$USER/; |
| 1550 | s,%SWIFT_DATA_DIR%,$SWIFT_DATA_DIR,; |
| 1551 | " $FILES/swift/rsyncd.conf | sudo tee /etc/rsyncd.conf |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1552 | if [[ "$os_PACKAGE" = "deb" ]]; then |
| 1553 | sudo sed -i '/^RSYNC_ENABLE=false/ { s/false/true/ }' /etc/default/rsync |
| 1554 | else |
| 1555 | sudo sed -i '/disable *= *yes/ { s/yes/no/ }' /etc/xinetd.d/rsync |
| 1556 | fi |
Chmouel Boudjnah | 45c5113 | 2011-11-01 19:32:23 +0100 | [diff] [blame] | 1557 | |
Chmouel Boudjnah | 6ae9ea5 | 2012-07-05 06:50:51 +0000 | [diff] [blame] | 1558 | if is_service_enabled swift3;then |
| 1559 | swift_auth_server="s3token " |
| 1560 | fi |
John Griffith | 4e823ff | 2012-07-20 13:18:17 -0600 | [diff] [blame] | 1561 | |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1562 | # By default Swift will be installed with the tempauth middleware |
| 1563 | # which has some default username and password if you have |
| 1564 | # configured keystone it will checkout the directory. |
| 1565 | if is_service_enabled key; then |
Chmouel Boudjnah | 84394b9 | 2012-08-06 10:07:43 +0000 | [diff] [blame] | 1566 | swift_auth_server+="authtoken keystoneauth" |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1567 | else |
| 1568 | swift_auth_server=tempauth |
| 1569 | fi |
Chmouel Boudjnah | 45c5113 | 2011-11-01 19:32:23 +0100 | [diff] [blame] | 1570 | |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1571 | SWIFT_CONFIG_PROXY_SERVER=${SWIFT_CONFIG_DIR}/proxy-server.conf |
| 1572 | cp ${SWIFT_DIR}/etc/proxy-server.conf-sample ${SWIFT_CONFIG_PROXY_SERVER} |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 1573 | |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1574 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user |
| 1575 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT user ${USER} |
| 1576 | |
| 1577 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir |
| 1578 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT swift_dir ${SWIFT_CONFIG_DIR} |
| 1579 | |
| 1580 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers |
| 1581 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT workers 1 |
| 1582 | |
| 1583 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level |
| 1584 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT log_level DEBUG |
| 1585 | |
| 1586 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port |
| 1587 | iniset ${SWIFT_CONFIG_PROXY_SERVER} DEFAULT bind_port ${SWIFT_DEFAULT_BIND_PORT:-8080} |
| 1588 | |
Chmouel Boudjnah | 6ae9ea5 | 2012-07-05 06:50:51 +0000 | [diff] [blame] | 1589 | # Only enable Swift3 if we have it enabled in ENABLED_SERVICES |
| 1590 | is_service_enabled swift3 && swift3=swift3 || swift3="" |
| 1591 | |
| 1592 | iniset ${SWIFT_CONFIG_PROXY_SERVER} pipeline:main pipeline "catch_errors healthcheck cache ratelimit ${swift3} ${swift_auth_server} proxy-logging proxy-server" |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1593 | |
| 1594 | iniset ${SWIFT_CONFIG_PROXY_SERVER} app:proxy-server account_autocreate true |
| 1595 | |
Chmouel Boudjnah | 84394b9 | 2012-08-06 10:07:43 +0000 | [diff] [blame] | 1596 | # Configure Keystone |
| 1597 | sed -i '/^# \[filter:authtoken\]/,/^# \[filter:keystoneauth\]$/ s/^#[ \t]*//' ${SWIFT_CONFIG_PROXY_SERVER} |
| 1598 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_host $KEYSTONE_AUTH_HOST |
| 1599 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_port $KEYSTONE_AUTH_PORT |
| 1600 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL |
| 1601 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken auth_uri $KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_SERVICE_PORT/ |
| 1602 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME |
| 1603 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken admin_user swift |
| 1604 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:authtoken admin_password $SERVICE_PASSWORD |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1605 | |
Chmouel Boudjnah | 84394b9 | 2012-08-06 10:07:43 +0000 | [diff] [blame] | 1606 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth use |
| 1607 | iniuncomment ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles |
| 1608 | iniset ${SWIFT_CONFIG_PROXY_SERVER} filter:keystoneauth operator_roles "Member, admin" |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1609 | |
Chmouel Boudjnah | 6ae9ea5 | 2012-07-05 06:50:51 +0000 | [diff] [blame] | 1610 | if is_service_enabled swift3;then |
| 1611 | cat <<EOF>>${SWIFT_CONFIG_PROXY_SERVER} |
| 1612 | # NOTE(chmou): s3token middleware is not updated yet to use only |
| 1613 | # username and password. |
| 1614 | [filter:s3token] |
| 1615 | paste.filter_factory = keystone.middleware.s3_token:filter_factory |
| 1616 | auth_port = ${KEYSTONE_AUTH_PORT} |
| 1617 | auth_host = ${KEYSTONE_AUTH_HOST} |
| 1618 | auth_protocol = ${KEYSTONE_AUTH_PROTOCOL} |
| 1619 | auth_token = ${SERVICE_TOKEN} |
| 1620 | admin_token = ${SERVICE_TOKEN} |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1621 | |
| 1622 | [filter:swift3] |
Chmouel Boudjnah | f8be428 | 2012-06-19 11:01:04 +0000 | [diff] [blame] | 1623 | use = egg:swift3#swift3 |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1624 | EOF |
Chmouel Boudjnah | 6ae9ea5 | 2012-07-05 06:50:51 +0000 | [diff] [blame] | 1625 | fi |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1626 | |
| 1627 | cp ${SWIFT_DIR}/etc/swift.conf-sample ${SWIFT_CONFIG_DIR}/swift.conf |
| 1628 | iniset ${SWIFT_CONFIG_DIR}/swift.conf swift-hash swift_hash_path_suffix ${SWIFT_HASH} |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 1629 | |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 1630 | # We need to generate a object/account/proxy configuration |
| 1631 | # emulating 4 nodes on different ports we have a little function |
| 1632 | # that help us doing that. |
| 1633 | function generate_swift_configuration() { |
| 1634 | local server_type=$1 |
| 1635 | local bind_port=$2 |
| 1636 | local log_facility=$3 |
| 1637 | local node_number |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1638 | local swift_node_config |
Vishvananda Ishaya | 5f03932 | 2011-11-05 16:12:20 -0700 | [diff] [blame] | 1639 | |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 1640 | for node_number in $(seq ${SWIFT_REPLICAS}); do |
| 1641 | node_path=${SWIFT_DATA_DIR}/${node_number} |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1642 | swift_node_config=${SWIFT_CONFIG_DIR}/${server_type}-server/${node_number}.conf |
| 1643 | |
| 1644 | cp ${SWIFT_DIR}/etc/${server_type}-server.conf-sample ${swift_node_config} |
| 1645 | |
| 1646 | iniuncomment ${swift_node_config} DEFAULT user |
| 1647 | iniset ${swift_node_config} DEFAULT user ${USER} |
| 1648 | |
| 1649 | iniuncomment ${swift_node_config} DEFAULT bind_port |
| 1650 | iniset ${swift_node_config} DEFAULT bind_port ${bind_port} |
| 1651 | |
| 1652 | iniuncomment ${swift_node_config} DEFAULT swift_dir |
| 1653 | iniset ${swift_node_config} DEFAULT swift_dir ${SWIFT_CONFIG_DIR} |
| 1654 | |
| 1655 | iniuncomment ${swift_node_config} DEFAULT devices |
| 1656 | iniset ${swift_node_config} DEFAULT devices ${node_path} |
| 1657 | |
| 1658 | iniuncomment ${swift_node_config} DEFAULT log_facility |
| 1659 | iniset ${swift_node_config} DEFAULT log_facility LOG_LOCAL${log_facility} |
| 1660 | |
| 1661 | iniuncomment ${swift_node_config} DEFAULT mount_check |
| 1662 | iniset ${swift_node_config} DEFAULT mount_check false |
| 1663 | |
| 1664 | iniuncomment ${swift_node_config} ${server_type}-replicator vm_test_mode |
| 1665 | iniset ${swift_node_config} ${server_type}-replicator vm_test_mode yes |
| 1666 | |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 1667 | bind_port=$(( ${bind_port} + 10 )) |
| 1668 | log_facility=$(( ${log_facility} + 1 )) |
| 1669 | done |
| 1670 | } |
| 1671 | generate_swift_configuration object 6010 2 |
| 1672 | generate_swift_configuration container 6011 2 |
| 1673 | generate_swift_configuration account 6012 2 |
Chmouel Boudjnah | a03f005 | 2011-11-01 13:08:29 +0000 | [diff] [blame] | 1674 | |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1675 | # We have some specific configuration for swift for rsyslog. See |
| 1676 | # the file /etc/rsyslog.d/10-swift.conf for more info. |
| 1677 | swift_log_dir=${SWIFT_DATA_DIR}/logs |
| 1678 | rm -rf ${swift_log_dir} |
| 1679 | mkdir -p ${swift_log_dir}/hourly |
| 1680 | sudo chown -R $USER:adm ${swift_log_dir} |
| 1681 | sed "s,%SWIFT_LOGDIR%,${swift_log_dir}," $FILES/swift/rsyslog.conf | sudo \ |
| 1682 | tee /etc/rsyslog.d/10-swift.conf |
| 1683 | restart_service rsyslog |
Chmouel Boudjnah | 769eb1c | 2011-11-22 13:04:40 +0100 | [diff] [blame] | 1684 | |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1685 | # This is where we create three different rings for swift with |
| 1686 | # different object servers binding on different ports. |
| 1687 | pushd ${SWIFT_CONFIG_DIR} >/dev/null && { |
Vishvananda Ishaya | ea4a53d | 2012-01-11 11:34:13 -0800 | [diff] [blame] | 1688 | |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1689 | rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz |
Chmouel Boudjnah | a95efab | 2012-02-16 10:35:26 +0000 | [diff] [blame] | 1690 | |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1691 | port_number=6010 |
| 1692 | swift-ring-builder object.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1 |
| 1693 | for x in $(seq ${SWIFT_REPLICAS}); do |
| 1694 | swift-ring-builder object.builder add z${x}-127.0.0.1:${port_number}/sdb1 1 |
| 1695 | port_number=$[port_number + 10] |
| 1696 | done |
| 1697 | swift-ring-builder object.builder rebalance |
Chmouel Boudjnah | a95efab | 2012-02-16 10:35:26 +0000 | [diff] [blame] | 1698 | |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1699 | port_number=6011 |
| 1700 | swift-ring-builder container.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1 |
| 1701 | for x in $(seq ${SWIFT_REPLICAS}); do |
| 1702 | swift-ring-builder container.builder add z${x}-127.0.0.1:${port_number}/sdb1 1 |
| 1703 | port_number=$[port_number + 10] |
| 1704 | done |
| 1705 | swift-ring-builder container.builder rebalance |
Chmouel Boudjnah | a95efab | 2012-02-16 10:35:26 +0000 | [diff] [blame] | 1706 | |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1707 | port_number=6012 |
| 1708 | swift-ring-builder account.builder create ${SWIFT_PARTITION_POWER_SIZE} ${SWIFT_REPLICAS} 1 |
| 1709 | for x in $(seq ${SWIFT_REPLICAS}); do |
| 1710 | swift-ring-builder account.builder add z${x}-127.0.0.1:${port_number}/sdb1 1 |
| 1711 | port_number=$[port_number + 10] |
| 1712 | done |
| 1713 | swift-ring-builder account.builder rebalance |
Chmouel Boudjnah | a95efab | 2012-02-16 10:35:26 +0000 | [diff] [blame] | 1714 | |
Chmouel Boudjnah | c7214e8 | 2012-06-06 13:56:39 +0200 | [diff] [blame] | 1715 | } && popd >/dev/null |
Chmouel Boudjnah | a95efab | 2012-02-16 10:35:26 +0000 | [diff] [blame] | 1716 | |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 1717 | # We then can start rsync. |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1718 | if [[ "$os_PACKAGE" = "deb" ]]; then |
| 1719 | sudo /etc/init.d/rsync restart || : |
| 1720 | else |
| 1721 | sudo systemctl start xinetd.service |
| 1722 | fi |
Vishvananda Ishaya | 5f03932 | 2011-11-05 16:12:20 -0700 | [diff] [blame] | 1723 | |
Dean Troyer | b1f6c18 | 2012-03-16 09:23:23 -0500 | [diff] [blame] | 1724 | # First spawn all the swift services then kill the |
Chmouel Boudjnah | 185c66e | 2012-03-15 17:17:39 +0000 | [diff] [blame] | 1725 | # proxy service so we can run it in foreground in screen. |
Dean Troyer | b1f6c18 | 2012-03-16 09:23:23 -0500 | [diff] [blame] | 1726 | # ``swift-init ... {stop|restart}`` exits with '1' if no servers are running, |
| 1727 | # ignore it just in case |
| 1728 | swift-init all restart || true |
| 1729 | swift-init proxy stop || true |
Chmouel Boudjnah | d5651bb | 2011-11-01 16:22:08 +0100 | [diff] [blame] | 1730 | |
Chmouel Boudjnah | a95efab | 2012-02-16 10:35:26 +0000 | [diff] [blame] | 1731 | unset s swift_hash swift_auth_server |
Chmouel Boudjnah | 28fa4e8 | 2011-11-01 12:30:55 +0100 | [diff] [blame] | 1732 | fi |
| 1733 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 1734 | |
Anthony Young | acff87a | 2011-10-20 10:12:58 -0700 | [diff] [blame] | 1735 | # Volume Service |
| 1736 | # -------------- |
| 1737 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 1738 | if is_service_enabled cinder; then |
| 1739 | init_cinder |
| 1740 | elif is_service_enabled n-vol; then |
| 1741 | # Configure a default volume group called '`stack-volumes`' for the volume |
Anthony Young | acff87a | 2011-10-20 10:12:58 -0700 | [diff] [blame] | 1742 | # service if it does not yet exist. If you don't wish to use a file backed |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 1743 | # volume group, create your own volume group called ``stack-volumes`` before |
| 1744 | # invoking ``stack.sh``. |
Anthony Young | acff87a | 2011-10-20 10:12:58 -0700 | [diff] [blame] | 1745 | # |
Eoghan Glynn | 9cb1776 | 2012-07-15 10:22:45 +0100 | [diff] [blame] | 1746 | # By default, the backing file is 5G in size, and is stored in ``/opt/stack/data``. |
Jesse Andrews | 38df122 | 2011-11-20 09:55:44 -0800 | [diff] [blame] | 1747 | |
Dean Troyer | 2229a6e | 2011-12-01 17:02:07 -0600 | [diff] [blame] | 1748 | if ! sudo vgs $VOLUME_GROUP; then |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 1749 | VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-$DATA_DIR/${VOLUME_GROUP}-backing-file} |
Dean Troyer | 2229a6e | 2011-12-01 17:02:07 -0600 | [diff] [blame] | 1750 | # Only create if the file doesn't already exists |
| 1751 | [[ -f $VOLUME_BACKING_FILE ]] || truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE |
Anthony Young | acff87a | 2011-10-20 10:12:58 -0700 | [diff] [blame] | 1752 | DEV=`sudo losetup -f --show $VOLUME_BACKING_FILE` |
Dean Troyer | 2229a6e | 2011-12-01 17:02:07 -0600 | [diff] [blame] | 1753 | # Only create if the loopback device doesn't contain $VOLUME_GROUP |
| 1754 | if ! sudo vgs $VOLUME_GROUP; then sudo vgcreate $VOLUME_GROUP $DEV; fi |
| 1755 | fi |
| 1756 | |
| 1757 | if sudo vgs $VOLUME_GROUP; then |
Vincent Untz | 0230aa8 | 2012-06-14 08:51:01 +0200 | [diff] [blame] | 1758 | if [[ "$os_PACKAGE" = "rpm" ]]; then |
| 1759 | # RPM doesn't start the service |
| 1760 | start_service tgtd |
| 1761 | fi |
| 1762 | |
Chuck Short | 3f603d9 | 2012-07-28 13:28:33 -0500 | [diff] [blame] | 1763 | # Setup tgtd configuration files |
| 1764 | mkdir -p $NOVA_DIR/volumes |
| 1765 | |
Anthony Young | 6325216 | 2012-02-08 00:54:20 +0000 | [diff] [blame] | 1766 | # Remove nova iscsi targets |
| 1767 | sudo tgtadm --op show --mode target | grep $VOLUME_NAME_PREFIX | grep Target | cut -f3 -d ' ' | sudo xargs -n1 tgt-admin --delete || true |
Dean Troyer | 2229a6e | 2011-12-01 17:02:07 -0600 | [diff] [blame] | 1768 | # Clean out existing volumes |
| 1769 | for lv in `sudo lvs --noheadings -o lv_name $VOLUME_GROUP`; do |
| 1770 | # VOLUME_NAME_PREFIX prefixes the LVs we want |
| 1771 | if [[ "${lv#$VOLUME_NAME_PREFIX}" != "$lv" ]]; then |
Dean Troyer | 2229a6e | 2011-12-01 17:02:07 -0600 | [diff] [blame] | 1772 | sudo lvremove -f $VOLUME_GROUP/$lv |
| 1773 | fi |
| 1774 | done |
Anthony Young | acff87a | 2011-10-20 10:12:58 -0700 | [diff] [blame] | 1775 | fi |
| 1776 | |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1777 | if [[ "$os_PACKAGE" = "deb" ]]; then |
Chuck Short | 3f603d9 | 2012-07-28 13:28:33 -0500 | [diff] [blame] | 1778 | |
| 1779 | # Setup the tgt configuration file |
| 1780 | if [[ ! -f /etc/tgt/conf.d/nova.conf ]]; then |
Renuka Apte | 5a4039a | 2012-08-09 17:45:17 -0700 | [diff] [blame] | 1781 | sudo mkdir -p /etc/tgt/conf.d |
Chuck Short | 3f603d9 | 2012-07-28 13:28:33 -0500 | [diff] [blame] | 1782 | echo "include $NOVA_DIR/volumes/*" | sudo tee /etc/tgt/conf.d/nova.conf |
| 1783 | fi |
| 1784 | |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1785 | # tgt in oneiric doesn't restart properly if tgtd isn't running |
| 1786 | # do it in two steps |
| 1787 | sudo stop tgt || true |
| 1788 | sudo start tgt |
| 1789 | else |
Vincent Untz | 9604b74 | 2012-06-29 15:04:19 +0200 | [diff] [blame] | 1790 | restart_service tgtd |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1791 | fi |
Anthony Young | acff87a | 2011-10-20 10:12:58 -0700 | [diff] [blame] | 1792 | fi |
| 1793 | |
Monty Taylor | 9fbeedd | 2012-08-17 12:52:27 -0400 | [diff] [blame] | 1794 | # Support entry points installation of console scripts |
| 1795 | if [ -d $NOVA_DIR/bin ] ; then |
| 1796 | NOVA_BIN_DIR=$NOVA_DIR/bin |
| 1797 | else |
| 1798 | NOVA_BIN_DIR=/usr/local/bin |
| 1799 | fi |
| 1800 | |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1801 | NOVA_CONF=nova.conf |
| 1802 | function add_nova_opt { |
| 1803 | echo "$1" >> $NOVA_CONF_DIR/$NOVA_CONF |
Jesse Andrews | d1879c5 | 2011-09-16 16:28:13 -0700 | [diff] [blame] | 1804 | } |
| 1805 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 1806 | # Remove legacy nova.conf |
Vishvananda Ishaya | 7a103dd | 2012-02-23 23:35:43 +0000 | [diff] [blame] | 1807 | rm -f $NOVA_DIR/bin/nova.conf |
| 1808 | |
Jesse Andrews | d1879c5 | 2011-09-16 16:28:13 -0700 | [diff] [blame] | 1809 | # (re)create nova.conf |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1810 | rm -f $NOVA_CONF_DIR/$NOVA_CONF |
| 1811 | add_nova_opt "[DEFAULT]" |
| 1812 | add_nova_opt "verbose=True" |
Vishvananda Ishaya | 50aef3b | 2012-03-05 23:12:04 -0800 | [diff] [blame] | 1813 | add_nova_opt "auth_strategy=keystone" |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1814 | add_nova_opt "allow_resize_to_same_host=True" |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 1815 | add_nova_opt "root_helper=sudo $NOVA_ROOTWRAP" |
Vishvananda Ishaya | 51aa401 | 2012-03-06 12:45:19 -0800 | [diff] [blame] | 1816 | add_nova_opt "compute_scheduler_driver=$SCHEDULER" |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1817 | add_nova_opt "dhcpbridge_flagfile=$NOVA_CONF_DIR/$NOVA_CONF" |
| 1818 | add_nova_opt "fixed_range=$FIXED_RANGE" |
Chmouel Boudjnah | 77b0e1d | 2012-02-29 16:55:43 +0000 | [diff] [blame] | 1819 | add_nova_opt "s3_host=$SERVICE_HOST" |
| 1820 | add_nova_opt "s3_port=$S3_SERVICE_PORT" |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 1821 | if is_service_enabled quantum; then |
Gary Kotton | 37dda8d | 2012-08-08 03:46:33 -0400 | [diff] [blame] | 1822 | add_nova_opt "network_api_class=nova.network.quantumv2.api.API" |
| 1823 | add_nova_opt "quantum_admin_username=$Q_ADMIN_USERNAME" |
| 1824 | add_nova_opt "quantum_admin_password=$SERVICE_PASSWORD" |
| 1825 | add_nova_opt "quantum_admin_auth_url=$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v2.0" |
| 1826 | add_nova_opt "quantum_auth_strategy=$Q_AUTH_STRATEGY" |
| 1827 | add_nova_opt "quantum_admin_tenant_name=$SERVICE_TENANT_NAME" |
| 1828 | add_nova_opt "quantum_url=http://$Q_HOST:$Q_PORT" |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1829 | |
| 1830 | if [[ "$Q_PLUGIN" = "openvswitch" ]]; then |
| 1831 | NOVA_VIF_DRIVER="nova.virt.libvirt.vif.LibvirtOpenVswitchDriver" |
| 1832 | LINUXNET_VIF_DRIVER="nova.network.linux_net.LinuxOVSInterfaceDriver" |
| 1833 | elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then |
| 1834 | NOVA_VIF_DRIVER="nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver" |
| 1835 | LINUXNET_VIF_DRIVER="nova.network.linux_net.QuantumLinuxBridgeInterfaceDriver" |
Brad Hall | 1bfa3d5 | 2011-10-27 18:18:20 -0700 | [diff] [blame] | 1836 | fi |
Dan Wendlandt | 0007f3a | 2012-05-18 13:37:47 -0700 | [diff] [blame] | 1837 | add_nova_opt "libvirt_vif_type=ethernet" |
| 1838 | add_nova_opt "libvirt_vif_driver=$NOVA_VIF_DRIVER" |
| 1839 | add_nova_opt "linuxnet_interface_driver=$LINUXNET_VIF_DRIVER" |
Brad Hall | 1bfa3d5 | 2011-10-27 18:18:20 -0700 | [diff] [blame] | 1840 | else |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1841 | add_nova_opt "network_manager=nova.network.manager.$NET_MAN" |
Brad Hall | 1bfa3d5 | 2011-10-27 18:18:20 -0700 | [diff] [blame] | 1842 | fi |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 1843 | if is_service_enabled n-vol; then |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1844 | add_nova_opt "volume_group=$VOLUME_GROUP" |
Vishvananda Ishaya | 0ac5a8a | 2012-05-02 00:27:27 +0000 | [diff] [blame] | 1845 | add_nova_opt "volume_name_template=${VOLUME_NAME_PREFIX}%s" |
Vishvananda Ishaya | 524aa54 | 2012-01-14 01:08:34 +0000 | [diff] [blame] | 1846 | # oneiric no longer supports ietadm |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1847 | add_nova_opt "iscsi_helper=tgtadm" |
Jesse Andrews | d02b7b7 | 2011-11-14 08:59:05 -0800 | [diff] [blame] | 1848 | fi |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1849 | add_nova_opt "osapi_compute_extension=nova.api.openstack.compute.contrib.standard_extensions" |
| 1850 | add_nova_opt "my_ip=$HOST_IP" |
| 1851 | add_nova_opt "public_interface=$PUBLIC_INTERFACE" |
| 1852 | add_nova_opt "vlan_interface=$VLAN_INTERFACE" |
| 1853 | add_nova_opt "flat_network_bridge=$FLAT_NETWORK_BRIDGE" |
John Garbutt | 8e2cffd | 2012-03-02 16:22:07 +0000 | [diff] [blame] | 1854 | if [ -n "$FLAT_INTERFACE" ]; then |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1855 | add_nova_opt "flat_interface=$FLAT_INTERFACE" |
John Garbutt | 8e2cffd | 2012-03-02 16:22:07 +0000 | [diff] [blame] | 1856 | fi |
Gabriel Hurley | 71f23eb | 2012-02-15 17:39:05 -0800 | [diff] [blame] | 1857 | add_nova_opt "sql_connection=$BASE_SQL_CONN/nova?charset=utf8" |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1858 | add_nova_opt "libvirt_type=$LIBVIRT_TYPE" |
Russell Bryant | e80c0be | 2012-07-12 11:06:50 -0400 | [diff] [blame] | 1859 | add_nova_opt "libvirt_cpu_mode=none" |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1860 | add_nova_opt "instance_name_template=${INSTANCE_NAME_PREFIX}%08x" |
Anthony Young | 2fcb666 | 2012-02-03 20:17:22 +0000 | [diff] [blame] | 1861 | # All nova-compute workers need to know the vnc configuration options |
| 1862 | # These settings don't hurt anything if n-xvnc and n-novnc are disabled |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 1863 | if is_service_enabled n-cpu; then |
Anthony Young | ce11691 | 2012-01-17 15:46:53 -0800 | [diff] [blame] | 1864 | NOVNCPROXY_URL=${NOVNCPROXY_URL:-"http://$SERVICE_HOST:6080/vnc_auto.html"} |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1865 | add_nova_opt "novncproxy_base_url=$NOVNCPROXY_URL" |
Anthony Young | ce11691 | 2012-01-17 15:46:53 -0800 | [diff] [blame] | 1866 | XVPVNCPROXY_URL=${XVPVNCPROXY_URL:-"http://$SERVICE_HOST:6081/console"} |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1867 | add_nova_opt "xvpvncproxy_base_url=$XVPVNCPROXY_URL" |
Anthony Young | ce11691 | 2012-01-17 15:46:53 -0800 | [diff] [blame] | 1868 | fi |
| 1869 | if [ "$VIRT_DRIVER" = 'xenserver' ]; then |
| 1870 | VNCSERVER_PROXYCLIENT_ADDRESS=${VNCSERVER_PROXYCLIENT_ADDRESS=169.254.0.1} |
| 1871 | else |
| 1872 | VNCSERVER_PROXYCLIENT_ADDRESS=${VNCSERVER_PROXYCLIENT_ADDRESS=127.0.0.1} |
| 1873 | fi |
Anthony Young | 50fc5c6 | 2012-01-26 09:38:33 -0800 | [diff] [blame] | 1874 | # Address on which instance vncservers will listen on compute hosts. |
| 1875 | # For multi-host, this should be the management ip of the compute host. |
| 1876 | VNCSERVER_LISTEN=${VNCSERVER_LISTEN=127.0.0.1} |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1877 | add_nova_opt "vncserver_listen=$VNCSERVER_LISTEN" |
| 1878 | add_nova_opt "vncserver_proxyclient_address=$VNCSERVER_PROXYCLIENT_ADDRESS" |
| 1879 | add_nova_opt "api_paste_config=$NOVA_CONF_DIR/api-paste.ini" |
| 1880 | add_nova_opt "image_service=nova.image.glance.GlanceImageService" |
| 1881 | add_nova_opt "ec2_dmz_host=$EC2_DMZ_HOST" |
John Garbutt | 22ddb27 | 2012-05-24 15:56:06 +0100 | [diff] [blame] | 1882 | if is_service_enabled qpid ; then |
| 1883 | add_nova_opt "rpc_backend=nova.rpc.impl_qpid" |
| 1884 | elif [ -n "$RABBIT_HOST" ] && [ -n "$RABBIT_PASSWORD" ]; then |
Russell Bryant | 4a22145 | 2012-03-13 13:44:12 -0400 | [diff] [blame] | 1885 | add_nova_opt "rabbit_host=$RABBIT_HOST" |
| 1886 | add_nova_opt "rabbit_password=$RABBIT_PASSWORD" |
Russell Bryant | 4a22145 | 2012-03-13 13:44:12 -0400 | [diff] [blame] | 1887 | fi |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1888 | add_nova_opt "glance_api_servers=$GLANCE_HOSTPORT" |
| 1889 | add_nova_opt "force_dhcp_release=True" |
Vishvananda Ishaya | 3e2b174 | 2011-10-28 12:20:07 -0700 | [diff] [blame] | 1890 | if [ -n "$INSTANCES_PATH" ]; then |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1891 | add_nova_opt "instances_path=$INSTANCES_PATH" |
Vishvananda Ishaya | e72bdb0 | 2011-10-28 13:34:38 -0700 | [diff] [blame] | 1892 | fi |
Vishvananda Ishaya | 5f03932 | 2011-11-05 16:12:20 -0700 | [diff] [blame] | 1893 | if [ "$MULTI_HOST" != "False" ]; then |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1894 | add_nova_opt "multi_host=True" |
| 1895 | add_nova_opt "send_arp_for_ha=True" |
Jesse Andrews | d1879c5 | 2011-09-16 16:28:13 -0700 | [diff] [blame] | 1896 | fi |
James E. Blair | 5855a64 | 2011-10-26 15:44:27 -0400 | [diff] [blame] | 1897 | if [ "$SYSLOG" != "False" ]; then |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1898 | add_nova_opt "use_syslog=True" |
James E. Blair | 5855a64 | 2011-10-26 15:44:27 -0400 | [diff] [blame] | 1899 | fi |
Vishvananda Ishaya | ed11195 | 2012-03-20 15:08:15 -0700 | [diff] [blame] | 1900 | if [ "$API_RATE_LIMIT" != "True" ]; then |
| 1901 | add_nova_opt "api_rate_limit=False" |
| 1902 | fi |
Vishvananda Ishaya | 6f13ba3 | 2012-06-01 23:17:38 +0000 | [diff] [blame] | 1903 | if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then |
| 1904 | # Add color to logging output |
| 1905 | add_nova_opt "logging_context_format_string=%(asctime)s %(color)s%(levelname)s %(name)s [[01;36m%(request_id)s [00;36m%(user_name)s %(project_name)s%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m" |
| 1906 | add_nova_opt "logging_default_format_string=%(asctime)s %(color)s%(levelname)s %(name)s [[00;36m-%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m" |
| 1907 | add_nova_opt "logging_debug_format_suffix=[00;33mfrom (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d[00m" |
| 1908 | add_nova_opt "logging_exception_prefix=%(color)s%(asctime)s TRACE %(name)s [01;35m%(instance)s[00m" |
| 1909 | else |
| 1910 | # Show user_name and project_name instead of user_id and project_id |
| 1911 | add_nova_opt "logging_context_format_string=%(asctime)s %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s" |
| 1912 | fi |
Vishvananda Ishaya | ed11195 | 2012-03-20 15:08:15 -0700 | [diff] [blame] | 1913 | |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 1914 | # If cinder is enabled, use the cinder volume driver |
| 1915 | if is_service_enabled cinder; then |
| 1916 | add_nova_opt "volume_api_class=nova.volume.cinder.API" |
| 1917 | fi |
Jesse Andrews | d1879c5 | 2011-09-16 16:28:13 -0700 | [diff] [blame] | 1918 | |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1919 | # Provide some transition from EXTRA_FLAGS to EXTRA_OPTS |
| 1920 | if [[ -z "$EXTRA_OPTS" && -n "$EXTRA_FLAGS" ]]; then |
Vishvananda Ishaya | ed11195 | 2012-03-20 15:08:15 -0700 | [diff] [blame] | 1921 | EXTRA_OPTS=$EXTRA_FLAGS |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1922 | fi |
| 1923 | |
| 1924 | # You can define extra nova conf flags by defining the array EXTRA_OPTS, |
| 1925 | # For Example: EXTRA_OPTS=(foo=true bar=2) |
| 1926 | for I in "${EXTRA_OPTS[@]}"; do |
| 1927 | # Attempt to convert flags to options |
John Garbutt | 030fb23 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 1928 | add_nova_opt ${I//--} |
Jesse Andrews | 38df122 | 2011-11-20 09:55:44 -0800 | [diff] [blame] | 1929 | done |
| 1930 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 1931 | |
Anthony Young | b62b4ca | 2011-10-26 22:29:08 -0700 | [diff] [blame] | 1932 | # XenServer |
| 1933 | # --------- |
| 1934 | |
| 1935 | if [ "$VIRT_DRIVER" = 'xenserver' ]; then |
| 1936 | read_password XENAPI_PASSWORD "ENTER A PASSWORD TO USE FOR XEN." |
Sean Dague | e0e91d2 | 2012-07-11 09:35:42 -0400 | [diff] [blame] | 1937 | add_nova_opt "compute_driver=xenapi.XenAPIDriver" |
John Garbutt | 92e8560 | 2012-03-02 16:08:37 +0000 | [diff] [blame] | 1938 | XENAPI_CONNECTION_URL=${XENAPI_CONNECTION_URL:-"http://169.254.0.1"} |
John Garbutt | 030fb23 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 1939 | XENAPI_USER=${XENAPI_USER:-"root"} |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1940 | add_nova_opt "xenapi_connection_url=$XENAPI_CONNECTION_URL" |
John Garbutt | 030fb23 | 2012-04-27 18:28:28 +0100 | [diff] [blame] | 1941 | add_nova_opt "xenapi_connection_username=$XENAPI_USER" |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1942 | add_nova_opt "xenapi_connection_password=$XENAPI_PASSWORD" |
| 1943 | add_nova_opt "flat_injected=False" |
Anthony Young | ce11691 | 2012-01-17 15:46:53 -0800 | [diff] [blame] | 1944 | # Need to avoid crash due to new firewall support |
| 1945 | XEN_FIREWALL_DRIVER=${XEN_FIREWALL_DRIVER:-"nova.virt.firewall.IptablesFirewallDriver"} |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1946 | add_nova_opt "firewall_driver=$XEN_FIREWALL_DRIVER" |
Devananda van der Veen | c0c6f00 | 2012-07-06 17:49:12 -0700 | [diff] [blame] | 1947 | elif [ "$VIRT_DRIVER" = 'openvz' ]; then |
| 1948 | # TODO(deva): OpenVZ driver does not yet work if compute_driver is set here. |
| 1949 | # Replace connection_type when this is fixed. |
| 1950 | # add_nova_opt "compute_driver=openvz.connection.OpenVzConnection" |
| 1951 | add_nova_opt "connection_type=openvz" |
| 1952 | LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.libvirt.firewall.IptablesFirewallDriver"} |
| 1953 | add_nova_opt "firewall_driver=$LIBVIRT_FIREWALL_DRIVER" |
Anthony Young | b62b4ca | 2011-10-26 22:29:08 -0700 | [diff] [blame] | 1954 | else |
Sean Dague | e0e91d2 | 2012-07-11 09:35:42 -0400 | [diff] [blame] | 1955 | add_nova_opt "compute_driver=libvirt.LibvirtDriver" |
Armando Migliaccio | 34f6249 | 2012-01-31 14:33:19 +0000 | [diff] [blame] | 1956 | LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.libvirt.firewall.IptablesFirewallDriver"} |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 1957 | add_nova_opt "firewall_driver=$LIBVIRT_FIREWALL_DRIVER" |
Anthony Young | b62b4ca | 2011-10-26 22:29:08 -0700 | [diff] [blame] | 1958 | fi |
| 1959 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 1960 | |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 1961 | # Nova Database |
| 1962 | # ~~~~~~~~~~~~~ |
| 1963 | |
| 1964 | # All nova components talk to a central database. We will need to do this step |
| 1965 | # only once for an entire cluster. |
| 1966 | |
Chmouel Boudjnah | c9e0188 | 2012-03-15 17:21:24 +0000 | [diff] [blame] | 1967 | if is_service_enabled mysql && is_service_enabled nova; then |
Anthony Young | a074800 | 2011-09-16 21:37:36 -0700 | [diff] [blame] | 1968 | # (re)create nova database |
Anthony Young | 7a549f4 | 2011-10-12 07:13:13 +0000 | [diff] [blame] | 1969 | mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS nova;' |
Vincent Untz | 6a57f26 | 2012-06-14 10:07:42 +0200 | [diff] [blame] | 1970 | # Explicitly use latin1: to avoid lp#829209, nova expects the database to |
| 1971 | # use latin1 by default, and then upgrades the database to utf8 (see the |
| 1972 | # 082_essex.py in nova) |
| 1973 | mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE nova CHARACTER SET latin1;' |
Jesse Andrews | cbe98d5 | 2011-10-02 17:47:32 -0400 | [diff] [blame] | 1974 | |
| 1975 | # (re)create nova database |
Monty Taylor | 9fbeedd | 2012-08-17 12:52:27 -0400 | [diff] [blame] | 1976 | $NOVA_BIN_DIR/nova-manage db sync |
Anthony Young | a074800 | 2011-09-16 21:37:36 -0700 | [diff] [blame] | 1977 | fi |
| 1978 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 1979 | # Heat |
| 1980 | # ------ |
| 1981 | if is_service_enabled heat; then |
| 1982 | init_heat |
| 1983 | fi |
Anthony Young | a074800 | 2011-09-16 21:37:36 -0700 | [diff] [blame] | 1984 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 1985 | # Launch Services |
| 1986 | # =============== |
Jesse Andrews | 30f68e9 | 2011-09-13 00:59:54 -0700 | [diff] [blame] | 1987 | |
Jesse Andrews | 1c1d150 | 2011-09-12 19:29:56 -0700 | [diff] [blame] | 1988 | # nova api crashes if we start it with a regular screen command, |
| 1989 | # so send the start command by forcing text into the window. |
Jesse Andrews | dfcd200 | 2011-09-13 13:17:22 -0700 | [diff] [blame] | 1990 | # Only run the services specified in ``ENABLED_SERVICES`` |
| 1991 | |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 1992 | # launch the glance registry service |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 1993 | if is_service_enabled g-reg; then |
Yong Sheng Gong | 0ddcae6 | 2012-03-20 21:17:39 +0800 | [diff] [blame] | 1994 | screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=$GLANCE_CONF_DIR/glance-registry.conf" |
Anthony Young | d000b22 | 2011-09-19 14:46:53 -0700 | [diff] [blame] | 1995 | fi |
| 1996 | |
Jesse Andrews | 644b8e8 | 2011-10-02 17:50:41 -0400 | [diff] [blame] | 1997 | # launch the glance api and wait for it to answer before continuing |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 1998 | if is_service_enabled g-api; then |
Yong Sheng Gong | 0ddcae6 | 2012-03-20 21:17:39 +0800 | [diff] [blame] | 1999 | screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=$GLANCE_CONF_DIR/glance-api.conf" |
James E. Blair | 92e8199 | 2011-10-11 09:26:29 -0500 | [diff] [blame] | 2000 | echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..." |
Dean Troyer | c727aa8 | 2012-01-13 12:13:59 -0600 | [diff] [blame] | 2001 | if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://$GLANCE_HOSTPORT; do sleep 1; done"; then |
James E. Blair | 92e8199 | 2011-10-11 09:26:29 -0500 | [diff] [blame] | 2002 | echo "g-api did not start" |
| 2003 | exit 1 |
| 2004 | fi |
Anthony Young | d000b22 | 2011-09-19 14:46:53 -0700 | [diff] [blame] | 2005 | fi |
| 2006 | |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 2007 | if is_service_enabled key; then |
termie | eacc595 | 2012-01-11 01:59:00 +0000 | [diff] [blame] | 2008 | # (re)create keystone database |
| 2009 | mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS keystone;' |
Gabriel Hurley | 71f23eb | 2012-02-15 17:39:05 -0800 | [diff] [blame] | 2010 | mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE keystone CHARACTER SET utf8;' |
termie | eacc595 | 2012-01-11 01:59:00 +0000 | [diff] [blame] | 2011 | |
Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 2012 | KEYSTONE_CONF_DIR=${KEYSTONE_CONF_DIR:-/etc/keystone} |
| 2013 | KEYSTONE_CONF=$KEYSTONE_CONF_DIR/keystone.conf |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 2014 | KEYSTONE_CATALOG_BACKEND=${KEYSTONE_CATALOG_BACKEND:-template} |
termie | eacc595 | 2012-01-11 01:59:00 +0000 | [diff] [blame] | 2015 | |
Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 2016 | if [[ ! -d $KEYSTONE_CONF_DIR ]]; then |
| 2017 | sudo mkdir -p $KEYSTONE_CONF_DIR |
| 2018 | sudo chown `whoami` $KEYSTONE_CONF_DIR |
| 2019 | fi |
| 2020 | |
| 2021 | if [[ "$KEYSTONE_CONF_DIR" != "$KEYSTONE_DIR/etc" ]]; then |
Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 2022 | cp -p $KEYSTONE_DIR/etc/keystone.conf.sample $KEYSTONE_CONF |
| 2023 | cp -p $KEYSTONE_DIR/etc/policy.json $KEYSTONE_CONF_DIR |
| 2024 | fi |
Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 2025 | |
| 2026 | # Rewrite stock keystone.conf: |
| 2027 | iniset $KEYSTONE_CONF DEFAULT admin_token "$SERVICE_TOKEN" |
| 2028 | iniset $KEYSTONE_CONF sql connection "$BASE_SQL_CONN/keystone?charset=utf8" |
Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 2029 | iniset $KEYSTONE_CONF ec2 driver "keystone.contrib.ec2.backends.sql.Ec2" |
Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 2030 | sed -e " |
| 2031 | /^pipeline.*ec2_extension crud_/s|ec2_extension crud_extension|ec2_extension s3_extension crud_extension|; |
| 2032 | " -i $KEYSTONE_CONF |
| 2033 | # Append the S3 bits |
| 2034 | iniset $KEYSTONE_CONF filter:s3_extension paste.filter_factory "keystone.contrib.s3:S3Extension.factory" |
Gabriel Hurley | 7bd3087 | 2012-02-23 13:20:03 -0800 | [diff] [blame] | 2035 | |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 2036 | if [[ "$KEYSTONE_CATALOG_BACKEND" = "sql" ]]; then |
| 2037 | # Configure keystone.conf to use sql |
| 2038 | iniset $KEYSTONE_CONF catalog driver keystone.catalog.backends.sql.Catalog |
| 2039 | inicomment $KEYSTONE_CONF catalog template_file |
| 2040 | else |
| 2041 | KEYSTONE_CATALOG=$KEYSTONE_CONF_DIR/default_catalog.templates |
| 2042 | cp -p $FILES/default_catalog.templates $KEYSTONE_CATALOG |
| 2043 | # Add swift endpoints to service catalog if swift is enabled |
| 2044 | if is_service_enabled swift; then |
| 2045 | echo "catalog.RegionOne.object_store.publicURL = http://%SERVICE_HOST%:8080/v1/AUTH_\$(tenant_id)s" >> $KEYSTONE_CATALOG |
| 2046 | echo "catalog.RegionOne.object_store.adminURL = http://%SERVICE_HOST%:8080/" >> $KEYSTONE_CATALOG |
| 2047 | echo "catalog.RegionOne.object_store.internalURL = http://%SERVICE_HOST%:8080/v1/AUTH_\$(tenant_id)s" >> $KEYSTONE_CATALOG |
| 2048 | echo "catalog.RegionOne.object_store.name = Swift Service" >> $KEYSTONE_CATALOG |
| 2049 | fi |
Gabriel Hurley | 7bd3087 | 2012-02-23 13:20:03 -0800 | [diff] [blame] | 2050 | |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 2051 | # Add quantum endpoints to service catalog if quantum is enabled |
| 2052 | if is_service_enabled quantum; then |
Aaron Rosen | 9313dfa | 2012-07-06 16:08:49 -0400 | [diff] [blame] | 2053 | echo "catalog.RegionOne.network.publicURL = http://%SERVICE_HOST%:$Q_PORT/" >> $KEYSTONE_CATALOG |
| 2054 | echo "catalog.RegionOne.network.adminURL = http://%SERVICE_HOST%:$Q_PORT/" >> $KEYSTONE_CATALOG |
| 2055 | echo "catalog.RegionOne.network.internalURL = http://%SERVICE_HOST%:$Q_PORT/" >> $KEYSTONE_CATALOG |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 2056 | echo "catalog.RegionOne.network.name = Quantum Service" >> $KEYSTONE_CATALOG |
| 2057 | fi |
Gabriel Hurley | 7bd3087 | 2012-02-23 13:20:03 -0800 | [diff] [blame] | 2058 | |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 2059 | sudo sed -e " |
| 2060 | s,%SERVICE_HOST%,$SERVICE_HOST,g; |
| 2061 | s,%S3_SERVICE_PORT%,$S3_SERVICE_PORT,g; |
| 2062 | " -i $KEYSTONE_CATALOG |
| 2063 | |
| 2064 | # Configure keystone.conf to use templates |
| 2065 | iniset $KEYSTONE_CONF catalog driver "keystone.catalog.backends.templated.TemplatedCatalog" |
| 2066 | iniset $KEYSTONE_CONF catalog template_file "$KEYSTONE_CATALOG" |
| 2067 | fi |
termie | eacc595 | 2012-01-11 01:59:00 +0000 | [diff] [blame] | 2068 | |
Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 2069 | # Set up logging |
| 2070 | LOGGING_ROOT="devel" |
termie | eacc595 | 2012-01-11 01:59:00 +0000 | [diff] [blame] | 2071 | if [ "$SYSLOG" != "False" ]; then |
Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 2072 | LOGGING_ROOT="$LOGGING_ROOT,production" |
termie | eacc595 | 2012-01-11 01:59:00 +0000 | [diff] [blame] | 2073 | fi |
Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 2074 | KEYSTONE_LOG_CONFIG="--log-config $KEYSTONE_CONF_DIR/logging.conf" |
| 2075 | cp $KEYSTONE_DIR/etc/logging.conf.sample $KEYSTONE_CONF_DIR/logging.conf |
| 2076 | iniset $KEYSTONE_CONF_DIR/logging.conf logger_root level "DEBUG" |
| 2077 | iniset $KEYSTONE_CONF_DIR/logging.conf logger_root handlers "devel,production" |
termie | eacc595 | 2012-01-11 01:59:00 +0000 | [diff] [blame] | 2078 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 2079 | # Initialize keystone database |
Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 2080 | $KEYSTONE_DIR/bin/keystone-manage db_sync |
Adam Young | 5119f6b | 2012-06-27 21:23:38 -0400 | [diff] [blame] | 2081 | # set up certificates |
| 2082 | $KEYSTONE_DIR/bin/keystone-manage pki_setup |
Dean Troyer | 09e636e | 2012-03-19 16:31:12 -0500 | [diff] [blame] | 2083 | |
| 2084 | # launch keystone and wait for it to answer before continuing |
termie | 8a41c9d | 2012-02-02 17:31:19 -0800 | [diff] [blame] | 2085 | screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone-all --config-file $KEYSTONE_CONF $KEYSTONE_LOG_CONFIG -d --debug" |
James E. Blair | 92e8199 | 2011-10-11 09:26:29 -0500 | [diff] [blame] | 2086 | echo "Waiting for keystone to start..." |
Zhang Hua | 91b0acd | 2012-07-02 13:57:53 +0800 | [diff] [blame] | 2087 | if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= curl -s $KEYSTONE_AUTH_PROTOCOL://$SERVICE_HOST:$KEYSTONE_API_PORT/v2.0/ >/dev/null; do sleep 1; done"; then |
James E. Blair | 92e8199 | 2011-10-11 09:26:29 -0500 | [diff] [blame] | 2088 | echo "keystone did not start" |
| 2089 | exit 1 |
| 2090 | fi |
termie | eacc595 | 2012-01-11 01:59:00 +0000 | [diff] [blame] | 2091 | |
Vishvananda Ishaya | d1f5243 | 2012-02-09 03:50:57 +0000 | [diff] [blame] | 2092 | # keystone_data.sh creates services, admin and demo users, and roles. |
| 2093 | SERVICE_ENDPOINT=$KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0 |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 2094 | |
| 2095 | ADMIN_PASSWORD=$ADMIN_PASSWORD SERVICE_TENANT_NAME=$SERVICE_TENANT_NAME SERVICE_PASSWORD=$SERVICE_PASSWORD \ |
| 2096 | SERVICE_TOKEN=$SERVICE_TOKEN SERVICE_ENDPOINT=$SERVICE_ENDPOINT SERVICE_HOST=$SERVICE_HOST \ |
| 2097 | S3_SERVICE_PORT=$S3_SERVICE_PORT KEYSTONE_CATALOG_BACKEND=$KEYSTONE_CATALOG_BACKEND \ |
| 2098 | DEVSTACK_DIR=$TOP_DIR ENABLED_SERVICES=$ENABLED_SERVICES \ |
Armando Migliaccio | 55576d6 | 2012-06-28 17:25:54 +0100 | [diff] [blame] | 2099 | bash -x $FILES/keystone_data.sh |
Chmouel Boudjnah | 77b0e1d | 2012-02-29 16:55:43 +0000 | [diff] [blame] | 2100 | |
Dean Troyer | 5cc2129 | 2012-06-28 17:50:28 -0500 | [diff] [blame] | 2101 | # Set up auth creds now that keystone is bootstrapped |
| 2102 | export OS_AUTH_URL=$SERVICE_ENDPOINT |
| 2103 | export OS_TENANT_NAME=admin |
| 2104 | export OS_USERNAME=admin |
| 2105 | export OS_PASSWORD=$ADMIN_PASSWORD |
| 2106 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 2107 | # Create an access key and secret key for nova ec2 register image |
Chmouel Boudjnah | 6ae9ea5 | 2012-07-05 06:50:51 +0000 | [diff] [blame] | 2108 | if is_service_enabled swift3 && is_service_enabled nova; then |
Dean Troyer | 3f7c06f | 2012-04-03 17:19:36 -0500 | [diff] [blame] | 2109 | NOVA_USER_ID=$(keystone user-list | grep ' nova ' | get_field 1) |
| 2110 | NOVA_TENANT_ID=$(keystone tenant-list | grep " $SERVICE_TENANT_NAME " | get_field 1) |
Dean Troyer | 5cc2129 | 2012-06-28 17:50:28 -0500 | [diff] [blame] | 2111 | CREDS=$(keystone ec2-credentials-create --user_id $NOVA_USER_ID --tenant_id $NOVA_TENANT_ID) |
Chmouel Boudjnah | 77b0e1d | 2012-02-29 16:55:43 +0000 | [diff] [blame] | 2112 | ACCESS_KEY=$(echo "$CREDS" | awk '/ access / { print $4 }') |
| 2113 | SECRET_KEY=$(echo "$CREDS" | awk '/ secret / { print $4 }') |
| 2114 | add_nova_opt "s3_access_key=$ACCESS_KEY" |
| 2115 | add_nova_opt "s3_secret_key=$SECRET_KEY" |
| 2116 | add_nova_opt "s3_affix_tenant=True" |
| 2117 | fi |
Anthony Young | d000b22 | 2011-09-19 14:46:53 -0700 | [diff] [blame] | 2118 | fi |
| 2119 | |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 2120 | # Launch the nova-api and wait for it to answer before continuing |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 2121 | if is_service_enabled n-api; then |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 2122 | add_nova_opt "enabled_apis=$NOVA_ENABLED_APIS" |
Monty Taylor | 9fbeedd | 2012-08-17 12:52:27 -0400 | [diff] [blame] | 2123 | screen_it n-api "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-api" |
James E. Blair | 92e8199 | 2011-10-11 09:26:29 -0500 | [diff] [blame] | 2124 | echo "Waiting for nova-api to start..." |
Dean Troyer | c727aa8 | 2012-01-13 12:13:59 -0600 | [diff] [blame] | 2125 | 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. Blair | 92e8199 | 2011-10-11 09:26:29 -0500 | [diff] [blame] | 2126 | echo "nova-api did not start" |
| 2127 | exit 1 |
| 2128 | fi |
Anthony Young | d000b22 | 2011-09-19 14:46:53 -0700 | [diff] [blame] | 2129 | fi |
Brad Hall | 1bfa3d5 | 2011-10-27 18:18:20 -0700 | [diff] [blame] | 2130 | |
Brad Hall | d9e544e | 2011-10-28 08:28:26 -0700 | [diff] [blame] | 2131 | # If we're using Quantum (i.e. q-svc is enabled), network creation has to |
| 2132 | # happen after we've started the Quantum service. |
Gary Kotton | 37dda8d | 2012-08-08 03:46:33 -0400 | [diff] [blame] | 2133 | if is_service_enabled q-svc; then |
| 2134 | TENANT_ID=$(keystone tenant-list | grep " demo " | get_field 1) |
Brad Hall | 1bfa3d5 | 2011-10-27 18:18:20 -0700 | [diff] [blame] | 2135 | |
Gary Kotton | 37dda8d | 2012-08-08 03:46:33 -0400 | [diff] [blame] | 2136 | # Create a small network |
| 2137 | # Since quantum command is executed in admin context at this point, |
| 2138 | # --tenant_id needs to be specified. |
| 2139 | NET_ID=$(quantum net-create --tenant_id $TENANT_ID net1 | grep ' id ' | get_field 2) |
| 2140 | quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE |
| 2141 | elif is_service_enabled mysql && is_service_enabled nova; then |
| 2142 | # Create a small network |
Monty Taylor | 9fbeedd | 2012-08-17 12:52:27 -0400 | [diff] [blame] | 2143 | $NOVA_BIN_DIR/nova-manage network create private $FIXED_RANGE 1 $FIXED_NETWORK_SIZE $NETWORK_CREATE_ARGS |
Dean Troyer | 696ad33 | 2012-01-10 15:34:34 -0600 | [diff] [blame] | 2144 | |
Gary Kotton | 37dda8d | 2012-08-08 03:46:33 -0400 | [diff] [blame] | 2145 | # Create some floating ips |
Monty Taylor | 9fbeedd | 2012-08-17 12:52:27 -0400 | [diff] [blame] | 2146 | $NOVA_BIN_DIR/nova-manage floating create $FLOATING_RANGE |
Aaron Rosen | 9313dfa | 2012-07-06 16:08:49 -0400 | [diff] [blame] | 2147 | |
Gary Kotton | 37dda8d | 2012-08-08 03:46:33 -0400 | [diff] [blame] | 2148 | # Create a second pool |
Monty Taylor | 9fbeedd | 2012-08-17 12:52:27 -0400 | [diff] [blame] | 2149 | $NOVA_BIN_DIR/nova-manage floating create --ip_range=$TEST_FLOATING_RANGE --pool=$TEST_FLOATING_POOL |
Brad Hall | 1bfa3d5 | 2011-10-27 18:18:20 -0700 | [diff] [blame] | 2150 | fi |
| 2151 | |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 2152 | # Launching nova-compute should be as simple as running ``nova-compute`` but |
| 2153 | # have to do a little more than that in our script. Since we add the group |
Jesse Andrews | 1f71760 | 2011-09-16 15:18:53 -0700 | [diff] [blame] | 2154 | # ``libvirtd`` to our user in this script, when nova-compute is run it is |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 2155 | # within the context of our original shell (so our groups won't be updated). |
Scott Moser | 8ab1ade | 2011-10-07 21:03:16 -0400 | [diff] [blame] | 2156 | # Use 'sg' to execute nova-compute as a member of the libvirtd group. |
Ken Pepple | 389f4ef | 2012-03-08 19:37:03 -0800 | [diff] [blame] | 2157 | # We don't check for is_service_enable as screen_it does it for us |
Monty Taylor | 9fbeedd | 2012-08-17 12:52:27 -0400 | [diff] [blame] | 2158 | screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_BIN_DIR/nova-compute" |
| 2159 | screen_it n-crt "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-cert" |
| 2160 | screen_it n-vol "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-volume" |
| 2161 | screen_it n-net "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-network" |
| 2162 | screen_it n-sch "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-scheduler" |
Ken Pepple | 389f4ef | 2012-03-08 19:37:03 -0800 | [diff] [blame] | 2163 | screen_it n-novnc "cd $NOVNC_DIR && ./utils/nova-novncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF --web ." |
| 2164 | screen_it n-xvnc "cd $NOVA_DIR && ./bin/nova-xvpvncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF" |
| 2165 | screen_it n-cauth "cd $NOVA_DIR && ./bin/nova-consoleauth" |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 2166 | if is_service_enabled cinder; then |
| 2167 | start_cinder |
| 2168 | fi |
John H. Tran | 9336164 | 2012-07-26 11:22:05 -0700 | [diff] [blame] | 2169 | if is_service_enabled ceilometer; then |
| 2170 | configure_ceilometer |
| 2171 | start_ceilometer |
| 2172 | fi |
Dean Troyer | 5218d45 | 2012-02-04 02:13:23 -0600 | [diff] [blame] | 2173 | screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/$APACHE_NAME/horizon_error.log" |
Dean Troyer | 1e51c11 | 2012-03-16 10:42:00 -0500 | [diff] [blame] | 2174 | screen_it swift "cd $SWIFT_DIR && $SWIFT_DIR/bin/swift-proxy-server ${SWIFT_CONFIG_DIR}/proxy-server.conf -v" |
Jesse Andrews | 75a3765 | 2011-09-12 17:09:08 -0700 | [diff] [blame] | 2175 | |
Chmouel Boudjnah | 6ae9ea5 | 2012-07-05 06:50:51 +0000 | [diff] [blame] | 2176 | # Starting the nova-objectstore only if swift3 service is not enabled. |
Chmouel Boudjnah | e347b99 | 2012-03-16 17:38:49 +0000 | [diff] [blame] | 2177 | # Swift will act as s3 objectstore. |
Chmouel Boudjnah | 6ae9ea5 | 2012-07-05 06:50:51 +0000 | [diff] [blame] | 2178 | is_service_enabled swift3 || \ |
Monty Taylor | 9fbeedd | 2012-08-17 12:52:27 -0400 | [diff] [blame] | 2179 | screen_it n-obj "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-objectstore" |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 2180 | |
Steve Baker | bfdad75 | 2012-08-18 09:00:42 +1200 | [diff] [blame] | 2181 | # launch heat engine, api and metadata |
| 2182 | if is_service_enabled heat; then |
| 2183 | start_heat |
| 2184 | fi |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 2185 | |
Jesse Andrews | d74257d | 2011-09-13 01:24:50 -0700 | [diff] [blame] | 2186 | # Install Images |
| 2187 | # ============== |
Jesse Andrews | e49b8bd | 2011-09-12 18:08:04 -0700 | [diff] [blame] | 2188 | |
Anthony Young | 0ab1d46 | 2011-10-13 23:03:23 -0700 | [diff] [blame] | 2189 | # Upload an image to glance. |
Jesse Andrews | 5372f43 | 2011-10-03 01:08:24 -0400 | [diff] [blame] | 2190 | # |
Dean Troyer | ca0e3d0 | 2012-04-13 15:58:37 -0500 | [diff] [blame] | 2191 | # The default image is cirros, a small testing image, which lets you login as root |
Anthony Young | 0ab1d46 | 2011-10-13 23:03:23 -0700 | [diff] [blame] | 2192 | # |
Dean Troyer | ca0e3d0 | 2012-04-13 15:58:37 -0500 | [diff] [blame] | 2193 | # cirros also uses ``cloud-init``, supporting login via keypair and sending scripts as |
Anthony Young | 0ab1d46 | 2011-10-13 23:03:23 -0700 | [diff] [blame] | 2194 | # userdata. See https://help.ubuntu.com/community/CloudInit for more on cloud-init |
| 2195 | # |
Chmouel Boudjnah | 3d9c5d5 | 2011-11-02 17:57:11 +0100 | [diff] [blame] | 2196 | # Override ``IMAGE_URLS`` with a comma-separated list of uec images. |
Jesse Andrews | aab7eae | 2011-10-19 10:30:19 -0700 | [diff] [blame] | 2197 | # |
Jesse Andrews | aab7eae | 2011-10-19 10:30:19 -0700 | [diff] [blame] | 2198 | # * **oneiric**: http://uec-images.ubuntu.com/oneiric/current/oneiric-server-cloudimg-amd64.tar.gz |
Dean Troyer | ca0e3d0 | 2012-04-13 15:58:37 -0500 | [diff] [blame] | 2199 | # * **precise**: http://uec-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64.tar.gz |
Jesse Andrews | 08e8b74 | 2011-10-02 23:42:56 -0400 | [diff] [blame] | 2200 | |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 2201 | if is_service_enabled g-reg; then |
Dean Troyer | 5cc2129 | 2012-06-28 17:50:28 -0500 | [diff] [blame] | 2202 | TOKEN=$(keystone token-get | grep ' id ' | get_field 2) |
termie | 747ee33 | 2012-01-11 22:31:59 +0000 | [diff] [blame] | 2203 | |
Anthony Young | b62b4ca | 2011-10-26 22:29:08 -0700 | [diff] [blame] | 2204 | # Option to upload legacy ami-tty, which works with xenserver |
Dean Troyer | 314da5a | 2012-03-28 19:15:48 -0500 | [diff] [blame] | 2205 | if [[ -n "$UPLOAD_LEGACY_TTY" ]]; then |
| 2206 | IMAGE_URLS="${IMAGE_URLS:+${IMAGE_URLS},}http://images.ansolabs.com/tty.tgz" |
Anthony Young | b62b4ca | 2011-10-26 22:29:08 -0700 | [diff] [blame] | 2207 | fi |
| 2208 | |
Anthony Young | 120f486 | 2011-10-14 09:31:09 -0700 | [diff] [blame] | 2209 | for image_url in ${IMAGE_URLS//,/ }; do |
Dean Troyer | ca0e3d0 | 2012-04-13 15:58:37 -0500 | [diff] [blame] | 2210 | upload_image $image_url $TOKEN |
Anthony Young | 120f486 | 2011-10-14 09:31:09 -0700 | [diff] [blame] | 2211 | done |
Jesse Andrews | e49b8bd | 2011-09-12 18:08:04 -0700 | [diff] [blame] | 2212 | fi |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 2213 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 2214 | |
Dean Troyer | f5633dd | 2012-03-28 11:21:40 -0500 | [diff] [blame] | 2215 | # Run local script |
| 2216 | # ================ |
| 2217 | |
| 2218 | # Run ``local.sh`` if it exists to perform user-managed tasks |
| 2219 | if [[ -x $TOP_DIR/local.sh ]]; then |
| 2220 | echo "Running user script $TOP_DIR/local.sh" |
| 2221 | $TOP_DIR/local.sh |
| 2222 | fi |
| 2223 | |
| 2224 | |
Scott Moser | b94f4bf | 2011-10-07 14:51:07 +0000 | [diff] [blame] | 2225 | # Fin |
| 2226 | # === |
| 2227 | |
Dean Troyer | 471de7a | 2011-12-27 11:45:55 -0600 | [diff] [blame] | 2228 | set +o xtrace |
Scott Moser | b94f4bf | 2011-10-07 14:51:07 +0000 | [diff] [blame] | 2229 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 2230 | |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 2231 | # Using the cloud |
| 2232 | # =============== |
| 2233 | |
Jesse Andrews | e19d884 | 2011-11-01 20:06:55 -0700 | [diff] [blame] | 2234 | echo "" |
| 2235 | echo "" |
| 2236 | echo "" |
| 2237 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 2238 | # If you installed Horizon on this server you should be able |
root | 40a3700 | 2011-09-20 18:06:14 +0000 | [diff] [blame] | 2239 | # to access the site using your browser. |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 2240 | if is_service_enabled horizon; then |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 2241 | echo "Horizon is now available at http://$SERVICE_HOST/" |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 2242 | fi |
| 2243 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 2244 | # If Keystone is present you can point ``nova`` cli to this server |
Chmouel Boudjnah | a6651e9 | 2012-02-16 10:16:52 +0000 | [diff] [blame] | 2245 | if is_service_enabled key; then |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 2246 | echo "Keystone is serving at $KEYSTONE_AUTH_PROTOCOL://$SERVICE_HOST:$KEYSTONE_API_PORT/v2.0/" |
| 2247 | echo "Examples on using novaclient command line is in exercise.sh" |
| 2248 | echo "The default users are: admin and demo" |
| 2249 | echo "The password: $ADMIN_PASSWORD" |
Jesse Andrews | 2485906 | 2011-09-15 21:28:23 -0700 | [diff] [blame] | 2250 | fi |
termie | 523c405 | 2011-09-28 19:49:40 -0500 | [diff] [blame] | 2251 | |
Anthony Young | 1097c7c | 2011-12-27 23:22:14 -0800 | [diff] [blame] | 2252 | # Echo HOST_IP - useful for build_uec.sh, which uses dhcp to give the instance an address |
| 2253 | echo "This is your host ip: $HOST_IP" |
| 2254 | |
Dean Troyer | df0972c | 2012-03-07 17:31:03 -0600 | [diff] [blame] | 2255 | # Warn that ``EXTRA_FLAGS`` needs to be converted to ``EXTRA_OPTS`` |
Dean Troyer | ced6517 | 2012-03-02 16:36:16 -0600 | [diff] [blame] | 2256 | if [[ -n "$EXTRA_FLAGS" ]]; then |
| 2257 | echo "WARNING: EXTRA_FLAGS is defined and may need to be converted to EXTRA_OPTS" |
| 2258 | fi |
| 2259 | |
Anthony Young | 1097c7c | 2011-12-27 23:22:14 -0800 | [diff] [blame] | 2260 | # Indicate how long this took to run (bash maintained variable 'SECONDS') |
Scott Moser | b94f4bf | 2011-10-07 14:51:07 +0000 | [diff] [blame] | 2261 | echo "stack.sh completed in $SECONDS seconds." |