Skip to content

Commit

Permalink
Parameterize disk_cachemodes
Browse files Browse the repository at this point in the history
The current manifests don't expose a way for end users to set
the disk_cachemodes directive in nova.conf, which can be useful
for improving disk performance.  This patch adds a parameter
allowing users to specify a list of values to be written in
to the disk_cachemodes setting.  The default value is an empty
list, which will cause the disk_cachemodes setting to be removed
entirely from nova.conf (thus matching the Nova default and
current behavior).

This patch is based on 0a5d6568f070d193b604513f194c966cc224a86b
but is slightly modified to account for a change in how the
nova.conf file is organized between Havana and Icehouse
(some libvirt params were moved from the [DEFAULT] section
to the new [libvirt] section in Icehouse).

Change-Id: I9173ef79e4e573515f290734535907794dda7dbf
(cherry picked from commit 0a5d6568f070d193b604513f194c966cc224a86b)
  • Loading branch information
Mark T. Voelker committed Mar 4, 2014
1 parent c1f246c commit 18f55e7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
27 changes: 23 additions & 4 deletions manifests/compute/libvirt.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@
# Defaults to 'host-model' if libvirt_type is set to either
# kvm or qemu, otherwise defaults to 'None'.
#
# [*libvirt_disk_cachemodes*]
# (optional) A list of cachemodes for different disk types, e.g.
# ["file=directsync", "block=none"]
# If an empty list is specified, the disk_cachemodes directive
# will be removed from nova.conf completely.
# Defaults to an empty list
#

class nova::compute::libvirt (
$libvirt_type = 'kvm',
$vncserver_listen = '127.0.0.1',
$migration_support = false,
$libvirt_cpu_mode = false,
$libvirt_type = 'kvm',
$vncserver_listen = '127.0.0.1',
$migration_support = false,
$libvirt_cpu_mode = false,
$libvirt_disk_cachemodes = [],
) {

include nova::params
Expand Down Expand Up @@ -93,4 +102,14 @@
'DEFAULT/vncserver_listen': value => $vncserver_listen;
'DEFAULT/libvirt_cpu_mode': value => $libvirt_cpu_mode_real;
}

if size($libvirt_disk_cachemodes) > 0 {
nova_config {
'DEFAULT/disk_cachemodes': value => join($libvirt_disk_cachemodes, ',');
}
} else {
nova_config {
'DEFAULT/disk_cachemodes': ensure => absent;
}
}
}
5 changes: 4 additions & 1 deletion spec/classes/nova_compute_libvirt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,22 @@
it { should contain_nova_config('DEFAULT/connection_type').with_value('libvirt')}
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('127.0.0.1')}
it { should contain_nova_config('DEFAULT/libvirt_cpu_mode').with_value('host-model')}
it { should contain_nova_config('DEFAULT/disk_cachemodes').with_ensure('absent')}
end

describe 'with params' do
let :params do
{ :libvirt_type => 'qemu',
:vncserver_listen => '0.0.0.0',
:libvirt_cpu_mode => 'host-passthrough'
:libvirt_cpu_mode => 'host-passthrough',
:libvirt_disk_cachemodes => ['file=directsync','block=none']
}
end

it { should contain_nova_config('DEFAULT/libvirt_type').with_value('qemu')}
it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('0.0.0.0')}
it { should contain_nova_config('DEFAULT/libvirt_cpu_mode').with_value('host-passthrough')}
it { should contain_nova_config('DEFAULT/disk_cachemodes').with_value('file=directsync,block=none')}
end

describe 'with migration_support enabled' do
Expand Down

0 comments on commit 18f55e7

Please sign in to comment.