Add trove::quota class

This patch is aim to add a specific class for managing trove quota
related parameters.

Change-Id: Id84e0ac02809f9adb6e5d3027a10eb1e2063e88f
Closes-Bug: #1469577
This commit is contained in:
Xingchao Yu 2015-06-28 23:16:00 +08:00
parent 9706bd779d
commit cc138ca445
3 changed files with 83 additions and 0 deletions

43
manifests/quota.pp Normal file
View File

@ -0,0 +1,43 @@
# == Class: trove::quota
#
# Setup and configure trove quotas.
#
# === Parameters
#
# [*max_instances_per_user*]
# (optional) Default maximum number of instances per tenant.
# Defaults to 5.
#
# [*max_accepted_volume_size*]
# (optional) Default maximum volume size (in GB) for an instance.
# Defaults to 5.
#
# [*max_volumes_per_user*]
# (optional) Default maximum volume capacity (in GB) spanning across
# all Trove volumes per tenant.
# Defaults to 20.
#
# [*max_backups_per_user*]
# (optional) Default maximum number of backups created by a tenant.
# Defaults to 50.
#
# [*quota_driver*]
# (optional) Default driver to use for quota checks.
# Defaults to 'trove.quota.quota.DbQuotaDriver'.
#
class trove::quota (
$max_instances_per_user = 5,
$max_accepted_volume_size = 5,
$max_volumes_per_user = 20,
$max_backups_per_user = 50,
$quota_driver = 'trove.quota.quota.DbQuotaDriver',
) {
trove_config {
'DEFAULT/max_instances_per_user': value => $max_instances_per_user;
'DEFAULT/max_accepted_volume_size': value => $max_accepted_volume_size;
'DEFAULT/max_volumes_per_user': value => $max_volumes_per_user;
'DEFAULT/max_backups_per_user': value => $max_backups_per_user;
'DEFAULT/quota_driver': value => $quota_driver;
}
}

View File

@ -97,6 +97,7 @@ describe 'basic trove' do
class { '::trove::client': }
class { '::trove::conductor': }
class { '::trove::taskmanager': }
class { '::trove::quota': }
EOS

View File

@ -0,0 +1,39 @@
require 'spec_helper'
describe 'trove::quota' do
describe 'with default parameters' do
it 'contains default values' do
is_expected.to contain_trove_config('DEFAULT/max_instances_per_user').with(
:value => 5)
is_expected.to contain_trove_config('DEFAULT/max_accepted_volume_size').with(
:value => 5)
is_expected.to contain_trove_config('DEFAULT/max_volumes_per_user').with(
:value => 20)
is_expected.to contain_trove_config('DEFAULT/max_backups_per_user').with(
:value => 50)
is_expected.to contain_trove_config('DEFAULT/quota_driver').with(
:value => 'trove.quota.quota.DbQuotaDriver')
end
end
describe 'with overridden parameters' do
let :params do
{ :max_instances_per_user => 10,
:max_accepted_volume_size => 10,
:max_volumes_per_user => 100,
:max_backups_per_user => 100,
}
end
it 'contains overrided values' do
is_expected.to contain_trove_config('DEFAULT/max_instances_per_user').with(
:value => 10)
is_expected.to contain_trove_config('DEFAULT/max_accepted_volume_size').with(
:value => 10)
is_expected.to contain_trove_config('DEFAULT/max_volumes_per_user').with(
:value => 100)
is_expected.to contain_trove_config('DEFAULT/max_backups_per_user').with(
:value => 100)
end
end
end