Add support for Ganesha options

Some share drivers like CephFS uses nfs-ganesha to provide NFS
interface. This change introduces a new resource type so that users
can set additional parameters for nfs-ganesha usage for some share
drivers.

Change-Id: Ie2e2d93176da896da77d777f9cf1e692247e4d7f
This commit is contained in:
Takashi Kajinami 2021-05-08 15:03:41 +09:00
parent a4635dedc8
commit 95dba69923
4 changed files with 179 additions and 16 deletions

View File

@ -0,0 +1,94 @@
#
# == Define: manila::ganesha
#
# Set NFS Ganesha options for share drivers
#
# === Parameters
#
# [*share_backend_name*]
# (optional) Name of the backend in manila.conf that
# these settings will reside in
# Defaults to: $name
#
# [*ganesha_config_dir*]
# (optional) Directory where Ganesha config files are stored.
# Defaults to $::os_service_default
#
# [*ganesha_config_path*]
# (optional) Path to main Ganesha config file.
# Defaults to $::os_service_default
#
# [*ganesha_service_name*]
# (optional) Name of the ganesha nfs service.
# Defaults to $::os_service_default
#
# [*ganesha_db_path*]
# (optional) Location of Ganesha database file (Ganesha module only).
# Defaults to $::os_service_default
#
# [*ganesha_export_dir*]
# (optional) Path to directory containing Ganesha export configuration.
# (Ganesha module only.)
# Defaults to $::os_service_default
#
# [*ganesha_export_template_dir*]
# (optional) Path to directory containing Ganesha export block templates.
# (Ganesha module only.)
# Defaults to $::os_service_default
#
# [*ganesha_rados_store_enable*]
# (optional) Persist Ganesha exports and export counter in Ceph RADOS objects
# Defaults to $::os_service_default
#
# [*ganesha_rados_store_pool_name*]
# (optional) Name of the Ceph RADOS pool to store Ganesha exports and export
# counter.
# Defaults to $::os_service_default
#
# [*ganesha_rados_export_counter*]
# (optional) Name of the CEPH RADOS object used as the Ganesha export counter.
# Defaults to $::os_service_default
#
# [*ganesha_rados_export_index*]
# (optional) Name of the CEPH RADOS object used to store a list of the export
# RADOS object URLs.
# Defaults to $::os_service_default
#
define manila::backend::ganesha (
$share_backend_name = $name,
$ganesha_config_dir = $::os_service_default,
$ganesha_config_path = $::os_service_default,
$ganesha_service_name = $::os_service_default,
$ganesha_db_path = $::os_service_default,
$ganesha_export_dir = $::os_service_default,
$ganesha_export_template_dir = $::os_service_default,
$ganesha_rados_store_enable = $::os_service_default,
$ganesha_rados_store_pool_name = $::os_service_default,
$ganesha_rados_export_counter = $::os_service_default,
$ganesha_rados_export_index = $::os_service_default,
) {
include manila::deps
manila_config {
"${share_backend_name}/ganesha_config_dir": value => $ganesha_config_dir;
"${share_backend_name}/ganesha_config_path": value => $ganesha_config_path;
"${share_backend_name}/ganesha_service_name": value => $ganesha_service_name;
"${share_backend_name}/ganesha_db_path": value => $ganesha_db_path;
"${share_backend_name}/ganesha_export_dir": value => $ganesha_export_dir;
"${share_backend_name}/ganesha_export_template_dir": value => $ganesha_export_template_dir;
"${share_backend_name}/ganesha_rados_store_enable": value => $ganesha_rados_store_enable;
"${share_backend_name}/ganesha_rados_store_pool_name": value => $ganesha_rados_store_pool_name;
"${share_backend_name}/ganesha_rados_export_counter": value => $ganesha_rados_export_counter;
"${share_backend_name}/ganesha_rados_export_index": value => $ganesha_rados_export_index;
}
if ($::osfamily == 'RedHat') {
ensure_packages( 'nfs-ganesha', {
ensure => present,
tag => ['openstack', 'manila-support-package'],
})
} else {
warning("Unsupported osfamily ${::osfamily}, Red Hat is the only supported platform.")
}
}

