From cc138ca44540fbe9d800661d0a58d674cface464 Mon Sep 17 00:00:00 2001 From: Xingchao Yu Date: Sun, 28 Jun 2015 23:16:00 +0800 Subject: [PATCH] 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 --- manifests/quota.pp | 43 +++++++++++++++++++++++++++++ spec/acceptance/basic_trove_spec.rb | 1 + spec/classes/trove_quota_spec.rb | 39 ++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 manifests/quota.pp create mode 100644 spec/classes/trove_quota_spec.rb diff --git a/manifests/quota.pp b/manifests/quota.pp new file mode 100644 index 00000000..874ea58f --- /dev/null +++ b/manifests/quota.pp @@ -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; + } +} diff --git a/spec/acceptance/basic_trove_spec.rb b/spec/acceptance/basic_trove_spec.rb index 8a7b1bbf..f604396e 100644 --- a/spec/acceptance/basic_trove_spec.rb +++ b/spec/acceptance/basic_trove_spec.rb @@ -97,6 +97,7 @@ describe 'basic trove' do class { '::trove::client': } class { '::trove::conductor': } class { '::trove::taskmanager': } + class { '::trove::quota': } EOS diff --git a/spec/classes/trove_quota_spec.rb b/spec/classes/trove_quota_spec.rb new file mode 100644 index 00000000..83f82efa --- /dev/null +++ b/spec/classes/trove_quota_spec.rb @@ -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