Merge "nova::quota fix correct conf group and rename params"

This commit is contained in:
Zuul 2018-11-08 11:28:43 +00:00 committed by Gerrit Code Review
commit d0d1353f85
3 changed files with 262 additions and 112 deletions

View File

@ -4,60 +4,59 @@
# #
# === Parameters: # === Parameters:
# #
# [*quota_instances*] # [*instances*]
# (optional) Number of instances # (optional) Number of instances
# Defaults to 10 # Defaults to 10
# #
# [*quota_cores*] # [*cores*]
# (optional) Number of cores # (optional) Number of cores
# Defaults to 20 # Defaults to 20
# #
# [*quota_ram*] # [*ram*]
# (optional) Ram in MB # (optional) Ram in MB
# Defaults to 51200 # Defaults to 51200
# #
# [*quota_floating_ips*] # [*floating_ips*]
# (optional) Number of floating IPs # (optional) Number of floating IPs
# Defaults to 10 # Defaults to 10
# #
# [*quota_fixed_ips*] # [*fixed_ips*]
# (optional) Number of fixed IPs (this should be at least the number of instances allowed) # (optional) Number of fixed IPs (this should be at least the number of instances allowed)
# Defaults to -1 # Defaults to -1
# #
# [*quota_metadata_items*] # [*metadata_items*]
# (optional) Number of metadata items per instance # (optional) Number of metadata items per instance
# Defaults to 128 # Defaults to 128
# #
# [*quota_injected_files*] # [*injected_files*]
# (optional) Number of files that can be injected per instance # (optional) Number of files that can be injected per instance
# Defaults to 5 # Defaults to 5
# #
# [*quota_injected_file_content_bytes*] # [*injected_file_content_bytes*]
# (optional) Maximum size in bytes of injected files # (optional) Maximum size in bytes of injected files
# Defaults to 10240 # Defaults to 10240
# #
# # [*injected_file_path_length*]
# [*quota_injected_file_path_length*]
# (optional) Maximum size in bytes of injected file path # (optional) Maximum size in bytes of injected file path
# Defaults to 255 # Defaults to 255
# #
# [*quota_security_groups*] # [*security_groups*]
# (optional) Number of security groups # (optional) Number of security groups
# Defaults to 10 # Defaults to 10
# #
# [*quota_security_group_rules*] # [*security_group_rules*]
# (optional) Number of security group rules # (optional) Number of security group rules
# Defaults to 20 # Defaults to 20
# #
# [*quota_key_pairs*] # [*key_pairs*]
# (optional) Number of key pairs # (optional) Number of key pairs
# Defaults to 100 # Defaults to 100
# #
# [*quota_server_groups*] # [*server_groups*]
# (optional) Number of server groups per project # (optional) Number of server groups per project
# Defaults to 10 # Defaults to 10
# #
# [*quota_server_group_members*] # [*server_group_members*]
# (optional) Number of servers per server group # (optional) Number of servers per server group
# Defaults to 10 # Defaults to 10
# #
@ -73,47 +72,134 @@
# (optional) Number of seconds between subsequent usage refreshes # (optional) Number of seconds between subsequent usage refreshes
# Defaults to 0 # Defaults to 0
# #
#### DEPRECATED PARAMS
#
# [*quota_instances*]
# (optional) Number of instances
# Defaults to undef
#
# [*quota_cores*]
# (optional) Number of cores
# Defaults to undef
#
# [*quota_ram*]
# (optional) Ram in MB
# Defaults to undef
#
# [*quota_floating_ips*]
# (optional) Number of floating IPs
# Defaults to undef
#
# [*quota_fixed_ips*]
# (optional) Number of fixed IPs (this should be at least the number of instances allowed)
# Defaults to undef
#
# [*quota_metadata_items*]
# (optional) Number of metadata items per instance
# Defaults to undef
#
# [*quota_injected_files*]
# (optional) Number of files that can be injected per instance
# Defaults to undef
#
# [*quota_injected_file_content_bytes*]
# (optional) Maximum size in bytes of injected files
# Defaults to undef
#
# [*quota_injected_file_path_length*]
# (optional) Maximum size in bytes of injected file path
# Defaults to undef
#
# [*quota_security_groups*]
# (optional) Number of security groups
# Defaults to undef
#
# [*quota_security_group_rules*]
# (optional) Number of security group rules
# Defaults to undef
#
# [*quota_key_pairs*]
# (optional) Number of key pairs
# Defaults to undef
#
# [*quota_server_groups*]
# (optional) Number of server groups per project
# Defaults to undef
#
# [*quota_server_group_members*]
# (optional) Number of servers per server group
# Defaults to undef
# #
class nova::quota( class nova::quota(
$quota_instances = 10, $instances = 10,
$quota_cores = 20, $cores = 20,
$quota_ram = 51200, $ram = 51200,
$quota_floating_ips = 10, $floating_ips = 10,
$quota_fixed_ips = -1, $fixed_ips = -1,
$quota_metadata_items = 128, $metadata_items = 128,
$quota_injected_files = 5, $injected_files = 5,
$quota_injected_file_content_bytes = 10240, $injected_file_content_bytes = 10240,
$quota_injected_file_path_length = 255, $injected_file_path_length = 255,
$quota_security_groups = 10, $security_groups = 10,
$quota_security_group_rules = 20, $security_group_rules = 20,
$quota_key_pairs = 100, $key_pairs = 100,
$quota_server_groups = 10, $server_groups = 10,
$quota_server_group_members = 10, $server_group_members = 10,
$reservation_expire = 86400, $reservation_expire = 86400,
$until_refresh = 0, $until_refresh = 0,
$max_age = 0, $max_age = 0,
# DEPRECATED PARAMS
$quota_instances = undef,
$quota_cores = undef,
$quota_ram = undef,
$quota_floating_ips = undef,
$quota_fixed_ips = undef,
$quota_metadata_items = undef,
$quota_injected_files = undef,
$quota_injected_file_content_bytes = undef,
$quota_injected_file_path_length = undef,
$quota_security_groups = undef,
$quota_security_group_rules = undef,
$quota_key_pairs = undef,
$quota_server_groups = undef,
$quota_server_group_members = undef,
) { ) {
include ::nova::deps include ::nova::deps
# TODO(tobias-urdin): Remove these params and picks in the T release.
$instances_real = pick($quota_instances, $instances)
$cores_real = pick($quota_cores, $cores)
$ram_real = pick($quota_ram, $ram)
$floating_ips_real = pick($quota_floating_ips, $floating_ips)
$fixed_ips_real = pick($quota_fixed_ips, $fixed_ips)
$metadata_items_real = pick($quota_metadata_items, $metadata_items)
$injected_files_real = pick($quota_injected_files, $injected_files)
$injected_file_content_bytes_real = pick($quota_injected_file_content_bytes, $injected_file_content_bytes)
$injected_file_path_length_real = pick($quota_injected_file_path_length, $injected_file_path_length)
$security_groups_real = pick($quota_security_groups, $security_groups)
$security_group_rules_real = pick($quota_security_group_rules, $security_group_rules)
$key_pairs_real = pick($quota_key_pairs, $key_pairs)
$server_groups_real = pick($quota_server_groups, $server_groups)
$server_group_members_real = pick($quota_server_group_members, $server_group_members)
nova_config { nova_config {
'DEFAULT/quota_instances': value => $quota_instances; 'quota/instances': value => $instances_real;
'DEFAULT/quota_cores': value => $quota_cores; 'quota/cores': value => $cores_real;
'DEFAULT/quota_ram': value => $quota_ram; 'quota/ram': value => $ram_real;
'DEFAULT/quota_floating_ips': value => $quota_floating_ips; 'quota/floating_ips': value => $floating_ips_real;
'DEFAULT/quota_fixed_ips': value => $quota_fixed_ips; 'quota/fixed_ips': value => $fixed_ips_real;
'DEFAULT/quota_metadata_items': value => $quota_metadata_items; 'quota/metadata_items': value => $metadata_items_real;
'DEFAULT/quota_injected_files': value => $quota_injected_files; 'quota/injected_files': value => $injected_files_real;
'DEFAULT/quota_injected_file_content_bytes': value => $quota_injected_file_content_bytes; 'quota/injected_file_content_bytes': value => $injected_file_content_bytes_real;
'DEFAULT/quota_injected_file_path_length': value => $quota_injected_file_path_length; 'quota/injected_file_path_length': value => $injected_file_path_length_real;
'DEFAULT/quota_security_groups': value => $quota_security_groups; 'quota/security_groups': value => $security_groups_real;
'DEFAULT/quota_security_group_rules': value => $quota_security_group_rules; 'quota/security_group_rules': value => $security_group_rules_real;
'DEFAULT/quota_key_pairs': value => $quota_key_pairs; 'quota/key_pairs': value => $key_pairs_real;
'DEFAULT/quota_server_groups': value => $quota_server_groups; 'quota/server_groups': value => $server_groups_real;
'DEFAULT/quota_server_group_members': value => $quota_server_group_members; 'quota/server_group_members': value => $server_group_members_real;
'DEFAULT/reservation_expire': value => $reservation_expire; 'quota/reservation_expire': value => $reservation_expire;
'DEFAULT/until_refresh': value => $until_refresh; 'quota/until_refresh': value => $until_refresh;
'DEFAULT/max_age': value => $max_age; 'quota/max_age': value => $max_age;
} }
} }

