Merge "Add database slave connection configure"

This commit is contained in:
Jenkins 2015-09-02 07:38:03 +00:00 committed by Gerrit Code Review
commit d921c1fdd9
3 changed files with 22 additions and 1 deletions

View File

@ -33,6 +33,9 @@ end
db_user = node['openstack']['db']['block-storage']['username']
db_pass = get_password 'db', 'cinder'
sql_connection = db_uri('block-storage', db_user, db_pass)
if node['openstack']['endpoints']['db']['enabled_slave']
slave_connection = db_uri('block-storage', db_user, db_pass, true)
end
mq_service_type = node['openstack']['mq']['block-storage']['service_type']
@ -100,6 +103,7 @@ template '/etc/cinder/cinder.conf' do
mode 00640
variables(
sql_connection: sql_connection,
slave_connection: slave_connection,
mq_service_type: mq_service_type,
mq_password: mq_password,
rabbit_hosts: rabbit_hosts,

View File

@ -275,11 +275,25 @@ describe 'openstack-block-storage::cinder-common' do
end
it 'has a db connection attribute' do
node.set['openstack']['endpoints']['db']['enabled_slave'] = false
allow_any_instance_of(Chef::Recipe).to receive(:db_uri)
.with('block-storage', anything, '').and_return('sql_connection_value')
.and_return('sql_connection_value')
expect(chef_run).to render_config_file(file.name)
.with_section_content('database', /^connection=sql_connection_value$/)
expect(chef_run).to_not render_config_file(file.name)
.with_section_content('database', /^slave_connection=sql_connection_value$/)
end
it 'has a slave db connection attribute' do
node.set['openstack']['endpoints']['db']['enabled_slave'] = true
allow_any_instance_of(Chef::Recipe).to receive(:db_uri)
.and_return('sql_connection_value')
expect(chef_run).to render_config_file(file.name)
.with_section_content('database', /^connection=sql_connection_value$/)
expect(chef_run).to render_config_file(file.name)
.with_section_content('database', /^slave_connection=sql_connection_value$/)
end
it 'has a db backend attribute' do

View File

@ -1031,6 +1031,9 @@ connection=<%= @sql_connection %>
# sql_connection_debug=0
#### (IntOpt) Verbosity of SQL debugging information. 0=None,
#### 100=Everything
<% if node['openstack']['endpoints']['db']['enabled_slave'] %>
slave_connection=<%= @slave_connection %>
<% end %>
[keymgr]