| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 1 | # lib/nova | 
| Dean Troyer | 6d04fd7 | 2012-12-21 11:03:37 -0600 | [diff] [blame] | 2 | # Functions to control the configuration and operation of the **Nova** service | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 3 |  | 
 | 4 | # Dependencies: | 
 | 5 | # ``functions`` file | 
| Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 6 | # ``DEST``, ``DATA_DIR``, ``STACK_USER`` must be defined | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 7 | # ``SERVICE_{TENANT_NAME|PASSWORD}`` must be defined | 
 | 8 | # ``LIBVIRT_TYPE`` must be defined | 
 | 9 | # ``INSTANCE_NAME_PREFIX``, ``VOLUME_NAME_PREFIX`` must be defined | 
| Dean Troyer | bc071bc | 2012-10-01 14:06:44 -0500 | [diff] [blame] | 10 | # ``KEYSTONE_TOKEN_FORMAT`` must be defined | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 11 |  | 
 | 12 | # ``stack.sh`` calls the entry points in this order: | 
 | 13 | # | 
 | 14 | # install_nova | 
 | 15 | # configure_nova | 
| Dean Troyer | da7b809 | 2012-10-08 18:12:14 -0500 | [diff] [blame] | 16 | # create_nova_conf | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 17 | # init_nova | 
 | 18 | # start_nova | 
 | 19 | # stop_nova | 
 | 20 | # cleanup_nova | 
 | 21 |  | 
 | 22 | # Save trace setting | 
 | 23 | XTRACE=$(set +o | grep xtrace) | 
 | 24 | set +o xtrace | 
 | 25 |  | 
 | 26 |  | 
 | 27 | # Defaults | 
 | 28 | # -------- | 
 | 29 |  | 
 | 30 | # Set up default directories | 
 | 31 | NOVA_DIR=$DEST/nova | 
 | 32 | NOVACLIENT_DIR=$DEST/python-novaclient | 
 | 33 | NOVA_STATE_PATH=${NOVA_STATE_PATH:=$DATA_DIR/nova} | 
 | 34 | # INSTANCES_PATH is the previous name for this | 
 | 35 | NOVA_INSTANCES_PATH=${NOVA_INSTANCES_PATH:=${INSTANCES_PATH:=$NOVA_STATE_PATH/instances}} | 
| Dean Troyer | bc071bc | 2012-10-01 14:06:44 -0500 | [diff] [blame] | 36 | NOVA_AUTH_CACHE_DIR=${NOVA_AUTH_CACHE_DIR:-/var/cache/nova} | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 37 |  | 
 | 38 | NOVA_CONF_DIR=/etc/nova | 
 | 39 | NOVA_CONF=$NOVA_CONF_DIR/nova.conf | 
 | 40 | NOVA_API_PASTE_INI=${NOVA_API_PASTE_INI:-$NOVA_CONF_DIR/api-paste.ini} | 
 | 41 |  | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 42 | # Public facing bits | 
 | 43 | NOVA_SERVICE_HOST=${NOVA_SERVICE_HOST:-$SERVICE_HOST} | 
 | 44 | NOVA_SERVICE_PORT=${NOVA_SERVICE_PORT:-8774} | 
 | 45 | NOVA_SERVICE_PORT_INT=${NOVA_SERVICE_PORT_INT:-18774} | 
 | 46 | NOVA_SERVICE_PROTOCOL=${NOVA_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL} | 
 | 47 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 48 | # Support entry points installation of console scripts | 
 | 49 | if [[ -d $NOVA_DIR/bin ]]; then | 
 | 50 |     NOVA_BIN_DIR=$NOVA_DIR/bin | 
 | 51 | else | 
 | 52 |     NOVA_BIN_DIR=/usr/local/bin | 
 | 53 | fi | 
 | 54 |  | 
 | 55 | # Set the paths of certain binaries | 
