Add support for share backup/restore options

This introduces support for options used by share backup and restore
feature, which was introduced to manila recently.

This also adds support for NFS share backup driver.

Change-Id: Idf187458b62e81999874f9582f932d9707c0d8c1
This commit is contained in:
Takashi Kajinami 2023-10-06 12:30:55 +09:00
parent f319ebb145
commit 2c6e685768
7 changed files with 217 additions and 13 deletions

View File

@ -20,17 +20,52 @@
# (Optional) Temporary path to create and mount shares during migration.
# Defaults to $facts['os_service_default'].
#
# [*backup_mount_tmp_location*]
# (Optional) Temporary path to create and mount shares during share backup.
# Defaults to $facts['os_service_default'].
#
# [*check_hash*]
# (Optional) Chooses whether hash of each file should be checked on data
# copying.
# Defaults to $facts['os_service_default'].
#
# [*backup_continue_update_interval*]
# (Optional) Interval to poll to perform the next steps of backup.
# Defaults to $facts['os_service_default'].
#
# [*restore_continue_update_interval*]
# (Optional) Interval to poll to perform the next steps of restore.
# Defaults to $facts['os_service_default'].
#
# [*backup_driver*]
# (Optional) Driver to use for backups
# Defaults to $facts['os_service_default'].
#
# [*backup_share_mount_template*]
# (Optional) The template for mounting shares during backup.
# Defaults to $facts['os_service_default'].
#
# [*backup_share_unmount_template*]
# (Optional) The template for unmounting shares during backup.
# Defaults to $facts['os_service_default'].
#
# [*backup_ignore_files*]
# (Optional) List of files and folders to be ignored when backing up shares.
# Defaults to $facts['os_service_default'].
#
class manila::data (
$package_ensure = 'present',
Boolean $enabled = true,
Boolean $manage_service = true,
$mount_tmp_location = $facts['os_service_default'],
$check_hash = $facts['os_service_default'],
$package_ensure = 'present',
Boolean $enabled = true,
Boolean $manage_service = true,
$mount_tmp_location = $facts['os_service_default'],
$backup_mount_tmp_location = $facts['os_service_default'],
$check_hash = $facts['os_service_default'],
$backup_continue_update_interval = $facts['os_service_default'],
$restore_continue_update_interval = $facts['os_service_default'],
$backup_driver = $facts['os_service_default'],
$backup_share_mount_template = $facts['os_service_default'],
$backup_share_unmount_template = $facts['os_service_default'],
$backup_ignore_files = $facts['os_service_default'],
) {
include manila::deps
@ -45,8 +80,15 @@ class manila::data (
}
manila_config {
'DEFAULT/mount_tmp_location': value => $mount_tmp_location;
'DEFAULT/check_hash': value => $check_hash;
'DEFAULT/mount_tmp_location': value => $mount_tmp_location;
'DEFAULT/backup_mount_tmp_location': value => $backup_mount_tmp_location;
'DEFAULT/check_hash': value => $check_hash;
'DEFAULT/backup_continue_update_interval': value => $backup_continue_update_interval;
'DEFAULT/restore_continue_update_interval': value => $restore_continue_update_interval;
'DEFAULT/backup_driver': value => $backup_driver;
'DEFAULT/backup_share_mount_template': value => $backup_share_mount_template;
'DEFAULT/backup_share_unmount_template': value => $backup_share_unmount_template;
'DEFAULT/backup_ignore_files': value => join(any2array($backup_ignore_files), ',');
}
if $manage_service {

View File

@ -0,0 +1,55 @@
# == Class: manila::data::backup::nfs
#
# Setup Manila to backup shares into NFS
#
# === Parameters
#
# [*backup_mount_export*]
# (Required) NFS backup export location.
# Defaults to $facts['os_service_default']
#
# [*backup_mount_template*]
# (Optional) The template for mounting NFS shares.
# Defaults to $facts['os_service_default']
#
# [*backup_unmount_template*]
# (Optional) The template for unmounting NFS shares.
# Defaults to $facts['os_service_default']
#
# [*backup_mount_proto*]
# (Optional) Mount Protocol for mounting NFS shares.
# Defaults to $facts['os_service_default']
#
# [*backup_mount_options*]
# (Optional) Mount ptions passed to the NFS client.
# Defaults to $facts['os_service_default']
#
# [*package_ensure*]
# (optional) Ensure state for package. Defaults to 'present'.
#
class manila::data::backup::nfs (
String[1] $backup_mount_export,
$backup_mount_template = $facts['os_service_default'],
$backup_unmount_template = $facts['os_service_default'],
$backup_mount_proto = $facts['os_service_default'],
$backup_mount_options = $facts['os_service_default'],
$package_ensure = 'present',
) {
include manila::deps
include manila::params
manila_config {
'DEFAULT/backup_mount_template': value => $backup_mount_template;
'DEFAULT/backup_unmount_template': value => $backup_unmount_template;
'DEFAULT/backup_mount_export': value => $backup_mount_export;
'DEFAULT/backup_mount_proto': value => $backup_mount_proto;
'DEFAULT/backup_mount_options': value => $backup_mount_options;
}
ensure_packages('nfs-client', {
name => $::manila::params::nfs_client_package_name,
ensure => $package_ensure,
tag => 'manila-support-package',
})
}

View File

@ -70,6 +70,14 @@
# roll back share state.
# Defaults to $facts['os_service_default'].
#
# [*driver_backup_continue_update_interval*]
# (Optional) Interval to poll to perform the next steps of backup.
# Defaults to $facts['os_service_default'].
#
# [*driver_restore_continue_update_interval*]
# (Optional) Interval to poll to perform the next steps of restore.
# Defaults to $facts['os_service_default'].
#
class manila::share (
$package_ensure = 'present',
Boolean $enabled = true,
@ -86,6 +94,8 @@ class manila::share (
$share_service_inithost_offload = $facts['os_service_default'],
$check_for_expired_shares_in_recycle_bin_interval = $facts['os_service_default'],
$check_for_expired_transfers = $facts['os_service_default'],
$driver_backup_continue_update_interval = $facts['os_service_default'],
$driver_restore_continue_update_interval = $facts['os_service_default'],
) {
include manila::deps
@ -112,6 +122,8 @@ class manila::share (
'DEFAULT/share_service_inithost_offload': value => $share_service_inithost_offload;
'DEFAULT/check_for_expired_shares_in_recycle_bin_interval': value => $check_for_expired_shares_in_recycle_bin_interval;
'DEFAULT/check_for_expired_transfers': value => $check_for_expired_transfers;
'DEFAULT/driver_backup_continue_update_interval': value => $driver_backup_continue_update_interval;
'DEFAULT/driver_restore_continue_update_interval': value => $driver_restore_continue_update_interval;
}
if $manage_service {

View File

@ -0,0 +1,8 @@
---
features:
- |
The ``manila::share`` class and the ``manila::data`` class now support
options for share backup and restore.
- |
The new ``manila::data::backup::nfs`` class has been added.

View File

@ -0,0 +1,56 @@
require 'spec_helper'
describe 'manila::data::backup::nfs' do
shared_examples_for 'manila::data::backup::nfs' do
let :params do
{
:backup_mount_export => '192.0.2.1:/backup',
}
end
context 'with default parameters' do
it 'should configure manila-data options' do
is_expected.to contain_manila_config('DEFAULT/backup_mount_template').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/backup_unmount_template').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/backup_mount_export').with_value('192.0.2.1:/backup')
is_expected.to contain_manila_config('DEFAULT/backup_mount_proto').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/backup_mount_options').with_value('<SERVICE DEFAULT>')
end
end
context 'with parameters' do
before :each do
params.merge!({
:backup_mount_template => 'mount -vt %(proto)s %(options)s %(export)s %(path)s',
:backup_unmount_template => 'umount -v %(path)s',
:backup_mount_proto => 'nfs',
:backup_mount_options => '',
})
end
it 'should configure manila-data options' do
is_expected.to contain_manila_config('DEFAULT/backup_mount_template').with_value('mount -vt %(proto)s %(options)s %(export)s %(path)s')
is_expected.to contain_manila_config('DEFAULT/backup_unmount_template').with_value('umount -v %(path)s')
is_expected.to contain_manila_config('DEFAULT/backup_mount_proto').with_value('nfs')
is_expected.to contain_manila_config('DEFAULT/backup_mount_options').with_value('')
end
end
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())
end
it_behaves_like 'manila::data::backup::nfs'
end
end
end

View File

@ -8,8 +8,17 @@ describe 'manila::data' do
it { is_expected.to contain_class('manila::params') }
it { is_expected.to contain_manila_config('DEFAULT/mount_tmp_location').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_manila_config('DEFAULT/check_hash').with_value('<SERVICE DEFAULT>') }
it 'should configure manila-data options' do
is_expected.to contain_manila_config('DEFAULT/mount_tmp_location').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/backup_mount_tmp_location').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/check_hash').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/backup_continue_update_interval').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/restore_continue_update_interval').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/backup_driver').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/backup_share_mount_template').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/backup_share_unmount_template').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/backup_ignore_files').with_value('<SERVICE DEFAULT>')
end
it { is_expected.to contain_service('manila-data').with(
:name => platform_params[:data_service],
@ -23,13 +32,29 @@ describe 'manila::data' do
context 'with parameters' do
let :params do
{
:mount_tmp_location => '/tmp/',
:check_hash => false,
:mount_tmp_location => '/tmp/',
:backup_mount_tmp_location => '/tmp/backup/',
:check_hash => false,
:backup_continue_update_interval => 10,
:restore_continue_update_interval => 11,
:backup_driver => 'manila.data.drivers.nfs.NFSBackupDriver',
:backup_share_mount_template => 'mount -vt %(proto)s %(options)s %(export)s %(path)s',
:backup_share_unmount_template => 'umount -v %(path)s',
:backup_ignore_files => ['lost+found'],
}
end
it { is_expected.to contain_manila_config('DEFAULT/mount_tmp_location').with_value('/tmp/') }
it { is_expected.to contain_manila_config('DEFAULT/check_hash').with_value(false) }
it 'should configure manila-data options' do
is_expected.to contain_manila_config('DEFAULT/mount_tmp_location').with_value('/tmp/')
is_expected.to contain_manila_config('DEFAULT/backup_mount_tmp_location').with_value('/tmp/backup/')
is_expected.to contain_manila_config('DEFAULT/check_hash').with_value(false)
is_expected.to contain_manila_config('DEFAULT/backup_continue_update_interval').with_value(10)
is_expected.to contain_manila_config('DEFAULT/restore_continue_update_interval').with_value(11)
is_expected.to contain_manila_config('DEFAULT/backup_driver').with_value('manila.data.drivers.nfs.NFSBackupDriver')
is_expected.to contain_manila_config('DEFAULT/backup_share_mount_template').with_value('mount -vt %(proto)s %(options)s %(export)s %(path)s')
is_expected.to contain_manila_config('DEFAULT/backup_share_unmount_template').with_value('umount -v %(path)s')
is_expected.to contain_manila_config('DEFAULT/backup_ignore_files').with_value('lost+found')
end
end
context 'with manage_service false' do

View File

@ -27,6 +27,8 @@ describe 'manila::share' do
is_expected.to contain_manila_config('DEFAULT/share_service_inithost_offload').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/check_for_expired_shares_in_recycle_bin_interval').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/check_for_expired_transfers').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/driver_backup_continue_update_interval').with_value('<SERVICE DEFAULT>')
is_expected.to contain_manila_config('DEFAULT/driver_restore_continue_update_interval').with_value('<SERVICE DEFAULT>')
end
end
@ -45,6 +47,8 @@ describe 'manila::share' do
:share_service_inithost_offload => false,
:check_for_expired_shares_in_recycle_bin_interval => 3600,
:check_for_expired_transfers => 300,
:driver_backup_continue_update_interval => 60,
:driver_restore_continue_update_interval => 60,
}
end
@ -61,6 +65,8 @@ describe 'manila::share' do
is_expected.to contain_manila_config('DEFAULT/share_service_inithost_offload').with_value(false)
is_expected.to contain_manila_config('DEFAULT/check_for_expired_shares_in_recycle_bin_interval').with_value(3600)
is_expected.to contain_manila_config('DEFAULT/check_for_expired_transfers').with_value(300)
is_expected.to contain_manila_config('DEFAULT/driver_backup_continue_update_interval').with_value(60)
is_expected.to contain_manila_config('DEFAULT/driver_restore_continue_update_interval').with_value(60)
end
end