Merge pull request #638 from enovance/instances-nfs

NFS backend support to store Nova instances
This commit is contained in:
Yanis Guenane 2014-09-25 08:22:02 -04:00
commit 15db684cd3
2 changed files with 92 additions and 4 deletions

View File

@ -33,6 +33,22 @@
# (optional) Allow to manage or not TSO issue.
# Default to true.
#
# [*nfs_enabled*]
# (optional) Store (or not) instances on a NFS share.
# Defaults to false
#
# [*nfs_device*]
# (optional) NFS device to mount
# Example: 'nfs.example.com:/vol1'
# Required when nfs_enabled is at true.
# Defaults to false
#
# [*filesystem_store_datadir*]
# (optional) Full path of data directory to store the instances.
# Don't modify this parameter if you don't know what you do.
# You may have side effects (SElinux for example).
# Defaults to '/var/lib/nova/instances'
#
class cloud::compute::hypervisor(
$server_proxyclient_address = '127.0.0.1',
$libvirt_type = 'kvm',
@ -47,6 +63,10 @@ class cloud::compute::hypervisor(
$vm_rbd = false,
$volume_rbd = false,
$manage_tso = true,
# when using NFS storage backend
$nfs_enabled = false,
$nfs_device = false,
$filesystem_store_datadir = '/var/lib/nova/instances',
# set to false to keep backward compatibility
$ks_spice_public_proto = false,
$ks_spice_public_host = false,
@ -84,6 +104,35 @@ class cloud::compute::hypervisor(
$ks_spice_public_host_real = $ks_nova_public_host
}
if $nfs_enabled {
if ! $vm_rbd {
# There is no NFS backend in Nova.
# We mount the NFS share in filesystem_store_datadir to fake the
# backend.
if $nfs_device {
nova_config { 'DEFAULT/instances_path': value => $filesystem_store_datadir; }
$nfs_mount = {
"${filesystem_store_datadir}" => {
'ensure' => 'present',
'fstype' => 'nfs',
'device' => $nfs_device
}
}
ensure_resource('class', 'nfs', {
mounts => $nfs_mount
})
# Not using /var/lib/nova/instances may cause side effects.
if $filesystem_store_datadir != '/var/lib/nova/instances' {
warning('filesystem_store_datadir is not /var/lib/nova/instances so you may have side effects (SElinux, etc)')
}
} else {
fail('When running NFS backend, you need to provide nfs_device parameter.')
}
} else {
fail('When running NFS backend, vm_rbd parameter cannot be set to true.')
}
}
file{ '/var/lib/nova/.ssh':
ensure => directory,
mode => '0700',

View File

@ -469,6 +469,41 @@ describe 'cloud::compute::hypervisor' do
)
end
end
context 'when storing instances on a NFS share' do
before :each do
params.merge!(
:nfs_enabled => true,
:nfs_device => 'nfs.example.com:/vol1' )
end
it 'configure nova instances path and NFS mount' do
should contain_nova_config('DEFAULT/instances_path').with('value' => '/var/lib/nova/instances')
should contain_mount('/var/lib/nova/instances').with({
'ensure' => 'present',
'fstype' => 'nfs',
'device' => 'nfs.example.com:/vol1',
})
end
end
context 'when storing instances on a NFS share without nfs_device' do
before :each do
params.merge!(
:nfs_enabled => true,
:nfs_device => false )
end
it_raises 'a Puppet::Error', /When running NFS backend, you need to provide nfs_device parameter./
end
context 'when storing instances on a NFS share with vm_rbd enabled' do
before :each do
params.merge!(
:nfs_enabled => true,
:vm_rbd => true,
:nfs_device => 'nfs.example.com:/vol1' )
end
it_raises 'a Puppet::Error', /When running NFS backend, vm_rbd parameter cannot be set to true./
end
end
context 'on Debian platforms' do
@ -476,7 +511,9 @@ describe 'cloud::compute::hypervisor' do
{ :osfamily => 'Debian',
:operatingsystem => 'Debian',
:vtx => true,
:concat_basedir => '/var/lib/puppet/concat'
:concat_basedir => '/var/lib/puppet/concat',
# required for rpcbind module
:lsbdistid => 'Debian'
}
end
@ -485,9 +522,11 @@ describe 'cloud::compute::hypervisor' do
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat',
:vtx => true,
:concat_basedir => '/var/lib/puppet/concat'
{ :osfamily => 'RedHat',
:vtx => true,
:concat_basedir => '/var/lib/puppet/concat',
# required for nfs module
:lsbmajdistrelease => '7'
}
end