diff --git a/manifests/proxy.pp b/manifests/proxy.pp index b4803fa3..41b1463b 100644 --- a/manifests/proxy.pp +++ b/manifests/proxy.pp @@ -25,6 +25,13 @@ # delete accounts. Optional. Defaults to true. # [*account_autocreate*] Rather accounts should automatically be created. # Has to be set to true for tempauth. Optional. Defaults to true. +# [*read_affinity*] +# Configures the read affinity of proxy-server. Optional. Defaults to undef. +# [*write_affinity*] +# Configures the write affinity of proxy-server. Optional. Defaults to undef. +# [*write_affinity_node_count*] +# Configures write_affinity_node_count for proxy-server. +# Optional but requires write_affinity to be set. Defaults to undef. # [*package_ensure*] Ensure state of the swift proxy package. # Optional. Defaults to present. # @@ -52,6 +59,9 @@ class swift::proxy( $log_level = 'INFO', $log_facility = 'LOG_LOCAL1', $log_handoffs = true, + $read_affinity = undef, + $write_affinity = undef, + $write_affinity_node_count = undef, $package_ensure = 'present' ) { @@ -62,6 +72,10 @@ class swift::proxy( validate_bool($allow_account_management) validate_array($pipeline) + if($write_affinity_node_count and ! $write_affinity) { + fail('Usage of write_affinity_node_count requires write_affinity to be set') + } + if(member($pipeline, 'tempauth')) { $auth_type = 'tempauth' } elsif(member($pipeline, 'swauth')) { diff --git a/spec/classes/swift_proxy_spec.rb b/spec/classes/swift_proxy_spec.rb index a3132824..7fcd9d52 100644 --- a/spec/classes/swift_proxy_spec.rb +++ b/spec/classes/swift_proxy_spec.rb @@ -92,13 +92,16 @@ describe 'swift::proxy' do describe 'when more parameters are set' do let :params do { - :proxy_local_net_ip => '10.0.0.2', - :port => '80', - :workers => 3, - :pipeline => ['swauth', 'proxy-server'], - :allow_account_management => false, - :account_autocreate => false, - :log_level => 'DEBUG' + :proxy_local_net_ip => '10.0.0.2', + :port => '80', + :workers => 3, + :pipeline => ['swauth', 'proxy-server'], + :allow_account_management => false, + :account_autocreate => false, + :log_level => 'DEBUG', + :read_affinity => 'r1z1=100, r1=200', + :write_affinity => 'r1', + :write_affinity_node_count => '2 * replicas', } end it 'should build the header file with provided values' do @@ -114,7 +117,10 @@ describe 'swift::proxy' do '[app:proxy-server]', 'use = egg:swift#proxy', 'allow_account_management = false', - 'account_autocreate = false' + 'account_autocreate = false', + 'read_affinity = r1z1=100, r1=200', + 'write_affinity = r1', + 'write_affinity_node_count = 2 * replicas' ] ) end @@ -130,6 +136,17 @@ describe 'swift::proxy' do expect { subject }.to raise_error(Puppet::Error, /is not a boolean/) end end + + let :params do + { + :proxy_local_net_ip => '127.0.0.1', + :write_affinity_node_count => '2 * replicas' + } + end + + it "should fail if write_affinity_node_count is used without write_affinity" do + expect { subject }.to raise_error(Puppet::Error, /write_affinity_node_count requires write_affinity/) + end end end diff --git a/templates/proxy-server.conf.erb b/templates/proxy-server.conf.erb index c55438a0..08454b8f 100644 --- a/templates/proxy-server.conf.erb +++ b/templates/proxy-server.conf.erb @@ -32,3 +32,12 @@ set log_address = <%= @log_address %> log_handoffs = <%= @log_handoffs %> allow_account_management = <%= @allow_account_management %> account_autocreate = <%= @account_autocreate %> +<% if @read_affinity -%> +read_affinity = <%= @read_affinity -%> +<% end %> +<% if @write_affinity -%> +write_affinity = <%= @write_affinity -%> +<% end %> +<% if @write_affinity_node_count -%> +write_affinity_node_count = <%= @write_affinity_node_count -%> +<% end %>