Merge "Support manila-data service"

This commit is contained in:
Zuul 2022-11-29 18:09:27 +00:00 committed by Gerrit Code Review
commit ee34cc6060
4 changed files with 175 additions and 0 deletions

67
manifests/data.pp Normal file
View File

@ -0,0 +1,67 @@
# == Class: manila::data
#
# Install and manage Manila data.
#
# === Parameters
#
# [*package_ensure*]
# (Optional) The state of the data package
# Defaults to 'present'.
#
# [*enabled*]
# (Optional) Whether to run the data service
# Defaults to true.
#
# [*manage_service*]
# (Optional) Whether to start/stop the service
# Defaults to true.
#
# [*mount_tmp_location*]
# (Optional) Temporary path to create and mount shares during migration.
# Defaults to $::os_service_default.
#
# [*check_hash*]
# (Optional) Chooses whether hash of each file should be checked on data
# copying.
# Defaults to $::os_service_default.
#
class manila::data (
$package_ensure = 'present',
$enabled = true,
$manage_service = true,
$mount_tmp_location = $::os_service_default,
$check_hash = $::os_service_default,
) {
include manila::deps
include manila::params
if $::manila::params::data_package {
package { 'manila-data':
ensure => $package_ensure,
name => $::manila::params::data_package,
tag => ['openstack', 'manila-package'],
}
}
manila_config {
'DEFAULT/mount_tmp_location': value => $mount_tmp_location;
'DEFAULT/check_hash': value => $check_hash;
}
if $manage_service {
if $enabled {
$ensure = 'running'
} else {
$ensure = 'stopped'
}
service { 'manila-data':
ensure => $ensure,
name => $::manila::params::data_service,
enable => $enabled,
hasstatus => true,
tag => 'manila-service',
}
}
}

View File

@ -16,6 +16,8 @@ class manila::params {
$package_name = 'manila-common'
$api_package = 'manila-api'
$api_service = 'manila-api'
$data_package = 'manila-data'
$data_service = 'manila-data'
$scheduler_package = 'manila-scheduler'
$scheduler_service = 'manila-scheduler'
$share_package = 'manila-share'
@ -31,6 +33,8 @@ class manila::params {
$package_name = 'openstack-manila'
$api_package = false
$api_service = 'openstack-manila-api'
$data_package = false
$data_service = 'openstack-manila-data'
$scheduler_package = false
$scheduler_service = 'openstack-manila-scheduler'
$share_package = 'openstack-manila-share'

View File

@ -0,0 +1,5 @@
---
features:
- |
The new ``manila::data`` class has been added. This class configures
the ``manila-data`` service.

View File

@ -0,0 +1,99 @@
require 'spec_helper'
describe 'manila::data' do
shared_examples_for 'manila::data' do
context 'with default parameters' 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 { is_expected.to contain_service('manila-data').with(
:name => platform_params[:data_service],
:enable => true,
:ensure => 'running',
:hasstatus => true,
:tag => 'manila-service',
) }
end
context 'with parameters' do
let :params do
{
:mount_tmp_location => '/tmp/',
:check_hash => false,
}
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) }
end
context 'with manage_service false' do
let :params do
{
:manage_service => false
}
end
it 'should not configure the service' do
is_expected.to_not contain_service('manila-data')
end
end
end
shared_examples_for 'manila::data on Debian' do
context 'with default parameters' do
it { is_expected.to contain_package('manila-data').with(
:name => 'manila-data',
:ensure => 'present',
:tag => ['openstack', 'manila-package'],
) }
end
context 'with parameters' do
let :params do
{
:package_ensure => 'installed'
}
end
it { is_expected.to contain_package('manila-data').with(
:name => 'manila-data',
:ensure => 'installed',
:tag => ['openstack', 'manila-package'],
) }
end
end
shared_examples_for 'manila::data on RedHat' do
context 'with default parameters' do
it { is_expected.to_not contain_package('manila-data') }
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
let :platform_params do
case facts[:osfamily]
when 'Debian'
{ :data_service => 'manila-data' }
when 'RedHat'
{ :data_service => 'openstack-manila-data' }
end
end
it_behaves_like 'manila::data'
it_behaves_like "manila::data on #{facts[:osfamily]}"
end
end
end