Add database slave connection configure
- According to the bool attribute node['openstack']['endpoints']['db']['enabled_slave'], enable/disable neutron database slave_connection - Add the slave_connection generated from db_uri function Implements: blueprint sql-slave-connection-support Change-Id: I19fc7fb4ab4a62fcdea77c9c4d18135fb2f49d41
This commit is contained in:
parent
b64ed92dc4
commit
94d875d7e1
|
@ -155,6 +155,9 @@ identity_uri = identity_uri_transform(identity_admin_endpoint)
|
|||
db_user = node['openstack']['db']['network']['username']
|
||||
db_pass = get_password 'db', 'neutron'
|
||||
sql_connection = db_uri('network', db_user, db_pass)
|
||||
if node['openstack']['endpoints']['db']['enabled_slave']
|
||||
slave_connection = db_uri('network', db_user, db_pass, true)
|
||||
end
|
||||
|
||||
network_api_bind = endpoint 'network-api-bind'
|
||||
service_pass = get_password 'service', 'openstack-network'
|
||||
|
@ -233,6 +236,7 @@ template '/etc/neutron/neutron.conf' do
|
|||
identity_admin_endpoint: identity_admin_endpoint,
|
||||
service_pass: service_pass,
|
||||
sql_connection: sql_connection,
|
||||
slave_connection: slave_connection,
|
||||
nova_endpoint: nova_endpoint,
|
||||
nova_admin_pass: nova_admin_pass,
|
||||
nova_auth_url: nova_auth_url,
|
||||
|
|
|
@ -893,6 +893,15 @@ describe 'openstack-network' do
|
|||
expect(chef_run).to render_file(file.name).with_content(/^connection = connection_value$/)
|
||||
end
|
||||
|
||||
it 'sets enabled_slave attribute' do
|
||||
node.set['openstack']['endpoints']['db']['enabled_slave'] = true
|
||||
node.set['openstack']['db']['network']['username'] = 'db_username_value'
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:db_uri)
|
||||
.and_return('slave_connection_value')
|
||||
expect(chef_run).to render_file(file.name)
|
||||
.with_content(/^slave_connection = slave_connection_value$/)
|
||||
end
|
||||
|
||||
%w(slave_connection max_retries retry_interval min_pool_size max_pool_size idle_timeout
|
||||
max_overflow connection_debug connection_trace pool_timeout).each do |attr|
|
||||
it "sets the #{attr} attribute" do
|
||||
|
|
|
@ -560,7 +560,11 @@ connection = <%= @sql_connection %>
|
|||
# engine =
|
||||
|
||||
# The SQLAlchemy connection string used to connect to the slave database
|
||||
<% if node['openstack']['endpoints']['db']['enabled_slave'] %>
|
||||
slave_connection = <%= @slave_connection %>
|
||||
<% else %>
|
||||
slave_connection = <%= node['openstack']['db']['network']['slave_connection'] %>
|
||||
<% end %>
|
||||
|
||||
# Database reconnection retry times - in event connectivity is lost
|
||||
# set to -1 implies an infinite retry count
|
||||
|
|
Loading…
Reference in New Issue