Add octavia::quota class

This patch add a new class octavia::quota to manage
the quota settings in Octavia services.

Change-Id: Ibd7d87ae1b7df0884b4b7a6f89ba79cefea2a9cc
This commit is contained in:
Xingchao Yu 2018-05-07 12:06:25 +12:00
parent 2b995012ab
commit a887994258
3 changed files with 107 additions and 0 deletions

44
manifests/quota.pp Normal file
View File

@ -0,0 +1,44 @@
# == Class: octavia::quota
#
# Setup and configure octavia quotas.
#
# === Parameters:
#
# [*load_balancer_quota*]
# (optional) Default per project load balancer quota
# Defaults to $::os_service_default
#
# [*listener_quota*]
# (optional) Default per project listener quota.
# Defaults to $::os_service_default
#
# [*member_quota*]
# (optional) Default per project member quota.
# Defaults to $::os_service_default
#
# [*pool_quota*]
# (optional) Default per project pool quota.
# Defaults to $::os_service_default
#
# [*health_monitor_quota*]
# (optional) Default per project health monitor quota.
# Defaults to $::os_service_default
#
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,
) {
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;
}
}

View File

@ -0,0 +1,4 @@
---
features:
- |
Add a new class octavia::quota to manage the quota settings in Octavia.

View File

@ -0,0 +1,59 @@
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>' }
end
let :params do
{}
end
shared_examples_for 'octavia quota' do
let :p do
default_params.merge(params)
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])
end
context 'configure quota with parameters' do
before :each do
params.merge!({ :load_balancer_quota => 10,
:listener_quota => 100,
:member_quota => 100 })
end
it 'contains overrided 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])
end
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge(OSDefaults.get_facts({:os_workers => 8}))
end
it_configures 'octavia quota'
end
end
end