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:
#
# [*endpoint_id*]
# (Required) The service's endpoint id which is registered in Keystone.
#
# [*password*]
# (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*]
# (Optional) The name of the service user
# Defaults to 'nova'
@ -56,36 +73,44 @@
# Defaults to $facts['os_service_default'].
#
class nova::limit(
$endpoint_id,
$password,
$username = 'nova',
$auth_url = 'http://localhost:5000',
$project_name = 'services',
$user_domain_name = 'Default',
$project_domain_name = 'Default',
$system_scope = $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'],
String[1] $password,
Optional[String[1]] $endpoint_id = undef,
Optional[String[1]] $endpoint_service_name = undef,
Optional[String[1]] $endpoint_service_type = undef,
$endpoint_region_name = $facts['os_service_default'],
$endpoint_interface = $facts['os_service_default'],
$username = 'nova',
$auth_url = 'http://localhost:5000',
$project_name = 'services',
$user_domain_name = 'Default',
$project_domain_name = 'Default',
$system_scope = $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
oslo::limit { 'nova_config':
endpoint_id => $endpoint_id,
username => $username,
password => $password,
auth_url => $auth_url,
project_name => $project_name,
user_domain_name => $user_domain_name,
project_domain_name => $project_domain_name,
system_scope => $system_scope,
auth_type => $auth_type,
service_type => $service_type,
valid_interfaces => join(any2array($valid_interfaces), ','),
region_name => $region_name,
endpoint_override => $endpoint_override,
endpoint_id => $endpoint_id,
endpoint_service_name => $endpoint_service_name,
endpoint_service_type => $endpoint_service_type,
endpoint_region_name => $endpoint_region_name,
endpoint_interface => $endpoint_interface,
username => $username,
password => $password,
auth_url => $auth_url,
project_name => $project_name,
user_domain_name => $user_domain_name,
project_domain_name => $project_domain_name,
system_scope => $system_scope,
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
{
:endpoint_id => 'b41eeaed-d2ae-4add-9bfd-9ea8ac912d64',
:password => 'nova_password',
:password => 'nova_password',
}
end
it 'configure limit default params' 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
context 'with endpoint_id' do
before :each do
params.merge!({
: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',
:endpoint_id => 'b41eeaed-d2ae-4add-9bfd-9ea8ac912d64',
})
end
it 'configure limit params' do
it 'configure limit default params' do
is_expected.to contain_oslo__limit('nova_config').with(
:endpoint_id => 'b41eeaed-d2ae-4add-9bfd-9ea8ac912d64',
: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',
:endpoint_id => 'b41eeaed-d2ae-4add-9bfd-9ea8ac912d64',
:endpoint_service_name => nil,
: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
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