Support new oslo.limit options to query endpoint

Depends-on: https://review.opendev.org/932062
Change-Id: Iec828782a2c81dcd47323d851f1b6e32c02a3ea3
This commit is contained in:
Takashi Kajinami
2024-10-12 01:18:10 +09:00
parent 06159d4b23
commit 311070231d
3 changed files with 186 additions and 75 deletions

View File

@@ -4,12 +4,29 @@
# #
# === Parameters: # === Parameters:
# #
# [*endpoint_id*]
# (Required) The service's endpoint id which is registered in Keystone.
#
# [*password*] # [*password*]
# (Required) Password to create for the service user # (Required) Password to create for the service user
# #
# [*endpoint_id*]
# (Optional) The service's endpoint id which is registered in Keystone.
# Defaults to undef
#
# [*endpoint_service_name*]
# (Optional) Service name for endpoint discovery
# Defaults to undef
#
# [*endpoint_service_type*]
# (Optional) Service type for endpoint discovery
# Defaults to undef
#
# [*endpoint_region_name*]
# (Optional) Region to which the endpoint belongs.
# Defaults to $facts['os_service_default']
#
# [*endpoint_interface*]
# (Optional) The interface for endpoint discovery.
# Defaults to $facts['os_service_default']
#
# [*username*] # [*username*]
# (Optional) The name of the service user # (Optional) The name of the service user
# Defaults to 'nova' # Defaults to 'nova'
@@ -56,36 +73,44 @@
# Defaults to $facts['os_service_default']. # Defaults to $facts['os_service_default'].
# #
class nova::limit( class nova::limit(
$endpoint_id, String[1] $password,
$password, Optional[String[1]] $endpoint_id = undef,
$username = 'nova', Optional[String[1]] $endpoint_service_name = undef,
$auth_url = 'http://localhost:5000', Optional[String[1]] $endpoint_service_type = undef,
$project_name = 'services', $endpoint_region_name = $facts['os_service_default'],
$user_domain_name = 'Default', $endpoint_interface = $facts['os_service_default'],
$project_domain_name = 'Default', $username = 'nova',
$system_scope = $facts['os_service_default'], $auth_url = 'http://localhost:5000',
$auth_type = 'password', $project_name = 'services',
$service_type = $facts['os_service_default'], $user_domain_name = 'Default',
$valid_interfaces = $facts['os_service_default'], $project_domain_name = 'Default',
$region_name = $facts['os_service_default'], $system_scope = $facts['os_service_default'],
$endpoint_override = $facts['os_service_default'], $auth_type = 'password',
$service_type = $facts['os_service_default'],
$valid_interfaces = $facts['os_service_default'],
$region_name = $facts['os_service_default'],
$endpoint_override = $facts['os_service_default'],
) { ) {
include nova::deps include nova::deps
oslo::limit { 'nova_config': oslo::limit { 'nova_config':
endpoint_id => $endpoint_id, endpoint_id => $endpoint_id,
username => $username, endpoint_service_name => $endpoint_service_name,
password => $password, endpoint_service_type => $endpoint_service_type,
auth_url => $auth_url, endpoint_region_name => $endpoint_region_name,
project_name => $project_name, endpoint_interface => $endpoint_interface,
user_domain_name => $user_domain_name, username => $username,
project_domain_name => $project_domain_name, password => $password,
system_scope => $system_scope, auth_url => $auth_url,
auth_type => $auth_type, project_name => $project_name,
service_type => $service_type, user_domain_name => $user_domain_name,
valid_interfaces => join(any2array($valid_interfaces), ','), project_domain_name => $project_domain_name,
region_name => $region_name, system_scope => $system_scope,
endpoint_override => $endpoint_override, auth_type => $auth_type,
service_type => $service_type,
valid_interfaces => join(any2array($valid_interfaces), ','),
region_name => $region_name,
endpoint_override => $endpoint_override,
} }
} }

View File

@@ -0,0 +1,9 @@
---
features:
- |
The following parameters have been added to the ``nova::limit`` class.
- ``endpoint_service_name``
- ``endpoint_service_type``
- ``endpoint_region_name``
- ``endpoint_interface``

View File

