Migrate instance_name_template to the base class

The [DEFAULT] instance_name_template parameter is used not only by
nova-api but by other services like nova-conductor or nova-compute.
This change migrate the parameter from the api class to the base class
so that users can configure the parameter for all services.

Change-Id: I0f590f12017e743a17d989d3a1008faa9b840e87
This commit is contained in:
Takashi Kajinami 2022-01-29 23:37:44 +09:00
parent 69d4a6d51d
commit 73eb553202
4 changed files with 42 additions and 8 deletions

View File

@ -48,10 +48,6 @@
# (optional) Number of workers for metadata service
# Defaults to $::os_workers
#
# [*instance_name_template*]
# (optional) Template string to be used to generate instance names
# Defaults to $::os_service_default
#
# [*sync_db*]
# (optional) Run nova-manage db sync on api nodes after installing the package.
# Defaults to true
@ -176,6 +172,10 @@
# enable this if you have a sanitizing proxy.
# Defaults to undef
#
# [*instance_name_template*]
# (optional) Template string to be used to generate instance names
# Defaults to undef
#
class nova::api(
$enabled = true,
$manage_service = true,
@ -191,7 +191,6 @@ class nova::api(
$sync_db = true,
$sync_db_api = true,
$db_online_data_migrations = false,
$instance_name_template = $::os_service_default,
$service_name = $::nova::params::api_service_name,
$metadata_service_name = $::nova::params::api_metadata_service_name,
$enable_proxy_headers_parsing = $::os_service_default,
@ -214,6 +213,7 @@ class nova::api(
$validate = undef,
$validation_options = undef,
$use_forwarded_for = undef,
$instance_name_template = undef,
) inherits nova::params {
include nova::deps
@ -238,8 +238,19 @@ class nova::api(
warning('The use_forwarded_for parameter has been deprecated.')
}
nova_config {
'DEFAULT/instance_name_template': value => $instance_name_template;
if $instance_name_template != undef {
warning("The nova::api::instance_name_template parameter is deprecated. \
Use the nova::instance_name_template parameter instead.")
nova_config {
'DEFAULT/instance_name_template': value => $instance_name_template;
}
} else {
# Try best to clean up the parameter
if defined(Class['nova']) and $::nova::instance_name_template == undef {
nova_config {
'DEFAULT/instance_name_template': value => $::os_service_default;
}
}
}
# enable metadata in eventlet if we do not run metadata via wsgi (nova::metadata)

View File

@ -356,6 +356,10 @@
# (optional) domain to use for building the hostnames
# Defaults to $::os_service_default
#
# [*instance_name_template*]
# (optional) Template string to be used to generate instance names
# Defaults to undef
#
# DEPRECATED PARAMETERS
#
# [*auth_strategy*]
@ -459,6 +463,7 @@ class nova(
$purge_config = false,
$my_ip = $::os_service_default,
$dhcp_domain = $::os_service_default,
$instance_name_template = undef,
# DEPRECATED PARAMETERS
$auth_strategy = undef,
$os_region_name = undef,
@ -601,6 +606,14 @@ but should be one of: ssh-rsa, ssh-dsa, ssh-ecdsa.")
'DEFAULT/dhcp_domain': value => $dhcp_domain;
}
# TODO(tkajinam): Change the default value to $::os_service_default when we
# remove nova::api::instance_name_template after Antelope.
if $instance_name_template != undef {
nova_config {
'DEFAULT/instance_name_template': value => $instance_name_template;
}
}
oslo::messaging::rabbit {'nova_config':
rabbit_use_ssl => $rabbit_use_ssl,
heartbeat_timeout_threshold => $rabbit_heartbeat_timeout_threshold,

View File

@ -0,0 +1,6 @@
---
deprecations:
- |
The ``nova::api::instance_name_template`` parameter has been deprecated.
Use the ``nova::instance_name_template`` parameter instead so that
the option is configured for all nova services.

View File

@ -101,6 +101,9 @@ describe 'nova' do
is_expected.to contain_nova_config('console/ssl_ciphers').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('console/ssl_minimum_version').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('DEFAULT/dhcp_domain').with_value('<SERVICE DEFAULT>')
# TODO(tkajinam): Uncomment this when we change default value of
# nova::instance_name_template
# is_expected.to contain_nova_config('DEFAULT/instance_name_template').with_value('<SERVICE DEFAULT>')
end
end
@ -160,7 +163,7 @@ describe 'nova' do
:console_ssl_ciphers => 'kEECDH+aECDSA+AES:kEECDH+AES+aRSA:kEDH+aRSA+AES',
:console_ssl_minimum_version => 'tlsv1_2',
:dhcp_domain => 'foo',
:instance_name_template => 'instance-%08x',
}
end
@ -253,6 +256,7 @@ describe 'nova' do
is_expected.to contain_nova_config('console/ssl_ciphers').with_value('kEECDH+aECDSA+AES:kEECDH+AES+aRSA:kEDH+aRSA+AES')
is_expected.to contain_nova_config('console/ssl_minimum_version').with_value('tlsv1_2')
is_expected.to contain_nova_config('DEFAULT/dhcp_domain').with_value('foo')
is_expected.to contain_nova_config('DEFAULT/instance_name_template').with_value('instance-%08x');
end
context 'with multiple notification_driver' do