From ae5a38efde4f871199ec60277af26a6cca4e8d50 Mon Sep 17 00:00:00 2001 From: Mykyta Karpin Date: Wed, 28 Oct 2015 11:56:54 +0200 Subject: [PATCH] Add possibility to use list of qpid hosts in cinder adding qpid_hosts parameter in oslo messaging section qpid_hosts parameter is a list of Qpid HA cluster host:port pairs. Change-Id: I596bdb06a9c7335e49053b56add72b7deeebc041 --- manifests/init.pp | 15 +++++++++++++-- spec/classes/cinder_spec.rb | 31 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index b19600a4..86305664 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -104,6 +104,10 @@ # (Optional) Port for qpid server. # Defaults to '5672'. # +# [*qpid_hosts*] +# (Optional) Qpid HA cluster host:port pairs. (list value) +# Defaults to false +# # [*qpid_username*] # (Optional) Username to use when connecting to qpid. # Defaults to 'guest'. @@ -259,6 +263,7 @@ class cinder ( $amqp_durable_queues = false, $qpid_hostname = 'localhost', $qpid_port = '5672', + $qpid_hosts = false, $qpid_username = 'guest', $qpid_password = false, $qpid_sasl_mechanisms = false, @@ -357,8 +362,6 @@ class cinder ( } cinder_config { - 'oslo_messaging_qpid/qpid_hostname': value => $qpid_hostname; - 'oslo_messaging_qpid/qpid_port': value => $qpid_port; 'oslo_messaging_qpid/qpid_username': value => $qpid_username; 'oslo_messaging_qpid/qpid_password': value => $qpid_password, secret => true; 'oslo_messaging_qpid/qpid_reconnect': value => $qpid_reconnect; @@ -373,6 +376,14 @@ class cinder ( 'oslo_messaging_qpid/amqp_durable_queues': value => $amqp_durable_queues; } + if $qpid_hosts { + cinder_config { 'oslo_messaging_qpid/qpid_hosts': value => join(any2array($qpid_hosts), ',') } + } else { + cinder_config { 'oslo_messaging_qpid/qpid_hosts': value => "${qpid_hostname}:${qpid_port}" } + cinder_config { 'oslo_messaging_qpid/qpid_hostname': value => $qpid_hostname } + cinder_config { 'oslo_messaging_qpid/qpid_port': value => $qpid_port } + } + if is_array($qpid_sasl_mechanisms) { cinder_config { 'DEFAULT/qpid_sasl_mechanisms': value => join($qpid_sasl_mechanisms, ' '); diff --git a/spec/classes/cinder_spec.rb b/spec/classes/cinder_spec.rb index 93745da8..e4d52abb 100644 --- a/spec/classes/cinder_spec.rb +++ b/spec/classes/cinder_spec.rb @@ -95,6 +95,7 @@ describe 'cinder' do it { is_expected.to contain_cinder_config('DEFAULT/rpc_backend').with_value('qpid') } it { is_expected.to contain_cinder_config('oslo_messaging_qpid/qpid_hostname').with_value('localhost') } it { is_expected.to contain_cinder_config('oslo_messaging_qpid/qpid_port').with_value('5672') } + it { is_expected.to contain_cinder_config('oslo_messaging_qpid/qpid_hosts').with_value('localhost:5672') } it { is_expected.to contain_cinder_config('oslo_messaging_qpid/qpid_username').with_value('guest') } it { is_expected.to contain_cinder_config('oslo_messaging_qpid/qpid_password').with_value('guest').with_secret(true) } it { is_expected.to contain_cinder_config('oslo_messaging_qpid/qpid_reconnect').with_value(true) } @@ -108,6 +109,36 @@ describe 'cinder' do it { is_expected.to contain_cinder_config('oslo_messaging_qpid/qpid_tcp_nodelay').with_value(true) } end + describe 'with modified qpid_hosts' do + let :params do + { + :database_connection => 'mysql://user:password@host/database', + :qpid_password => 'guest', + :rpc_backend => 'qpid', + :qpid_hosts => ['qpid1:5672', 'qpid2:5672'] + } + end + + it 'should contain many' do + is_expected.to contain_cinder_config('oslo_messaging_qpid/qpid_hosts').with(:value => 'qpid1:5672,qpid2:5672') + end + end + + describe 'with a single qpid_hosts entry' do + let :params do + { + :database_connection => 'mysql://user:password@host/database', + :qpid_password => 'guest', + :rpc_backend => 'qpid', + :qpid_hosts => ['qpid1:5672'] + } + end + + it 'should contain one' do + is_expected.to contain_cinder_config('oslo_messaging_qpid/qpid_hosts').with(:value => 'qpid1:5672') + end + end + describe 'with qpid rpc and no qpid_sasl_mechanisms' do let :params do {