| 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 | 
| Kieran Spear | fb2a3ae | 2013-03-11 23:55:49 +0000 | [diff] [blame] | 40 | NOVA_CELLS_CONF=$NOVA_CONF_DIR/nova-cells.conf | 
|  | 41 | NOVA_CELLS_DB=${NOVA_CELLS_DB:-nova_cell} | 
|  | 42 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 43 | NOVA_API_PASTE_INI=${NOVA_API_PASTE_INI:-$NOVA_CONF_DIR/api-paste.ini} | 
|  | 44 |  | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 45 | # Public facing bits | 
|  | 46 | NOVA_SERVICE_HOST=${NOVA_SERVICE_HOST:-$SERVICE_HOST} | 
|  | 47 | NOVA_SERVICE_PORT=${NOVA_SERVICE_PORT:-8774} | 
|  | 48 | NOVA_SERVICE_PORT_INT=${NOVA_SERVICE_PORT_INT:-18774} | 
|  | 49 | NOVA_SERVICE_PROTOCOL=${NOVA_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL} | 
|  | 50 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 51 | # Support entry points installation of console scripts | 
|  | 52 | if [[ -d $NOVA_DIR/bin ]]; then | 
|  | 53 | NOVA_BIN_DIR=$NOVA_DIR/bin | 
|  | 54 | else | 
| Jakub Ruzicka | 4196d55 | 2013-01-30 15:35:54 +0100 | [diff] [blame] | 55 | NOVA_BIN_DIR=$(get_python_exec_prefix) | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 56 | fi | 
|  | 57 |  | 
|  | 58 | # Set the paths of certain binaries | 
| Vincent Untz | 856a11e | 2012-11-21 16:04:12 +0100 | [diff] [blame] | 59 | NOVA_ROOTWRAP=$(get_rootwrap_location nova) | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 60 |  | 
|  | 61 | # Allow rate limiting to be turned off for testing, like for Tempest | 
|  | 62 | # NOTE: Set API_RATE_LIMIT="False" to turn OFF rate limiting | 
|  | 63 | API_RATE_LIMIT=${API_RATE_LIMIT:-"True"} | 
|  | 64 |  | 
|  | 65 | # Nova supports pluggable schedulers.  The default ``FilterScheduler`` | 
|  | 66 | # should work in most cases. | 
|  | 67 | SCHEDULER=${SCHEDULER:-nova.scheduler.filter_scheduler.FilterScheduler} | 
|  | 68 |  | 
|  | 69 | QEMU_CONF=/etc/libvirt/qemu.conf | 
|  | 70 |  | 
| Dean Troyer | b7490da | 2013-03-18 16:07:56 -0500 | [diff] [blame] | 71 | NOVNC_DIR=$DEST/noVNC | 
|  | 72 | SPICE_DIR=$DEST/spice-html5 | 
|  | 73 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 74 |  | 
| Dean Troyer | b323691 | 2013-03-17 15:17:05 -0500 | [diff] [blame] | 75 | # Nova Network Configuration | 
|  | 76 | # -------------------------- | 
|  | 77 |  | 
|  | 78 | # Set defaults according to the virt driver | 
|  | 79 | if [ "$VIRT_DRIVER" = 'xenserver' ]; then | 
| Mate Lakat | 5a56cd6 | 2013-06-17 13:54:43 +0100 | [diff] [blame] | 80 | PUBLIC_INTERFACE_DEFAULT=eth2 | 
| Dean Troyer | b323691 | 2013-03-17 15:17:05 -0500 | [diff] [blame] | 81 | GUEST_INTERFACE_DEFAULT=eth1 | 
|  | 82 | # Allow ``build_domU.sh`` to specify the flat network bridge via kernel args | 
| Mate Lakat | f652e0f | 2013-05-21 18:12:48 +0100 | [diff] [blame] | 83 | FLAT_NETWORK_BRIDGE_DEFAULT=$(sed -e 's/.* flat_network_bridge=\([[:alnum:]]*\).*$/\1/g' /proc/cmdline) | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 84 | if is_service_enabled neutron; then | 
| Mate Lakat | f652e0f | 2013-05-21 18:12:48 +0100 | [diff] [blame] | 85 | XEN_INTEGRATION_BRIDGE=$(sed -e 's/.* xen_integration_bridge=\([[:alnum:]]*\).*$/\1/g' /proc/cmdline) | 
|  | 86 | fi | 
| Dean Troyer | b323691 | 2013-03-17 15:17:05 -0500 | [diff] [blame] | 87 | elif [ "$VIRT_DRIVER" = 'baremetal' ]; then | 
|  | 88 | NETWORK_MANAGER=${NETWORK_MANAGER:-FlatManager} | 
|  | 89 | PUBLIC_INTERFACE_DEFAULT=eth0 | 
|  | 90 | FLAT_INTERFACE=${FLAT_INTERFACE:-eth0} | 
|  | 91 | FLAT_NETWORK_BRIDGE_DEFAULT=br100 | 
|  | 92 | STUB_NETWORK=${STUB_NETWORK:-False} | 
|  | 93 | else | 
|  | 94 | PUBLIC_INTERFACE_DEFAULT=br100 | 
|  | 95 | GUEST_INTERFACE_DEFAULT=eth0 | 
|  | 96 | FLAT_NETWORK_BRIDGE_DEFAULT=br100 | 
|  | 97 | fi | 
|  | 98 |  | 
|  | 99 | NETWORK_MANAGER=${NETWORK_MANAGER:-${NET_MAN:-FlatDHCPManager}} | 
|  | 100 | PUBLIC_INTERFACE=${PUBLIC_INTERFACE:-$PUBLIC_INTERFACE_DEFAULT} | 
|  | 101 | VLAN_INTERFACE=${VLAN_INTERFACE:-$GUEST_INTERFACE_DEFAULT} | 
|  | 102 | FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-$FLAT_NETWORK_BRIDGE_DEFAULT} | 
|  | 103 | EC2_DMZ_HOST=${EC2_DMZ_HOST:-$SERVICE_HOST} | 
|  | 104 |  | 
|  | 105 | # If you are using the FlatDHCP network mode on multiple hosts, set the | 
|  | 106 | # ``FLAT_INTERFACE`` variable but make sure that the interface doesn't already | 
|  | 107 | # have an IP or you risk breaking things. | 
|  | 108 | # | 
|  | 109 | # **DHCP Warning**:  If your flat interface device uses DHCP, there will be a | 
|  | 110 | # hiccup while the network is moved from the flat interface to the flat network | 
|  | 111 | # bridge.  This will happen when you launch your first instance.  Upon launch | 
|  | 112 | # you will lose all connectivity to the node, and the VM launch will probably | 
|  | 113 | # fail. | 
|  | 114 | # | 
|  | 115 | # If you are running on a single node and don't need to access the VMs from | 
|  | 116 | # devices other than that node, you can set ``FLAT_INTERFACE=`` | 
|  | 117 | # This will stop nova from bridging any interfaces into ``FLAT_NETWORK_BRIDGE``. | 
| Davanum Srinivas | b93b74c | 2013-03-21 21:25:05 -0400 | [diff] [blame] | 118 | FLAT_INTERFACE=${FLAT_INTERFACE:-$GUEST_INTERFACE_DEFAULT} | 
| Dean Troyer | b323691 | 2013-03-17 15:17:05 -0500 | [diff] [blame] | 119 |  | 
|  | 120 | # ``MULTI_HOST`` is a mode where each compute node runs its own network node.  This | 
|  | 121 | # allows network operations and routing for a VM to occur on the server that is | 
|  | 122 | # running the VM - removing a SPOF and bandwidth bottleneck. | 
|  | 123 | MULTI_HOST=`trueorfalse False $MULTI_HOST` | 
|  | 124 |  | 
|  | 125 | # Test floating pool and range are used for testing.  They are defined | 
|  | 126 | # here until the admin APIs can replace nova-manage | 
|  | 127 | TEST_FLOATING_POOL=${TEST_FLOATING_POOL:-test} | 
|  | 128 | TEST_FLOATING_RANGE=${TEST_FLOATING_RANGE:-192.168.253.0/29} | 
|  | 129 |  | 
|  | 130 |  | 
| Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 131 | # Functions | 
|  | 132 | # --------- | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 133 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 134 | # Helper to clean iptables rules | 
|  | 135 | function clean_iptables() { | 
|  | 136 | # Delete rules | 
|  | 137 | 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 | 
|  | 138 | # Delete nat rules | 
|  | 139 | 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 | 
|  | 140 | # Delete chains | 
|  | 141 | 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 | 
|  | 142 | # Delete nat chains | 
|  | 143 | 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 | 
|  | 144 | } | 
|  | 145 |  | 
|  | 146 | # cleanup_nova() - Remove residual data files, anything left over from previous | 
|  | 147 | # runs that a clean run would need to clean up | 
|  | 148 | function cleanup_nova() { | 
|  | 149 | if is_service_enabled n-cpu; then | 
|  | 150 | # Clean iptables from previous runs | 
|  | 151 | clean_iptables | 
|  | 152 |  | 
|  | 153 | # Destroy old instances | 
|  | 154 | instances=`sudo virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"` | 
|  | 155 | if [ ! "$instances" = "" ]; then | 
|  | 156 | echo $instances | xargs -n1 sudo virsh destroy || true | 
| Daniel P. Berrange | d52008a | 2013-05-20 15:03:43 +0100 | [diff] [blame] | 157 | echo $instances | xargs -n1 sudo virsh undefine --managed-save || true | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 158 | fi | 
|  | 159 |  | 
|  | 160 | # Logout and delete iscsi sessions | 
| Dan Smith | c0fad2b | 2013-03-28 12:22:25 -0700 | [diff] [blame] | 161 | tgts=$(sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d ' ' -f2) | 
|  | 162 | for target in $tgts; do | 
|  | 163 | sudo iscsiadm --mode node -T $target --logout || true | 
|  | 164 | done | 
|  | 165 | sudo iscsiadm --mode node --op delete || true | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 166 |  | 
|  | 167 | # Clean out the instances directory. | 
|  | 168 | sudo rm -rf $NOVA_INSTANCES_PATH/* | 
|  | 169 | fi | 
| Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 170 |  | 
|  | 171 | sudo rm -rf $NOVA_STATE_PATH $NOVA_AUTH_CACHE_DIR | 
| Dean Troyer | 2aa2a89 | 2013-08-04 19:53:19 -0500 | [diff] [blame] | 172 |  | 
|  | 173 | # NOTE(dtroyer): This really should be called from here but due to the way | 
|  | 174 | #                nova abuses the _cleanup() function we're moving it | 
|  | 175 | #                directly into cleanup.sh until this can be fixed. | 
|  | 176 | #if is_service_enabled n-cpu && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then | 
|  | 177 | #    cleanup_nova_hypervisor | 
|  | 178 | #fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 179 | } | 
|  | 180 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 181 | # configure_nova_rootwrap() - configure Nova's rootwrap | 
|  | 182 | function configure_nova_rootwrap() { | 
|  | 183 | # Deploy new rootwrap filters files (owned by root). | 
|  | 184 | # Wipe any existing rootwrap.d files first | 
|  | 185 | if [[ -d $NOVA_CONF_DIR/rootwrap.d ]]; then | 
|  | 186 | sudo rm -rf $NOVA_CONF_DIR/rootwrap.d | 
|  | 187 | fi | 
|  | 188 | # Deploy filters to /etc/nova/rootwrap.d | 
|  | 189 | sudo mkdir -m 755 $NOVA_CONF_DIR/rootwrap.d | 
|  | 190 | sudo cp $NOVA_DIR/etc/nova/rootwrap.d/*.filters $NOVA_CONF_DIR/rootwrap.d | 
|  | 191 | sudo chown -R root:root $NOVA_CONF_DIR/rootwrap.d | 
|  | 192 | sudo chmod 644 $NOVA_CONF_DIR/rootwrap.d/* | 
|  | 193 | # Set up rootwrap.conf, pointing to /etc/nova/rootwrap.d | 
|  | 194 | sudo cp $NOVA_DIR/etc/nova/rootwrap.conf $NOVA_CONF_DIR/ | 
|  | 195 | sudo sed -e "s:^filters_path=.*$:filters_path=$NOVA_CONF_DIR/rootwrap.d:" -i $NOVA_CONF_DIR/rootwrap.conf | 
|  | 196 | sudo chown root:root $NOVA_CONF_DIR/rootwrap.conf | 
|  | 197 | sudo chmod 0644 $NOVA_CONF_DIR/rootwrap.conf | 
|  | 198 | # Specify rootwrap.conf as first parameter to nova-rootwrap | 
|  | 199 | ROOTWRAP_SUDOER_CMD="$NOVA_ROOTWRAP $NOVA_CONF_DIR/rootwrap.conf *" | 
|  | 200 |  | 
|  | 201 | # Set up the rootwrap sudoers for nova | 
|  | 202 | TEMPFILE=`mktemp` | 
|  | 203 | echo "$USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE | 
|  | 204 | chmod 0440 $TEMPFILE | 
|  | 205 | sudo chown root:root $TEMPFILE | 
|  | 206 | sudo mv $TEMPFILE /etc/sudoers.d/nova-rootwrap | 
|  | 207 | } | 
|  | 208 |  | 
|  | 209 | # configure_nova() - Set config files, create data dirs, etc | 
|  | 210 | function configure_nova() { | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 211 | # Put config files in ``/etc/nova`` for everyone to find | 
|  | 212 | if [[ ! -d $NOVA_CONF_DIR ]]; then | 
|  | 213 | sudo mkdir -p $NOVA_CONF_DIR | 
|  | 214 | fi | 
| Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 215 | sudo chown $STACK_USER $NOVA_CONF_DIR | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 216 |  | 
|  | 217 | cp -p $NOVA_DIR/etc/nova/policy.json $NOVA_CONF_DIR | 
|  | 218 |  | 
|  | 219 | configure_nova_rootwrap | 
|  | 220 |  | 
|  | 221 | if is_service_enabled n-api; then | 
|  | 222 | # Use the sample http middleware configuration supplied in the | 
|  | 223 | # Nova sources.  This paste config adds the configuration required | 
|  | 224 | # for Nova to validate Keystone tokens. | 
|  | 225 |  | 
|  | 226 | # Remove legacy paste config if present | 
|  | 227 | rm -f $NOVA_DIR/bin/nova-api-paste.ini | 
|  | 228 |  | 
|  | 229 | # Get the sample configuration file in place | 
|  | 230 | cp $NOVA_DIR/etc/nova/api-paste.ini $NOVA_CONF_DIR | 
|  | 231 |  | 
| Mate Lakat | a6601a5 | 2013-03-13 13:35:47 +0000 | [diff] [blame] | 232 | iniset $NOVA_API_PASTE_INI filter:authtoken auth_host $KEYSTONE_AUTH_HOST | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 233 | if is_service_enabled tls-proxy; then | 
| Mate Lakat | a6601a5 | 2013-03-13 13:35:47 +0000 | [diff] [blame] | 234 | iniset $NOVA_API_PASTE_INI filter:authtoken auth_protocol $KEYSTONE_AUTH_PROTOCOL | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 235 | fi | 
| Dean Troyer | b205cc8 | 2013-02-11 17:34:39 -0600 | [diff] [blame] | 236 | iniset $NOVA_API_PASTE_INI filter:authtoken admin_tenant_name $SERVICE_TENANT_NAME | 
|  | 237 | iniset $NOVA_API_PASTE_INI filter:authtoken admin_user nova | 
|  | 238 | iniset $NOVA_API_PASTE_INI filter:authtoken admin_password $SERVICE_PASSWORD | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 239 | fi | 
|  | 240 |  | 
| Akihiro MOTOKI | 5e3deb6 | 2012-12-11 17:09:02 +0900 | [diff] [blame] | 241 | 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] | 242 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 243 | if is_service_enabled n-cpu; then | 
|  | 244 | # Force IP forwarding on, just on case | 
|  | 245 | sudo sysctl -w net.ipv4.ip_forward=1 | 
|  | 246 |  | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 247 | if [[ "$VIRT_DRIVER" = 'libvirt' ]]; then | 
|  | 248 | # Attempt to load modules: network block device - used to manage qcow images | 
|  | 249 | sudo modprobe nbd || true | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 250 |  | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 251 | # Check for kvm (hardware based virtualization).  If unable to initialize | 
|  | 252 | # kvm, we drop back to the slower emulation mode (qemu).  Note: many systems | 
|  | 253 | # come with hardware virtualization disabled in BIOS. | 
|  | 254 | if [[ "$LIBVIRT_TYPE" == "kvm" ]]; then | 
|  | 255 | sudo modprobe kvm || true | 
|  | 256 | if [ ! -e /dev/kvm ]; then | 
|  | 257 | echo "WARNING: Switching to QEMU" | 
|  | 258 | LIBVIRT_TYPE=qemu | 
|  | 259 | if which selinuxenabled 2>&1 > /dev/null && selinuxenabled; then | 
|  | 260 | # https://bugzilla.redhat.com/show_bug.cgi?id=753589 | 
|  | 261 | sudo setsebool virt_use_execmem on | 
|  | 262 | fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 263 | fi | 
|  | 264 | fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 265 |  | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 266 | # Install and configure **LXC** if specified.  LXC is another approach to | 
|  | 267 | # splitting a system into many smaller parts.  LXC uses cgroups and chroot | 
|  | 268 | # to simulate multiple systems. | 
|  | 269 | if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then | 
|  | 270 | if is_ubuntu; then | 
|  | 271 | if [[ ! "$DISTRO" > natty ]]; then | 
|  | 272 | cgline="none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0" | 
|  | 273 | sudo mkdir -p /cgroup | 
|  | 274 | if ! grep -q cgroup /etc/fstab; then | 
|  | 275 | echo "$cgline" | sudo tee -a /etc/fstab | 
|  | 276 | fi | 
|  | 277 | if ! mount -n | grep -q cgroup; then | 
|  | 278 | sudo mount /cgroup | 
|  | 279 | fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 280 | fi | 
|  | 281 | fi | 
|  | 282 | fi | 
|  | 283 | fi | 
|  | 284 |  | 
| Devananda van der Veen | f35cf91 | 2012-11-12 17:58:38 -0800 | [diff] [blame] | 285 | # Prepare directories and packages for baremetal driver | 
|  | 286 | if is_baremetal; then | 
|  | 287 | configure_baremetal_nova_dirs | 
|  | 288 | fi | 
|  | 289 |  | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 290 | if [[ "$VIRT_DRIVER" = 'libvirt' ]]; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 291 | if is_service_enabled neutron && is_neutron_ovs_base_plugin && ! sudo grep -q '^cgroup_device_acl' $QEMU_CONF; then | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 292 | # Add /dev/net/tun to cgroup_device_acls, needed for type=ethernet interfaces | 
|  | 293 | cat <<EOF | sudo tee -a $QEMU_CONF | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 294 | cgroup_device_acl = [ | 
|  | 295 | "/dev/null", "/dev/full", "/dev/zero", | 
|  | 296 | "/dev/random", "/dev/urandom", | 
|  | 297 | "/dev/ptmx", "/dev/kvm", "/dev/kqemu", | 
|  | 298 | "/dev/rtc", "/dev/hpet","/dev/net/tun", | 
|  | 299 | ] | 
|  | 300 | EOF | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 301 | fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 302 |  | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 303 | if is_ubuntu; then | 
|  | 304 | LIBVIRT_DAEMON=libvirt-bin | 
|  | 305 | else | 
|  | 306 | LIBVIRT_DAEMON=libvirtd | 
|  | 307 | fi | 
| Vincent Untz | f1c094c | 2012-12-05 17:59:04 +0100 | [diff] [blame] | 308 |  | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 309 | if is_fedora || is_suse; then | 
| Dean Troyer | 1a6d449 | 2013-06-03 16:47:36 -0500 | [diff] [blame] | 310 | if is_fedora && [[ $DISTRO =~ (rhel6) || "$os_RELEASE" -le "17" ]]; then | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 311 | sudo bash -c "cat <<EOF >/etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla | 
| Ralf Haferkamp | 76ca9a9 | 2013-04-12 12:39:58 +0200 | [diff] [blame] | 312 | [libvirt Management Access] | 
| Émilien Macchi | b2ef890 | 2013-05-04 00:48:20 +0200 | [diff] [blame] | 313 | Identity=unix-group:$LIBVIRT_GROUP | 
| Ralf Haferkamp | 76ca9a9 | 2013-04-12 12:39:58 +0200 | [diff] [blame] | 314 | Action=org.libvirt.unix.manage | 
|  | 315 | ResultAny=yes | 
|  | 316 | ResultInactive=yes | 
|  | 317 | ResultActive=yes | 
| Émilien Macchi | b2ef890 | 2013-05-04 00:48:20 +0200 | [diff] [blame] | 318 | EOF" | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 319 | elif is_suse && [[ $os_RELEASE = 12.2 || "$os_VENDOR" = "SUSE LINUX" ]]; then | 
|  | 320 | # openSUSE < 12.3 or SLE | 
|  | 321 | # Work around the fact that polkit-default-privs overrules pklas | 
|  | 322 | # with 'unix-group:$group'. | 
|  | 323 | sudo bash -c "cat <<EOF >/etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla | 
| Ralf Haferkamp | 76ca9a9 | 2013-04-12 12:39:58 +0200 | [diff] [blame] | 324 | [libvirt Management Access] | 
|  | 325 | Identity=unix-user:$USER | 
|  | 326 | Action=org.libvirt.unix.manage | 
|  | 327 | ResultAny=yes | 
|  | 328 | ResultInactive=yes | 
|  | 329 | ResultActive=yes | 
|  | 330 | EOF" | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 331 | else | 
|  | 332 | # Starting with fedora 18 and opensuse-12.3 enable stack-user to | 
|  | 333 | # virsh -c qemu:///system by creating a policy-kit rule for | 
|  | 334 | # stack-user using the new Javascript syntax | 
|  | 335 | rules_dir=/etc/polkit-1/rules.d | 
|  | 336 | sudo mkdir -p $rules_dir | 
|  | 337 | sudo bash -c "cat <<EOF > $rules_dir/50-libvirt-$STACK_USER.rules | 
| Sunil Thaha | a534e0b | 2013-01-21 17:00:50 +1000 | [diff] [blame] | 338 | polkit.addRule(function(action, subject) { | 
|  | 339 | if (action.id == 'org.libvirt.unix.manage' && | 
|  | 340 | subject.user == '"$STACK_USER"') { | 
|  | 341 | return polkit.Result.YES; | 
|  | 342 | } | 
|  | 343 | }); | 
|  | 344 | EOF" | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 345 | unset rules_dir | 
|  | 346 | fi | 
| Sunil Thaha | a534e0b | 2013-01-21 17:00:50 +1000 | [diff] [blame] | 347 | fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 348 |  | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 349 | # The user that nova runs as needs to be member of **libvirtd** group otherwise | 
|  | 350 | # nova-compute will be unable to use libvirt. | 
|  | 351 | if ! getent group $LIBVIRT_GROUP >/dev/null; then | 
|  | 352 | sudo groupadd $LIBVIRT_GROUP | 
|  | 353 | fi | 
|  | 354 | add_user_to_group $STACK_USER $LIBVIRT_GROUP | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 355 |  | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 356 | # libvirt detects various settings on startup, as we potentially changed | 
|  | 357 | # the system configuration (modules, filesystems), we need to restart | 
|  | 358 | # libvirt to detect those changes. | 
|  | 359 | restart_service $LIBVIRT_DAEMON | 
|  | 360 | fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 361 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 362 | # Instance Storage | 
|  | 363 | # ---------------- | 
|  | 364 |  | 
|  | 365 | # Nova stores each instance in its own directory. | 
| Doug Hellmann | cf9eef8 | 2013-03-25 19:34:48 -0400 | [diff] [blame] | 366 | sudo mkdir -p $NOVA_INSTANCES_PATH | 
|  | 367 | sudo chown -R $STACK_USER $NOVA_INSTANCES_PATH | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 368 |  | 
|  | 369 | # You can specify a different disk to be mounted and used for backing the | 
|  | 370 | # virtual machines.  If there is a partition labeled nova-instances we | 
|  | 371 | # mount it (ext filesystems can be labeled via e2label). | 
|  | 372 | if [ -L /dev/disk/by-label/nova-instances ]; then | 
|  | 373 | if ! mount -n | grep -q $NOVA_INSTANCES_PATH; then | 
|  | 374 | sudo mount -L nova-instances $NOVA_INSTANCES_PATH | 
| Attila Fazekas | 91b8d13 | 2013-01-06 22:40:09 +0100 | [diff] [blame] | 375 | sudo chown -R $STACK_USER $NOVA_INSTANCES_PATH | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 376 | fi | 
|  | 377 | fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 378 | fi | 
|  | 379 | } | 
|  | 380 |  | 
| Dean Troyer | a0dce26 | 2012-12-11 16:52:37 -0600 | [diff] [blame] | 381 | # create_nova_accounts() - Set up common required nova accounts | 
|  | 382 |  | 
|  | 383 | # Tenant               User       Roles | 
|  | 384 | # ------------------------------------------------------------------ | 
|  | 385 | # service              nova       admin, [ResellerAdmin (swift only)] | 
|  | 386 |  | 
|  | 387 | # Migrated from keystone_data.sh | 
|  | 388 | create_nova_accounts() { | 
|  | 389 |  | 
|  | 390 | SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }") | 
|  | 391 | ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }") | 
|  | 392 |  | 
|  | 393 | # Nova | 
|  | 394 | if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then | 
|  | 395 | NOVA_USER=$(keystone user-create \ | 
|  | 396 | --name=nova \ | 
|  | 397 | --pass="$SERVICE_PASSWORD" \ | 
|  | 398 | --tenant_id $SERVICE_TENANT \ | 
|  | 399 | --email=nova@example.com \ | 
|  | 400 | | grep " id " | get_field 2) | 
|  | 401 | keystone user-role-add \ | 
| Jorge Valderrama Romero | f39ee96 | 2013-09-02 17:18:40 +0200 | [diff] [blame] | 402 | --tenant-id $SERVICE_TENANT \ | 
|  | 403 | --user-id $NOVA_USER \ | 
|  | 404 | --role-id $ADMIN_ROLE | 
| Dean Troyer | a0dce26 | 2012-12-11 16:52:37 -0600 | [diff] [blame] | 405 | if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then | 
|  | 406 | NOVA_SERVICE=$(keystone service-create \ | 
|  | 407 | --name=nova \ | 
|  | 408 | --type=compute \ | 
|  | 409 | --description="Nova Compute Service" \ | 
|  | 410 | | grep " id " | get_field 2) | 
|  | 411 | keystone endpoint-create \ | 
|  | 412 | --region RegionOne \ | 
|  | 413 | --service_id $NOVA_SERVICE \ | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 414 | --publicurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2/\$(tenant_id)s" \ | 
|  | 415 | --adminurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2/\$(tenant_id)s" \ | 
|  | 416 | --internalurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v2/\$(tenant_id)s" | 
| Andrea Frittoli | 806233e | 2013-06-17 15:34:54 +0100 | [diff] [blame] | 417 | NOVA_V3_SERVICE=$(keystone service-create \ | 
|  | 418 | --name=nova \ | 
|  | 419 | --type=computev3 \ | 
|  | 420 | --description="Nova Compute Service V3" \ | 
|  | 421 | | grep " id " | get_field 2) | 
|  | 422 | keystone endpoint-create \ | 
|  | 423 | --region RegionOne \ | 
|  | 424 | --service_id $NOVA_V3_SERVICE \ | 
|  | 425 | --publicurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v3" \ | 
|  | 426 | --adminurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v3" \ | 
|  | 427 | --internalurl "$NOVA_SERVICE_PROTOCOL://$NOVA_SERVICE_HOST:$NOVA_SERVICE_PORT/v3" | 
| Dean Troyer | a0dce26 | 2012-12-11 16:52:37 -0600 | [diff] [blame] | 428 | fi | 
|  | 429 | fi | 
|  | 430 | } | 
|  | 431 |  | 
| Dean Troyer | da7b809 | 2012-10-08 18:12:14 -0500 | [diff] [blame] | 432 | # create_nova_conf() - Create a new nova.conf file | 
|  | 433 | function create_nova_conf() { | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 434 | # Remove legacy ``nova.conf`` | 
|  | 435 | rm -f $NOVA_DIR/bin/nova.conf | 
|  | 436 |  | 
|  | 437 | # (Re)create ``nova.conf`` | 
| Dean Troyer | 3cf1ffb | 2012-10-02 11:51:27 -0500 | [diff] [blame] | 438 | rm -f $NOVA_CONF | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 439 | iniset $NOVA_CONF DEFAULT verbose "True" | 
| Ben Nemec | 0399794 | 2013-08-10 09:56:16 -0500 | [diff] [blame] | 440 | iniset $NOVA_CONF DEFAULT debug "$ENABLE_DEBUG_LOG_LEVEL" | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 441 | iniset $NOVA_CONF DEFAULT auth_strategy "keystone" | 
|  | 442 | iniset $NOVA_CONF DEFAULT allow_resize_to_same_host "True" | 
|  | 443 | iniset $NOVA_CONF DEFAULT api_paste_config "$NOVA_API_PASTE_INI" | 
|  | 444 | iniset $NOVA_CONF DEFAULT rootwrap_config "$NOVA_CONF_DIR/rootwrap.conf" | 
| Scott Moser | 50686e5 | 2013-07-17 11:32:35 -0400 | [diff] [blame] | 445 | iniset $NOVA_CONF DEFAULT scheduler_driver "$SCHEDULER" | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 446 | iniset $NOVA_CONF DEFAULT dhcpbridge_flagfile "$NOVA_CONF" | 
|  | 447 | iniset $NOVA_CONF DEFAULT force_dhcp_release "True" | 
| mathrock | 27c0695 | 2013-03-13 00:23:18 -0400 | [diff] [blame] | 448 | iniset $NOVA_CONF DEFAULT fixed_range "" | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 449 | iniset $NOVA_CONF DEFAULT default_floating_pool "$PUBLIC_NETWORK_NAME" | 
|  | 450 | iniset $NOVA_CONF DEFAULT s3_host "$SERVICE_HOST" | 
|  | 451 | iniset $NOVA_CONF DEFAULT s3_port "$S3_SERVICE_PORT" | 
|  | 452 | iniset $NOVA_CONF DEFAULT osapi_compute_extension "nova.api.openstack.compute.contrib.standard_extensions" | 
|  | 453 | iniset $NOVA_CONF DEFAULT my_ip "$HOST_IP" | 
| Joe Gordon | 33b3318 | 2013-09-05 13:06:52 -0700 | [diff] [blame] | 454 | iniset $NOVA_CONF DEFAULT osapi_compute_workers "4" | 
|  | 455 | iniset $NOVA_CONF DEFAULT ec2_workers "4" | 
|  | 456 | iniset $NOVA_CONF DEFAULT metadata_workers "4" | 
| Attila Fazekas | 7e79d91 | 2013-03-03 12:23:04 +0100 | [diff] [blame] | 457 | iniset $NOVA_CONF DEFAULT sql_connection `database_connection_url nova` | 
| Devananda van der Veen | f35cf91 | 2012-11-12 17:58:38 -0800 | [diff] [blame] | 458 | if is_baremetal; then | 
| Attila Fazekas | 7e79d91 | 2013-03-03 12:23:04 +0100 | [diff] [blame] | 459 | iniset $NOVA_CONF baremetal sql_connection `database_connection_url nova_bm` | 
| Devananda van der Veen | f35cf91 | 2012-11-12 17:58:38 -0800 | [diff] [blame] | 460 | fi | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 461 | if [[ "$VIRT_DRIVER" = 'libvirt' ]]; then | 
|  | 462 | iniset $NOVA_CONF DEFAULT libvirt_type "$LIBVIRT_TYPE" | 
|  | 463 | iniset $NOVA_CONF DEFAULT libvirt_cpu_mode "none" | 
| joequant | 4f7dccc | 2013-08-19 11:58:25 +0800 | [diff] [blame] | 464 | iniset $NOVA_CONF DEFAULT use_usb_tablet "False" | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 465 | fi | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 466 | iniset $NOVA_CONF DEFAULT instance_name_template "${INSTANCE_NAME_PREFIX}%08x" | 
| Chris Yeoh | 1b4d91b | 2013-06-03 16:23:01 +0930 | [diff] [blame] | 467 | iniset $NOVA_CONF osapi_v3 enabled "True" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 468 |  | 
| Ian Wienand | 00fd79d | 2013-06-06 11:19:16 +1000 | [diff] [blame] | 469 | if is_fedora; then | 
|  | 470 | # nova defaults to /usr/local/bin, but fedora pip likes to | 
|  | 471 | # install things in /usr/bin | 
|  | 472 | iniset $NOVA_CONF DEFAULT bindir "/usr/bin" | 
|  | 473 | fi | 
|  | 474 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 475 | if is_service_enabled n-api; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 476 | iniset $NOVA_CONF DEFAULT enabled_apis "$NOVA_ENABLED_APIS" | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 477 | if is_service_enabled tls-proxy; then | 
|  | 478 | # 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] | 479 | iniset $NOVA_CONF DEFAULT osapi_compute_listen_port "$NOVA_SERVICE_PORT_INT" | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 480 | fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 481 | fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 482 | if is_service_enabled cinder; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 483 | iniset $NOVA_CONF DEFAULT volume_api_class "nova.volume.cinder.API" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 484 | fi | 
|  | 485 | if [ -n "$NOVA_STATE_PATH" ]; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 486 | iniset $NOVA_CONF DEFAULT state_path "$NOVA_STATE_PATH" | 
|  | 487 | iniset $NOVA_CONF DEFAULT lock_path "$NOVA_STATE_PATH" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 488 | fi | 
|  | 489 | if [ -n "$NOVA_INSTANCES_PATH" ]; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 490 | iniset $NOVA_CONF DEFAULT instances_path "$NOVA_INSTANCES_PATH" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 491 | fi | 
|  | 492 | if [ "$MULTI_HOST" != "False" ]; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 493 | iniset $NOVA_CONF DEFAULT multi_host "True" | 
|  | 494 | iniset $NOVA_CONF DEFAULT send_arp_for_ha "True" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 495 | fi | 
|  | 496 | if [ "$SYSLOG" != "False" ]; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 497 | iniset $NOVA_CONF DEFAULT use_syslog "True" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 498 | fi | 
|  | 499 | if [ "$API_RATE_LIMIT" != "True" ]; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 500 | iniset $NOVA_CONF DEFAULT api_rate_limit "False" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 501 | fi | 
| Salvatore Orlando | 05ae833 | 2013-08-20 14:51:08 -0700 | [diff] [blame] | 502 | # Format logging | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 503 | if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then | 
| Salvatore Orlando | 05ae833 | 2013-08-20 14:51:08 -0700 | [diff] [blame] | 504 | setup_colorized_logging $NOVA_CONF DEFAULT | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 505 | else | 
|  | 506 | # 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] | 507 | 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] | 508 | fi | 
| Eoghan Glynn | 1fcc6a1 | 2012-10-25 14:57:14 +0000 | [diff] [blame] | 509 | if is_service_enabled ceilometer; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 510 | iniset $NOVA_CONF DEFAULT instance_usage_audit "True" | 
|  | 511 | iniset $NOVA_CONF DEFAULT instance_usage_audit_period "hour" | 
| Julien Danjou | a9787d0 | 2013-07-02 11:30:40 +0200 | [diff] [blame] | 512 | iniset $NOVA_CONF DEFAULT notify_on_state_change "vm_and_task_state" | 
| Eoghan Glynn | 1fcc6a1 | 2012-10-25 14:57:14 +0000 | [diff] [blame] | 513 | fi | 
|  | 514 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 515 | # Provide some transition from ``EXTRA_FLAGS`` to ``EXTRA_OPTS`` | 
|  | 516 | if [[ -z "$EXTRA_OPTS" && -n "$EXTRA_FLAGS" ]]; then | 
|  | 517 | EXTRA_OPTS=$EXTRA_FLAGS | 
|  | 518 | fi | 
|  | 519 |  | 
|  | 520 | # Define extra nova conf flags by defining the array ``EXTRA_OPTS``. | 
|  | 521 | # For Example: ``EXTRA_OPTS=(foo=true bar=2)`` | 
|  | 522 | for I in "${EXTRA_OPTS[@]}"; do | 
| Dean Troyer | dff9512 | 2013-01-10 20:51:28 -0600 | [diff] [blame] | 523 | # Replace the first '=' with ' ' for iniset syntax | 
|  | 524 | iniset $NOVA_CONF DEFAULT ${I/=/ } | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 525 | done | 
| Dean Troyer | b323691 | 2013-03-17 15:17:05 -0500 | [diff] [blame] | 526 |  | 
|  | 527 | # All nova-compute workers need to know the vnc configuration options | 
|  | 528 | # These settings don't hurt anything if n-xvnc and n-novnc are disabled | 
|  | 529 | if is_service_enabled n-cpu; then | 
|  | 530 | NOVNCPROXY_URL=${NOVNCPROXY_URL:-"http://$SERVICE_HOST:6080/vnc_auto.html"} | 
|  | 531 | iniset $NOVA_CONF DEFAULT novncproxy_base_url "$NOVNCPROXY_URL" | 
|  | 532 | XVPVNCPROXY_URL=${XVPVNCPROXY_URL:-"http://$SERVICE_HOST:6081/console"} | 
|  | 533 | iniset $NOVA_CONF DEFAULT xvpvncproxy_base_url "$XVPVNCPROXY_URL" | 
|  | 534 | SPICEHTML5PROXY_URL=${SPICEHTML5PROXY_URL:-"http://$SERVICE_HOST:6082/spice_auto.html"} | 
|  | 535 | iniset $NOVA_CONF spice html5proxy_base_url "$SPICEHTML5PROXY_URL" | 
|  | 536 | fi | 
|  | 537 | if [ "$VIRT_DRIVER" = 'xenserver' ]; then | 
|  | 538 | VNCSERVER_PROXYCLIENT_ADDRESS=${VNCSERVER_PROXYCLIENT_ADDRESS=169.254.0.1} | 
|  | 539 | else | 
|  | 540 | VNCSERVER_PROXYCLIENT_ADDRESS=${VNCSERVER_PROXYCLIENT_ADDRESS=127.0.0.1} | 
|  | 541 | fi | 
|  | 542 |  | 
| Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 543 | if is_service_enabled n-novnc || is_service_enabled n-xvnc; then | 
| Dean Troyer | b323691 | 2013-03-17 15:17:05 -0500 | [diff] [blame] | 544 | # Address on which instance vncservers will listen on compute hosts. | 
|  | 545 | # For multi-host, this should be the management ip of the compute host. | 
|  | 546 | VNCSERVER_LISTEN=${VNCSERVER_LISTEN=127.0.0.1} | 
|  | 547 | iniset $NOVA_CONF DEFAULT vnc_enabled true | 
|  | 548 | iniset $NOVA_CONF DEFAULT vncserver_listen "$VNCSERVER_LISTEN" | 
|  | 549 | iniset $NOVA_CONF DEFAULT vncserver_proxyclient_address "$VNCSERVER_PROXYCLIENT_ADDRESS" | 
|  | 550 | else | 
|  | 551 | iniset $NOVA_CONF DEFAULT vnc_enabled false | 
|  | 552 | fi | 
|  | 553 |  | 
|  | 554 | if is_service_enabled n-spice; then | 
|  | 555 | # Address on which instance spiceservers will listen on compute hosts. | 
|  | 556 | # For multi-host, this should be the management ip of the compute host. | 
|  | 557 | SPICESERVER_PROXYCLIENT_ADDRESS=${SPICESERVER_PROXYCLIENT_ADDRESS=127.0.0.1} | 
|  | 558 | SPICESERVER_LISTEN=${SPICESERVER_LISTEN=127.0.0.1} | 
|  | 559 | iniset $NOVA_CONF spice enabled true | 
|  | 560 | iniset $NOVA_CONF spice server_listen "$SPICESERVER_LISTEN" | 
|  | 561 | iniset $NOVA_CONF spice server_proxyclient_address "$SPICESERVER_PROXYCLIENT_ADDRESS" | 
|  | 562 | else | 
|  | 563 | iniset $NOVA_CONF spice enabled false | 
|  | 564 | fi | 
|  | 565 |  | 
|  | 566 | iniset $NOVA_CONF DEFAULT ec2_dmz_host "$EC2_DMZ_HOST" | 
|  | 567 | iniset_rpc_backend nova $NOVA_CONF DEFAULT | 
|  | 568 | iniset $NOVA_CONF DEFAULT glance_api_servers "$GLANCE_HOSTPORT" | 
| Dean Troyer | da7b809 | 2012-10-08 18:12:14 -0500 | [diff] [blame] | 569 | } | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 570 |  | 
| Kieran Spear | fb2a3ae | 2013-03-11 23:55:49 +0000 | [diff] [blame] | 571 | function init_nova_cells() { | 
|  | 572 | if is_service_enabled n-cell; then | 
|  | 573 | cp $NOVA_CONF $NOVA_CELLS_CONF | 
|  | 574 | iniset $NOVA_CELLS_CONF DEFAULT sql_connection `database_connection_url $NOVA_CELLS_DB` | 
|  | 575 | iniset $NOVA_CELLS_CONF DEFAULT rabbit_virtual_host child_cell | 
|  | 576 | iniset $NOVA_CELLS_CONF DEFAULT dhcpbridge_flagfile $NOVA_CELLS_CONF | 
|  | 577 | iniset $NOVA_CELLS_CONF cells enable True | 
| Chris Behrens | c62c2b9 | 2013-07-24 03:56:13 -0700 | [diff] [blame] | 578 | iniset $NOVA_CELLS_CONF cells cell_type compute | 
| Kieran Spear | fb2a3ae | 2013-03-11 23:55:49 +0000 | [diff] [blame] | 579 | iniset $NOVA_CELLS_CONF cells name child | 
|  | 580 |  | 
| Kieran Spear | fb2a3ae | 2013-03-11 23:55:49 +0000 | [diff] [blame] | 581 | iniset $NOVA_CONF cells enable True | 
| Chris Behrens | c62c2b9 | 2013-07-24 03:56:13 -0700 | [diff] [blame] | 582 | iniset $NOVA_CONF cells cell_type api | 
| Kieran Spear | fb2a3ae | 2013-03-11 23:55:49 +0000 | [diff] [blame] | 583 | iniset $NOVA_CONF cells name region | 
|  | 584 |  | 
|  | 585 | if is_service_enabled n-api-meta; then | 
|  | 586 | NOVA_ENABLED_APIS=$(echo $NOVA_ENABLED_APIS | sed "s/,metadata//") | 
|  | 587 | iniset $NOVA_CONF DEFAULT enabled_apis $NOVA_ENABLED_APIS | 
|  | 588 | iniset $NOVA_CELLS_CONF DEFAULT enabled_apis metadata | 
|  | 589 | fi | 
|  | 590 |  | 
|  | 591 | $NOVA_BIN_DIR/nova-manage --config-file $NOVA_CELLS_CONF db sync | 
|  | 592 | $NOVA_BIN_DIR/nova-manage --config-file $NOVA_CELLS_CONF cell create --name=region --cell_type=parent --username=guest --hostname=$RABBIT_HOST --port=5672 --password=$RABBIT_PASSWORD --virtual_host=/ --woffset=0 --wscale=1 | 
|  | 593 | $NOVA_BIN_DIR/nova-manage cell create --name=child --cell_type=child --username=guest --hostname=$RABBIT_HOST --port=5672 --password=$RABBIT_PASSWORD --virtual_host=child_cell --woffset=0 --wscale=1 | 
|  | 594 | fi | 
|  | 595 | } | 
|  | 596 |  | 
| Dean Troyer | f03bafe | 2013-02-12 10:58:28 -0600 | [diff] [blame] | 597 | # create_nova_cache_dir() - Part of the init_nova() process | 
|  | 598 | function create_nova_cache_dir() { | 
|  | 599 | # Create cache dir | 
|  | 600 | sudo mkdir -p $NOVA_AUTH_CACHE_DIR | 
|  | 601 | sudo chown $STACK_USER $NOVA_AUTH_CACHE_DIR | 
|  | 602 | rm -f $NOVA_AUTH_CACHE_DIR/* | 
|  | 603 | } | 
|  | 604 |  | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 605 | function create_nova_conf_nova_network() { | 
| Dean Troyer | b323691 | 2013-03-17 15:17:05 -0500 | [diff] [blame] | 606 | iniset $NOVA_CONF DEFAULT network_manager "nova.network.manager.$NETWORK_MANAGER" | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 607 | iniset $NOVA_CONF DEFAULT public_interface "$PUBLIC_INTERFACE" | 
|  | 608 | iniset $NOVA_CONF DEFAULT vlan_interface "$VLAN_INTERFACE" | 
|  | 609 | iniset $NOVA_CONF DEFAULT flat_network_bridge "$FLAT_NETWORK_BRIDGE" | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 610 | if [ -n "$FLAT_INTERFACE" ]; then | 
| Devananda van der Veen | 9bc47db | 2012-12-12 16:52:55 -0800 | [diff] [blame] | 611 | iniset $NOVA_CONF DEFAULT flat_interface "$FLAT_INTERFACE" | 
| Akihiro MOTOKI | 66afb47 | 2012-12-21 15:34:13 +0900 | [diff] [blame] | 612 | fi | 
|  | 613 | } | 
|  | 614 |  | 
| Dean Troyer | f03bafe | 2013-02-12 10:58:28 -0600 | [diff] [blame] | 615 | # create_nova_keys_dir() - Part of the init_nova() process | 
|  | 616 | function create_nova_keys_dir() { | 
|  | 617 | # Create keys dir | 
|  | 618 | sudo mkdir -p ${NOVA_STATE_PATH}/keys | 
|  | 619 | sudo chown -R $STACK_USER ${NOVA_STATE_PATH} | 
|  | 620 | } | 
|  | 621 |  | 
| Dean Troyer | da7b809 | 2012-10-08 18:12:14 -0500 | [diff] [blame] | 622 | # init_nova() - Initialize databases, etc. | 
|  | 623 | function init_nova() { | 
| Dean Troyer | f03bafe | 2013-02-12 10:58:28 -0600 | [diff] [blame] | 624 | # All nova components talk to a central database. | 
|  | 625 | # Only do this step once on the API node for an entire cluster. | 
| Bob Melander | c439b5d | 2012-12-19 14:49:34 +0100 | [diff] [blame] | 626 | if is_service_enabled $DATABASE_BACKENDS && is_service_enabled n-api; then | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 627 | # (Re)create nova database | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 628 | # Explicitly use latin1: to avoid lp#829209, nova expects the database to | 
|  | 629 | # use latin1 by default, and then upgrades the database to utf8 (see the | 
|  | 630 | # 082_essex.py in nova) | 
| Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 631 | recreate_database nova latin1 | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 632 |  | 
| Dean Troyer | f03bafe | 2013-02-12 10:58:28 -0600 | [diff] [blame] | 633 | # Migrate nova database | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 634 | $NOVA_BIN_DIR/nova-manage db sync | 
| Devananda van der Veen | f35cf91 | 2012-11-12 17:58:38 -0800 | [diff] [blame] | 635 |  | 
| Kieran Spear | fb2a3ae | 2013-03-11 23:55:49 +0000 | [diff] [blame] | 636 | if is_service_enabled n-cell; then | 
|  | 637 | recreate_database $NOVA_CELLS_DB latin1 | 
|  | 638 | fi | 
|  | 639 |  | 
| Devananda van der Veen | f35cf91 | 2012-11-12 17:58:38 -0800 | [diff] [blame] | 640 | # (Re)create nova baremetal database | 
|  | 641 | if is_baremetal; then | 
|  | 642 | recreate_database nova_bm latin1 | 
|  | 643 | $NOVA_BIN_DIR/nova-baremetal-manage db sync | 
|  | 644 | fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 645 | fi | 
|  | 646 |  | 
| Dean Troyer | f03bafe | 2013-02-12 10:58:28 -0600 | [diff] [blame] | 647 | create_nova_cache_dir | 
|  | 648 | create_nova_keys_dir | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 649 | } | 
|  | 650 |  | 
|  | 651 | # install_novaclient() - Collect source and prepare | 
|  | 652 | function install_novaclient() { | 
|  | 653 | git_clone $NOVACLIENT_REPO $NOVACLIENT_DIR $NOVACLIENT_BRANCH | 
| Dean Troyer | 253a1a3 | 2013-04-01 18:23:22 -0500 | [diff] [blame] | 654 | setup_develop $NOVACLIENT_DIR | 
| Attila Fazekas | fac533e | 2013-08-14 16:04:01 +0200 | [diff] [blame] | 655 | sudo install -D -m 0644 -o $STACK_USER {$NOVACLIENT_DIR/tools/,/etc/bash_completion.d/}nova.bash_completion | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 656 | } | 
|  | 657 |  | 
|  | 658 | # install_nova() - Collect source and prepare | 
|  | 659 | function install_nova() { | 
|  | 660 | if is_service_enabled n-cpu; then | 
| Dean Troyer | 2aa2a89 | 2013-08-04 19:53:19 -0500 | [diff] [blame] | 661 | if [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then | 
|  | 662 | install_nova_hypervisor | 
|  | 663 | elif [[ "$VIRT_DRIVER" = 'libvirt' ]]; then | 
| Vincent Untz | c18b965 | 2012-12-04 12:36:34 +0100 | [diff] [blame] | 664 | if is_ubuntu; then | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 665 | install_package kvm | 
|  | 666 | install_package libvirt-bin | 
|  | 667 | install_package python-libvirt | 
|  | 668 | elif is_fedora || is_suse; then | 
|  | 669 | install_package kvm | 
|  | 670 | install_package libvirt | 
|  | 671 | install_package libvirt-python | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 672 | else | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 673 | exit_distro_not_supported "libvirt installation" | 
|  | 674 | fi | 
|  | 675 |  | 
|  | 676 | # Install and configure **LXC** if specified.  LXC is another approach to | 
|  | 677 | # splitting a system into many smaller parts.  LXC uses cgroups and chroot | 
|  | 678 | # to simulate multiple systems. | 
|  | 679 | if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then | 
|  | 680 | if is_ubuntu; then | 
|  | 681 | if [[ "$DISTRO" > natty ]]; then | 
|  | 682 | install_package cgroup-lite | 
|  | 683 | fi | 
|  | 684 | else | 
|  | 685 | ### FIXME(dtroyer): figure this out | 
|  | 686 | echo "RPM-based cgroup not implemented yet" | 
|  | 687 | yum_install libcgroup-tools | 
|  | 688 | fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 689 | fi | 
|  | 690 | fi | 
|  | 691 | fi | 
|  | 692 |  | 
|  | 693 | git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH | 
| Dean Troyer | 253a1a3 | 2013-04-01 18:23:22 -0500 | [diff] [blame] | 694 | setup_develop $NOVA_DIR | 
| Attila Fazekas | fac533e | 2013-08-14 16:04:01 +0200 | [diff] [blame] | 695 | sudo install -D -m 0644 -o $STACK_USER {$NOVA_DIR/tools/,/etc/bash_completion.d/}nova-manage.bash_completion | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 696 | } | 
|  | 697 |  | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 698 | # start_nova_api() - Start the API process ahead of other things | 
|  | 699 | function start_nova_api() { | 
|  | 700 | # Get right service port for testing | 
|  | 701 | local service_port=$NOVA_SERVICE_PORT | 
|  | 702 | if is_service_enabled tls-proxy; then | 
|  | 703 | service_port=$NOVA_SERVICE_PORT_INT | 
|  | 704 | fi | 
|  | 705 |  | 
|  | 706 | screen_it n-api "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-api" | 
|  | 707 | echo "Waiting for nova-api to start..." | 
|  | 708 | if ! wait_for_service $SERVICE_TIMEOUT http://$SERVICE_HOST:$service_port; then | 
| Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 709 | die $LINENO "nova-api did not start" | 
| Dean Troyer | 3a3a2ba | 2012-12-11 15:26:24 -0600 | [diff] [blame] | 710 | fi | 
|  | 711 |  | 
|  | 712 | # Start proxies if enabled | 
|  | 713 | if is_service_enabled tls-proxy; then | 
|  | 714 | start_tls_proxy '*' $NOVA_SERVICE_PORT $NOVA_SERVICE_HOST $NOVA_SERVICE_PORT_INT & | 
|  | 715 | fi | 
|  | 716 | } | 
|  | 717 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 718 | # start_nova() - Start running processes, including screen | 
|  | 719 | function start_nova() { | 
| Kieran Spear | fb2a3ae | 2013-03-11 23:55:49 +0000 | [diff] [blame] | 720 | NOVA_CONF_BOTTOM=$NOVA_CONF | 
|  | 721 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 722 | # ``screen_it`` checks ``is_service_enabled``, it is not needed here | 
| Russell Bryant | ff7f308 | 2012-11-29 22:00:51 -0500 | [diff] [blame] | 723 | screen_it n-cond "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-conductor" | 
| Kieran Spear | fb2a3ae | 2013-03-11 23:55:49 +0000 | [diff] [blame] | 724 |  | 
|  | 725 | if is_service_enabled n-cell; then | 
|  | 726 | NOVA_CONF_BOTTOM=$NOVA_CELLS_CONF | 
|  | 727 | screen_it n-cond "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-conductor --config-file $NOVA_CELLS_CONF" | 
| Chris Behrens | c62c2b9 | 2013-07-24 03:56:13 -0700 | [diff] [blame] | 728 | screen_it n-cell-region "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-cells --config-file $NOVA_CONF" | 
|  | 729 | screen_it n-cell-child "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-cells --config-file $NOVA_CELLS_CONF" | 
| Kieran Spear | fb2a3ae | 2013-03-11 23:55:49 +0000 | [diff] [blame] | 730 | fi | 
|  | 731 |  | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 732 | if [[ "$VIRT_DRIVER" = 'libvirt' ]]; then | 
|  | 733 | # The group **$LIBVIRT_GROUP** is added to the current user in this script. | 
|  | 734 | # Use 'sg' to execute nova-compute as a member of the **$LIBVIRT_GROUP** group. | 
|  | 735 | screen_it n-cpu "cd $NOVA_DIR && sg $LIBVIRT_GROUP '$NOVA_BIN_DIR/nova-compute --config-file $NOVA_CONF_BOTTOM'" | 
| Joe Gordon | 2c94ee5 | 2013-08-02 02:02:01 +0000 | [diff] [blame] | 736 | elif [[ "$VIRT_DRIVER" = 'fake' ]]; then | 
|  | 737 | for i in `seq 1 $NUMBER_FAKE_NOVA_COMPUTE` | 
|  | 738 | do | 
|  | 739 | screen_it n-cpu "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-compute --config-file $NOVA_CONF_BOTTOM" | 
|  | 740 | done | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 741 | else | 
| Dean Troyer | 2aa2a89 | 2013-08-04 19:53:19 -0500 | [diff] [blame] | 742 | if is_service_enabled n-cpu && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then | 
|  | 743 | start_nova_hypervisor | 
|  | 744 | fi | 
| Bob Ball | b1e49bf | 2013-05-30 16:47:19 +0100 | [diff] [blame] | 745 | screen_it n-cpu "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-compute --config-file $NOVA_CONF_BOTTOM" | 
|  | 746 | fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 747 | screen_it n-crt "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-cert" | 
| Kieran Spear | fb2a3ae | 2013-03-11 23:55:49 +0000 | [diff] [blame] | 748 | screen_it n-net "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-network --config-file $NOVA_CONF_BOTTOM" | 
|  | 749 | screen_it n-sch "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-scheduler --config-file $NOVA_CONF_BOTTOM" | 
|  | 750 | screen_it n-api-meta "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-api-metadata --config-file $NOVA_CONF_BOTTOM" | 
|  | 751 |  | 
| Daniel P. Berrange | 3edddd1 | 2013-01-03 12:06:47 +0000 | [diff] [blame] | 752 | 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] | 753 | 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] | 754 | 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] | 755 | screen_it n-cauth "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-consoleauth" | 
| Dean Troyer | 1c6c112 | 2013-03-27 17:40:53 -0500 | [diff] [blame] | 756 |  | 
|  | 757 | # Starting the nova-objectstore only if swift3 service is not enabled. | 
|  | 758 | # Swift will act as s3 objectstore. | 
|  | 759 | is_service_enabled swift3 || \ | 
|  | 760 | screen_it n-obj "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-objectstore" | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 761 | } | 
|  | 762 |  | 
|  | 763 | # stop_nova() - Stop running processes (non-screen) | 
|  | 764 | function stop_nova() { | 
|  | 765 | # Kill the nova screen windows | 
| Kieran Spear | fb2a3ae | 2013-03-11 23:55:49 +0000 | [diff] [blame] | 766 | # Some services are listed here twice since more than one instance | 
|  | 767 | # of a service may be running in certain configs. | 
|  | 768 | for serv in n-api n-cpu n-crt n-net n-sch n-novnc n-xvnc n-cauth n-spice n-cond n-cond n-cell n-cell n-api-meta; do | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 769 | screen -S $SCREEN_NAME -p $serv -X kill | 
|  | 770 | done | 
| Dean Troyer | 2aa2a89 | 2013-08-04 19:53:19 -0500 | [diff] [blame] | 771 | if is_service_enabled n-cpu && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then | 
|  | 772 | stop_nova_hypervisor | 
|  | 773 | fi | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 774 | } | 
|  | 775 |  | 
| Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 776 |  | 
| Dean Troyer | bf67c19 | 2012-09-21 15:09:37 -0500 | [diff] [blame] | 777 | # Restore xtrace | 
|  | 778 | $XTRACE | 
| Sean Dague | 584d90e | 2013-03-29 14:34:53 -0400 | [diff] [blame] | 779 |  | 
|  | 780 | # Local variables: | 
|  | 781 | # mode: shell-script | 
|  | 782 | # End: |