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: I8d904ca7076d7e6a74f1eda09c40ee79f1fc1a7f
This commit is contained in:
parent
964f74ace2
commit
e6d706c956
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue