blob: dfd8a67fd92277c3a5c2b32175078cc09d3c8e0f [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Dean Troyer8c032d12013-09-23 13:53:13 -05003# lib/nova_plugins/hypervisor-libvirt
4# Configure the libvirt hypervisor
5
6# Enable with:
7# VIRT_DRIVER=libvirt
8
9# Dependencies:
10# ``functions`` file
11# ``nova`` configuration
12
13# install_nova_hypervisor - install any external requirements
14# configure_nova_hypervisor - make configuration changes, including those to other services
15# start_nova_hypervisor - start any external services
16# stop_nova_hypervisor - stop any external services
17# cleanup_nova_hypervisor - remove transient data and cache
18
19# Save trace setting
20MY_XTRACE=$(set +o | grep xtrace)
21set +o xtrace
22
Adam Gandelman0f73ff22014-03-13 14:20:43 -070023source $TOP_DIR/lib/nova_plugins/functions-libvirt
Dean Troyer8c032d12013-09-23 13:53:13 -050024
25# Defaults
26# --------
27
Russell Bryant5705db62014-02-01 20:06:42 -050028# File injection is disabled by default in Nova. This will turn it back on.
Dirk Mueller0ae942b2015-06-03 14:09:05 +020029ENABLE_FILE_INJECTION=$(trueorfalse False ENABLE_FILE_INJECTION)
Russell Bryant5705db62014-02-01 20:06:42 -050030
Dean Troyer8c032d12013-09-23 13:53:13 -050031
32# Entry Points
33# ------------
34
35# clean_nova_hypervisor - Clean up an installation
Ian Wienandaee18c72014-02-21 15:35:08 +110036function cleanup_nova_hypervisor {
Dean Troyer8c032d12013-09-23 13:53:13 -050037 # This function intentionally left blank
38 :
39}
40
41# configure_nova_hypervisor - Set config files, create data dirs, etc
Ian Wienandaee18c72014-02-21 15:35:08 +110042function configure_nova_hypervisor {
Adam Gandelman0f73ff22014-03-13 14:20:43 -070043 configure_libvirt
Joe Gordon1cd8efc2014-04-17 16:46:36 -070044 iniset $NOVA_CONF libvirt virt_type "$LIBVIRT_TYPE"
45 iniset $NOVA_CONF libvirt cpu_mode "none"
Gary Kotton51c681d2014-04-22 01:40:56 -070046 iniset $NOVA_CONF libvirt use_usb_tablet "False"
Adam Gandelmana1ffcfa2014-11-20 16:42:32 -080047 iniset $NOVA_CONF libvirt live_migration_uri "qemu+ssh://$STACK_USER@%s/system"
Sean Dague6bf1f1f2014-02-01 17:05:18 -050048 iniset $NOVA_CONF DEFAULT default_ephemeral_format "ext4"
Dean Troyer8c032d12013-09-23 13:53:13 -050049 iniset $NOVA_CONF DEFAULT compute_driver "libvirt.LibvirtDriver"
50 LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.libvirt.firewall.IptablesFirewallDriver"}
51 iniset $NOVA_CONF DEFAULT firewall_driver "$LIBVIRT_FIREWALL_DRIVER"
52 # Power architecture currently does not support graphical consoles.
53 if is_arch "ppc64"; then
54 iniset $NOVA_CONF DEFAULT vnc_enabled "false"
55 fi
Russell Bryant5705db62014-02-01 20:06:42 -050056
Clark Laughlinfcc3f6e2015-04-07 16:31:47 +000057 # arm64-specific configuration
58 if is_arch "aarch64"; then
59 # arm64 architecture currently does not support graphical consoles.
60 iniset $NOVA_CONF DEFAULT vnc_enabled "false"
61 fi
62
Russell Bryant5705db62014-02-01 20:06:42 -050063 if [[ "$ENABLE_FILE_INJECTION" = "True" ]] ; then
64 # When libguestfs is available for file injection, enable using
65 # libguestfs to inspect the image and figure out the proper
66 # partition to inject into.
67 iniset $NOVA_CONF libvirt inject_partition '-1'
68 iniset $NOVA_CONF libvirt inject_key 'true'
69 else
70 # File injection is being disabled by default in the near future -
71 # disable it here for now to avoid surprises later.
72 iniset $NOVA_CONF libvirt inject_partition '-2'
73 fi
Evgeny Antyshev19354582014-11-24 14:20:35 +040074
75 if [[ "$LIBVIRT_TYPE" = "parallels" ]]; then
76 iniset $NOVA_CONF libvirt connection_uri "parallels+unix:///system"
77 iniset $NOVA_CONF libvirt images_type "ploop"
Maxim Nestratove6f37b92015-06-30 14:54:12 +030078 iniset $NOVA_CONF DEFAULT force_raw_images "False"
79 iniset $NOVA_CONF DEFAULT vncserver_proxyclient_address $HOST_IP
80 iniset $NOVA_CONF DEFAULT vncserver_listen $HOST_IP
81 iniset $NOVA_CONF DEFAULT vnc_keymap
Evgeny Antyshev19354582014-11-24 14:20:35 +040082 fi
Dean Troyer8c032d12013-09-23 13:53:13 -050083}
84
85# install_nova_hypervisor() - Install external components
Ian Wienandaee18c72014-02-21 15:35:08 +110086function install_nova_hypervisor {
Adam Gandelman0f73ff22014-03-13 14:20:43 -070087 install_libvirt
Dean Troyer8c032d12013-09-23 13:53:13 -050088
89 # Install and configure **LXC** if specified. LXC is another approach to
90 # splitting a system into many smaller parts. LXC uses cgroups and chroot
91 # to simulate multiple systems.
92 if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
93 if is_ubuntu; then
94 if [[ "$DISTRO" > natty ]]; then
95 install_package cgroup-lite
96 fi
97 else
98 ### FIXME(dtroyer): figure this out
99 echo "RPM-based cgroup not implemented yet"
100 yum_install libcgroup-tools
101 fi
102 fi
Dirk Mueller0ae942b2015-06-03 14:09:05 +0200103
104 if [[ "$ENABLE_FILE_INJECTION" = "True" ]] ; then
105 if is_ubuntu; then
106 install_package python-guestfs
107 elif is_fedora || is_suse; then
108 install_package python-libguestfs
109 fi
110 fi
Dean Troyer8c032d12013-09-23 13:53:13 -0500111}
112
113# start_nova_hypervisor - Start any required external services
Ian Wienandaee18c72014-02-21 15:35:08 +1100114function start_nova_hypervisor {
Dean Troyer8c032d12013-09-23 13:53:13 -0500115 # This function intentionally left blank
116 :
117}
118
119# stop_nova_hypervisor - Stop any external services
Ian Wienandaee18c72014-02-21 15:35:08 +1100120function stop_nova_hypervisor {
Dean Troyer8c032d12013-09-23 13:53:13 -0500121 # This function intentionally left blank
122 :
123}
124
125
126# Restore xtrace
127$MY_XTRACE
128
129# Local variables:
130# mode: shell-script
131# End: