Add database slave connection configure
- According to the bool attribute node['openstack']['endpoints']['db']['enabled_slave'], enable/disable nova database slave_connection - Add the slave_connection generated from db_uri function Implements: blueprint sql-slave-connection-support Change-Id: I9520441952993e8c6b4205e6886778815b5a2e4b
This commit is contained in:
parent
ea2fbba04a
commit
528cb177f6
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue