Merge "Separate a class for Glance configurations"

This commit is contained in:
Zuul 2021-01-25 06:43:23 +00:00 committed by Gerrit Code Review
commit 7efa708f76
5 changed files with 112 additions and 30 deletions

29
manifests/glance.pp Normal file
View File

@ -0,0 +1,29 @@
# == Class: nova::glance
#
# Configure usage of the glance service in nova
#
# === Parameters
#
# [*endpoint_override*]
# (optional) Override the endpoint to use to talk to Glance.
# Defaults to $::os_service_default
#
# [*num_retries*]
# (optional) Number of retries in glance operation
# Defaults to $::os_service_default
#
class nova::glance (
$endpoint_override = $::os_service_default,
$num_retries = $::os_service_default,
) {
include nova::deps
$endpoint_override_real = pick($::nova::glance_endpoint_override, $endpoint_override)
$num_retries_real = pick($::nova::glance_num_retries, $num_retries)
nova_config {
'glance/endpoint_override': value => $endpoint_override_real;
'glance/num_retries': value => $num_retries_real;
}
}

View File

@ -25,14 +25,6 @@
# option.
# Defaults to $::os_service_default
#
# [*glance_endpoint_override*]
# (optional) Override the endpoint to use to talk to Glance.
# Defaults to $::os_service_default
#
# [*glance_num_retries*]
# (optional) Number of retries in glance operation
# Defaults to $::os_service_default
#
# [*rabbit_use_ssl*]
# (optional) Boolean. Connect over SSL for RabbitMQ. (boolean value)
# Defaults to $::os_service_default
@ -365,10 +357,6 @@
# (optional) The strategy to use for auth: noauth or keystone.
# Defaults to undef
#
# [*glance_api_servers*]
# (optional) List of addresses for api servers.
# Defaults to undef
#
# [*database_min_pool_size*]
# (optional) Minimum number of SQL connections to keep open in a pool.
# Defaults to undef.
@ -431,6 +419,14 @@
# (Optional) Accept clients using either SSL or plain TCP
# Defaults to undef.
#
# [*glance_endpoint_override*]
# (optional) Override the endpoint to use to talk to Glance.
# Defaults to undef.
#
# [*glance_num_retries*]
# (optional) Number of retries in glance operation
# Defaults to undef.
#
class nova(
$ensure_package = 'present',
$block_device_allocate_retries = $::os_service_default,
@ -438,8 +434,6 @@ class nova(
$default_transport_url = $::os_service_default,
$rpc_response_timeout = $::os_service_default,
$control_exchange = $::os_service_default,
$glance_endpoint_override = $::os_service_default,
$glance_num_retries = $::os_service_default,
$rabbit_use_ssl = $::os_service_default,
$rabbit_heartbeat_timeout_threshold = $::os_service_default,
$rabbit_heartbeat_rate = $::os_service_default,
@ -509,7 +503,6 @@ class nova(
$dhcp_domain = $::os_service_default,
# DEPRECATED PARAMETERS
$auth_strategy = undef,
$glance_api_servers = undef,
$database_min_pool_size = undef,
$os_region_name = undef,
$cinder_catalog_info = undef,
@ -524,6 +517,8 @@ class nova(
$database_retry_interval = undef,
$database_max_overflow = undef,
$amqp_allow_insecure_clients = undef,
$glance_endpoint_override = undef,
$glance_num_retries = undef,
) inherits nova::params {
include nova::deps
@ -600,6 +595,16 @@ removed in a future realse. Use nova::db::database_retry_interval instead')
removed in a future realse. Use nova::db::database_max_overflow instead')
}
if $glance_endpoint_override != undef {
warning('The glance_endpoint_override parameter is deprecated. \
Use nova::glance::endpoint_override instead.')
}
if $glance_num_retries != undef {
warning('The glance_num_retries parameter is deprecated. \
Use nova::glance::num_retries instead.')
}
if $use_ssl {
if !$cert_file {
fail('The cert_file parameter is required when use_ssl is set to true')
@ -684,13 +689,6 @@ but should be one of: ssh-rsa, ssh-dsa, ssh-ecdsa.")
purge => $purge_config,
}
if $glance_api_servers {
warning(
'The glance_api_servers parameter is deprecated, and will be removed in a future release.'
)
nova_config { 'glance/api_servers': value => $glance_api_servers }
}
if $auth_strategy {
warning('The auth_strategy parameter is deprecated, and will be removed in a future release.')
nova_config { 'api/auth_strategy': value => $auth_strategy }
@ -817,8 +815,8 @@ but should be one of: ssh-rsa, ssh-dsa, ssh-ecdsa.")
'upgrade_levels/intercell': value => $upgrade_level_intercell;
'upgrade_levels/network': value => $upgrade_level_network;
'upgrade_levels/scheduler': value => $upgrade_level_scheduler;
'glance/endpoint_override': value => $glance_endpoint_override;
'glance/num_retries': value => $glance_num_retries;
}
# TODO(tkajinam): Remove this when we remove the deprecated glance_* options
include nova::glance
}

View File

@ -0,0 +1,17 @@
---
features:
- |
The new ``nova::glance`` class has been added to manage configurations
to determine usage of the Glance service.
upgrade:
- |
The deprecated ``nova::glance_api_servers`` parameter has been removed.
deprecations:
- |
The following parameters in the ``nova`` class has been deprecated. Use
the new ``nova::glance`` class instead.
- ``glance_endpoint_override``
- ``glance_num_retries``

View File

@ -0,0 +1,44 @@
require 'spec_helper'
describe 'nova::glance' do
shared_examples_for 'nova::glance' do
context 'with default params' do
let :params do
{}
end
it 'configure default params' do
is_expected.to contain_nova_config('glance/endpoint_override').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('glance/num_retries').with_value('<SERVICE DEFAULT>')
end
end
context 'with specific parameters' do
let :params do
{
:endpoint_override => 'http://localhost:9292',
:num_retries => 3,
}
end
it 'configure glance params' do
is_expected.to contain_nova_config('glance/endpoint_override').with_value('http://localhost:9292')
is_expected.to contain_nova_config('glance/num_retries').with_value(3)
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 'nova::glance'
end
end
end

View File

@ -30,10 +30,6 @@ describe 'nova' do
:refreshonly => true
)}
it 'does not configure glance api servers' do
is_expected.to_not contain_nova_config('glance/api_servers')
end
it 'does not configure auth_strategy' do
is_expected.not_to contain_nova_config('api/auth_strategy')
end
@ -81,7 +77,6 @@ describe 'nova' do
{
:glance_endpoint_override => 'http://localhost:9292',
:glance_num_retries => 3,
:glance_api_servers => ['http://localhost:9292', 'http://localhost:9293'],
:default_transport_url => 'rabbit://rabbit_user:password@localhost:5673',
:rpc_response_timeout => '30',
:control_exchange => 'nova',
@ -139,7 +134,6 @@ describe 'nova' do
it 'configures glance parameters' do
is_expected.to contain_nova_config('glance/endpoint_override').with_value('http://localhost:9292')
is_expected.to contain_nova_config('glance/num_retries').with_value(3)
is_expected.to contain_nova_config('glance/api_servers').with_value(['http://localhost:9292', 'http://localhost:9293'])
end
it 'configures auth_strategy' do