View File

@ -0,0 +1,24 @@
---
issues:
- |
The nova::quota class now properly sets the config options in the [quota]
section and not the [DEFAULT] section which is deprecated.
deprecations:
- |
The following parameters in nova::quota class has been deprecated and has
changed name:
- ``quota_instances`` (now ``instances``)
- ``quota_cores`` (now ``cores``)
- ``quota_ram`` (now ``ram``)
- ``quota_floating_ips`` (now ``floating_ips``)
- ``quota_fixed_ips`` (now ``fixed_ips``)
- ``quota_metadata_items`` (now ``metadata_items``)
- ``quota_injected_files`` (now ``injected_files``)
- ``quota_injected_file_content_bytes`` (now ``injected_file_content_bytes``)
- ``quota_injected_file_path_length`` (now ``injected_file_path_length``)
- ``quota_security_groups`` (now ``security_groups``)
- ``quota_security_group_rules`` (now ``security_group_rules``)
- ``quota_key_pairs`` (now ``key_pairs``)
- ``quota_server_groups`` (now ``server_groups``)
- ``quota_server_group_members`` (now ``server_group_members``)

View File

@ -1,83 +1,123 @@
require 'spec_helper' require 'spec_helper'
describe 'nova::quota' do describe 'nova::quota' do
let :params do let :params do
{} {}
end end
let :default_params do let :default_params do
{ :quota_instances => 10, {
:quota_cores => 20, :instances => 10,
:quota_ram => 51200, :cores => 20,
:quota_floating_ips => 10, :ram => 51200,
:quota_fixed_ips => -1, :floating_ips => 10,
:quota_metadata_items => 128, :fixed_ips => -1,
:quota_injected_files => 5, :metadata_items => 128,
:quota_injected_file_content_bytes => 10240, :injected_files => 5,
:quota_injected_file_path_length => 255, :injected_file_content_bytes => 10240,
:quota_security_groups => 10, :injected_file_path_length => 255,
:quota_security_group_rules => 20, :security_groups => 10,
:quota_key_pairs => 100, :security_group_rules => 20,
:quota_server_groups => 10, :key_pairs => 100,
:quota_server_group_members => 10, :server_groups => 10,
:reservation_expire => 86400, :server_group_members => 10,
:until_refresh => 0, :reservation_expire => 86400,
:max_age => 0 } :until_refresh => 0,
:max_age => 0
}
end end
shared_examples_for 'nova quota' do shared_examples 'nova::quota config options' do
let :params_hash do let :params_hash do
default_params.merge(params) default_params.merge!(params)
end end
it 'configures quota in nova.conf' do it {
params_hash.each_pair do |config,value| params_hash.each_pair do |config, value|
is_expected.to contain_nova_config("DEFAULT/#{config}").with_value( value ) should contain_nova_config("quota/#{config}").with_value(value)
end end
}
end
shared_examples 'nova::quota' do
context 'with default parameters' do
it_behaves_like 'nova::quota config options'
end
context 'with provided parameters' do
before do
params.merge!({
:instances => 20,
:cores => 40,
:ram => 102400,
:floating_ips => 20,
:fixed_ips => 512,
:metadata_items => 256,
:injected_files => 10,
:injected_file_content_bytes => 20480,
:injected_file_path_length => 254,
:security_groups => 20,
:security_group_rules => 40,
:key_pairs => 200,
:server_groups => 20,
:server_group_members => 20,
:reservation_expire => 6400,
:until_refresh => 30,
:max_age => 60
})
end
it_behaves_like 'nova::quota config options'
end
context 'with deprecated parameters' do
before do
params.merge!({
:quota_instances => 20,
:quota_cores => 40,
:quota_ram => 102400,
:quota_floating_ips => 20,
:quota_fixed_ips => 512,
:quota_metadata_items => 256,
:quota_injected_files => 10,
:quota_injected_file_content_bytes => 20480,
:quota_injected_file_path_length => 254,
:quota_security_groups => 20,
:quota_security_group_rules => 40,
:quota_key_pairs => 200,
:quota_server_groups => 20,
:quota_server_group_members => 20
})
end
it {
should contain_nova_config('quota/instances').with_value(params[:quota_instances])
should contain_nova_config('quota/cores').with_value(params[:quota_cores])
should contain_nova_config('quota/ram').with_value(params[:quota_ram])
should contain_nova_config('quota/floating_ips').with_value(params[:quota_floating_ips])
should contain_nova_config('quota/fixed_ips').with_value(params[:quota_fixed_ips])
should contain_nova_config('quota/metadata_items').with_value(params[:quota_metadata_items])
should contain_nova_config('quota/injected_files').with_value(params[:quota_injected_files])
should contain_nova_config('quota/injected_file_content_bytes').with_value(params[:quota_injected_file_content_bytes])
should contain_nova_config('quota/injected_file_path_length').with_value(params[:quota_injected_file_path_length])
should contain_nova_config('quota/security_groups').with_value(params[:quota_security_groups])
should contain_nova_config('quota/security_group_rules').with_value(params[:quota_security_group_rules])
should contain_nova_config('quota/key_pairs').with_value(params[:quota_key_pairs])
should contain_nova_config('quota/server_groups').with_value(params[:quota_server_groups])
should contain_nova_config('quota/server_group_members').with_value(params[:quota_server_group_members])
}
end end
end end
context 'with default parameters' do on_supported_os({
it_configures 'nova quota' :supported_os => OSDefaults.get_supported_os
end }).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
context 'with provided parameters' do it_behaves_like 'nova::quota'
before do
params.merge!({
:quota_instances => 20,
:quota_cores => 40,
:quota_ram => 102400,
:quota_floating_ips => 20,
:quota_fixed_ips => 512,
:quota_metadata_items => 256,
:quota_injected_files => 10,
:quota_injected_file_content_bytes => 20480,
:quota_injected_file_path_length => 254,
:quota_security_groups => 20,
:quota_security_group_rules => 40,
:quota_key_pairs => 200,
:quota_server_groups => 20,
:quota_server_group_members => 20,
:reservation_expire => 6400,
:until_refresh => 30,
:max_age => 60
})
end end
it_configures 'nova quota'
end end
it { is_expected.to contain_nova_config('DEFAULT/quota_ram').with_value('51200') }
describe 'when overriding params' do
let :params do
{:quota_ram => '1'}
end
it { is_expected.to contain_nova_config('DEFAULT/quota_ram').with_value('1') }
end
end end