Merge "Add database slave connection configure"

This commit is contained in:
Jenkins 2015-09-02 07:41:07 +00:00 committed by Gerrit Code Review
commit 9a30eacb3a
3 changed files with 29 additions and 0 deletions

View File

@ -77,6 +77,9 @@ end
db_user = node['openstack']['db']['compute']['username']
db_pass = get_password 'db', 'nova'
sql_connection = db_uri('compute', db_user, db_pass)
if node['openstack']['endpoints']['db']['enabled_slave']
slave_connection = db_uri('compute', db_user, db_pass, true)
end
mq_service_type = node['openstack']['mq']['compute']['service_type']
@ -142,6 +145,7 @@ template '/etc/nova/nova.conf' do
mode 00640
variables(
sql_connection: sql_connection,
slave_connection: slave_connection,
novncproxy_base_url: novnc_endpoint.to_s,
xvpvncproxy_base_url: xvpvnc_endpoint.to_s,
xvpvncproxy_bind_host: xvpvnc_bind.host,

View File

@ -984,6 +984,28 @@ describe 'openstack-compute::nova-common' do
end
end
end
context 'set enabled_slave attribute' do
it 'sets overide database enabled_slave attribute as true' do
node.set['openstack']['endpoints']['db']['enabled_slave'] = true
node.set['openstack']['endpoints']['db']['slave_host'] = '10.10.1.1'
node.set['openstack']['endpoints']['db']['slave_port'] = '3326'
node.set['openstack']['db']['compute']['username'] = 'nova1'
expect(chef_run).to render_config_file(file.name)\
.with_section_content('database', %r{slave_connection=mysql://nova1:@10.10.1.1:3326/nova\?charset=utf8$})
end
it 'sets overide database enabled_slave attribute as false' do
node.set['openstack']['endpoints']['db']['enabled_slave'] = false
node.set['openstack']['endpoints']['db']['slave_host'] = '10.10.1.1'
node.set['openstack']['endpoints']['db']['slave_port'] = '3326'
node.set['openstack']['db']['compute']['username'] = 'nova1'
expect(chef_run).to_not render_config_file(file.name)\
.with_section_content('database', %r{slave_connection=mysql://nova1:@10.10.1.1:3326/nova\?charset=utf8$})
end
end
end
describe 'rootwrap.conf' do

View File

@ -339,6 +339,9 @@ connection=<%= @sql_connection %>
# The SQLAlchemy connection string to use to connect to the
# slave database. (string value)
#slave_connection=<None>
<% if node['openstack']['endpoints']['db']['enabled_slave'] %>
slave_connection=<%= @slave_connection %>
<% end %>
# The SQL mode to be used for MySQL sessions. This option,
# including the default, overrides any server-set SQL mode. To