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