blob: 095c65efbd9bafe736e56c7353729acbaa6a5723 [file] [log] [blame]
Dean Troyerbf67c192012-09-21 15:09:37 -05001# lib/nova
2# Functions to control the configuration and operation of the XXXX service
3
4# Dependencies:
5# ``functions`` file
6# ``DEST``, ``DATA_DIR`` must be defined
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 Troyerbc071bc2012-10-01 14:06:44 -050010# ``KEYSTONE_TOKEN_FORMAT`` must be defined
Dean Troyerbf67c192012-09-21 15:09:37 -050011
12# ``stack.sh`` calls the entry points in this order:
13#
14# install_nova
15# configure_nova
Dean Troyerda7b8092012-10-08 18:12:14 -050016# create_nova_conf
Dean Troyerbf67c192012-09-21 15:09:37 -050017# init_nova
18# start_nova
19# stop_nova
20# cleanup_nova
21
22# Save trace setting
23XTRACE=$(set +o | grep xtrace)
24set +o xtrace
25
26
27# Defaults
28# --------
29
30# Set up default directories
31NOVA_DIR=$DEST/nova
32NOVACLIENT_DIR=$DEST/python-novaclient
33NOVA_STATE_PATH=${NOVA_STATE_PATH:=$DATA_DIR/nova}
34# INSTANCES_PATH is the previous name for this
35NOVA_INSTANCES_PATH=${NOVA_INSTANCES_PATH:=${INSTANCES_PATH:=$NOVA_STATE_PATH/instances}}
Dean Troyerbc071bc2012-10-01 14:06:44 -050036NOVA_AUTH_CACHE_DIR=${NOVA_AUTH_CACHE_DIR:-/var/cache/nova}
Dean Troyerbf67c192012-09-21 15:09:37 -050037
38NOVA_CONF_DIR=/etc/nova
39NOVA_CONF=$NOVA_CONF_DIR/nova.conf
40NOVA_API_PASTE_INI=${NOVA_API_PASTE_INI:-$NOVA_CONF_DIR/api-paste.ini}
41
42# Support entry points installation of console scripts
43if [[ -d $NOVA_DIR/bin ]]; then
44 NOVA_BIN_DIR=$NOVA_DIR/bin
45else
46 NOVA_BIN_DIR=/usr/local/bin
47fi
48
49# Set the paths of certain binaries
Vincent Untz856a11e2012-11-21 16:04:12 +010050NOVA_ROOTWRAP=$(get_rootwrap_location nova)
Dean Troyerbf67c192012-09-21 15:09:37 -050051
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
54API_RATE_LIMIT=${API_RATE_LIMIT:-"True"}
55
56# Nova supports pluggable schedulers. The default ``FilterScheduler``
57# should work in most cases.
58SCHEDULER=${SCHEDULER:-nova.scheduler.filter_scheduler.FilterScheduler}
59
60QEMU_CONF=/etc/libvirt/qemu.conf
61
62
63# Entry Points
64# ------------
65
66function add_nova_opt {
67 echo "$1" >>$NOVA_CONF
68}
69
70# Helper to clean iptables rules
71function 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
84function 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
106function configure_novaclient() {
107 setup_develop $NOVACLIENT_DIR
108}
109
110# configure_nova_rootwrap() - configure Nova's rootwrap
111function 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
139function 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
Dean Troyerbc071bc2012-10-01 14:06:44 -0500175 if [[ "$KEYSTONE_TOKEN_FORMAT" == "PKI" ]]; then
176 iniset $NOVA_API_PASTE_INI filter:authtoken signing_dir $NOVA_AUTH_CACHE_DIR
177 fi
178
Dean Troyerbf67c192012-09-21 15:09:37 -0500179 if is_service_enabled n-cpu; then
180 # Force IP forwarding on, just on case
181 sudo sysctl -w net.ipv4.ip_forward=1
182
183 # Attempt to load modules: network block device - used to manage qcow images
184 sudo modprobe nbd || true
185
186 # Check for kvm (hardware based virtualization). If unable to initialize
187 # kvm, we drop back to the slower emulation mode (qemu). Note: many systems
188 # come with hardware virtualization disabled in BIOS.
189 if [[ "$LIBVIRT_TYPE" == "kvm" ]]; then
190 sudo modprobe kvm || true
191 if [ ! -e /dev/kvm ]; then
192 echo "WARNING: Switching to QEMU"
193 LIBVIRT_TYPE=qemu
194 if which selinuxenabled 2>&1 > /dev/null && selinuxenabled; then
195 # https://bugzilla.redhat.com/show_bug.cgi?id=753589
196 sudo setsebool virt_use_execmem on
197 fi
198 fi
199 fi
200
201 # Install and configure **LXC** if specified. LXC is another approach to
202 # splitting a system into many smaller parts. LXC uses cgroups and chroot
203 # to simulate multiple systems.
204 if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
Vincent Untzc18b9652012-12-04 12:36:34 +0100205 if is_ubuntu; then
Dean Troyerbf67c192012-09-21 15:09:37 -0500206 if [[ ! "$DISTRO" > natty ]]; then
207 cgline="none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0"
208 sudo mkdir -p /cgroup
209 if ! grep -q cgroup /etc/fstab; then
210 echo "$cgline" | sudo tee -a /etc/fstab
211 fi
212 if ! mount -n | grep -q cgroup; then
213 sudo mount /cgroup
214 fi
215 fi
216 fi
217 fi
218
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000219 if is_service_enabled quantum && is_quantum_ovs_base_plugin "$Q_PLUGIN" && ! sudo grep -q '^cgroup_device_acl' $QEMU_CONF ; then
Dean Troyerbf67c192012-09-21 15:09:37 -0500220 # Add /dev/net/tun to cgroup_device_acls, needed for type=ethernet interfaces
221 cat <<EOF | sudo tee -a $QEMU_CONF
222cgroup_device_acl = [
223 "/dev/null", "/dev/full", "/dev/zero",
224 "/dev/random", "/dev/urandom",
225 "/dev/ptmx", "/dev/kvm", "/dev/kqemu",
226 "/dev/rtc", "/dev/hpet","/dev/net/tun",
227]
228EOF
229 fi
230
Vincent Untzc18b9652012-12-04 12:36:34 +0100231 if is_ubuntu; then
Dean Troyerbf67c192012-09-21 15:09:37 -0500232 LIBVIRT_DAEMON=libvirt-bin
233 else
234 # http://wiki.libvirt.org/page/SSHPolicyKitSetup
Vincent Untz3ab927c2012-12-05 16:15:26 +0100235 if ! getent group libvirtd >/dev/null; then
Dean Troyerbf67c192012-09-21 15:09:37 -0500236 sudo groupadd libvirtd
237 fi
238 sudo bash -c 'cat <<EOF >/etc/polkit-1/localauthority/50-local.d/50-libvirt-remote-access.pkla
239[libvirt Management Access]
240Identity=unix-group:libvirtd
241Action=org.libvirt.unix.manage
242ResultAny=yes
243ResultInactive=yes
244ResultActive=yes
245EOF'
246 LIBVIRT_DAEMON=libvirtd
247 fi
248
249 # The user that nova runs as needs to be member of **libvirtd** group otherwise
250 # nova-compute will be unable to use libvirt.
Vincent Untz856a11e2012-11-21 16:04:12 +0100251 add_user_to_group `whoami` libvirtd
Dean Troyerbf67c192012-09-21 15:09:37 -0500252
253 # libvirt detects various settings on startup, as we potentially changed
254 # the system configuration (modules, filesystems), we need to restart
255 # libvirt to detect those changes.
256 restart_service $LIBVIRT_DAEMON
257
258
259 # Instance Storage
260 # ----------------
261
262 # Nova stores each instance in its own directory.
263 mkdir -p $NOVA_INSTANCES_PATH
264
265 # You can specify a different disk to be mounted and used for backing the
266 # virtual machines. If there is a partition labeled nova-instances we
267 # mount it (ext filesystems can be labeled via e2label).
268 if [ -L /dev/disk/by-label/nova-instances ]; then
269 if ! mount -n | grep -q $NOVA_INSTANCES_PATH; then
270 sudo mount -L nova-instances $NOVA_INSTANCES_PATH
271 sudo chown -R `whoami` $NOVA_INSTANCES_PATH
272 fi
273 fi
274
275 # Clean up old instances
276 cleanup_nova
277 fi
278}
279
Dean Troyera0dce262012-12-11 16:52:37 -0600280# create_nova_accounts() - Set up common required nova accounts
281
282# Tenant User Roles
283# ------------------------------------------------------------------
284# service nova admin, [ResellerAdmin (swift only)]
285
286# Migrated from keystone_data.sh
287create_nova_accounts() {
288
289 SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
290 ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
291
292 # Nova
293 if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
294 NOVA_USER=$(keystone user-create \
295 --name=nova \
296 --pass="$SERVICE_PASSWORD" \
297 --tenant_id $SERVICE_TENANT \
298 --email=nova@example.com \
299 | grep " id " | get_field 2)
300 keystone user-role-add \
301 --tenant_id $SERVICE_TENANT \
302 --user_id $NOVA_USER \
303 --role_id $ADMIN_ROLE
304 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
305 NOVA_SERVICE=$(keystone service-create \
306 --name=nova \
307 --type=compute \
308 --description="Nova Compute Service" \
309 | grep " id " | get_field 2)
310 keystone endpoint-create \
311 --region RegionOne \
312 --service_id $NOVA_SERVICE \
313 --publicurl "http://$SERVICE_HOST:\$(compute_port)s/v2/\$(tenant_id)s" \
314 --adminurl "http://$SERVICE_HOST:\$(compute_port)s/v2/\$(tenant_id)s" \
315 --internalurl "http://$SERVICE_HOST:\$(compute_port)s/v2/\$(tenant_id)s"
316 fi
317 fi
318}
319
Dean Troyerda7b8092012-10-08 18:12:14 -0500320# create_nova_conf() - Create a new nova.conf file
321function create_nova_conf() {
Dean Troyerbf67c192012-09-21 15:09:37 -0500322 # Remove legacy ``nova.conf``
323 rm -f $NOVA_DIR/bin/nova.conf
324
325 # (Re)create ``nova.conf``
Dean Troyer3cf1ffb2012-10-02 11:51:27 -0500326 rm -f $NOVA_CONF
Dean Troyerbf67c192012-09-21 15:09:37 -0500327 add_nova_opt "[DEFAULT]"
328 add_nova_opt "verbose=True"
329 add_nova_opt "auth_strategy=keystone"
330 add_nova_opt "allow_resize_to_same_host=True"
331 add_nova_opt "api_paste_config=$NOVA_API_PASTE_INI"
332 add_nova_opt "rootwrap_config=$NOVA_CONF_DIR/rootwrap.conf"
333 add_nova_opt "compute_scheduler_driver=$SCHEDULER"
Dean Troyer3cf1ffb2012-10-02 11:51:27 -0500334 add_nova_opt "dhcpbridge_flagfile=$NOVA_CONF"
Dean Troyerbf67c192012-09-21 15:09:37 -0500335 add_nova_opt "force_dhcp_release=True"
336 add_nova_opt "fixed_range=$FIXED_RANGE"
337 add_nova_opt "s3_host=$SERVICE_HOST"
338 add_nova_opt "s3_port=$S3_SERVICE_PORT"
339 add_nova_opt "osapi_compute_extension=nova.api.openstack.compute.contrib.standard_extensions"
340 add_nova_opt "my_ip=$HOST_IP"
Terry Wilson428af5a2012-11-01 16:12:39 -0400341 local dburl
342 database_connection_url dburl nova
343 add_nova_opt "sql_connection=$dburl"
Dean Troyerbf67c192012-09-21 15:09:37 -0500344 add_nova_opt "libvirt_type=$LIBVIRT_TYPE"
345 add_nova_opt "libvirt_cpu_mode=none"
346 add_nova_opt "instance_name_template=${INSTANCE_NAME_PREFIX}%08x"
Dean Troyerbf67c192012-09-21 15:09:37 -0500347
348 if is_service_enabled n-api; then
349 add_nova_opt "enabled_apis=$NOVA_ENABLED_APIS"
350 fi
Dean Troyerbf67c192012-09-21 15:09:37 -0500351 if is_service_enabled cinder; then
352 add_nova_opt "volume_api_class=nova.volume.cinder.API"
353 fi
354 if [ -n "$NOVA_STATE_PATH" ]; then
355 add_nova_opt "state_path=$NOVA_STATE_PATH"
Dean Troyer13314452012-10-23 15:09:50 -0500356 add_nova_opt "lock_path=$NOVA_STATE_PATH"
Dean Troyerbf67c192012-09-21 15:09:37 -0500357 fi
358 if [ -n "$NOVA_INSTANCES_PATH" ]; then
359 add_nova_opt "instances_path=$NOVA_INSTANCES_PATH"
360 fi
361 if [ "$MULTI_HOST" != "False" ]; then
362 add_nova_opt "multi_host=True"
363 add_nova_opt "send_arp_for_ha=True"
364 fi
365 if [ "$SYSLOG" != "False" ]; then
366 add_nova_opt "use_syslog=True"
367 fi
368 if [ "$API_RATE_LIMIT" != "True" ]; then
369 add_nova_opt "api_rate_limit=False"
370 fi
371 if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
372 # Add color to logging output
373 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"
374 add_nova_opt "logging_default_format_string=%(asctime)s %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s"
375 add_nova_opt "logging_debug_format_suffix=from (pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d"
376 add_nova_opt "logging_exception_prefix=%(color)s%(asctime)s TRACE %(name)s %(instance)s"
377 else
378 # Show user_name and project_name instead of user_id and project_id
379 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"
380 fi
Eoghan Glynn1fcc6a12012-10-25 14:57:14 +0000381 if is_service_enabled ceilometer; then
382 add_nova_opt "instance_usage_audit=True"
383 add_nova_opt "instance_usage_audit_period=hour"
384 add_nova_opt "notification_driver=nova.openstack.common.notifier.rabbit_notifier"
385 add_nova_opt "notification_driver=ceilometer.compute.nova_notifier"
386 fi
387
Dean Troyerbf67c192012-09-21 15:09:37 -0500388
389 # Provide some transition from ``EXTRA_FLAGS`` to ``EXTRA_OPTS``
390 if [[ -z "$EXTRA_OPTS" && -n "$EXTRA_FLAGS" ]]; then
391 EXTRA_OPTS=$EXTRA_FLAGS
392 fi
393
394 # Define extra nova conf flags by defining the array ``EXTRA_OPTS``.
395 # For Example: ``EXTRA_OPTS=(foo=true bar=2)``
396 for I in "${EXTRA_OPTS[@]}"; do
397 # Attempt to convert flags to options
398 add_nova_opt ${I//--}
399 done
Dean Troyerda7b8092012-10-08 18:12:14 -0500400}
Dean Troyerbf67c192012-09-21 15:09:37 -0500401
Dean Troyerda7b8092012-10-08 18:12:14 -0500402# init_nova() - Initialize databases, etc.
403function init_nova() {
Dean Troyerbf67c192012-09-21 15:09:37 -0500404 # Nova Database
405 # -------------
406
407 # All nova components talk to a central database. We will need to do this step
408 # only once for an entire cluster.
409
Terry Wilson428af5a2012-11-01 16:12:39 -0400410 if is_service_enabled $DATABASE_BACKENDS && is_service_enabled nova; then
Dean Troyerbf67c192012-09-21 15:09:37 -0500411 # (Re)create nova database
Dean Troyerbf67c192012-09-21 15:09:37 -0500412 # Explicitly use latin1: to avoid lp#829209, nova expects the database to
413 # use latin1 by default, and then upgrades the database to utf8 (see the
414 # 082_essex.py in nova)
Terry Wilson428af5a2012-11-01 16:12:39 -0400415 recreate_database nova latin1
Dean Troyerbf67c192012-09-21 15:09:37 -0500416
417 # (Re)create nova database
418 $NOVA_BIN_DIR/nova-manage db sync
419 fi
420
Dean Troyerbc071bc2012-10-01 14:06:44 -0500421 if [[ "$KEYSTONE_TOKEN_FORMAT" == "PKI" ]]; then
422 # Create cache dir
423 sudo mkdir -p $NOVA_AUTH_CACHE_DIR
424 sudo chown `whoami` $NOVA_AUTH_CACHE_DIR
425 fi
Dean Troyerbf67c192012-09-21 15:09:37 -0500426}
427
428# install_novaclient() - Collect source and prepare
429function install_novaclient() {
430 git_clone $NOVACLIENT_REPO $NOVACLIENT_DIR $NOVACLIENT_BRANCH
431}
432
433# install_nova() - Collect source and prepare
434function install_nova() {
435 if is_service_enabled n-cpu; then
Vincent Untzc18b9652012-12-04 12:36:34 +0100436 if is_ubuntu; then
Dean Troyerbf67c192012-09-21 15:09:37 -0500437 LIBVIRT_PKG_NAME=libvirt-bin
438 else
439 LIBVIRT_PKG_NAME=libvirt
440 fi
441 install_package $LIBVIRT_PKG_NAME
442 # Install and configure **LXC** if specified. LXC is another approach to
443 # splitting a system into many smaller parts. LXC uses cgroups and chroot
444 # to simulate multiple systems.
445 if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
Vincent Untzc18b9652012-12-04 12:36:34 +0100446 if is_ubuntu; then
Dean Troyerbf67c192012-09-21 15:09:37 -0500447 if [[ "$DISTRO" > natty ]]; then
448 install_package cgroup-lite
449 fi
450 else
451 ### FIXME(dtroyer): figure this out
452 echo "RPM-based cgroup not implemented yet"
453 yum_install libcgroup-tools
454 fi
455 fi
456 fi
457
458 git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH
459}
460
461# start_nova() - Start running processes, including screen
462function start_nova() {
463 # The group **libvirtd** is added to the current user in this script.
464 # Use 'sg' to execute nova-compute as a member of the **libvirtd** group.
465 # ``screen_it`` checks ``is_service_enabled``, it is not needed here
Russell Bryantff7f3082012-11-29 22:00:51 -0500466 screen_it n-cond "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-conductor"
Dean Troyerbf67c192012-09-21 15:09:37 -0500467 screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_BIN_DIR/nova-compute"
468 screen_it n-crt "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-cert"
469 screen_it n-net "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-network"
470 screen_it n-sch "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-scheduler"
Dean Troyer3cf1ffb2012-10-02 11:51:27 -0500471 screen_it n-novnc "cd $NOVNC_DIR && ./utils/nova-novncproxy --config-file $NOVA_CONF --web ."
Monty Taylor0edfd6f2012-11-23 15:00:38 -0800472 screen_it n-xvnc "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-xvpvncproxy --config-file $NOVA_CONF"
473 screen_it n-cauth "cd $NOVA_DIR && $NOVA_BIN_DIR/nova-consoleauth"
Dean Troyerbf67c192012-09-21 15:09:37 -0500474}
475
476# stop_nova() - Stop running processes (non-screen)
477function stop_nova() {
478 # Kill the nova screen windows
Dan Smithd57ccf02012-11-15 10:09:33 -0800479 for serv in n-api n-cpu n-crt n-net n-sch n-novnc n-xvnc n-cauth n-cond; do
Dean Troyerbf67c192012-09-21 15:09:37 -0500480 screen -S $SCREEN_NAME -p $serv -X kill
481 done
482}
483
484# Restore xtrace
485$XTRACE