Improve default hypervisor config, make hypervisor configurable

- Introduce a new parameter, CONFIG_NOVA_LIBVIRT_VIRT_TYPE where
  someone can forcefully use either 'qemu' or 'kvm' while still
  maintaining the default to 'qemu' for virtual environments and
  'kvm' for bare metal servers

- Remove the qemu-kvm-ev detection. If qemu-kvm-ev is available,
  it will be installed since it osboletes qemu-kvm.

- Improve the workaround for the /dev/kvm permissions fix

Change-Id: I87ea47cde3e02cfa5f3a26cacf010a18c29083b5
This commit is contained in:
David Moreau-Simard 2016-08-17 18:20:42 -04:00
parent df00bfcf1a
commit d3b4502be4
4 changed files with 51 additions and 23 deletions

View File

@ -737,6 +737,10 @@ Nova Options
**CONFIG_NOVA_MANAGE_FLAVORS**
Whether or not Packstack should manage a default initial set of Nova flavors. Defaults to 'y'.
**CONFIG_NOVA_LIBVIRT_VIRT_TYPE**
The hypervisor driver to use with Nova. Can be either 'qemu' or 'kvm'.
Defaults to 'qemu' on virtual machines and 'kvm' on bare metal hardware.
**CONFIG_NOVA_SCHED_CPU_ALLOC_RATIO**
Overcommitment ratio for virtual to physical CPUs. Specify 1.0 to disable CPU overcommitment.

View File

@ -212,6 +212,19 @@ def initConfig(controller):
"USE_DEFAULT": False,
"NEED_CONFIRM": False,
"CONDITION": False},
{"CMD_OPTION": "nova-libvirt-virt-type",
"PROMPT": (
"The nova hypervisor that should be used. Either qemu or kvm."
),
"OPTION_LIST": ['qemu', 'kvm'],
"DEFAULT_VALUE": '%{::default_hypervisor}',
"MASK_INPUT": False,
"LOOSE_VALIDATION": False,
"CONF_NAME": "CONFIG_NOVA_LIBVIRT_VIRT_TYPE",
"USE_DEFAULT": False,
"NEED_CONFIRM": True,
"CONDITION": False},
],
"NOVA_NETWORK": [

View File

@ -0,0 +1,16 @@
# Custom fact to keep backwards compatibility to default to qemu when the
# is_virtual fact is true and otherwise default to kvm
# This fact is then used as a default value for the
# CONFIG_NOVA_LIBVIRT_VIRT_TYPE packstack parameter.
Facter.add(:default_hypervisor) do
setcode do
if Facter.value(:is_virtual) == true
output = 'qemu'
else
output = 'kvm'
end
output
end
end

View File

@ -1,30 +1,8 @@
class packstack::nova::compute::libvirt ()
{
Firewall <| |> -> Class['::nova::compute::libvirt']
# Ensure Firewall changes happen before libvirt service start
# preventing a clash with rules being set by libvirt
if str2bool($::is_virtual) {
$libvirt_virt_type = 'qemu'
} else {
$libvirt_virt_type = 'kvm'
}
# We need to preferably install qemu-kvm-rhev
exec { 'qemu-kvm':
path => '/usr/bin',
command => 'yum install -y -d 0 -e 0 qemu-kvm',
onlyif => 'yum install -y -d 0 -e 0 qemu-kvm-rhev &> /dev/null && exit 1 || exit 0',
before => Class['::nova::compute::libvirt'],
} ->
# chmod is workaround for https://bugzilla.redhat.com/show_bug.cgi?id=950436
file { '/dev/kvm':
owner => 'root',
group => 'kvm',
mode => '666',
before => Class['::nova::compute::libvirt'],
}
Firewall <| |> -> Class['::nova::compute::libvirt']
$libvirt_vnc_bind_host = hiera('CONFIG_IP_VERSION') ? {
'ipv6' => '::0',
@ -32,6 +10,23 @@ class packstack::nova::compute::libvirt ()
# TO-DO(mmagr): Add IPv6 support when hostnames are used
}
$libvirt_virt_type = hiera('CONFIG_NOVA_LIBVIRT_VIRT_TYPE')
if $libvirt_virt_type == 'kvm' {
# Workaround for bad /dev/kvm permissions
# https://bugzilla.redhat.com/show_bug.cgi?id=950436
file { '/dev/kvm':
owner => 'root',
group => 'kvm',
mode => '666',
}
# We have to fix the permissions after the installation has been done
# and before the service is started.
Package <| title == 'libvirt' |> ->
File['/dev/kvm'] ->
Service <| title == 'libvirt' |>
}
class { '::nova::compute::libvirt':
libvirt_virt_type => $libvirt_virt_type,
vncserver_listen => $libvirt_vnc_bind_host,