NFS backend for Cinder volumes
This commit is contained in:
parent
bd81cb5677
commit
016ebdfc0e
88
manifests/volume/backend/nfs.pp
Normal file
88
manifests/volume/backend/nfs.pp
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
# Configure NFS backend for Cinder
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# [*nfs_servers*]
|
||||||
|
# (required) Array of NFS servers in the form 'ipaddress:/share'
|
||||||
|
#
|
||||||
|
# [*nfs_mount_options*]
|
||||||
|
# (optional) Mount options passed to the nfs client. See section
|
||||||
|
# of the nfs man page for details.
|
||||||
|
# Defaults to undef
|
||||||
|
#
|
||||||
|
# [*nfs_disk_util*]
|
||||||
|
# (optional) Use du or df for free space calculation
|
||||||
|
# Defaults to undef
|
||||||
|
#
|
||||||
|
# [*nfs_sparsed_volumes*]
|
||||||
|
# (optional) Create volumes as sparsed files which take no space.
|
||||||
|
# If set to 'false' volume is created as regular file.
|
||||||
|
# In such case volume creation takes a lot of time.
|
||||||
|
# Defaults to undef
|
||||||
|
#
|
||||||
|
# [*nfs_mount_point_base*]
|
||||||
|
# (optional) Base dir containing mount points for nfs shares.
|
||||||
|
# Defaults to undef
|
||||||
|
#
|
||||||
|
# [*nfs_shares_config*]
|
||||||
|
# (optional) File with the list of available NFS shares.
|
||||||
|
# Defaults to '/etc/cinder/shares.conf'
|
||||||
|
#
|
||||||
|
# [*nfs_used_ratio*]
|
||||||
|
# (optional) Percent of ACTUAL usage of the underlying volume
|
||||||
|
# before no new volumes can be allocated to the volume destination.
|
||||||
|
# Defaults to 0.95
|
||||||
|
#
|
||||||
|
# [*nfs_oversub_ratio*]
|
||||||
|
# (optional) This will compare the allocated to available space on
|
||||||
|
# the volume destination. If the ratio exceeds this number, the
|
||||||
|
# destination will no longer be valid.
|
||||||
|
# Defaults to 1.0
|
||||||
|
#
|
||||||
|
|
||||||
|
define cloud::volume::backend::nfs(
|
||||||
|
$volume_backend_name = $name,
|
||||||
|
$nfs_servers = [],
|
||||||
|
$nfs_mount_options = undef,
|
||||||
|
$nfs_disk_util = undef,
|
||||||
|
$nfs_sparsed_volumes = undef,
|
||||||
|
$nfs_mount_point_base = undef,
|
||||||
|
$nfs_shares_config = '/etc/cinder/shares.conf',
|
||||||
|
$nfs_used_ratio = '0.95',
|
||||||
|
$nfs_oversub_ratio = '1.0',
|
||||||
|
) {
|
||||||
|
|
||||||
|
cinder::backend::nfs { $name:
|
||||||
|
volume_backend_name => $volume_backend_name,
|
||||||
|
nfs_servers => $nfs_servers,
|
||||||
|
nfs_mount_options => $nfs_mount_options,
|
||||||
|
nfs_disk_util => $nfs_disk_util,
|
||||||
|
nfs_sparsed_volumes => $nfs_sparsed_volumes,
|
||||||
|
nfs_mount_point_base => $nfs_mount_point_base,
|
||||||
|
nfs_shares_config => $nfs_shares_config,
|
||||||
|
nfs_used_ratio => $nfs_used_ratio,
|
||||||
|
nfs_oversub_ratio => $nfs_oversub_ratio,
|
||||||
|
}
|
||||||
|
|
||||||
|
@cinder::type { $volume_backend_name:
|
||||||
|
set_key => 'volume_backend_name',
|
||||||
|
set_value => $volume_backend_name,
|
||||||
|
notify => Service['cinder-volume']
|
||||||
|
}
|
||||||
|
}
|
@ -99,8 +99,16 @@ class cloud::volume::storage(
|
|||||||
$emc_vnx_backends = { }
|
$emc_vnx_backends = { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if has_key($cinder_backends, 'nfs') {
|
||||||
|
$nfs_backends = $cinder_backends['nfs']
|
||||||
|
create_resources('cloud::volume::backend::nfs', $nfs_backends)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$nfs_backends = { }
|
||||||
|
}
|
||||||
|
|
||||||
class { 'cinder::backends':
|
class { 'cinder::backends':
|
||||||
enabled_backends => keys(merge($rbd_backends, $netapp_backends, $iscsi_backends, $emc_vnx_backends))
|
enabled_backends => keys(merge($rbd_backends, $netapp_backends, $iscsi_backends, $emc_vnx_backends, $nfs_backends))
|
||||||
}
|
}
|
||||||
|
|
||||||
# Manage Volume types.
|
# Manage Volume types.
|
||||||
|
@ -69,6 +69,17 @@ describe 'cloud::volume::storage' do
|
|||||||
'san_password' => 'secrete',
|
'san_password' => 'secrete',
|
||||||
'storage_vnx_pool_name' => 'emc-volumes',
|
'storage_vnx_pool_name' => 'emc-volumes',
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'nfs' => {
|
||||||
|
'freenas' => {
|
||||||
|
'nfs_servers' => ['10.0.0.1:/myshare'],
|
||||||
|
'nfs_mount_options' => 'defaults',
|
||||||
|
'nfs_disk_util' => 'df',
|
||||||
|
'nfs_mount_point_base' => '/mnt/shares',
|
||||||
|
'nfs_shares_config' => '/etc/cinder/shares.conf',
|
||||||
|
'nfs_used_ratio' => '0.6',
|
||||||
|
'nfs_oversub_ratio' => '1.0'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
:ks_keystone_internal_proto => 'http',
|
:ks_keystone_internal_proto => 'http',
|
||||||
@ -174,6 +185,24 @@ describe 'cloud::volume::storage' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with NFS backend' do
|
||||||
|
it 'configures NFS volume driver' do
|
||||||
|
is_expected.to contain_cinder_config('freenas/volume_backend_name').with_value('freenas')
|
||||||
|
is_expected.to contain_cinder_config('freenas/nfs_mount_options').with_value('defaults')
|
||||||
|
is_expected.to contain_cinder_config('freenas/nfs_mount_point_base').with_value('/mnt/shares')
|
||||||
|
is_expected.to contain_cinder_config('freenas/nfs_disk_util').with_value('df')
|
||||||
|
is_expected.to contain_cinder_config('freenas/nfs_shares_config').with_value('/etc/cinder/shares.conf')
|
||||||
|
is_expected.to contain_cinder_config('freenas/nfs_used_ratio').with_value('0.6')
|
||||||
|
is_expected.to contain_cinder_config('freenas/nfs_oversub_ratio').with_value('1.0')
|
||||||
|
is_expected.to contain_cinder__type('freenas').with(
|
||||||
|
:set_key => 'volume_backend_name',
|
||||||
|
:set_value => 'freenas',
|
||||||
|
:notify => 'Service[cinder-volume]'
|
||||||
|
)
|
||||||
|
should contain_file('/etc/cinder/shares.conf').with_content(/^10.0.0.1:\/myshare$/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'with two RBD backends' do
|
context 'with two RBD backends' do
|
||||||
before :each do
|
before :each do
|
||||||
params.merge!(
|
params.merge!(
|
||||||
@ -227,7 +256,7 @@ describe 'cloud::volume::storage' do
|
|||||||
context 'with all backends enabled' do
|
context 'with all backends enabled' do
|
||||||
it 'configure all cinder backends' do
|
it 'configure all cinder backends' do
|
||||||
is_expected.to contain_class('cinder::backends').with(
|
is_expected.to contain_class('cinder::backends').with(
|
||||||
:enabled_backends => ['lowcost', 'premium', 'fast', 'very-fast']
|
:enabled_backends => ['lowcost', 'premium', 'fast', 'very-fast', 'freenas']
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user