@@ -6,61 +6,138 @@ describe 'nova::limit' do
let :params do let :params do
{ {
:endpoint_id => 'b41eeaed-d2ae-4add-9bfd-9ea8ac912d64', :password => 'nova_password',
:password => 'nova_password',
} }
end end
it 'configure limit default params' do context 'with endpoint_id' do
is_expected.to contain_oslo__limit('nova_config').with(
:endpoint_id => 'b41eeaed-d2ae-4add-9bfd-9ea8ac912d64',
:username => 'nova',
:password => 'nova_password',
:auth_url => 'http://localhost:5000',
:project_name => 'services',
:user_domain_name => 'Default',
:project_domain_name => 'Default',
:system_scope => '<SERVICE DEFAULT>',
:auth_type => 'password',
:service_type => '<SERVICE DEFAULT>',
:valid_interfaces => '<SERVICE DEFAULT>',
:region_name => '<SERVICE DEFAULT>',
:endpoint_override => '<SERVICE DEFAULT>',
)
end
context 'with specific parameters' do
before :each do before :each do
params.merge!({ params.merge!({
:username => 'alt_nova', :endpoint_id => 'b41eeaed-d2ae-4add-9bfd-9ea8ac912d64',
:auth_url => 'http://192.168.0.1:5000',
:project_name => 'alt_services',
:user_domain_name => 'domainX',
:project_domain_name => 'domainX',
:system_scope => 'all',
:auth_type => 'v3password',
:service_type => 'identity',
:valid_interfaces => 'public',
:region_name => 'regionOne',
:endpoint_override => 'http://192.168.0.2:5000',
}) })
end end
it 'configure limit params' do it 'configure limit default params' do
is_expected.to contain_oslo__limit('nova_config').with( is_expected.to contain_oslo__limit('nova_config').with(
:endpoint_id => 'b41eeaed-d2ae-4add-9bfd-9ea8ac912d64', :endpoint_id => 'b41eeaed-d2ae-4add-9bfd-9ea8ac912d64',
:username => 'alt_nova', :endpoint_service_name => nil,
:password => 'nova_password', :endpoint_service_type => nil,
:auth_url => 'http://192.168.0.1:5000', :endpoint_region_name => '<SERVICE DEFAULT>',
:project_name => 'alt_services', :endpoint_interface => '<SERVICE DEFAULT>',
:user_domain_name => 'domainX', :username => 'nova',
:project_domain_name => 'domainX', :password => 'nova_password',
:system_scope => 'all', :auth_url => 'http://localhost:5000',
:auth_type => 'v3password', :project_name => 'services',
:service_type => 'identity', :user_domain_name => 'Default',
:valid_interfaces => 'public', :project_domain_name => 'Default',
:region_name => 'regionOne', :system_scope => '<SERVICE DEFAULT>',
:endpoint_override => 'http://192.168.0.2:5000', :auth_type => 'password',
:service_type => '<SERVICE DEFAULT>',
:valid_interfaces => '<SERVICE DEFAULT>',
:region_name => '<SERVICE DEFAULT>',
:endpoint_override => '<SERVICE DEFAULT>',
)
end
context 'with specific parameters' do
before :each do
params.merge!({
:endpoint_region_name => 'regionOne',
:endpoint_interface => 'public',
:username => 'alt_nova',
:auth_url => 'http://192.168.0.1:5000',
:project_name => 'alt_services',
:user_domain_name => 'domainX',
:project_domain_name => 'domainX',
:system_scope => 'all',
:auth_type => 'v3password',
:service_type => 'identity',
:valid_interfaces => 'public',
:region_name => 'regionOne',
:endpoint_override => 'http://192.168.0.2:5000',
})
end
it 'configure limit params' do
is_expected.to contain_oslo__limit('nova_config').with(
:endpoint_id => 'b41eeaed-d2ae-4add-9bfd-9ea8ac912d64',
:endpoint_service_name => nil,
:endpoint_service_type => nil,
:endpoint_region_name => 'regionOne',
:endpoint_interface => 'public',
:username => 'alt_nova',
:password => 'nova_password',
:auth_url => 'http://192.168.0.1:5000',
:project_name => 'alt_services',
:user_domain_name => 'domainX',
:project_domain_name => 'domainX',
:system_scope => 'all',
:auth_type => 'v3password',
:service_type => 'identity',
:valid_interfaces => 'public',
:region_name => 'regionOne',
:endpoint_override => 'http://192.168.0.2:5000',
)
end
end
end
context 'with endpoint_service_name' do
before :each do
params.merge!({
:endpoint_service_name => 'nova',
})
end
it 'configure limit default params' do
is_expected.to contain_oslo__limit('nova_config').with(
:endpoint_id => nil,
:endpoint_service_name => 'nova',
:endpoint_service_type => nil,
:endpoint_region_name => '<SERVICE DEFAULT>',
:endpoint_interface => '<SERVICE DEFAULT>',
:username => 'nova',
:password => 'nova_password',
:auth_url => 'http://localhost:5000',
:project_name => 'services',
:user_domain_name => 'Default',
:project_domain_name => 'Default',
:system_scope => '<SERVICE DEFAULT>',
:auth_type => 'password',
:service_type => '<SERVICE DEFAULT>',
:valid_interfaces => '<SERVICE DEFAULT>',
:region_name => '<SERVICE DEFAULT>',
:endpoint_override => '<SERVICE DEFAULT>',
)
end
end
context 'with endpoint_service_type' do
before :each do
params.merge!({
:endpoint_service_type => 'compute',
})
end
it 'configure limit default params' do
is_expected.to contain_oslo__limit('nova_config').with(
:endpoint_id => nil,
:endpoint_service_name => nil,
:endpoint_service_type => 'compute',
:endpoint_region_name => '<SERVICE DEFAULT>',
:endpoint_interface => '<SERVICE DEFAULT>',
:username => 'nova',
:password => 'nova_password',
:auth_url => 'http://localhost:5000',
:project_name => 'services',
:user_domain_name => 'Default',
:project_domain_name => 'Default',
:system_scope => '<SERVICE DEFAULT>',
:auth_type => 'password',
:service_type => '<SERVICE DEFAULT>',
:valid_interfaces => '<SERVICE DEFAULT>',
:region_name => '<SERVICE DEFAULT>',
:endpoint_override => '<SERVICE DEFAULT>',
) )
end end
end end