Add mariadb database support to openstack-common
1. Add a new db.service_type as 'mariadb' 2. Reuse compatible code for mysql to support mariadb 3. Set mariadb as default database type for RHEL family Change-Id: Ib537dc921b6e9d05cb79ef3e95dac558a7180816 blueprint: mariadb-support
This commit is contained in:
parent
e17ae52931
commit
79b561353f
@ -79,10 +79,10 @@ default['openstack']['endpoints']['db']['bind_interface'] = nil
|
||||
|
||||
# Default database attributes
|
||||
default['openstack']['db']['server_role'] = 'os-ops-database'
|
||||
default['openstack']['db']['service_type'] = 'mysql'
|
||||
# Database charset during create database
|
||||
default['openstack']['db']['charset'] = {
|
||||
mysql: 'utf8',
|
||||
mariadb: 'utf8',
|
||||
postgresql: nil,
|
||||
pgsql: nil,
|
||||
sqlite: nil,
|
||||
@ -93,12 +93,30 @@ default['openstack']['db']['charset'] = {
|
||||
# Database connection options. Should include starting '?'
|
||||
default['openstack']['db']['options'] = {
|
||||
mysql: "?charset=#{node['openstack']['db']['charset']['mysql']}",
|
||||
mariadb: "?charset=#{node['openstack']['db']['charset']['mariadb']}",
|
||||
postgresql: '',
|
||||
sqlite: '',
|
||||
db2: "?charset=#{node['openstack']['db']['charset']['db2']}",
|
||||
nosql: ''
|
||||
}
|
||||
|
||||
case node['platform_family']
|
||||
when 'rhel'
|
||||
default['openstack']['db']['service_type'] = 'mariadb'
|
||||
default['openstack']['db']['python_packages']['mysql'] = ['MySQL-python']
|
||||
default['openstack']['db']['python_packages']['mariadb'] = ['MySQL-python']
|
||||
default['openstack']['db']['python_packages']['db2'] = ['python-ibm-db', 'python-ibm-db-sa']
|
||||
when 'suse'
|
||||
default['openstack']['db']['service_type'] = 'mysql'
|
||||
default['openstack']['db']['python_packages']['mysql'] = ['python-mysql']
|
||||
default['openstack']['db']['python_packages']['mariadb'] = ['python-mysql']
|
||||
when 'debian'
|
||||
default['openstack']['db']['service_type'] = 'mysql'
|
||||
default['openstack']['db']['python_packages']['mysql'] = ['python-mysqldb']
|
||||
default['openstack']['db']['python_packages']['mariadb'] = ['python-mysqldb']
|
||||
default['openstack']['db']['python_packages']['db2'] = ['ibm-db', 'ibm-db-sa']
|
||||
end
|
||||
|
||||
# Database used by the OpenStack Compute (Nova) service
|
||||
default['openstack']['db']['compute']['service_type'] = node['openstack']['db']['service_type']
|
||||
default['openstack']['db']['compute']['host'] = node['openstack']['endpoints']['db']['host']
|
||||
@ -213,13 +231,3 @@ default['openstack']['db']['python_packages'] = {
|
||||
postgresql: ['python-psycopg2'],
|
||||
sqlite: []
|
||||
}
|
||||
case node['platform_family']
|
||||
when 'rhel'
|
||||
default['openstack']['db']['python_packages']['mysql'] = ['MySQL-python']
|
||||
default['openstack']['db']['python_packages']['db2'] = ['python-ibm-db', 'python-ibm-db-sa']
|
||||
when 'suse'
|
||||
default['openstack']['db']['python_packages']['mysql'] = ['python-mysql']
|
||||
when 'debian'
|
||||
default['openstack']['db']['python_packages']['mysql'] = ['python-mysqldb']
|
||||
default['openstack']['db']['python_packages']['db2'] = ['ibm-db', 'ibm-db-sa']
|
||||
end
|
||||
|
@ -43,7 +43,7 @@ module ::Openstack # rubocop:disable Documentation
|
||||
super_user = 'postgres'
|
||||
user_key = node['openstack']['db']['root_user_key']
|
||||
super_password = get_password 'user', user_key
|
||||
when 'mysql'
|
||||
when 'mysql', 'mariadb'
|
||||
db_prov = ::Chef::Provider::Database::Mysql
|
||||
user_prov = ::Chef::Provider::Database::MysqlUser
|
||||
super_user = 'root'
|
||||
|
@ -73,6 +73,8 @@ module ::Openstack # rubocop:disable Documentation
|
||||
end
|
||||
when 'pgsql'
|
||||
type = 'postgresql'
|
||||
when 'mariadb'
|
||||
type = 'mysql'
|
||||
end
|
||||
|
||||
# Build uri
|
||||
|
@ -18,6 +18,7 @@ end
|
||||
|
||||
depends 'apt', '~> 2.6.1'
|
||||
depends 'database', '~> 4.0.2'
|
||||
depends 'mariadb', '~> 0.3.0'
|
||||
depends 'mysql', '~> 6.0.13'
|
||||
depends 'yum', '~> 3.5.2'
|
||||
depends 'yum-epel', '~> 0.6.0'
|
||||
|
@ -20,7 +20,7 @@ describe 'openstack-common::default' do
|
||||
end
|
||||
|
||||
it 'returns db info and creates database with user when service found' do
|
||||
['mysql', 'pgsql', 'postgresql'].each do |db_type|
|
||||
%w(mysql, mariadb, pgsql, postgresql).each do |db_type|
|
||||
encoding = node['openstack']['db']['charset'][db_type]
|
||||
if encoding.nil?
|
||||
allow(subject).to receive(:database).and_return({})
|
||||
|
@ -383,6 +383,15 @@ describe 'openstack-common::set_endpoints_by_interface' do
|
||||
subject.db_uri('telemetry', 'user', 'pass')
|
||||
).to eq(expected)
|
||||
end
|
||||
|
||||
it 'returns compute db info hash when service found for mariadb' do
|
||||
node.set['openstack']['db']['service_type'] = 'mariadb'
|
||||
allow(subject).to receive(:node).and_return(chef_run.node)
|
||||
expected = 'mysql://user:pass@127.0.0.1:3306/nova?charset=utf8'
|
||||
expect(
|
||||
subject.db_uri('compute', 'user', 'pass')
|
||||
).to eq(expected)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#address' do
|
||||
|
Loading…
x
Reference in New Issue
Block a user