Browse code

Move Nova to lib/nova

The next in a line of changes to break down stack.sh and make
it a bit more manageable.

Part of blueprint devstack-modular

Change-Id: I3fae739996aad0b340dae72ef51acd669a3ab893

Dean Troyer authored on 2012/09/22 05:09:37
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,433 @@
0
+# lib/nova
1
+# Functions to control the configuration and operation of the XXXX service
2
+
3
+# Dependencies:
4
+# ``functions`` file
5
+# ``DEST``, ``DATA_DIR`` must be defined
6
+# ``SERVICE_{TENANT_NAME|PASSWORD}`` must be defined
7
+# ``LIBVIRT_TYPE`` must be defined
8
+# ``INSTANCE_NAME_PREFIX``, ``VOLUME_NAME_PREFIX`` must be defined
9
+
10
+# ``stack.sh`` calls the entry points in this order:
11
+#
12
+# install_nova
13
+# configure_nova
14
+# init_nova
15
+# start_nova
16
+# stop_nova
17
+# cleanup_nova
18
+
19
+# Save trace setting
20
+XTRACE=$(set +o | grep xtrace)
21
+set +o xtrace
22
+
23
+
24
+# Defaults
25
+# --------
26
+
27
+# Set up default directories
28
+NOVA_DIR=$DEST/nova
29
+NOVACLIENT_DIR=$DEST/python-novaclient
30
+NOVA_STATE_PATH=${NOVA_STATE_PATH:=$DATA_DIR/nova}
31
+# INSTANCES_PATH is the previous name for this
32
+NOVA_INSTANCES_PATH=${NOVA_INSTANCES_PATH:=${INSTANCES_PATH:=$NOVA_STATE_PATH/instances}}
33
+
34
+NOVA_CONF_DIR=/etc/nova
35
+NOVA_CONF=$NOVA_CONF_DIR/nova.conf
36
+NOVA_API_PASTE_INI=${NOVA_API_PASTE_INI:-$NOVA_CONF_DIR/api-paste.ini}
37
+
38
+# Support entry points installation of console scripts
39
+if [[ -d $NOVA_DIR/bin ]]; then
40
+    NOVA_BIN_DIR=$NOVA_DIR/bin
41
+else
42
+    NOVA_BIN_DIR=/usr/local/bin
43
+fi
44
+
45
+# Set the paths of certain binaries
46
+if [[ "$os_PACKAGE" = "deb" ]]; then
47
+    NOVA_ROOTWRAP=/usr/local/bin/nova-rootwrap
48
+else
49
+    NOVA_ROOTWRAP=/usr/bin/nova-rootwrap
50
+fi
51
+
52
+# Allow rate limiting to be turned off for testing, like for Tempest
53
+# NOTE: Set API_RATE_LIMIT="False" to turn OFF rate limiting
54
+API_RATE_LIMIT=${API_RATE_LIMIT:-"True"}
55
+
56
+# Nova supports pluggable schedulers.  The default ``FilterScheduler``
57
+# should work in most cases.
58
+SCHEDULER=${SCHEDULER:-nova.scheduler.filter_scheduler.FilterScheduler}
59
+
60
+QEMU_CONF=/etc/libvirt/qemu.conf
61
+
62
+
63
+# Entry Points
64
+# ------------
65
+
66
+function add_nova_opt {
67
+    echo "$1" >>$NOVA_CONF
68
+}
69
+
70
+# Helper to clean iptables rules
71
+function clean_iptables() {
72
+    # Delete rules
73
+    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
74
+    # Delete nat rules
75
+    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
76
+    # Delete chains
77
+    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
78
+    # Delete nat chains
79
+    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
80
+}
81
+
82
+# cleanup_nova() - Remove residual data files, anything left over from previous
83
+# runs that a clean run would need to clean up
84
+function cleanup_nova() {
85
+    if is_service_enabled n-cpu; then
86
+        # Clean iptables from previous runs
87
+        clean_iptables
88
+
89
+        # Destroy old instances
90
+        instances=`sudo virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"`
91
+        if [ ! "$instances" = "" ]; then
92
+            echo $instances | xargs -n1 sudo virsh destroy || true
93
+            echo $instances | xargs -n1 sudo virsh undefine || true
94
+        fi
95
+
96
+        # Logout and delete iscsi sessions
97
+        sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | xargs sudo iscsiadm --mode node --logout || true
98
+        sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | sudo iscsiadm --mode node --op delete || true
99
+
100
+        # Clean out the instances directory.
101
+        sudo rm -rf $NOVA_INSTANCES_PATH/*
102
+    fi
103
+}
104
+
105
+# configure_novaclient() - Set config files, create data dirs, etc
106
+function configure_novaclient() {
107
+    setup_develop $NOVACLIENT_DIR
108
+}
109
+
110
+# configure_nova_rootwrap() - configure Nova's rootwrap
111
+function configure_nova_rootwrap() {
112
+    # Deploy new rootwrap filters files (owned by root).
113
+    # Wipe any existing rootwrap.d files first
114
+    if [[ -d $NOVA_CONF_DIR/rootwrap.d ]]; then
115
+        sudo rm -rf $NOVA_CONF_DIR/rootwrap.d
116
+    fi
117
+    # Deploy filters to /etc/nova/rootwrap.d
118
+    sudo mkdir -m 755 $NOVA_CONF_DIR/rootwrap.d
119
+    sudo cp $NOVA_DIR/etc/nova/rootwrap.d/*.filters $NOVA_CONF_DIR/rootwrap.d
120
+    sudo chown -R root:root $NOVA_CONF_DIR/rootwrap.d
121
+    sudo chmod 644 $NOVA_CONF_DIR/rootwrap.d/*
122
+    # Set up rootwrap.conf, pointing to /etc/nova/rootwrap.d
123
+    sudo cp $NOVA_DIR/etc/nova/rootwrap.conf $NOVA_CONF_DIR/
124
+    sudo sed -e "s:^filters_path=.*$:filters_path=$NOVA_CONF_DIR/rootwrap.d:" -i $NOVA_CONF_DIR/rootwrap.conf
125
+    sudo chown root:root $NOVA_CONF_DIR/rootwrap.conf
126
+    sudo chmod 0644 $NOVA_CONF_DIR/rootwrap.conf
127
+    # Specify rootwrap.conf as first parameter to nova-rootwrap
128
+    ROOTWRAP_SUDOER_CMD="$NOVA_ROOTWRAP $NOVA_CONF_DIR/rootwrap.conf *"
129
+
130
+    # Set up the rootwrap sudoers for nova
131
+    TEMPFILE=`mktemp`
132
+    echo "$USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE
133
+    chmod 0440 $TEMPFILE
134
+    sudo chown root:root $TEMPFILE
135
+    sudo mv $TEMPFILE /etc/sudoers.d/nova-rootwrap
136
+}
137
+
138
+# configure_nova() - Set config files, create data dirs, etc
139
+function configure_nova() {
140
+    setup_develop $NOVA_DIR
141
+
142
+    # Put config files in ``/etc/nova`` for everyone to find
143
+    if [[ ! -d $NOVA_CONF_DIR ]]; then
144
+        sudo mkdir -p $NOVA_CONF_DIR
145
+    fi
146
+    sudo chown `whoami` $NOVA_CONF_DIR
147
+
148
+    cp -p $NOVA_DIR/etc/nova/policy.json $NOVA_CONF_DIR
149
+
150
+    configure_nova_rootwrap
151
+
152
+    if is_service_enabled n-api; then
153
+        # Use the sample http middleware configuration supplied in the
154
+        # Nova sources.  This paste config adds the configuration required
155
+        # for Nova to validate Keystone tokens.
156
+
157
+        # Remove legacy paste config if present
158
+        rm -f $NOVA_DIR/bin/nova-api-paste.ini
159
+
160
+        # Get the sample configuration file in place
161
+        cp $NOVA_DIR/etc/nova/api-paste.ini $NOVA_CONF_DIR
162
+
163
+        # Rewrite the authtoken configuration for our Keystone service.
164
+        # This is a bit defensive to allow the sample file some variance.
165
+        sed -e "
166
+            /^admin_token/i admin_tenant_name = $SERVICE_TENANT_NAME
167
+            /admin_tenant_name/s/^.*$/admin_tenant_name = $SERVICE_TENANT_NAME/;
168
+            /admin_user/s/^.*$/admin_user = nova/;
169
+            /admin_password/s/^.*$/admin_password = $SERVICE_PASSWORD/;
170
+            s,%SERVICE_TENANT_NAME%,$SERVICE_TENANT_NAME,g;
171
+            s,%SERVICE_TOKEN%,$SERVICE_TOKEN,g;
172
+        " -i $NOVA_API_PASTE_INI
173
+    fi
174
+
175
+    if is_service_enabled n-cpu; then
176
+        # Force IP forwarding on, just on case
177
+        sudo sysctl -w net.ipv4.ip_forward=1
178
+
179
+        # Attempt to load modules: network block device - used to manage qcow images
180
+        sudo modprobe nbd || true
181
+
182
+        # Check for kvm (hardware based virtualization).  If unable to initialize
183
+        # kvm, we drop back to the slower emulation mode (qemu).  Note: many systems
184
+        # come with hardware virtualization disabled in BIOS.
185
+        if [[ "$LIBVIRT_TYPE" == "kvm" ]]; then
186
+            sudo modprobe kvm || true
187
+            if [ ! -e /dev/kvm ]; then
188
+                echo "WARNING: Switching to QEMU"
189
+                LIBVIRT_TYPE=qemu
190
+                if which selinuxenabled 2>&1 > /dev/null && selinuxenabled; then
191
+                    # https://bugzilla.redhat.com/show_bug.cgi?id=753589
192
+                    sudo setsebool virt_use_execmem on
193
+                fi
194
+            fi
195
+        fi
196
+
197
+        # Install and configure **LXC** if specified.  LXC is another approach to
198
+        # splitting a system into many smaller parts.  LXC uses cgroups and chroot
199
+        # to simulate multiple systems.
200
+        if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
201
+            if [[ "$os_PACKAGE" = "deb" ]]; then
202
+                if [[ ! "$DISTRO" > natty ]]; then
203
+                    cgline="none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0"
204
+                    sudo mkdir -p /cgroup
205
+                    if ! grep -q cgroup /etc/fstab; then
206
+                        echo "$cgline" | sudo tee -a /etc/fstab
207
+                    fi
208
+                    if ! mount -n | grep -q cgroup; then
209
+                        sudo mount /cgroup
210
+                    fi
211
+                fi
212
+            fi
213
+        fi
214
+
215
+        if is_service_enabled quantum && [[ $Q_PLUGIN = "openvswitch" ]] && ! sudo grep -q '^cgroup_device_acl' $QEMU_CONF ; then
216
+            # Add /dev/net/tun to cgroup_device_acls, needed for type=ethernet interfaces
217
+            cat <<EOF | sudo tee -a $QEMU_CONF
218
+cgroup_device_acl = [
219
+    "/dev/null", "/dev/full", "/dev/zero",
220
+    "/dev/random", "/dev/urandom",
221
+    "/dev/ptmx", "/dev/kvm", "/dev/kqemu",
222
+    "/dev/rtc", "/dev/hpet","/dev/net/tun",
223
+]
224
+EOF
225
+        fi
226
+
227
+        if [[ "$os_PACKAGE" = "deb" ]]; then
228
+            LIBVIRT_DAEMON=libvirt-bin
229
+        else
230
+            # http://wiki.libvirt.org/page/SSHPolicyKitSetup
231
+            if ! grep ^libvirtd: /etc/group >/dev/null; then
232
+                sudo groupadd libvirtd
233
+            fi
234
+            sudo bash -c 'cat <<EOF >/etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla
235
+[libvirt Management Access]
236
+Identity=unix-group:libvirtd
237
+Action=org.libvirt.unix.manage
238
+ResultAny=yes
239
+ResultInactive=yes
240
+ResultActive=yes
241
+EOF'
242
+            LIBVIRT_DAEMON=libvirtd
243
+        fi
244
+
245
+        # The user that nova runs as needs to be member of **libvirtd** group otherwise
246
+        # nova-compute will be unable to use libvirt.
247
+        sudo usermod -a -G libvirtd `whoami`
248
+
249
+        # libvirt detects various settings on startup, as we potentially changed
250
+        # the system configuration (modules, filesystems), we need to restart
251
+        # libvirt to detect those changes.
252
+        restart_service $LIBVIRT_DAEMON
253
+
254
+
255
+        # Instance Storage
256
+        # ----------------
257
+
258
+        # Nova stores each instance in its own directory.
259
+        mkdir -p $NOVA_INSTANCES_PATH
260
+
261
+        # You can specify a different disk to be mounted and used for backing the
262
+        # virtual machines.  If there is a partition labeled nova-instances we
263
+        # mount it (ext filesystems can be labeled via e2label).
264
+        if [ -L /dev/disk/by-label/nova-instances ]; then
265
+            if ! mount -n | grep -q $NOVA_INSTANCES_PATH; then
266
+                sudo mount -L nova-instances $NOVA_INSTANCES_PATH
267
+                sudo chown -R `whoami` $NOVA_INSTANCES_PATH
268
+            fi
269
+        fi
270
+
271
+        # Clean up old instances
272
+        cleanup_nova
273
+    fi
274
+}
275
+
276
+# init_nova() - Initialize databases, etc.
277
+function init_nova() {
278
+    # Remove legacy ``nova.conf``
279
+    rm -f $NOVA_DIR/bin/nova.conf
280
+
281
+    # (Re)create ``nova.conf``
282
+    rm -f $NOVA_CONF_DIR/$NOVA_CONF
283
+    add_nova_opt "[DEFAULT]"
284
+    add_nova_opt "verbose=True"
285
+    add_nova_opt "auth_strategy=keystone"
286
+    add_nova_opt "allow_resize_to_same_host=True"
287
+    add_nova_opt "api_paste_config=$NOVA_API_PASTE_INI"
288
+    add_nova_opt "rootwrap_config=$NOVA_CONF_DIR/rootwrap.conf"
289
+    add_nova_opt "compute_scheduler_driver=$SCHEDULER"
290
+    add_nova_opt "dhcpbridge_flagfile=$NOVA_CONF_DIR/$NOVA_CONF"
291
+    add_nova_opt "force_dhcp_release=True"
292
+    add_nova_opt "fixed_range=$FIXED_RANGE"
293
+    add_nova_opt "s3_host=$SERVICE_HOST"
294
+    add_nova_opt "s3_port=$S3_SERVICE_PORT"
295
+    add_nova_opt "osapi_compute_extension=nova.api.openstack.compute.contrib.standard_extensions"
296
+    add_nova_opt "my_ip=$HOST_IP"
297
+    add_nova_opt "sql_connection=$BASE_SQL_CONN/nova?charset=utf8"
298
+    add_nova_opt "libvirt_type=$LIBVIRT_TYPE"
299
+    add_nova_opt "libvirt_cpu_mode=none"
300
+    add_nova_opt "instance_name_template=${INSTANCE_NAME_PREFIX}%08x"
301
+    add_nova_opt "image_service=nova.image.glance.GlanceImageService"
302
+
303
+    if is_service_enabled n-api; then
304
+        add_nova_opt "enabled_apis=$NOVA_ENABLED_APIS"
305
+    fi
306
+    if is_service_enabled n-vol; then
307
+        add_nova_opt "volume_api_class=nova.volume.api.API"
308
+        add_nova_opt "volume_group=$VOLUME_GROUP"
309
+        add_nova_opt "volume_name_template=${VOLUME_NAME_PREFIX}%s"
310
+        # oneiric no longer supports ietadm
311
+        add_nova_opt "iscsi_helper=tgtadm"
312
+    fi
313
+    if is_service_enabled cinder; then
314
+        add_nova_opt "volume_api_class=nova.volume.cinder.API"
315
+    fi
316
+    if [ -n "$NOVA_STATE_PATH" ]; then
317
+        add_nova_opt "state_path=$NOVA_STATE_PATH"
318
+    fi
319
+    if [ -n "$NOVA_INSTANCES_PATH" ]; then
320
+        add_nova_opt "instances_path=$NOVA_INSTANCES_PATH"
321
+    fi
322
+    if [ "$MULTI_HOST" != "False" ]; then
323
+        add_nova_opt "multi_host=True"
324
+        add_nova_opt "send_arp_for_ha=True"
325
+    fi
326
+    if [ "$SYSLOG" != "False" ]; then
327
+        add_nova_opt "use_syslog=True"
328
+    fi
329
+    if [ "$API_RATE_LIMIT" != "True" ]; then
330
+        add_nova_opt "api_rate_limit=False"
331
+    fi
332
+    if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
333
+        # Add color to logging output
334
+        add_nova_opt "logging_context_format_string=%(asctime)s %(color)s%(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s%(color)s] %(instance)s%(color)s%(message)s"
335
+        add_nova_opt "logging_default_format_string=%(asctime)s %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s"
336
+        add_nova_opt "logging_debug_format_suffix=from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d"
337
+        add_nova_opt "logging_exception_prefix=%(color)s%(asctime)s TRACE %(name)s %(instance)s"
338
+    else
339
+        # Show user_name and project_name instead of user_id and project_id
340
+        add_nova_opt "logging_context_format_string=%(asctime)s %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s"
341
+    fi
342
+
343
+    # Provide some transition from ``EXTRA_FLAGS`` to ``EXTRA_OPTS``
344
+    if [[ -z "$EXTRA_OPTS" && -n "$EXTRA_FLAGS" ]]; then
345
+        EXTRA_OPTS=$EXTRA_FLAGS
346
+    fi
347
+
348
+    # Define extra nova conf flags by defining the array ``EXTRA_OPTS``.
349
+    # For Example: ``EXTRA_OPTS=(foo=true bar=2)``
350
+    for I in "${EXTRA_OPTS[@]}"; do
351
+        # Attempt to convert flags to options
352
+        add_nova_opt ${I//--}
353
+    done
354
+
355
+    # Nova Database
356
+    # -------------
357
+
358
+    # All nova components talk to a central database.  We will need to do this step
359
+    # only once for an entire cluster.
360
+
361
+    if is_service_enabled mysql && is_service_enabled nova; then
362
+        # (Re)create nova database
363
+        mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS nova;'
364
+
365
+        # Explicitly use latin1: to avoid lp#829209, nova expects the database to
366
+        # use latin1 by default, and then upgrades the database to utf8 (see the
367
+        # 082_essex.py in nova)
368
+        mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE nova CHARACTER SET latin1;'
369
+
370
+        # (Re)create nova database
371
+        $NOVA_BIN_DIR/nova-manage db sync
372
+    fi
373
+
374
+}
375
+
376
+# install_novaclient() - Collect source and prepare
377
+function install_novaclient() {
378
+    git_clone $NOVACLIENT_REPO $NOVACLIENT_DIR $NOVACLIENT_BRANCH
379
+}
380
+
381
+# install_nova() - Collect source and prepare
382
+function install_nova() {
383
+    if is_service_enabled n-cpu; then
384
+        if [[ "$os_PACKAGE" = "deb" ]]; then
385
+            LIBVIRT_PKG_NAME=libvirt-bin
386
+        else
387
+            LIBVIRT_PKG_NAME=libvirt
388
+        fi
389
+        install_package $LIBVIRT_PKG_NAME
390
+        # Install and configure **LXC** if specified.  LXC is another approach to
391
+        # splitting a system into many smaller parts.  LXC uses cgroups and chroot
392
+        # to simulate multiple systems.
393
+        if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
394
+            if [[ "$os_PACKAGE" = "deb" ]]; then
395
+                if [[ "$DISTRO" > natty ]]; then
396
+                    install_package cgroup-lite
397
+                fi
398
+            else
399
+                ### FIXME(dtroyer): figure this out
400
+                echo "RPM-based cgroup not implemented yet"
401
+                yum_install libcgroup-tools
402
+            fi
403
+        fi
404
+    fi
405
+
406
+    git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH
407
+}
408
+
409
+# start_nova() - Start running processes, including screen
410
+function start_nova() {
411
+    # The group **libvirtd** is added to the current user in this script.
412
+    # Use 'sg' to execute nova-compute as a member of the **libvirtd** group.
413
+    # ``screen_it`` checks ``is_service_enabled``, it is not needed here
414
+    screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_BIN_DIR/nova-compute"
415
+    screen_it n-crt "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-cert"
416
+    screen_it n-net "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-network"
417
+    screen_it n-sch "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-scheduler"
418
+    screen_it n-novnc "cd $NOVNC_DIR && ./utils/nova-novncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF --web ."
419
+    screen_it n-xvnc "cd $NOVA_DIR && ./bin/nova-xvpvncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF"
420
+    screen_it n-cauth "cd $NOVA_DIR && ./bin/nova-consoleauth"
421
+}
422
+
423
+# stop_nova() - Stop running processes (non-screen)
424
+function stop_nova() {
425
+    # Kill the nova screen windows
426
+    for serv in n-api n-cpu n-crt n-net n-sch n-novnc n-xvnc n-cauth; do
427
+        screen -S $SCREEN_NAME -p $serv -X kill
428
+    done
429
+}
430
+
431
+# Restore xtrace
432
+$XTRACE
... ...
@@ -112,13 +112,6 @@ if [ "${DISTRO}" = "oneiric" ] && is_service_enabled qpid ; then
112 112
     exit 1
113 113
 fi
114 114
 
115
-# Set the paths of certain binaries
116
-if [[ "$os_PACKAGE" = "deb" ]]; then
117
-    NOVA_ROOTWRAP=/usr/local/bin/nova-rootwrap
118
-else
119
-    NOVA_ROOTWRAP=/usr/bin/nova-rootwrap
120
-fi
121
-
122 115
 # ``stack.sh`` keeps function libraries here
123 116
 # Make sure ``$TOP_DIR/lib`` directory is present
124 117
 if [ ! -d $TOP_DIR/lib ]; then
... ...
@@ -314,6 +307,7 @@ SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}
314 314
 # Get project function libraries
315 315
 source $TOP_DIR/lib/keystone
316 316
 source $TOP_DIR/lib/glance
317
+source $TOP_DIR/lib/nova
317 318
 source $TOP_DIR/lib/cinder
318 319
 source $TOP_DIR/lib/n-vol
319 320
 source $TOP_DIR/lib/ceilometer
... ...
@@ -330,20 +324,6 @@ SWIFTCLIENT_DIR=$DEST/python-swiftclient
330 330
 QUANTUM_DIR=$DEST/quantum
331 331
 QUANTUM_CLIENT_DIR=$DEST/python-quantumclient
332 332
 
333
-# Nova defaults
334
-NOVA_DIR=$DEST/nova
335
-NOVACLIENT_DIR=$DEST/python-novaclient
336
-NOVA_STATE_PATH=${NOVA_STATE_PATH:=$DATA_DIR/nova}
337
-# INSTANCES_PATH is the previous name for this
338
-NOVA_INSTANCES_PATH=${NOVA_INSTANCES_PATH:=${INSTANCES_PATH:=$NOVA_STATE_PATH/instances}}
339
-
340
-# Support entry points installation of console scripts
341
-if [[ -d $NOVA_DIR/bin ]]; then
342
-    NOVA_BIN_DIR=$NOVA_DIR/bin
343
-else
344
-    NOVA_BIN_DIR=/usr/local/bin
345
-fi
346
-
347 333
 # Default Quantum Plugin
348 334
 Q_PLUGIN=${Q_PLUGIN:-openvswitch}
349 335
 # Default Quantum Port
... ...
@@ -366,10 +346,6 @@ VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes}
366 366
 VOLUME_NAME_PREFIX=${VOLUME_NAME_PREFIX:-volume-}
367 367
 INSTANCE_NAME_PREFIX=${INSTANCE_NAME_PREFIX:-instance-}
368 368
 
369
-# Nova supports pluggable schedulers.  The default ``FilterScheduler``
370
-# should work in most cases.
371
-SCHEDULER=${SCHEDULER:-nova.scheduler.filter_scheduler.FilterScheduler}
372
-
373 369
 # Generic helper to configure passwords
374 370
 function read_password {
375 371
     XTRACE=$(set +o | grep xtrace)
... ...
@@ -813,30 +789,6 @@ if is_service_enabled q-agt; then
813 813
     fi
814 814
 fi
815 815
 
816
-if is_service_enabled n-cpu; then
817
-
818
-    if [[ "$os_PACKAGE" = "deb" ]]; then
819
-        LIBVIRT_PKG_NAME=libvirt-bin
820
-    else
821
-        LIBVIRT_PKG_NAME=libvirt
822
-    fi
823
-    install_package $LIBVIRT_PKG_NAME
824
-    # Install and configure **LXC** if specified.  LXC is another approach to
825
-    # splitting a system into many smaller parts.  LXC uses cgroups and chroot
826
-    # to simulate multiple systems.
827
-    if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
828
-        if [[ "$os_PACKAGE" = "deb" ]]; then
829
-            if [[ "$DISTRO" > natty ]]; then
830
-                install_package cgroup-lite
831
-            fi
832
-        else
833
-            ### FIXME(dtroyer): figure this out
834
-            echo "RPM-based cgroup not implemented yet"
835
-            yum_install libcgroup-tools
836
-        fi
837
-    fi
838
-fi
839
-
840 816
 if is_service_enabled swift; then
841 817
     # Install memcached for swift.
842 818
     install_package memcached
... ...
@@ -867,11 +819,9 @@ echo_summary "Installing OpenStack project source"
867 867
 
868 868
 install_keystoneclient
869 869
 install_glanceclient
870
-
871
-git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH
870
+install_novaclient
872 871
 
873 872
 # Check out the client libs that are used most
874
-git_clone $NOVACLIENT_REPO $NOVACLIENT_DIR $NOVACLIENT_BRANCH
875 873
 git_clone $OPENSTACKCLIENT_REPO $OPENSTACKCLIENT_DIR $OPENSTACKCLIENT_BRANCH
876 874
 
877 875
 # glance, swift middleware and nova api needs keystone middleware
... ...
@@ -893,6 +843,10 @@ if is_service_enabled g-api n-api; then
893 893
     # image catalog service
894 894
     install_glance
895 895
 fi
896
+if is_service_enabled nova; then
897
+    # compute service
898
+    install_nova
899
+fi
896 900
 if is_service_enabled n-novnc; then
897 901
     # a websockets/html5 or flash powered VNC console for vm instances
898 902
     git_clone $NOVNC_REPO $NOVNC_DIR $NOVNC_BRANCH
... ...
@@ -927,7 +881,7 @@ echo_summary "Configuring OpenStack projects"
927 927
 # Set up our checkouts so they are installed into python path
928 928
 # allowing ``import nova`` or ``import glance.client``
929 929
 configure_keystoneclient
930
-setup_develop $NOVACLIENT_DIR
930
+configure_novaclient
931 931
 setup_develop $OPENSTACKCLIENT_DIR
932 932
 if is_service_enabled key g-api n-api swift; then
933 933
     configure_keystone
... ...
@@ -947,7 +901,9 @@ fi
947 947
 # TODO(dtroyer): figure out when this is no longer necessary
948 948
 configure_glanceclient
949 949
 
950
-setup_develop $NOVA_DIR
950
+if is_service_enabled nova; then
951
+    configure_nova
952
+fi
951 953
 if is_service_enabled horizon; then
952 954
     setup_develop $HORIZON_DIR
953 955
 fi
... ...
@@ -1486,195 +1442,9 @@ fi
1486 1486
 # Nova
1487 1487
 # ----
1488 1488
 
1489
-echo_summary "Configuring Nova"
1490
-
1491
-# Put config files in ``/etc/nova`` for everyone to find
1492
-NOVA_CONF_DIR=/etc/nova
1493
-if [[ ! -d $NOVA_CONF_DIR ]]; then
1494
-    sudo mkdir -p $NOVA_CONF_DIR
1495
-fi
1496
-sudo chown `whoami` $NOVA_CONF_DIR
1497
-
1498
-cp -p $NOVA_DIR/etc/nova/policy.json $NOVA_CONF_DIR
1499
-
1500
-# Deploy new rootwrap filters files (owned by root).
1501
-# Wipe any existing rootwrap.d files first
1502
-if [[ -d $NOVA_CONF_DIR/rootwrap.d ]]; then
1503
-    sudo rm -rf $NOVA_CONF_DIR/rootwrap.d
1504
-fi
1505
-# Deploy filters to /etc/nova/rootwrap.d
1506
-sudo mkdir -m 755 $NOVA_CONF_DIR/rootwrap.d
1507
-sudo cp $NOVA_DIR/etc/nova/rootwrap.d/*.filters $NOVA_CONF_DIR/rootwrap.d
1508
-sudo chown -R root:root $NOVA_CONF_DIR/rootwrap.d
1509
-sudo chmod 644 $NOVA_CONF_DIR/rootwrap.d/*
1510
-# Set up rootwrap.conf, pointing to /etc/nova/rootwrap.d
1511
-sudo cp $NOVA_DIR/etc/nova/rootwrap.conf $NOVA_CONF_DIR/
1512
-sudo sed -e "s:^filters_path=.*$:filters_path=$NOVA_CONF_DIR/rootwrap.d:" -i $NOVA_CONF_DIR/rootwrap.conf
1513
-sudo chown root:root $NOVA_CONF_DIR/rootwrap.conf
1514
-sudo chmod 0644 $NOVA_CONF_DIR/rootwrap.conf
1515
-# Specify rootwrap.conf as first parameter to nova-rootwrap
1516
-ROOTWRAP_SUDOER_CMD="$NOVA_ROOTWRAP $NOVA_CONF_DIR/rootwrap.conf *"
1517
-
1518
-# Set up the rootwrap sudoers for nova
1519
-TEMPFILE=`mktemp`
1520
-echo "$USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE
1521
-chmod 0440 $TEMPFILE
1522
-sudo chown root:root $TEMPFILE
1523
-sudo mv $TEMPFILE /etc/sudoers.d/nova-rootwrap
1524
-
1525
-if is_service_enabled n-api; then
1526
-    # Use the sample http middleware configuration supplied in the
1527
-    # Nova sources.  This paste config adds the configuration required
1528
-    # for Nova to validate Keystone tokens.
1529
-
1530
-    # Allow rate limiting to be turned off for testing, like for Tempest
1531
-    # NOTE: Set API_RATE_LIMIT="False" to turn OFF rate limiting
1532
-    API_RATE_LIMIT=${API_RATE_LIMIT:-"True"}
1533
-
1534
-    # Remove legacy paste config if present
1535
-    rm -f $NOVA_DIR/bin/nova-api-paste.ini
1536
-
1537
-    # Get the sample configuration file in place
1538
-    cp $NOVA_DIR/etc/nova/api-paste.ini $NOVA_CONF_DIR
1539
-
1540
-    # Rewrite the authtoken configuration for our Keystone service.
1541
-    # This is a bit defensive to allow the sample file some variance.
1542
-    sed -e "
1543
-        /^admin_token/i admin_tenant_name = $SERVICE_TENANT_NAME
1544
-        /admin_tenant_name/s/^.*$/admin_tenant_name = $SERVICE_TENANT_NAME/;
1545
-        /admin_user/s/^.*$/admin_user = nova/;
1546
-        /admin_password/s/^.*$/admin_password = $SERVICE_PASSWORD/;
1547
-        s,%SERVICE_TENANT_NAME%,$SERVICE_TENANT_NAME,g;
1548
-        s,%SERVICE_TOKEN%,$SERVICE_TOKEN,g;
1549
-    " -i $NOVA_CONF_DIR/api-paste.ini
1550
-fi
1551
-
1552
-# Helper to clean iptables rules
1553
-function clean_iptables() {
1554
-    # Delete rules
1555
-    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
1556
-    # Delete nat rules
1557
-    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
1558
-    # Delete chains
1559
-    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
1560
-    # Delete nat chains
1561
-    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
1562
-}
1563
-
1564
-if is_service_enabled n-cpu; then
1565
-
1566
-    # Force IP forwarding on, just on case
1567
-    sudo sysctl -w net.ipv4.ip_forward=1
1568
-
1569
-    # Attempt to load modules: network block device - used to manage qcow images
1570
-    sudo modprobe nbd || true
1571
-
1572
-    # Check for kvm (hardware based virtualization).  If unable to initialize
1573
-    # kvm, we drop back to the slower emulation mode (qemu).  Note: many systems
1574
-    # come with hardware virtualization disabled in BIOS.
1575
-    if [[ "$LIBVIRT_TYPE" == "kvm" ]]; then
1576
-        sudo modprobe kvm || true
1577
-        if [ ! -e /dev/kvm ]; then
1578
-            echo "WARNING: Switching to QEMU"
1579
-            LIBVIRT_TYPE=qemu
1580
-            if which selinuxenabled 2>&1 > /dev/null && selinuxenabled; then
1581
-                # https://bugzilla.redhat.com/show_bug.cgi?id=753589
1582
-                sudo setsebool virt_use_execmem on
1583
-            fi
1584
-        fi
1585
-    fi
1586
-
1587
-    # Install and configure **LXC** if specified.  LXC is another approach to
1588
-    # splitting a system into many smaller parts.  LXC uses cgroups and chroot
1589
-    # to simulate multiple systems.
1590
-    if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
1591
-        if [[ "$os_PACKAGE" = "deb" ]]; then
1592
-            if [[ ! "$DISTRO" > natty ]]; then
1593
-                cgline="none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0"
1594
-                sudo mkdir -p /cgroup
1595
-                if ! grep -q cgroup /etc/fstab; then
1596
-                    echo "$cgline" | sudo tee -a /etc/fstab
1597
-                fi
1598
-                if ! mount -n | grep -q cgroup; then
1599
-                    sudo mount /cgroup
1600
-                fi
1601
-            fi
1602
-        fi
1603
-    fi
1604
-
1605
-    QEMU_CONF=/etc/libvirt/qemu.conf
1606
-    if is_service_enabled quantum && [[ $Q_PLUGIN = "openvswitch" ]] && ! sudo grep -q '^cgroup_device_acl' $QEMU_CONF ; then
1607
-        # Add /dev/net/tun to cgroup_device_acls, needed for type=ethernet interfaces
1608
-        cat <<EOF | sudo tee -a $QEMU_CONF
1609
-cgroup_device_acl = [
1610
-    "/dev/null", "/dev/full", "/dev/zero",
1611
-    "/dev/random", "/dev/urandom",
1612
-    "/dev/ptmx", "/dev/kvm", "/dev/kqemu",
1613
-    "/dev/rtc", "/dev/hpet","/dev/net/tun",
1614
-]
1615
-EOF
1616
-    fi
1617
-
1618
-    if [[ "$os_PACKAGE" = "deb" ]]; then
1619
-        LIBVIRT_DAEMON=libvirt-bin
1620
-    else
1621
-        # http://wiki.libvirt.org/page/SSHPolicyKitSetup
1622
-        if ! grep ^libvirtd: /etc/group >/dev/null; then
1623
-            sudo groupadd libvirtd
1624
-        fi
1625
-        sudo bash -c 'cat <<EOF >/etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla
1626
-[libvirt Management Access]
1627
-Identity=unix-group:libvirtd
1628
-Action=org.libvirt.unix.manage
1629
-ResultAny=yes
1630
-ResultInactive=yes
1631
-ResultActive=yes
1632
-EOF'
1633
-        LIBVIRT_DAEMON=libvirtd
1634
-    fi
1635
-
1636
-    # The user that nova runs as needs to be member of **libvirtd** group otherwise
1637
-    # nova-compute will be unable to use libvirt.
1638
-    sudo usermod -a -G libvirtd `whoami`
1639
-
1640
-    # libvirt detects various settings on startup, as we potentially changed
1641
-    # the system configuration (modules, filesystems), we need to restart
1642
-    # libvirt to detect those changes.
1643
-    restart_service $LIBVIRT_DAEMON
1644
-
1645
-
1646
-    # Instance Storage
1647
-    # ~~~~~~~~~~~~~~~~
1648
-
1649
-    # Nova stores each instance in its own directory.
1650
-    mkdir -p $NOVA_INSTANCES_PATH
1651
-
1652
-    # You can specify a different disk to be mounted and used for backing the
1653
-    # virtual machines.  If there is a partition labeled nova-instances we
1654
-    # mount it (ext filesystems can be labeled via e2label).
1655
-    if [ -L /dev/disk/by-label/nova-instances ]; then
1656
-        if ! mount -n | grep -q $NOVA_INSTANCES_PATH; then
1657
-            sudo mount -L nova-instances $NOVA_INSTANCES_PATH
1658
-            sudo chown -R `whoami` $NOVA_INSTANCES_PATH
1659
-        fi
1660
-    fi
1661
-
1662
-    # Clean iptables from previous runs
1663
-    clean_iptables
1664
-
1665
-    # Destroy old instances
1666
-    instances=`sudo virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"`
1667
-    if [ ! "$instances" = "" ]; then
1668
-        echo $instances | xargs -n1 sudo virsh destroy || true
1669
-        echo $instances | xargs -n1 sudo virsh undefine || true
1670
-    fi
1671
-
1672
-    # Logout and delete iscsi sessions
1673
-    sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | xargs sudo iscsiadm --mode node --logout || true
1674
-    sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | sudo iscsiadm --mode node --op delete || true
1675
-
1676
-    # Clean out the instances directory.
1677
-    sudo rm -rf $NOVA_INSTANCES_PATH/*
1489
+if is_service_enabled nova; then
1490
+    echo_summary "Configuring Nova"
1491
+    configure_nova
1678 1492
 fi
1679 1493
 
1680 1494
 if is_service_enabled n-net q-dhcp; then
... ...
@@ -1955,26 +1725,12 @@ elif is_service_enabled n-vol; then
1955 1955
     init_nvol
1956 1956
 fi
1957 1957
 
1958
-NOVA_CONF=nova.conf
1959
-function add_nova_opt {
1960
-    echo "$1" >> $NOVA_CONF_DIR/$NOVA_CONF
1961
-}
1958
+if is_service_enabled nova; then
1959
+    echo_summary "Configuring Nova"
1960
+    init_nova
1961
+fi
1962 1962
 
1963
-# Remove legacy ``nova.conf``
1964
-rm -f $NOVA_DIR/bin/nova.conf
1965
-
1966
-# (Re)create ``nova.conf``
1967
-rm -f $NOVA_CONF_DIR/$NOVA_CONF
1968
-add_nova_opt "[DEFAULT]"
1969
-add_nova_opt "verbose=True"
1970
-add_nova_opt "auth_strategy=keystone"
1971
-add_nova_opt "allow_resize_to_same_host=True"
1972
-add_nova_opt "rootwrap_config=$NOVA_CONF_DIR/rootwrap.conf"
1973
-add_nova_opt "compute_scheduler_driver=$SCHEDULER"
1974
-add_nova_opt "dhcpbridge_flagfile=$NOVA_CONF_DIR/$NOVA_CONF"
1975
-add_nova_opt "fixed_range=$FIXED_RANGE"
1976
-add_nova_opt "s3_host=$SERVICE_HOST"
1977
-add_nova_opt "s3_port=$S3_SERVICE_PORT"
1963
+# Additional Nova configuration that is dependent on other services
1978 1964
 if is_service_enabled quantum; then
1979 1965
     add_nova_opt "network_api_class=nova.network.quantumv2.api.API"
1980 1966
     add_nova_opt "quantum_admin_username=$Q_ADMIN_USERNAME"
... ...
@@ -2000,18 +1756,6 @@ else
2000 2000
         add_nova_opt "flat_interface=$FLAT_INTERFACE"
2001 2001
     fi
2002 2002
 fi
2003
-if is_service_enabled n-vol; then
2004
-    add_nova_opt "volume_group=$VOLUME_GROUP"
2005
-    add_nova_opt "volume_name_template=${VOLUME_NAME_PREFIX}%s"
2006
-    # oneiric no longer supports ietadm
2007
-    add_nova_opt "iscsi_helper=tgtadm"
2008
-fi
2009
-add_nova_opt "osapi_compute_extension=nova.api.openstack.compute.contrib.standard_extensions"
2010
-add_nova_opt "my_ip=$HOST_IP"
2011
-add_nova_opt "sql_connection=$BASE_SQL_CONN/nova?charset=utf8"
2012
-add_nova_opt "libvirt_type=$LIBVIRT_TYPE"
2013
-add_nova_opt "libvirt_cpu_mode=none"
2014
-add_nova_opt "instance_name_template=${INSTANCE_NAME_PREFIX}%08x"
2015 2003
 # All nova-compute workers need to know the vnc configuration options
2016 2004
 # These settings don't hurt anything if n-xvnc and n-novnc are disabled
2017 2005
 if is_service_enabled n-cpu; then
... ...
@@ -2030,8 +1774,6 @@ fi
2030 2030
 VNCSERVER_LISTEN=${VNCSERVER_LISTEN=127.0.0.1}
2031 2031
 add_nova_opt "vncserver_listen=$VNCSERVER_LISTEN"
2032 2032
 add_nova_opt "vncserver_proxyclient_address=$VNCSERVER_PROXYCLIENT_ADDRESS"
2033
-add_nova_opt "api_paste_config=$NOVA_CONF_DIR/api-paste.ini"
2034
-add_nova_opt "image_service=nova.image.glance.GlanceImageService"
2035 2033
 add_nova_opt "ec2_dmz_host=$EC2_DMZ_HOST"
2036 2034
 if is_service_enabled zeromq; then
2037 2035
     add_nova_opt "rpc_backend=nova.openstack.common.rpc.impl_zmq"
... ...
@@ -2042,51 +1784,6 @@ elif [ -n "$RABBIT_HOST" ] &&  [ -n "$RABBIT_PASSWORD" ]; then
2042 2042
     add_nova_opt "rabbit_password=$RABBIT_PASSWORD"
2043 2043
 fi
2044 2044
 add_nova_opt "glance_api_servers=$GLANCE_HOSTPORT"
2045
-add_nova_opt "force_dhcp_release=True"
2046
-if [ -n "$NOVA_STATE_PATH" ]; then
2047
-    add_nova_opt "state_path=$NOVA_STATE_PATH"
2048
-fi
2049
-if [ -n "$NOVA_INSTANCES_PATH" ]; then
2050
-    add_nova_opt "instances_path=$NOVA_INSTANCES_PATH"
2051
-fi
2052
-if [ "$MULTI_HOST" != "False" ]; then
2053
-    add_nova_opt "multi_host=True"
2054
-    add_nova_opt "send_arp_for_ha=True"
2055
-fi
2056
-if [ "$SYSLOG" != "False" ]; then
2057
-    add_nova_opt "use_syslog=True"
2058
-fi
2059
-if [ "$API_RATE_LIMIT" != "True" ]; then
2060
-    add_nova_opt "api_rate_limit=False"
2061
-fi
2062
-if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
2063
-    # Add color to logging output
2064
-    add_nova_opt "logging_context_format_string=%(asctime)s %(color)s%(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s%(color)s] %(instance)s%(color)s%(message)s"
2065
-    add_nova_opt "logging_default_format_string=%(asctime)s %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s"
2066
-    add_nova_opt "logging_debug_format_suffix=from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d"
2067
-    add_nova_opt "logging_exception_prefix=%(color)s%(asctime)s TRACE %(name)s %(instance)s"
2068
-else
2069
-    # Show user_name and project_name instead of user_id and project_id
2070
-    add_nova_opt "logging_context_format_string=%(asctime)s %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s"
2071
-fi
2072
-
2073
-# If cinder is enabled, use the cinder volume driver
2074
-if is_service_enabled cinder; then
2075
-    add_nova_opt "volume_api_class=nova.volume.cinder.API"
2076
-fi
2077
-
2078
-# Provide some transition from ``EXTRA_FLAGS`` to ``EXTRA_OPTS``
2079
-if [[ -z "$EXTRA_OPTS" && -n "$EXTRA_FLAGS" ]]; then
2080
-    EXTRA_OPTS=$EXTRA_FLAGS
2081
-fi
2082
-
2083
-# Define extra nova conf flags by defining the array ``EXTRA_OPTS``.
2084
-# For Example: ``EXTRA_OPTS=(foo=true bar=2)``
2085
-for I in "${EXTRA_OPTS[@]}"; do
2086
-    # Attempt to convert flags to options
2087
-    add_nova_opt ${I//--}
2088
-done
2089
-
2090 2045
 
2091 2046
 # XenServer
2092 2047
 # ---------
... ...
@@ -2120,26 +1817,6 @@ else
2120 2120
 fi
2121 2121
 
2122 2122
 
2123
-# Nova Database
2124
-# -------------
2125
-
2126
-# All nova components talk to a central database.  We will need to do this step
2127
-# only once for an entire cluster.
2128
-
2129
-if is_service_enabled mysql && is_service_enabled nova; then
2130
-    # (Re)create nova database
2131
-    mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'DROP DATABASE IF EXISTS nova;'
2132
-
2133
-    # Explicitly use latin1: to avoid lp#829209, nova expects the database to
2134
-    # use latin1 by default, and then upgrades the database to utf8 (see the
2135
-    # 082_essex.py in nova)
2136
-    mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE nova CHARACTER SET latin1;'
2137
-
2138
-    # (Re)create nova database
2139
-    $NOVA_BIN_DIR/nova-manage db sync
2140
-fi
2141
-
2142
-
2143 2123
 # Heat
2144 2124
 # ----
2145 2125
 
... ...
@@ -2152,8 +1829,6 @@ fi
2152 2152
 # Launch Services
2153 2153
 # ===============
2154 2154
 
2155
-# Nova api crashes if we start it with a regular screen command,
2156
-# so send the start command by forcing text into the window.
2157 2155
 # Only run the services specified in ``ENABLED_SERVICES``
2158 2156
 
2159 2157
 # Launch the Glance services
... ...
@@ -2179,7 +1854,6 @@ screen_it zeromq "cd $NOVA_DIR && $NOVA_DIR/bin/nova-rpc-zmq-receiver"
2179 2179
 # Launch the nova-api and wait for it to answer before continuing
2180 2180
 if is_service_enabled n-api; then
2181 2181
     echo_summary "Starting Nova API"
2182
-    add_nova_opt "enabled_apis=$NOVA_ENABLED_APIS"
2183 2182
     screen_it n-api "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-api"
2184 2183
     echo "Waiting for nova-api to start..."
2185 2184
     if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://127.0.0.1:8774; do sleep 1; done"; then
... ...
@@ -2243,17 +1917,10 @@ screen_it q-agt "python $AGENT_BINARY --config-file $Q_CONF_FILE --config-file /
2243 2243
 screen_it q-dhcp "python $AGENT_DHCP_BINARY --config-file $Q_CONF_FILE --config-file=$Q_DHCP_CONF_FILE"
2244 2244
 screen_it q-l3 "python $AGENT_L3_BINARY --config-file $Q_CONF_FILE --config-file=$Q_L3_CONF_FILE"
2245 2245
 
2246
-echo_summary "Starting Nova"
2247
-# The group **libvirtd** is added to the current user in this script.
2248
-# Use 'sg' to execute nova-compute as a member of the **libvirtd** group.
2249
-# ``screen_it`` checks ``is_service_enabled``, it is not needed here
2250
-screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_BIN_DIR/nova-compute"
2251
-screen_it n-crt "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-cert"
2252
-screen_it n-net "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-network"
2253
-screen_it n-sch "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-scheduler"
2254
-screen_it n-novnc "cd $NOVNC_DIR && ./utils/nova-novncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF --web ."
2255
-screen_it n-xvnc "cd $NOVA_DIR && ./bin/nova-xvpvncproxy --config-file $NOVA_CONF_DIR/$NOVA_CONF"
2256
-screen_it n-cauth "cd $NOVA_DIR && ./bin/nova-consoleauth"
2246
+if is_service_enabled nova; then
2247
+    echo_summary "Starting Nova"
2248
+    start_nova
2249
+fi
2257 2250
 if is_service_enabled n-vol; then
2258 2251
     echo_summary "Starting Nova volumes"
2259 2252
     start_nvol