Add cinder::nova class to configure nova section

Adds new class cinder::nova that can be used to
configure the nova section in cinder.conf as in [1].

[1] https://docs.openstack.org/cinder/latest/configuration/block-storage/samples/cinder.conf.html

Change-Id: I35885a30ff9f023f52e29fd2585805e44ab6f85e
(cherry picked from commit 944d484020)
This commit is contained in:
Tobias Urdin 2018-09-06 23:43:43 +02:00 committed by Alan Bishop
parent 8d55d0566f
commit 2d9e7fd02e
3 changed files with 163 additions and 0 deletions

89
manifests/nova.pp Normal file
View File

@ -0,0 +1,89 @@
# == Class: cinder::nova
#
# Setup and configure cinder.conf nova section.
#
# === Parameters
#
# [*region_name*]
# (Optional) Name of nova region to use.
# Defaults to $::os_service_default
#
# [*interface*]
# (Optional) Type of the nova endpoint to use.
# Defaults to $::os_service_default
#
# [*token_auth_url*]
# (Optional) The authentication URL for the nova
# connection when using the current users token.
# Defaults to $::os_service_default
#
# [*cafile*]
# (Optional) PEM encoded Certificate Authority to use
# when verifying HTTPs connections.
# Defaults to $::os_service_default
#
# [*certfile*]
# (Optional) PEM encoded client certificate cert file.
# Defaults to $::os_service_default
#
# [*keyfile*]
# (Optional) PEM encoded client certificate key file.
# Defaults to $::os_service_default
#
# [*insecure*]
# (Optional) Verify HTTPS connections.
# Defaults to $::os_service_default
#
# [*timeout*]
# (Optional) Timeout value for http requests.
# Defaults to $::os_service_default
#
# [*collect_timing*]
# (Optional) Collect per-API call timing information.
# Defaults to $::os_service_default
#
# [*split_loggers*]
# (Optional) Log requests to multiple loggers.
# Defaults to $::os_service_default
#
# [*auth_type*]
# (Optional) Authentication type to load.
# Defaults to $::os_service_default
#
# [*auth_section*]
# (Optional) Config Section from which to load plugin
# specific options.
# Defaults to $::os_service_default
#
class cinder::nova (
$region_name = $::os_service_default,
$interface = $::os_service_default,
$token_auth_url = $::os_service_default,
$cafile = $::os_service_default,
$certfile = $::os_service_default,
$keyfile = $::os_service_default,
$insecure = $::os_service_default,
$timeout = $::os_service_default,
$collect_timing = $::os_service_default,
$split_loggers = $::os_service_default,
$auth_type = $::os_service_default,
$auth_section = $::os_service_default,
) {
include ::cinder::deps
cinder_config {
'nova/region_name': value => $region_name;
'nova/interface': value => $interface;
'nova/token_auth_url': value => $token_auth_url;
'nova/cafile': value => $cafile;
'nova/certfile': value => $certfile;
'nova/keyfile': value => $keyfile;
'nova/insecure': value => $insecure;
'nova/timeout': value => $timeout;
'nova/collect_timing': value => $collect_timing;
'nova/split_loggers': value => $split_loggers;
'nova/auth_type': value => $auth_type;
'nova/auth_section': value => $auth_section;
}
}

View File

@ -0,0 +1,5 @@
---
features:
- |
Added new class cinder::nova which can be used to configure the options
in the nova section in cinder.conf

View File

@ -0,0 +1,69 @@
require 'spec_helper'
describe 'cinder::nova' do
shared_examples 'cinder::nova' do
context 'with default parameters' do
it {
should contain_cinder_config('nova/region_name').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('nova/interface').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('nova/token_auth_url').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('nova/cafile').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('nova/certfile').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('nova/keyfile').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('nova/insecure').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('nova/timeout').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('nova/collect_timing').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('nova/split_loggers').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('nova/auth_type').with_value('<SERVICE DEFAULT>')
should contain_cinder_config('nova/auth_section').with_value('<SERVICE DEFAULT>')
}
end
context 'with specified parameters' do
let :params do
{
:region_name => 'RegionOne',
:interface => 'internal',
:token_auth_url => 'http://127.0.0.1:5000/v3',
:cafile => '/etc/ssl/certs/ca.crt',
:certfile => '/etc/ssl/certs/cert.crt',
:keyfile => '/etc/ssl/private/key.key',
:insecure => false,
:timeout => 30,
:collect_timing => true,
:split_loggers => true,
:auth_type => 'password',
:auth_section => 'my_section'
}
end
it {
should contain_cinder_config('nova/region_name').with_value('RegionOne')
should contain_cinder_config('nova/interface').with_value('internal')
should contain_cinder_config('nova/token_auth_url').with_value('http://127.0.0.1:5000/v3')
should contain_cinder_config('nova/cafile').with_value('/etc/ssl/certs/ca.crt')
should contain_cinder_config('nova/certfile').with_value('/etc/ssl/certs/cert.crt')
should contain_cinder_config('nova/keyfile').with_value('/etc/ssl/private/key.key')
should contain_cinder_config('nova/insecure').with_value(false)
should contain_cinder_config('nova/timeout').with_value(30)
should contain_cinder_config('nova/collect_timing').with_value(true)
should contain_cinder_config('nova/split_loggers').with_value(true)
should contain_cinder_config('nova/auth_type').with_value('password')
should contain_cinder_config('nova/auth_section').with_value('my_section')
}
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 'cinder::nova'
end
end
end