blob: 53dbfb976f9e10ef4a3c719bc04383bbdb0606f2 [file] [log] [blame]
Dean Troyer8c032d12013-09-23 13:53:13 -05001# lib/nova_plugins/hypervisor-libvirt
2# Configure the libvirt hypervisor
3
4# Enable with:
5# VIRT_DRIVER=libvirt
6
7# Dependencies:
8# ``functions`` file
9# ``nova`` configuration
10
11# install_nova_hypervisor - install any external requirements
12# configure_nova_hypervisor - make configuration changes, including those to other services
13# start_nova_hypervisor - start any external services
14# stop_nova_hypervisor - stop any external services
15# cleanup_nova_hypervisor - remove transient data and cache
16
17# Save trace setting
18MY_XTRACE=$(set +o | grep xtrace)
19set +o xtrace
20
Adam Gandelman0f73ff22014-03-13 14:20:43 -070021source $TOP_DIR/lib/nova_plugins/functions-libvirt
Dean Troyer8c032d12013-09-23 13:53:13 -050022
23# Defaults
24# --------
25
Russell Bryant5705db62014-02-01 20:06:42 -050026# File injection is disabled by default in Nova. This will turn it back on.
27ENABLE_FILE_INJECTION=${ENABLE_FILE_INJECTION:-False}
28
Dean Troyer8c032d12013-09-23 13:53:13 -050029
30# Entry Points
31# ------------
32
33# clean_nova_hypervisor - Clean up an installation
Ian Wienandaee18c72014-02-21 15:35:08 +110034function cleanup_nova_hypervisor {
Dean Troyer8c032d12013-09-23 13:53:13 -050035 # This function intentionally left blank
36 :
37}
38
39# configure_nova_hypervisor - Set config files, create data dirs, etc
Ian Wienandaee18c72014-02-21 15:35:08 +110040function configure_nova_hypervisor {
Adam Gandelman0f73ff22014-03-13 14:20:43 -070041 configure_libvirt
Joe Gordon1cd8efc2014-04-17 16:46:36 -070042 iniset $NOVA_CONF libvirt virt_type "$LIBVIRT_TYPE"
43 iniset $NOVA_CONF libvirt cpu_mode "none"
Gary Kotton51c681d2014-04-22 01:40:56 -070044 iniset $NOVA_CONF libvirt use_usb_tablet "False"
Adam Gandelmana1ffcfa2014-11-20 16:42:32 -080045 iniset $NOVA_CONF libvirt live_migration_uri "qemu+ssh://$STACK_USER@%s/system"
Sean Dague6bf1f1f2014-02-01 17:05:18 -050046 iniset $NOVA_CONF DEFAULT default_ephemeral_format "ext4"
Dean Troyer8c032d12013-09-23 13:53:13 -050047 iniset $NOVA_CONF DEFAULT compute_driver "libvirt.LibvirtDriver"
48 LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.libvirt.firewall.IptablesFirewallDriver"}
49 iniset $NOVA_CONF DEFAULT firewall_driver "$LIBVIRT_FIREWALL_DRIVER"
50 # Power architecture currently does not support graphical consoles.
51 if is_arch "ppc64"; then
52 iniset $NOVA_CONF DEFAULT vnc_enabled "false"
53 fi
Russell Bryant5705db62014-02-01 20:06:42 -050054
55 ENABLE_FILE_INJECTION=$(trueorfalse False $ENABLE_FILE_INJECTION)
56 if [[ "$ENABLE_FILE_INJECTION" = "True" ]] ; then
57 # When libguestfs is available for file injection, enable using
58 # libguestfs to inspect the image and figure out the proper
59 # partition to inject into.
60 iniset $NOVA_CONF libvirt inject_partition '-1'
61 iniset $NOVA_CONF libvirt inject_key 'true'
62 else
63 # File injection is being disabled by default in the near future -
64 # disable it here for now to avoid surprises later.
65 iniset $NOVA_CONF libvirt inject_partition '-2'
66 fi
Dean Troyer8c032d12013-09-23 13:53:13 -050067}
68
69# install_nova_hypervisor() - Install external components
Ian Wienandaee18c72014-02-21 15:35:08 +110070function install_nova_hypervisor {
Adam Gandelman0f73ff22014-03-13 14:20:43 -070071 install_libvirt
Dean Troyer8c032d12013-09-23 13:53:13 -050072
73 # Install and configure **LXC** if specified. LXC is another approach to
74 # splitting a system into many smaller parts. LXC uses cgroups and chroot
75 # to simulate multiple systems.
76 if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
77 if is_ubuntu; then
78 if [[ "$DISTRO" > natty ]]; then
79 install_package cgroup-lite
80 fi
81 else
82 ### FIXME(dtroyer): figure this out
83 echo "RPM-based cgroup not implemented yet"
84 yum_install libcgroup-tools
85 fi
86 fi
87}
88
89# start_nova_hypervisor - Start any required external services
Ian Wienandaee18c72014-02-21 15:35:08 +110090function start_nova_hypervisor {
Dean Troyer8c032d12013-09-23 13:53:13 -050091 # This function intentionally left blank
92 :
93}
94
95# stop_nova_hypervisor - Stop any external services
Ian Wienandaee18c72014-02-21 15:35:08 +110096function stop_nova_hypervisor {
Dean Troyer8c032d12013-09-23 13:53:13 -050097 # This function intentionally left blank
98 :
99}
100
101
102# Restore xtrace
103$MY_XTRACE
104
105# Local variables:
106# mode: shell-script
107# End: