Use consistent parameter names for quota options

This change renames parameters of octavia::quota options, so that we
use consistent parameter names with the definitions in Octavia.

Change-Id: I63a585b34eaeb5350dbbd72936b4949ebd96e0f0
This commit is contained in:
Takashi Kajinami 2021-01-24 11:20:05 +09:00
parent 46cffbd1e9
commit 7d5b8aafc8
3 changed files with 107 additions and 29 deletions

View File

@ -4,41 +4,86 @@
#
# === Parameters:
#
# [*load_balancer_quota*]
# [*default_load_balancer_quota*]
# (optional) Default per project load balancer quota
# Defaults to $::os_service_default
#
# [*listener_quota*]
# [*default_listener_quota*]
# (optional) Default per project listener quota.
# Defaults to $::os_service_default
#
# [*member_quota*]
# [*default_member_quota*]
# (optional) Default per project member quota.
# Defaults to $::os_service_default
#
# [*pool_quota*]
# [*default_pool_quota*]
# (optional) Default per project pool quota.
# Defaults to $::os_service_default
#
# [*health_monitor_quota*]
# [*default_health_monitor_quota*]
# (optional) Default per project health monitor quota.
# Defaults to $::os_service_default
#
# DEPRECATED PARAMETERS
#
# [*load_balancer_quota*]
# (optional) Default per project load balancer quota
# Defaults to undef
#
# [*listener_quota*]
# (optional) Default per project listener quota.
# Defaults to undef
#
# [*member_quota*]
# (optional) Default per project member quota.
# Defaults to undef
#
# [*pool_quota*]
# (optional) Default per project pool quota.
# Defaults to undef
#
# [*health_monitor_quota*]
# (optional) Default per project health monitor quota.
# Defaults to undef
#
class octavia::quota (
$load_balancer_quota = $::os_service_default,
$listener_quota = $::os_service_default,
$member_quota = $::os_service_default,
$pool_quota = $::os_service_default,
$health_monitor_quota = $::os_service_default,
$default_load_balancer_quota = $::os_service_default,
$default_listener_quota = $::os_service_default,
$default_member_quota = $::os_service_default,
$default_pool_quota = $::os_service_default,
$default_health_monitor_quota = $::os_service_default,
# DEPRECATED PARAMETERS
$load_balancer_quota = undef,
$listener_quota = undef,
$member_quota = undef,
$pool_quota = undef,
$health_monitor_quota = undef,
) {
include octavia::deps
octavia_config {
'quotas/default_load_balancer_quota': value => $load_balancer_quota;
'quotas/default_listener_quota': value => $listener_quota;
'quotas/default_member_quota': value => $member_quota;
'quotas/default_pool_quota': value => $pool_quota;
'quotas/default_health_monitor_quota': value => $health_monitor_quota;
[
'load_balancer_quota',
'listener_quota',
'member_quota',
'pool_quota',
'health_monitor_quota'
].each |String $quota_opt| {
if getvar("${quota_opt}") != undef {
warning("The ${quota_opt} parameter is deprecated. Use the default_${quota_opt} parameter.")
}
octavia_config {
"quotas/default_${quota_opt}": value => pick(getvar("${quota_opt}"), getvar("default_${quota_opt}"))
}
}
# NOTE(tkajinam): Revert back to this implementation when we remove
# the deprecated parameters.
# octavia_config {
# 'quotas/default_load_balancer_quota': value => $load_balancer_quota;
# 'quotas/default_listener_quota': value => $listener_quota;
# 'quotas/default_member_quota': value => $member_quota;
# 'quotas/default_pool_quota': value => $pool_quota;
# 'quotas/default_health_monitor_quota': value => $health_monitor_quota;
# }
}

View File

@ -0,0 +1,7 @@
---
deprecations:
- |
Now all parameters of the ``quota::class`` class are prefixed with
``defualt_``, to be consistent with the parameter names in Octavia.
All exisitng parameters without the ``default_`` prefix are deprecated and
will be removed in a future release.

View File

@ -2,11 +2,13 @@ require 'spec_helper'
describe 'octavia::quota' do
let :default_params do
{ :load_balancer_quota => '<SERVICE DEFAULT>',
:listener_quota => '<SERVICE DEFAULT>',
:member_quota => '<SERVICE DEFAULT>',
:pool_quota => '<SERVICE DEFAULT>',
:health_monitor_quota => '<SERVICE DEFAULT>' }
{
:default_load_balancer_quota => '<SERVICE DEFAULT>',
:default_listener_quota => '<SERVICE DEFAULT>',
:default_member_quota => '<SERVICE DEFAULT>',
:default_pool_quota => '<SERVICE DEFAULT>',
:default_health_monitor_quota => '<SERVICE DEFAULT>'
}
end
let :params do
@ -20,18 +22,42 @@ describe 'octavia::quota' do
end
it 'contains default values' do
is_expected.to contain_octavia_config('quotas/default_load_balancer_quota').with_value(p[:load_balancer_quota])
is_expected.to contain_octavia_config('quotas/default_listener_quota').with_value(p[:listener_quota])
is_expected.to contain_octavia_config('quotas/default_member_quota').with_value(p[:member_quota])
is_expected.to contain_octavia_config('quotas/default_pool_quota').with_value(p[:pool_quota])
is_expected.to contain_octavia_config('quotas/default_health_monitor_quota').with_value(p[:health_monitor_quota])
is_expected.to contain_octavia_config('quotas/default_load_balancer_quota').with_value(p[:default_load_balancer_quota])
is_expected.to contain_octavia_config('quotas/default_listener_quota').with_value(p[:default_listener_quota])
is_expected.to contain_octavia_config('quotas/default_member_quota').with_value(p[:default_member_quota])
is_expected.to contain_octavia_config('quotas/default_pool_quota').with_value(p[:default_pool_quota])
is_expected.to contain_octavia_config('quotas/default_health_monitor_quota').with_value(p[:default_health_monitor_quota])
end
context 'configure quota with parameters' do
before :each do
params.merge!({ :load_balancer_quota => 10,
:listener_quota => 100,
:member_quota => 100 })
params.merge!({
:default_load_balancer_quota => 10,
:default_listener_quota => 20,
:default_member_quota => 30,
:default_pool_quota => 40,
:default_health_monitor_quota => 50
})
end
it 'contains overrided values' do
is_expected.to contain_octavia_config('quotas/default_load_balancer_quota').with_value(p[:default_load_balancer_quota])
is_expected.to contain_octavia_config('quotas/default_listener_quota').with_value(p[:default_listener_quota])
is_expected.to contain_octavia_config('quotas/default_member_quota').with_value(p[:default_member_quota])
is_expected.to contain_octavia_config('quotas/default_pool_quota').with_value(p[:default_pool_quota])
is_expected.to contain_octavia_config('quotas/default_health_monitor_quota').with_value(p[:default_health_monitor_quota])
end
end
context 'configure quota with deprecated parameters' do
before :each do
params.merge!({
:load_balancer_quota => 10,
:listener_quota => 20,
:member_quota => 30,
:pool_quota => 40,
:health_monitor_quota => 50
})
end
it 'contains overrided values' do