blob: c54a7166a0969514b83548e9243123346b8e95a9 [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
28
29# Entry Points
30# ------------
31
32# clean_nova_hypervisor - Clean up an installation
Ian Wienandaee18c72014-02-21 15:35:08 +110033function cleanup_nova_hypervisor {
Dean Troyer8c032d12013-09-23 13:53:13 -050034 # This function intentionally left blank
35 :
36}
37
38# configure_nova_hypervisor - Set config files, create data dirs, etc
Ian Wienandaee18c72014-02-21 15:35:08 +110039function configure_nova_hypervisor {
Adam Gandelman0f73ff22014-03-13 14:20:43 -070040 configure_libvirt
Joe Gordon1cd8efc2014-04-17 16:46:36 -070041 iniset $NOVA_CONF libvirt virt_type "$LIBVIRT_TYPE"
42 iniset $NOVA_CONF libvirt cpu_mode "none"
Gary Kotton51c681d2014-04-22 01:40:56 -070043 iniset $NOVA_CONF libvirt use_usb_tablet "False"
Adam Gandelmana1ffcfa2014-11-20 16:42:32 -080044 iniset $NOVA_CONF libvirt live_migration_uri "qemu+ssh://$STACK_USER@%s/system"
Sean Dague6bf1f1f2014-02-01 17:05:18 -050045 iniset $NOVA_CONF DEFAULT default_ephemeral_format "ext4"
Dean Troyer8c032d12013-09-23 13:53:13 -050046 iniset $NOVA_CONF DEFAULT compute_driver "libvirt.LibvirtDriver"
47 LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.libvirt.firewall.IptablesFirewallDriver"}
48 iniset $NOVA_CONF DEFAULT firewall_driver "$LIBVIRT_FIREWALL_DRIVER"
49 # Power architecture currently does not support graphical consoles.
50 if is_arch "ppc64"; then
51 iniset $NOVA_CONF DEFAULT vnc_enabled "false"
52 fi
Russell Bryant5705db62014-02-01 20:06:42 -050053
Clark Laughlinfcc3f6e2015-04-07 16:31:47 +000054 # arm64-specific configuration
55 if is_arch "aarch64"; then
56 # arm64 architecture currently does not support graphical consoles.
57 iniset $NOVA_CONF DEFAULT vnc_enabled "false"
58 fi
59
Dirk Muellera3c94462015-06-23 12:23:29 +020060 # File injection is being disabled by default in the near future -
61 # disable it here for now to avoid surprises later.
62 iniset $NOVA_CONF libvirt inject_partition '-2'
Evgeny Antyshev19354582014-11-24 14:20:35 +040063
64 if [[ "$LIBVIRT_TYPE" = "parallels" ]]; then
65 iniset $NOVA_CONF libvirt connection_uri "parallels+unix:///system"
66 iniset $NOVA_CONF libvirt images_type "ploop"
Maxim Nestratove6f37b92015-06-30 14:54:12 +030067 iniset $NOVA_CONF DEFAULT force_raw_images "False"
68 iniset $NOVA_CONF DEFAULT vncserver_proxyclient_address $HOST_IP
69 iniset $NOVA_CONF DEFAULT vncserver_listen $HOST_IP
70 iniset $NOVA_CONF DEFAULT vnc_keymap
Evgeny Antyshev19354582014-11-24 14:20:35 +040071 fi
Dean Troyer8c032d12013-09-23 13:53:13 -050072}
73
74# install_nova_hypervisor() - Install external components
Ian Wienandaee18c72014-02-21 15:35:08 +110075function install_nova_hypervisor {
Adam Gandelman0f73ff22014-03-13 14:20:43 -070076 install_libvirt
Dean Troyer8c032d12013-09-23 13:53:13 -050077
78 # Install and configure **LXC** if specified. LXC is another approach to
79 # splitting a system into many smaller parts. LXC uses cgroups and chroot
80 # to simulate multiple systems.
81 if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
82 if is_ubuntu; then
83 if [[ "$DISTRO" > natty ]]; then
84 install_package cgroup-lite
85 fi
86 else
87 ### FIXME(dtroyer): figure this out
88 echo "RPM-based cgroup not implemented yet"
89 yum_install libcgroup-tools
90 fi
91 fi
92}
93
94# start_nova_hypervisor - Start any required external services
Ian Wienandaee18c72014-02-21 15:35:08 +110095function start_nova_hypervisor {
Dean Troyer8c032d12013-09-23 13:53:13 -050096 # This function intentionally left blank
97 :
98}
99
100# stop_nova_hypervisor - Stop any external services
Ian Wienandaee18c72014-02-21 15:35:08 +1100101function stop_nova_hypervisor {
Dean Troyer8c032d12013-09-23 13:53:13 -0500102 # This function intentionally left blank
103 :
104}
105
106
107# Restore xtrace
108$MY_XTRACE
109
110# Local variables:
111# mode: shell-script
112# End: