From 4157cb9a4141c071337f7e7c1946f32dd0342945 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Tue, 29 Oct 2013 16:02:20 +0100 Subject: [PATCH] Add Quota middlewares support Two middlewares exist for managing quotas: - account_quotas - container_quotas Change-Id: Ic6d539db480d8749769279b44e1f38302ac0fa62 Signed-off-by: Emilien Macchi --- manifests/proxy/account_quotas.pp | 27 ++++++++++++ manifests/proxy/container_quotas.pp | 27 ++++++++++++ .../swift_proxy_account_quotas_spec.rb | 43 +++++++++++++++++++ .../swift_proxy_container_quotas_spec.rb | 43 +++++++++++++++++++ templates/proxy/account_quotas.conf.erb | 4 ++ templates/proxy/container_quotas.conf.erb | 4 ++ tests/site.pp | 4 ++ 7 files changed, 152 insertions(+) create mode 100644 manifests/proxy/account_quotas.pp create mode 100644 manifests/proxy/container_quotas.pp create mode 100644 spec/classes/swift_proxy_account_quotas_spec.rb create mode 100644 spec/classes/swift_proxy_container_quotas_spec.rb create mode 100644 templates/proxy/account_quotas.conf.erb create mode 100644 templates/proxy/container_quotas.conf.erb diff --git a/manifests/proxy/account_quotas.pp b/manifests/proxy/account_quotas.pp new file mode 100644 index 00000000..2d50920d --- /dev/null +++ b/manifests/proxy/account_quotas.pp @@ -0,0 +1,27 @@ +# +# Copyright (C) 2013 eNovance SAS +# +# Author: Emilien Macchi +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Configure Swift Account Quotas +# + +class swift::proxy::account_quotas() { + concat::fragment { 'swift_proxy_account_quotas': + target => '/etc/swift/proxy-server.conf', + content => template('swift/proxy/account_quotas.conf.erb'), + order => '80', + } +} diff --git a/manifests/proxy/container_quotas.pp b/manifests/proxy/container_quotas.pp new file mode 100644 index 00000000..b3c9b2d3 --- /dev/null +++ b/manifests/proxy/container_quotas.pp @@ -0,0 +1,27 @@ +# +# Copyright (C) 2013 eNovance SAS +# +# Author: Emilien Macchi +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Configure Swift Container Quotas +# + +class swift::proxy::container_quotas() { + concat::fragment { 'swift_proxy_container_quotas': + target => '/etc/swift/proxy-server.conf', + content => template('swift/proxy/container_quotas.conf.erb'), + order => '81', + } +} diff --git a/spec/classes/swift_proxy_account_quotas_spec.rb b/spec/classes/swift_proxy_account_quotas_spec.rb new file mode 100644 index 00000000..12a4a2d4 --- /dev/null +++ b/spec/classes/swift_proxy_account_quotas_spec.rb @@ -0,0 +1,43 @@ +# +# Copyright (C) 2013 eNovance SAS +# +# Author: Emilien Macchi +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Tests for swift::proxy::account_quotas +# + +require 'spec_helper' + +describe 'swift::proxy::account_quotas' do + + let :facts do + { + :concat_basedir => '/var/lib/puppet/concat' + } + end + + let :pre_condition do + 'class { "concat::setup": } + concat { "/etc/swift/proxy-server.conf": }' + end + + let :fragment_file do + "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/80_swift_proxy_account_quotas" + end + + it { should contain_file(fragment_file).with_content(/\[filter:account-quotas\]/) } + it { should contain_file(fragment_file).with_content(/use = egg:swift#account_quotas/) } + +end diff --git a/spec/classes/swift_proxy_container_quotas_spec.rb b/spec/classes/swift_proxy_container_quotas_spec.rb new file mode 100644 index 00000000..fdb77265 --- /dev/null +++ b/spec/classes/swift_proxy_container_quotas_spec.rb @@ -0,0 +1,43 @@ +# +# Copyright (C) 2013 eNovance SAS +# +# Author: Emilien Macchi +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Tests for swift::proxy::container_quotas +# + +require 'spec_helper' + +describe 'swift::proxy::container_quotas' do + + let :facts do + { + :concat_basedir => '/var/lib/puppet/concat' + } + end + + let :pre_condition do + 'class { "concat::setup": } + concat { "/etc/swift/proxy-server.conf": }' + end + + let :fragment_file do + "/var/lib/puppet/concat/_etc_swift_proxy-server.conf/fragments/81_swift_proxy_container_quotas" + end + + it { should contain_file(fragment_file).with_content(/\[filter:container-quotas\]/) } + it { should contain_file(fragment_file).with_content(/use = egg:swift#container_quotas/) } + +end diff --git a/templates/proxy/account_quotas.conf.erb b/templates/proxy/account_quotas.conf.erb new file mode 100644 index 00000000..3a99cdfa --- /dev/null +++ b/templates/proxy/account_quotas.conf.erb @@ -0,0 +1,4 @@ + +[filter:account-quotas] +use = egg:swift#account_quotas + diff --git a/templates/proxy/container_quotas.conf.erb b/templates/proxy/container_quotas.conf.erb new file mode 100644 index 00000000..f2816c9f --- /dev/null +++ b/templates/proxy/container_quotas.conf.erb @@ -0,0 +1,4 @@ + +[filter:container-quotas] +use = egg:swift#container_quotas + diff --git a/tests/site.pp b/tests/site.pp index 9b9aec3e..0121ea17 100644 --- a/tests/site.pp +++ b/tests/site.pp @@ -191,6 +191,8 @@ node /swift-proxy/ inherits swift_base { 's3token', 'authtoken', 'keystone', + 'account_quotas', + 'container_quotas', 'proxy-server' ], account_autocreate => true, @@ -200,7 +202,9 @@ node /swift-proxy/ inherits swift_base { # configure all of the middlewares class { [ + 'swift::proxy::account_quotas', 'swift::proxy::catch_errors', + 'swift::proxy::container_quotas', 'swift::proxy::healthcheck', 'swift::proxy::cache', 'swift::proxy::swift3',