| Vincent Untz | 856a11e | 2012-11-21 16:04:12 +0100 | [diff] [blame] | 56 | NOVA_ROOTWRAP=$(get_rootwrap_location nova) | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 57 |  | 
 | 58 | # Allow rate limiting to be turned off for testing, like for Tempest | 
 | 59 | # NOTE: Set API_RATE_LIMIT="False" to turn OFF rate limiting | 
 | 60 | API_RATE_LIMIT=${API_RATE_LIMIT:-"True"} | 
 | 61 |  | 
 | 62 | # Nova supports pluggable schedulers.  The default ``FilterScheduler`` | 
 | 63 | # should work in most cases. | 
 | 64 | SCHEDULER=${SCHEDULER:-nova.scheduler.filter_scheduler.FilterScheduler} | 
 | 65 |  | 
 | 66 | QEMU_CONF=/etc/libvirt/qemu.conf | 
 | 67 |  | 
 | 68 |  | 
 | 69 | # Entry Points | 
 | 70 | # ------------ | 
 | 71 |  | 
 | 72 | function add_nova_opt { | 
 | 73 |     echo "$1" >>$NOVA_CONF | 
 | 74 | } | 
 | 75 |  | 
 | 76 | # Helper to clean iptables rules | 
 | 77 | function clean_iptables() { | 
 | 78 |     # Delete rules | 
 | 79 |     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 | 
 | 80 |     # Delete nat rules | 
 | 81 |     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 | 
 | 82 |     # Delete chains | 
 | 83 |     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 | 
 | 84 |     # Delete nat chains | 
 | 85 |     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 | 
 | 86 | } | 
 | 87 |  | 
 | 88 | # cleanup_nova() - Remove residual data files, anything left over from previous | 
 | 89 | # runs that a clean run would need to clean up | 
 | 90 | function cleanup_nova() { | 
 | 91 |     if is_service_enabled n-cpu; then | 
 | 92 |         # Clean iptables from previous runs | 
 | 93 |         clean_iptables | 
 | 94 |  | 
 | 95 |         # Destroy old instances | 
 | 96 |         instances=`sudo virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"` | 
 | 97 |         if [ ! "$instances" = "" ]; then | 
 | 98 |             echo $instances | xargs -n1 sudo virsh destroy || true | 
 | 99 |             echo $instances | xargs -n1 sudo virsh undefine || true | 
 | 100 |         fi | 
 | 101 |  | 
 | 102 |         # Logout and delete iscsi sessions | 
 | 103 |         sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | xargs sudo iscsiadm --mode node --logout || true | 
 | 104 |         sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | sudo iscsiadm --mode node --op delete || true | 
 | 105 |  | 
 | 106 |         # Clean out the instances directory. | 
 | 107 |         sudo rm -rf $NOVA_INSTANCES_PATH/* | 
 | 108 |     fi | 
 | 109 | } | 
 | 110 |  | 
 | 111 | # configure_novaclient() - Set config files, create data dirs, etc | 
 | 112 | function configure_novaclient() { | 
 | 113 |     setup_develop $NOVACLIENT_DIR | 
 | 114 | } | 
 | 115 |  | 
 | 116 | # configure_nova_rootwrap() - configure Nova's rootwrap | 
 | 117 | function configure_nova_rootwrap() { | 
 | 118 |     # Deploy new rootwrap filters files (owned by root). | 
 | 119 |     # Wipe any existing rootwrap.d files first | 
 | 120 |     if [[ -d $NOVA_CONF_DIR/rootwrap.d ]]; then | 
 | 121 |         sudo rm -rf $NOVA_CONF_DIR/rootwrap.d | 
 | 122 |     fi | 
 | 123 |     # Deploy filters to /etc/nova/rootwrap.d | 
 | 124 |     sudo mkdir -m 755 $NOVA_CONF_DIR/rootwrap.d | 
 | 125 |     sudo cp $NOVA_DIR/etc/nova/rootwrap.d/*.filters $NOVA_CONF_DIR/rootwrap.d | 
 | 126 |     sudo chown -R root:root $NOVA_CONF_DIR/rootwrap.d | 
 | 127 |     sudo chmod 644 $NOVA_CONF_DIR/rootwrap.d/* | 
 | 128 |     # Set up rootwrap.conf, pointing to /etc/nova/rootwrap.d | 
 | 129 |     sudo cp $NOVA_DIR/etc/nova/rootwrap.conf $NOVA_CONF_DIR/ | 
 | 130 |     sudo sed -e "s:^filters_path=.*$:filters_path=$NOVA_CONF_DIR/rootwrap.d:" -i $NOVA_CONF_DIR/rootwrap.conf | 
 | 131 |     sudo chown root:root $NOVA_CONF_DIR/rootwrap.conf | 
 | 132 |     sudo chmod 0644 $NOVA_CONF_DIR/rootwrap.conf | 
 | 133 |     # Specify rootwrap.conf as first parameter to nova-rootwrap | 
 | 134 |     ROOTWRAP_SUDOER_CMD="$NOVA_ROOTWRAP $NOVA_CONF_DIR/rootwrap.conf *" | 
 | 135 |  | 
 | 136 |     # Set up the rootwrap sudoers for nova | 
 | 137 |     TEMPFILE=`mktemp` | 
 | 138 |     echo "$USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE | 
 | 139 |     chmod 0440 $TEMPFILE | 
 | 140 |     sudo chown root:root $TEMPFILE | 
 | 141 |     sudo mv $TEMPFILE /etc/sudoers.d/nova-rootwrap | 
 | 142 | } | 
 | 143 |  | 
 | 144 | # configure_nova() - Set config files, create data dirs, etc | 
 | 145 | function configure_nova() { | 
 | 146 |     setup_develop $NOVA_DIR | 
 | 147 |  | 
 | 148 |     # Put config files in ``/etc/nova`` for everyone to find | 
 | 149 |     if [[ ! -d $NOVA_CONF_DIR ]]; then | 
 | 150 |         sudo mkdir -p $NOVA_CONF_DIR | 
 | 151 |     fi | 
| Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 152 |     sudo chown $STACK_USER $NOVA_CONF_DIR | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 153 |  | 
 | 154 |     cp -p $NOVA_DIR/etc/nova/policy.json $NOVA_CONF_DIR | 
 | 155 |  | 
 | 156 |     configure_nova_rootwrap | 
 | 157 |  | 
 | 158 |     if is_service_enabled n-api; then | 
 | 159 |         # Use the sample http middleware configuration supplied in the | 
 | 160 |         # Nova sources.  This paste config adds the configuration required | 
 | 161 |         # for Nova to validate Keystone tokens. | 
 | 162 |  | 
 | 163 |         # Remove legacy paste config if present | 
 | 164 |         rm -f $NOVA_DIR/bin/nova-api-paste.ini | 
 | 165 |  | 
 | 166 |         # Get the sample configuration file in place | 
 | 167 |         cp $NOVA_DIR/etc/nova/api-paste.ini $NOVA_CONF_DIR | 
 | 168 |  | 
 | 169 |         # Rewrite the authtoken configuration for our Keystone service. | 
 | 170 |         # This is a bit defensive to allow the sample file some variance. | 
 | 171 |         sed -e " | 
 | 172 |             /^admin_token/i admin_tenant_name = $SERVICE_TENANT_NAME | 
 | 173 |             /admin_tenant_name/s/^.*$/admin_tenant_name = $SERVICE_TENANT_NAME/; | 
 | 174 |             /admin_user/s/^.*$/admin_user = nova/; | 
 | 175 |             /admin_password/s/^.*$/admin_password = $SERVICE_PASSWORD/; | 
 | 176 |             s,%SERVICE_TENANT_NAME%,$SERVICE_TENANT_NAME,g; | 
 | 177 |             s,%SERVICE_TOKEN%,$SERVICE_TOKEN,g; | 
 | 178 |         " -i $NOVA_API_PASTE_INI | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 179 |         iniset $NOVA_API_PASTE_INI filter:authtoken auth_host $SERVICE_HOST | 
 | 180 |         if is_service_enabled tls-proxy; then | 
 | 181 |             iniset $NOVA_API_PASTE_INI filter:authtoken auth_protocol $SERVICE_PROTOCOL | 
 | 182 |         fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 183 |     fi | 
 | 184 |  | 
| Akihiro MOTOKI | 5e3deb6 | 2012-12-11 17:09:02 +0900 | [diff] [blame] | 185 |     iniset $NOVA_API_PASTE_INI filter:authtoken signing_dir $NOVA_AUTH_CACHE_DIR | 
| Dean Troyer | bc071bc | 2012-10-01 14:06:44 -0500 | [diff] [blame] | 186 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 187 |     if is_service_enabled n-cpu; then | 
 | 188 |         # Force IP forwarding on, just on case | 
 | 189 |         sudo sysctl -w net.ipv4.ip_forward=1 | 
 | 190 |  | 
 | 191 |         # Attempt to load modules: network block device - used to manage qcow images | 
 | 192 |         sudo modprobe nbd || true | 
 | 193 |  | 
 | 194 |         # Check for kvm (hardware based virtualization).  If unable to initialize | 
 | 195 |         # kvm, we drop back to the slower emulation mode (qemu).  Note: many systems | 
 | 196 |         # come with hardware virtualization disabled in BIOS. | 
 | 197 |         if [[ "$LIBVIRT_TYPE" == "kvm" ]]; then | 
 | 198 |             sudo modprobe kvm || true | 
 | 199 |             if [ ! -e /dev/kvm ]; then | 
 | 200 |                 echo "WARNING: Switching to QEMU" | 
 | 201 |                 LIBVIRT_TYPE=qemu | 
 | 202 |                 if which selinuxenabled 2>&1 > /dev/null && selinuxenabled; then | 
 | 203 |                     # https://bugzilla.redhat.com/show_bug.cgi?id=753589 | 
 | 204 |                     sudo setsebool virt_use_execmem on | 
 | 205 |                 fi | 
 | 206 |             fi | 
 | 207 |         fi | 
 | 208 |  | 
 | 209 |         # Install and configure **LXC** if specified.  LXC is another approach to | 
 | 210 |         # splitting a system into many smaller parts.  LXC uses cgroups and chroot | 
 | 211 |         # to simulate multiple systems. | 
 | 212 |         if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then | 
| Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 213 |             if is_ubuntu; then | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 214 |                 if [[ ! "$DISTRO" > natty ]]; then | 
 | 215 |                     cgline="none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0" | 
 | 216 |                     sudo mkdir -p /cgroup | 
 | 217 |                     if ! grep -q cgroup /etc/fstab; then | 
 | 218 |                         echo "$cgline" | sudo tee -a /etc/fstab | 
 | 219 |                     fi | 
 | 220 |                     if ! mount -n | grep -q cgroup; then | 
 | 221 |                         sudo mount /cgroup | 
 | 222 |                     fi | 
 | 223 |                 fi | 
 | 224 |             fi | 
 | 225 |         fi | 
 | 226 |  | 
| Devananda van der Veen | f35cf91 | 2012-11-12 17:58:38 -0800 | [diff] [blame] | 227 |         # Prepare directories and packages for baremetal driver | 
 | 228 |         if is_baremetal; then | 
 | 229 |             configure_baremetal_nova_dirs | 
 | 230 |         fi | 
 | 231 |  | 
| Isaku Yamahata | 0dd34df | 2012-12-28 13:15:31 +0900 | [diff] [blame] | 232 |         if is_service_enabled quantum && is_quantum_ovs_base_plugin && ! sudo grep -q '^cgroup_device_acl' $QEMU_CONF ; then | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 233 |             # Add /dev/net/tun to cgroup_device_acls, needed for type=ethernet interfaces | 
 | 234 |             cat <<EOF | sudo tee -a $QEMU_CONF | 
 | 235 | cgroup_device_acl = [ | 
 | 236 |     "/dev/null", "/dev/full", "/dev/zero", | 
 | 237 |     "/dev/random", "/dev/urandom", | 
 | 238 |     "/dev/ptmx", "/dev/kvm", "/dev/kqemu", | 
 | 239 |     "/dev/rtc", "/dev/hpet","/dev/net/tun", | 
 | 240 | ] | 
 | 241 | EOF | 
 | 242 |         fi | 
 | 243 |  | 
| Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 244 |         if is_ubuntu; then | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 245 |             LIBVIRT_DAEMON=libvirt-bin | 
 | 246 |         else | 
| Vincent Untz | f1c094c | 2012-12-05 17:59:04 +0100 | [diff] [blame] | 247 |             LIBVIRT_DAEMON=libvirtd | 
 | 248 |         fi | 
 | 249 |  | 
| Sunil Thaha | a534e0b | 2013-01-21 17:00:50 +1000 | [diff] [blame] | 250 |  | 
 | 251 |  | 
| Vincent Untz | f1c094c | 2012-12-05 17:59:04 +0100 | [diff] [blame] | 252 |         if is_fedora; then | 
| Sunil Thaha | a534e0b | 2013-01-21 17:00:50 +1000 | [diff] [blame] | 253 |             # Starting with fedora 18 enable stack-user to virsh -c qemu:///system | 
 | 254 |             # by creating a policy-kit rule for stack-user | 
 | 255 |             if [[ "$os_RELEASE" -ge "18" ]]; then | 
 | 256 |                 rules_dir=/etc/polkit-1/rules.d | 
 | 257 |                 sudo mkdir -p $rules_dir | 
 | 258 |                 sudo bash -c "cat <<EOF > $rules_dir/50-libvirt-$STACK_USER.rules | 
 | 259 | polkit.addRule(function(action, subject) { | 
 | 260 |      if (action.id == 'org.libvirt.unix.manage' && | 
 | 261 |          subject.user == '"$STACK_USER"') { | 
 | 262 |          return polkit.Result.YES; | 
 | 263 |      } | 
 | 264 | }); | 
 | 265 | EOF" | 
 | 266 |                 unset rules_dir | 
 | 267 |             else | 
 | 268 |                 sudo bash -c 'cat <<EOF >/etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 269 | [libvirt Management Access] | 
 | 270 | Identity=unix-group:libvirtd | 
 | 271 | Action=org.libvirt.unix.manage | 
 | 272 | ResultAny=yes | 
 | 273 | ResultInactive=yes | 
 | 274 | ResultActive=yes | 
 | 275 | EOF' | 
| Sunil Thaha | a534e0b | 2013-01-21 17:00:50 +1000 | [diff] [blame] | 276 |             fi | 
| Vincent Untz | f1c094c | 2012-12-05 17:59:04 +0100 | [diff] [blame] | 277 |         elif is_suse; then | 
 | 278 |             # Work around the fact that polkit-default-privs overrules pklas | 
 | 279 |             # with 'unix-group:$group'. | 
 | 280 |             sudo bash -c "cat <<EOF >/etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla | 
 | 281 | [libvirt Management Access] | 
 | 282 | Identity=unix-user:$USER | 
 | 283 | Action=org.libvirt.unix.manage | 
 | 284 | ResultAny=yes | 
 | 285 | ResultInactive=yes | 
 | 286 | ResultActive=yes | 
 | 287 | EOF" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 288 |         fi | 
 | 289 |  | 
 | 290 |         # The user that nova runs as needs to be member of **libvirtd** group otherwise | 
 | 291 |         # nova-compute will be unable to use libvirt. | 
| Vincent Untz | f1c094c | 2012-12-05 17:59:04 +0100 | [diff] [blame] | 292 |         if ! getent group libvirtd >/dev/null; then | 
 | 293 |             sudo groupadd libvirtd | 
 | 294 |         fi | 
| Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 295 |         add_user_to_group $STACK_USER libvirtd | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 296 |  | 
 | 297 |         # libvirt detects various settings on startup, as we potentially changed | 
 | 298 |         # the system configuration (modules, filesystems), we need to restart | 
 | 299 |         # libvirt to detect those changes. | 
 | 300 |         restart_service $LIBVIRT_DAEMON | 
 | 301 |  | 
 | 302 |  | 
 | 303 |         # Instance Storage | 
 | 304 |         # ---------------- | 
 | 305 |  | 
 | 306 |         # Nova stores each instance in its own directory. | 
 | 307 |         mkdir -p $NOVA_INSTANCES_PATH | 
 | 308 |  | 
 | 309 |         # You can specify a different disk to be mounted and used for backing the | 
 | 310 |         # virtual machines.  If there is a partition labeled nova-instances we | 
 | 311 |         # mount it (ext filesystems can be labeled via e2label). | 
 | 312 |         if [ -L /dev/disk/by-label/nova-instances ]; then | 
 | 313 |             if ! mount -n | grep -q $NOVA_INSTANCES_PATH; then | 
 | 314 |                 sudo mount -L nova-instances $NOVA_INSTANCES_PATH | 
| Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 315 |                 sudo chown -R $STACK_USER $NOVA_INSTANCES_PATH | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 316 |             fi | 
 | 317 |         fi | 
 | 318 |  | 
 | 319 |         # Clean up old instances | 
 | 320 |         cleanup_nova | 
 | 321 |     fi | 
 | 322 | } | 
 | 323 |  | 
| Dean Troyer | a0dce26 | 2012-12-11 16:52:37 -0600 | [diff] [blame] | 324 | # create_nova_accounts() - Set up common required nova accounts | 
 | 325 |  | 
 | 326 | # Tenant               User       Roles | 
 | 327 | # ------------------------------------------------------------------ | 
 | 328 | # service              nova       admin, [ResellerAdmin (swift only)] | 
 | 329 |  | 
 | 330 | # Migrated from keystone_data.sh | 
 | 331 | create_nova_accounts() { | 
 | 332 |  | 
 | 333 |     SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }") | 
 | 334 |     ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }") | 
 | 335 |  | 
 | 336 |     # Nova | 
 | 337 |     if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then | 
 | 338 |         NOVA_USER=$(keystone user-create \ | 
 | 339 |             --name=nova \ | 
 | 340 |             --pass="$SERVICE_PASSWORD" \ | 
 | 341 |             --tenant_id $SERVICE_TENANT \ | 
 | 342 |             --email=nova@example.com \ | 
 | 343 |             | grep " id " | get_field 2) | 
 | 344 |         keystone user-role-add \ | 
 | 345 |             --tenant_id $SERVICE_TENANT \ | 
 | 346 |             --user_id $NOVA_USER \ | 
 | 347 |             --role_id $ADMIN_ROLE | 
 | 348 |         if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then | 
 | 349 |             NOVA_SERVICE=$(keystone service-create \ | 
 | 350 |                 --name=nova \ | 
 | 351 |                 --type=compute \ | 
 | 352 |                 --description="Nova Compute Service" \ | 
 | 353 |                 | grep " id " | get_field 2) | 
 | 354 |             keystone endpoint-create \ | 
 | 355 |                 --region RegionOne \ | 
 | 356 |                 --service_id $NOVA_SERVICE \ | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 357 |                 --publicurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2/\$(tenant_id)s" \ | 
 | 358 |                 --adminurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2/\$(tenant_id)s" \ | 
 | 359 |                 --internalurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2/\$(tenant_id)s" | 
| Dean Troyer | a0dce26 | 2012-12-11 16:52:37 -0600 | [diff] [blame] | 360 |         fi | 
 | 361 |     fi | 
 | 362 | } | 
 | 363 |  | 
| Dean Troyer | da7b809 | 2012-10-08 18:12:14 -0500 | [diff] [blame] | 364 | # create_nova_conf() - Create a new nova.conf file | 
 | 365 | function create_nova_conf() { | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 366 |     # Remove legacy ``nova.conf`` | 
 | 367 |     rm -f $NOVA_DIR/bin/nova.conf | 
 | 368 |  | 
 | 369 |     # (Re)create ``nova.conf`` | 
| Dean Troyer | 3cf1ffb | 2012-10-02 11:51:27 -0500 | [diff] [blame] | 370 |     rm -f $NOVA_CONF | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 371 |     add_nova_opt "[DEFAULT]" | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 372 |     iniset $NOVA_CONF DEFAULT verbose "True" | 
| Joe Gordon | 8750b3d | 2013-01-17 23:49:50 -0500 | [diff] [blame] | 373 |     iniset $NOVA_CONF DEFAULT debug "True" | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 374 |     iniset $NOVA_CONF DEFAULT auth_strategy "keystone" | 
 | 375 |     iniset $NOVA_CONF DEFAULT allow_resize_to_same_host "True" | 
 | 376 |     iniset $NOVA_CONF DEFAULT api_paste_config "$NOVA_API_PASTE_INI" | 
 | 377 |     iniset $NOVA_CONF DEFAULT rootwrap_config "$NOVA_CONF_DIR/rootwrap.conf" | 
 | 378 |     iniset $NOVA_CONF DEFAULT compute_scheduler_driver "$SCHEDULER" | 
 | 379 |     iniset $NOVA_CONF DEFAULT dhcpbridge_flagfile "$NOVA_CONF" | 
 | 380 |     iniset $NOVA_CONF DEFAULT force_dhcp_release "True" | 
 | 381 |     iniset $NOVA_CONF DEFAULT fixed_range "$FIXED_RANGE" | 
 | 382 |     iniset $NOVA_CONF DEFAULT default_floating_pool "$PUBLIC_NETWORK_NAME" | 
 | 383 |     iniset $NOVA_CONF DEFAULT s3_host "$SERVICE_HOST" | 
 | 384 |     iniset $NOVA_CONF DEFAULT s3_port "$S3_SERVICE_PORT" | 
 | 385 |     iniset $NOVA_CONF DEFAULT osapi_compute_extension "nova.api.openstack.compute.contrib.standard_extensions" | 
 | 386 |     iniset $NOVA_CONF DEFAULT my_ip "$HOST_IP" | 
| Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 387 |     local dburl | 
 | 388 |     database_connection_url dburl nova | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 389 |     iniset $NOVA_CONF DEFAULT sql_connection "$dburl" | 
| Devananda van der Veen | f35cf91 | 2012-11-12 17:58:38 -0800 | [diff] [blame] | 390 |     if is_baremetal; then | 
 | 391 |         database_connection_url dburl nova_bm | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 392 |         iniset $NOVA_CONF baremetal sql_connection $dburl | 
| Devananda van der Veen | f35cf91 | 2012-11-12 17:58:38 -0800 | [diff] [blame] | 393 |     fi | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 394 |     iniset $NOVA_CONF DEFAULT libvirt_type "$LIBVIRT_TYPE" | 
 | 395 |     iniset $NOVA_CONF DEFAULT libvirt_cpu_mode "none" | 
 | 396 |     iniset $NOVA_CONF DEFAULT instance_name_template "${INSTANCE_NAME_PREFIX}%08x" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 397 |  | 
 | 398 |     if is_service_enabled n-api; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 399 |         iniset $NOVA_CONF DEFAULT enabled_apis "$NOVA_ENABLED_APIS" | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 400 |         if is_service_enabled tls-proxy; then | 
 | 401 |             # Set the service port for a proxy to take the original | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 402 |             iniset $NOVA_CONF DEFAULT osapi_compute_listen_port "$NOVA_SERVICE_PORT_INT" | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 403 |         fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 404 |     fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 405 |     if is_service_enabled cinder; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 406 |         iniset $NOVA_CONF DEFAULT volume_api_class "nova.volume.cinder.API" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 407 |     fi | 
 | 408 |     if [ -n "$NOVA_STATE_PATH" ]; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 409 |         iniset $NOVA_CONF DEFAULT state_path "$NOVA_STATE_PATH" | 
 | 410 |         iniset $NOVA_CONF DEFAULT lock_path "$NOVA_STATE_PATH" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 411 |     fi | 
 | 412 |     if [ -n "$NOVA_INSTANCES_PATH" ]; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 413 |         iniset $NOVA_CONF DEFAULT instances_path "$NOVA_INSTANCES_PATH" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 414 |     fi | 
 | 415 |     if [ "$MULTI_HOST" != "False" ]; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 416 |         iniset $NOVA_CONF DEFAULT multi_host "True" | 
 | 417 |         iniset $NOVA_CONF DEFAULT send_arp_for_ha "True" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 418 |     fi | 
 | 419 |     if [ "$SYSLOG" != "False" ]; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 420 |         iniset $NOVA_CONF DEFAULT use_syslog "True" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 421 |     fi | 
 | 422 |     if [ "$API_RATE_LIMIT" != "True" ]; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 423 |         iniset $NOVA_CONF DEFAULT api_rate_limit "False" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 424 |     fi | 
 | 425 |     if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then | 
 | 426 |         # Add color to logging output | 
| Joe Gordon | 07db713 | 2013-01-30 13:07:25 -0800 | [diff] [blame^] | 427 |         iniset $NOVA_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[01;36m%(request_id)s [00;36m%(user_name)s %(project_name)s%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m" | 
 | 428 |         iniset $NOVA_CONF DEFAULT logging_default_format_string "%(asctime)s.%(msecs)03d %(color)s%(levelname)s %(name)s [[00;36m-%(color)s] [01;35m%(instance)s%(color)s%(message)s[00m" | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 429 |         iniset $NOVA_CONF DEFAULT logging_debug_format_suffix "[00;33mfrom (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d[00m" | 
| Joe Gordon | 07db713 | 2013-01-30 13:07:25 -0800 | [diff] [blame^] | 430 |         iniset $NOVA_CONF DEFAULT logging_exception_prefix "%(color)s%(asctime)s.%(msecs)03d TRACE %(name)s [01;35m%(instance)s[00m" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 431 |     else | 
 | 432 |         # Show user_name and project_name instead of user_id and project_id | 
| Joe Gordon | 07db713 | 2013-01-30 13:07:25 -0800 | [diff] [blame^] | 433 |         iniset $NOVA_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 434 |     fi | 
| Eoghan Glynn | 1fcc6a1 | 2012-10-25 14:57:14 +0000 | [diff] [blame] | 435 |     if is_service_enabled ceilometer; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 436 |         iniset $NOVA_CONF DEFAULT instance_usage_audit "True" | 
 | 437 |         iniset $NOVA_CONF DEFAULT instance_usage_audit_period "hour" | 
 | 438 |         iniset $NOVA_CONF DEFAULT notification_driver "nova.openstack.common.notifier.rpc_notifier" | 
 | 439 |         iniset $NOVA_CONF DEFAULT notification_driver "ceilometer.compute.nova_notifier" | 
| Eoghan Glynn | 1fcc6a1 | 2012-10-25 14:57:14 +0000 | [diff] [blame] | 440 |     fi | 
 | 441 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 442 |  | 
 | 443 |     # Provide some transition from ``EXTRA_FLAGS`` to ``EXTRA_OPTS`` | 
 | 444 |     if [[ -z "$EXTRA_OPTS" && -n "$EXTRA_FLAGS" ]]; then | 
 | 445 |         EXTRA_OPTS=$EXTRA_FLAGS | 
 | 446 |     fi | 
 | 447 |  | 
 | 448 |     # Define extra nova conf flags by defining the array ``EXTRA_OPTS``. | 
 | 449 |     # For Example: ``EXTRA_OPTS=(foo=true bar=2)`` | 
 | 450 |     for I in "${EXTRA_OPTS[@]}"; do | 
| Dean Troyer | dff9512 | 2013-01-10 20:51:28 -0600 | [diff] [blame] | 451 |         # Replace the first '=' with ' ' for iniset syntax | 
 | 452 |         iniset $NOVA_CONF DEFAULT ${I/=/ } | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 453 |     done | 
| Dean Troyer | da7b809 | 2012-10-08 18:12:14 -0500 | [diff] [blame] | 454 | } | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 455 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 456 | function create_nova_conf_nova_network() { | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 457 |     iniset $NOVA_CONF DEFAULT network_manager "nova.network.manager.$NET_MAN" | 
 | 458 |     iniset $NOVA_CONF DEFAULT public_interface "$PUBLIC_INTERFACE" | 
 | 459 |     iniset $NOVA_CONF DEFAULT vlan_interface "$VLAN_INTERFACE" | 
 | 460 |     iniset $NOVA_CONF DEFAULT flat_network_bridge "$FLAT_NETWORK_BRIDGE" | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 461 |     if [ -n "$FLAT_INTERFACE" ]; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 462 |         iniset $NOVA_CONF DEFAULT flat_interface "$FLAT_INTERFACE" | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 463 |     fi | 
 | 464 | } | 
 | 465 |  | 
| Dean Troyer | da7b809 | 2012-10-08 18:12:14 -0500 | [diff] [blame] | 466 | # init_nova() - Initialize databases, etc. | 
 | 467 | function init_nova() { | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 468 |     # Nova Database | 
 | 469 |     # ------------- | 
 | 470 |  | 
 | 471 |     # All nova components talk to a central database.  We will need to do this step | 
 | 472 |     # only once for an entire cluster. | 
 | 473 |  | 
| Bob Melander | c439b5d | 2012-12-19 14:49:34 +0100 | [diff] [blame] | 474 |     if is_service_enabled $DATABASE_BACKENDS && is_service_enabled n-api; then | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 475 |         # (Re)create nova database | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 476 |         # Explicitly use latin1: to avoid lp#829209, nova expects the database to | 
 | 477 |         # use latin1 by default, and then upgrades the database to utf8 (see the | 
 | 478 |         # 082_essex.py in nova) | 
| Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 479 |         recreate_database nova latin1 | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 480 |  | 
 | 481 |         # (Re)create nova database | 
 | 482 |         $NOVA_BIN_DIR/nova-manage db sync | 
| Devananda van der Veen | f35cf91 | 2012-11-12 17:58:38 -0800 | [diff] [blame] | 483 |  | 
 | 484 |         # (Re)create nova baremetal database | 
 | 485 |         if is_baremetal; then | 
 | 486 |             recreate_database nova_bm latin1 | 
 | 487 |             $NOVA_BIN_DIR/nova-baremetal-manage db sync | 
 | 488 |         fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 489 |     fi | 
 | 490 |  | 
| Akihiro MOTOKI | 5e3deb6 | 2012-12-11 17:09:02 +0900 | [diff] [blame] | 491 |     # Create cache dir | 
 | 492 |     sudo mkdir -p $NOVA_AUTH_CACHE_DIR | 
| Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 493 |     sudo chown $STACK_USER $NOVA_AUTH_CACHE_DIR | 
| Vishvananda Ishaya | 23431f3 | 2012-12-12 15:57:33 -0800 | [diff] [blame] | 494 |     rm -f $NOVA_AUTH_CACHE_DIR/* | 
| Devananda van der Veen | f35cf91 | 2012-11-12 17:58:38 -0800 | [diff] [blame] | 495 |  | 
 | 496 |     # Create the keys folder | 
 | 497 |     sudo mkdir -p ${NOVA_STATE_PATH}/keys | 
 | 498 |     # make sure we own NOVA_STATE_PATH and all subdirs | 
| Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 499 |     sudo chown -R $STACK_USER ${NOVA_STATE_PATH} | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 500 | } | 
 | 501 |  | 
 | 502 | # install_novaclient() - Collect source and prepare | 
 | 503 | function install_novaclient() { | 
 | 504 |     git_clone $NOVACLIENT_REPO $NOVACLIENT_DIR $NOVACLIENT_BRANCH | 
 | 505 | } | 
 | 506 |  | 
 | 507 | # install_nova() - Collect source and prepare | 
 | 508 | function install_nova() { | 
 | 509 |     if is_service_enabled n-cpu; then | 
| Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 510 |         if is_ubuntu; then | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 511 |             install_package libvirt-bin | 
 | 512 |         elif is_fedora || is_suse; then | 
 | 513 |             install_package libvirt | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 514 |         else | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 515 |             exit_distro_not_supported "libvirt installation" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 516 |         fi | 
| Vincent Untz | 00011c0 | 2012-12-06 09:56:32 +0100 | [diff] [blame] | 517 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 518 |         # Install and configure **LXC** if specified.  LXC is another approach to | 
 | 519 |         # splitting a system into many smaller parts.  LXC uses cgroups and chroot | 
 | 520 |         # to simulate multiple systems. | 
 | 521 |         if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then | 
| Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 522 |             if is_ubuntu; then | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 523 |                 if [[ "$DISTRO" > natty ]]; then | 
 | 524 |                     install_package cgroup-lite | 
 | 525 |                 fi | 
 | 526 |             else | 
 | 527 |                 ### FIXME(dtroyer): figure this out | 
 | 528 |                 echo "RPM-based cgroup not implemented yet" | 
 | 529 |                 yum_install libcgroup-tools | 
 | 530 |             fi | 
 | 531 |         fi | 
 | 532 |     fi | 
 | 533 |  | 
 | 534 |     git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH | 
 | 535 | } | 
 | 536 |  | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 537 | # start_nova_api() - Start the API process ahead of other things | 
 | 538 | function start_nova_api() { | 
 | 539 |     # Get right service port for testing | 
 | 540 |     local service_port=$NOVA_SERVICE_PORT | 
 | 541 |     if is_service_enabled tls-proxy; then | 
 | 542 |         service_port=$NOVA_SERVICE_PORT_INT | 
 | 543 |     fi | 
 | 544 |  | 
 | 545 |     screen_it n-api "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-api" | 
 | 546 |     echo "Waiting for nova-api to start..." | 
 | 547 |     if ! wait_for_service $SERVICE_TIMEOUT http://$SERVICE_HOST:$service_port; then | 
 | 548 |       echo "nova-api did not start" | 
 | 549 |       exit 1 | 
 | 550 |     fi | 
 | 551 |  | 
 | 552 |     # Start proxies if enabled | 
 | 553 |     if is_service_enabled tls-proxy; then | 
 | 554 |         start_tls_proxy '*' $NOVA_SERVICE_PORT $NOVA_SERVICE_HOST $NOVA_SERVICE_PORT_INT & | 
 | 555 |     fi | 
 | 556 | } | 
 | 557 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 558 | # start_nova() - Start running processes, including screen | 
 | 559 | function start_nova() { | 
 | 560 |     # The group **libvirtd** is added to the current user in this script. | 
 | 561 |     # Use 'sg' to execute nova-compute as a member of the **libvirtd** group. | 
 | 562 |     # ``screen_it`` checks ``is_service_enabled``, it is not needed here | 
| Russell Bryant | ff7f308 | 2012-11-29 22:00:51 -0500 | [diff] [blame] | 563 |     screen_it n-cond "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-conductor" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 564 |     screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_BIN_DIR/nova-compute" | 
 | 565 |     screen_it n-crt "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-cert" | 
 | 566 |     screen_it n-net "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-network" | 
 | 567 |     screen_it n-sch "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-scheduler" | 
| Daniel P. Berrange | 3edddd1 | 2013-01-03 12:06:47 +0000 | [diff] [blame] | 568 |     screen_it n-novnc "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-novncproxy --config-file $NOVA_CONF --web $NOVNC_DIR" | 
| Monty Taylor | 0edfd6f | 2012-11-23 15:00:38 -0800 | [diff] [blame] | 569 |     screen_it n-xvnc "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-xvpvncproxy --config-file $NOVA_CONF" | 
| Daniel P. Berrange | d10e12f | 2013-01-03 11:51:42 +0000 | [diff] [blame] | 570 |     screen_it n-spice "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-spicehtml5proxy --config-file $NOVA_CONF --web $SPICE_DIR" | 
| Monty Taylor | 0edfd6f | 2012-11-23 15:00:38 -0800 | [diff] [blame] | 571 |     screen_it n-cauth "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-consoleauth" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 572 | } | 
 | 573 |  | 
 | 574 | # stop_nova() - Stop running processes (non-screen) | 
 | 575 | function stop_nova() { | 
 | 576 |     # Kill the nova screen windows | 
| Daniel P. Berrange | d10e12f | 2013-01-03 11:51:42 +0000 | [diff] [blame] | 577 |     for serv in n-api n-cpu n-crt n-net n-sch n-novnc n-xvnc n-cauth n-cond n-spice; do | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 578 |         screen -S $SCREEN_NAME -p $serv -X kill | 
 | 579 |     done | 
 | 580 | } | 
 | 581 |  | 
 | 582 | # Restore xtrace | 
 | 583 | $XTRACE |