View File

@ -41,21 +41,12 @@ class manila::ganesha (
include manila::deps
manila_config {
'DEFAULT/ganesha_config_dir': value => $ganesha_config_dir;
'DEFAULT/ganesha_config_path': value => $ganesha_config_path;
'DEFAULT/ganesha_service_name': value => $ganesha_service_name;
'DEFAULT/ganesha_db_path': value => $ganesha_db_path;
'DEFAULT/ganesha_export_dir': value => $ganesha_export_dir;
'DEFAULT/ganesha_export_template_dir': value => $ganesha_export_template_dir;
}
if ($::osfamily == 'RedHat') {
package { 'nfs-ganesha':
ensure => present,
tag => ['openstack', 'manila-support-package'],
}
} else {
warning("Unsupported osfamily ${::osfamily}, Red Hat is the only supported platform.")
manila::backend::ganesha { 'DEFAULT':
ganesha_config_dir => $ganesha_config_dir,
ganesha_config_path => $ganesha_config_path,
ganesha_service_name => $ganesha_service_name,
ganesha_db_path => $ganesha_db_path,
ganesha_export_dir => $ganesha_export_dir,
ganesha_export_template_dir => $ganesha_export_template_dir,
}
}

View File

@ -0,0 +1,5 @@
---
features:
- |
The ``manila::backend::ganesha`` resource type has been added. This allows
configuring Ganesha share which is supported by some drivers like CephFS.

View File

@ -0,0 +1,73 @@
require 'spec_helper'
describe 'manila::backend::ganesha' do
shared_examples_for 'manila::backend::ganesha' do
let(:title) {'ganesha'}
context 'with defaults' do
let :params do
{}
end
it 'set the default values' do
is_expected.to contain_manila_config('ganesha/ganesha_config_dir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('ganesha/ganesha_config_path').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('ganesha/ganesha_service_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('ganesha/ganesha_db_path').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('ganesha/ganesha_export_dir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('ganesha/ganesha_export_template_dir').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('ganesha/ganesha_rados_store_enable').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('ganesha/ganesha_rados_store_pool_name').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('ganesha/ganesha_rados_export_counter').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('ganesha/ganesha_rados_export_index').with_value('<SERVICE DEFAULT>')
end
end
context 'with specific parameters' do
let :params do
{
:ganesha_config_dir => '/etc/ganesha',
:ganesha_config_path => '/etc/ganesha/ganesha.conf',
:ganesha_service_name => 'ganesha.nfsd',
:ganesha_db_path => '$state_path/manila-ganesha.db',
:ganesha_export_dir => '/etc/ganesha/export.d',
:ganesha_export_template_dir => '/etc/manila/ganesha-export-templ.d',
:ganesha_rados_store_enable => true,
:ganesha_rados_store_pool_name => 'storepool',
:ganesha_rados_export_counter => 'ganesha-export-counter',
:ganesha_rados_export_index => 'ganesha-export-index',
}
end
it 'Adds NFS Ganesha options to the share drivers' do
params.each_pair do |config,value|
is_expected.to contain_manila_config("ganesha/#{config}").with_value(value)
end
end
end
end
shared_examples_for 'manila::backend::ganesha on RedHat' do
let(:title) {'ganesha'}
it { is_expected.to contain_package('nfs-ganesha').with(
:name => 'nfs-ganesha',
:ensure => 'present',
) }
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts({ :fqdn => 'some.host.tld'}))
end
it_configures 'manila::backend::ganesha'
if facts[:osfamily] == 'RedHat'
it_configures 'manila::backend::ganesha on RedHat'
end
end
end
end