Merge "Support of PyMySQL driver for MySQL backend"
This commit is contained in:
commit
4171fe573e
@ -43,6 +43,8 @@ class murano::db (
|
|||||||
$database_max_overflow = $::os_service_default,
|
$database_max_overflow = $::os_service_default,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
include ::murano::params
|
||||||
|
|
||||||
# NOTE(aderyugin): In order to keep backward compatibility we rely on the pick function
|
# NOTE(aderyugin): In order to keep backward compatibility we rely on the pick function
|
||||||
# to use murano::<myparam> if murano::db::<myparam> isn't specified.
|
# to use murano::<myparam> if murano::db::<myparam> isn't specified.
|
||||||
$database_connection_real = pick($::murano::database_connection, $database_connection)
|
$database_connection_real = pick($::murano::database_connection, $database_connection)
|
||||||
@ -53,13 +55,17 @@ class murano::db (
|
|||||||
$database_retry_interval_real = pick($::murano::database_retry_interval, $database_retry_interval)
|
$database_retry_interval_real = pick($::murano::database_retry_interval, $database_retry_interval)
|
||||||
$database_max_overflow_real = pick($::murano::database_max_overflow, $database_max_overflow)
|
$database_max_overflow_real = pick($::murano::database_max_overflow, $database_max_overflow)
|
||||||
|
|
||||||
validate_re($database_connection_real, '(mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
validate_re($database_connection_real, '^(mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||||
|
|
||||||
case $database_connection_real {
|
case $database_connection_real {
|
||||||
/^mysql:\/\//: {
|
/^mysql(\+pymysql)?:\/\//: {
|
||||||
$backend_package = false
|
|
||||||
require mysql::bindings
|
require mysql::bindings
|
||||||
require mysql::bindings::python
|
require mysql::bindings::python
|
||||||
|
if $database_connection_real =~ /^mysql\+pymysql/ {
|
||||||
|
$backend_package = $::murano::params::pymysql_package_name
|
||||||
|
} else {
|
||||||
|
$backend_package = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/^postgresql:\/\//: {
|
/^postgresql:\/\//: {
|
||||||
$backend_package = false
|
$backend_package = false
|
||||||
|
@ -21,6 +21,7 @@ class murano::params {
|
|||||||
$engine_service_name = 'murano-engine'
|
$engine_service_name = 'murano-engine'
|
||||||
# dashboard config file
|
# dashboard config file
|
||||||
$local_settings_path = '/etc/openstack-dashboard/local_settings'
|
$local_settings_path = '/etc/openstack-dashboard/local_settings'
|
||||||
|
$pymysql_package_name = undef
|
||||||
}
|
}
|
||||||
'Debian': {
|
'Debian': {
|
||||||
# package names
|
# package names
|
||||||
@ -36,6 +37,7 @@ class murano::params {
|
|||||||
$engine_service_name = 'murano-engine'
|
$engine_service_name = 'murano-engine'
|
||||||
# dashboard config file
|
# dashboard config file
|
||||||
$local_settings_path = '/etc/openstack-dashboard/local_settings.py'
|
$local_settings_path = '/etc/openstack-dashboard/local_settings.py'
|
||||||
|
$pymysql_package_name = 'python-pymysql'
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}")
|
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}")
|
||||||
|
@ -51,7 +51,7 @@ describe 'basic murano' do
|
|||||||
rabbit_own_user => 'murano',
|
rabbit_own_user => 'murano',
|
||||||
rabbit_own_password => 'an_even_bigger_secret',
|
rabbit_own_password => 'an_even_bigger_secret',
|
||||||
rabbit_own_vhost => '/murano',
|
rabbit_own_vhost => '/murano',
|
||||||
database_connection => 'mysql://murano:a_big_secret@127.0.0.1/murano?charset=utf8',
|
database_connection => 'mysql+pymysql://murano:a_big_secret@127.0.0.1/murano?charset=utf8',
|
||||||
}
|
}
|
||||||
class { '::murano::api': }
|
class { '::murano::api': }
|
||||||
class { '::murano::engine': }
|
class { '::murano::engine': }
|
||||||
|
@ -15,7 +15,7 @@ describe 'murano::db' do
|
|||||||
|
|
||||||
context 'with specific parameters' do
|
context 'with specific parameters' do
|
||||||
let :params do
|
let :params do
|
||||||
{ :database_connection => 'mysql://murano:murano@localhost/murano',
|
{ :database_connection => 'mysql+pymysql://murano:murano@localhost/murano',
|
||||||
:database_idle_timeout => '3601',
|
:database_idle_timeout => '3601',
|
||||||
:database_min_pool_size => '2',
|
:database_min_pool_size => '2',
|
||||||
:database_max_retries => '11',
|
:database_max_retries => '11',
|
||||||
@ -25,7 +25,7 @@ describe 'murano::db' do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to contain_murano_config('database/connection').with_value('mysql://murano:murano@localhost/murano') }
|
it { is_expected.to contain_murano_config('database/connection').with_value('mysql+pymysql://murano:murano@localhost/murano') }
|
||||||
it { is_expected.to contain_murano_config('database/idle_timeout').with_value('3601') }
|
it { is_expected.to contain_murano_config('database/idle_timeout').with_value('3601') }
|
||||||
it { is_expected.to contain_murano_config('database/min_pool_size').with_value('2') }
|
it { is_expected.to contain_murano_config('database/min_pool_size').with_value('2') }
|
||||||
it { is_expected.to contain_murano_config('database/max_retries').with_value('11') }
|
it { is_expected.to contain_murano_config('database/max_retries').with_value('11') }
|
||||||
@ -45,6 +45,14 @@ describe 'murano::db' do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with MySQL-python library as backend package' do
|
||||||
|
let :params do
|
||||||
|
{ :database_connection => 'mysql://murano:murano@localhost/murano', }
|
||||||
|
end
|
||||||
|
|
||||||
|
it { is_expected.to contain_package('python-mysqldb').with(:ensure => 'present') }
|
||||||
|
end
|
||||||
|
|
||||||
context 'with incorrect database_connection string' do
|
context 'with incorrect database_connection string' do
|
||||||
let :params do
|
let :params do
|
||||||
{ :database_connection => 'sqlite://murano:murano@localhost/murano', }
|
{ :database_connection => 'sqlite://murano:murano@localhost/murano', }
|
||||||
@ -52,6 +60,14 @@ describe 'murano::db' do
|
|||||||
|
|
||||||
it_raises 'a Puppet::Error', /validate_re/
|
it_raises 'a Puppet::Error', /validate_re/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with incorrect pymysql database_connection string' do
|
||||||
|
let :params do
|
||||||
|
{ :database_connection => 'foo+pymysql://murano:murano@localhost/murano', }
|
||||||
|
end
|
||||||
|
|
||||||
|
it_raises 'a Puppet::Error', /validate_re/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'on Debian platforms' do
|
context 'on Debian platforms' do
|
||||||
@ -63,6 +79,20 @@ describe 'murano::db' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it_configures 'murano::db'
|
it_configures 'murano::db'
|
||||||
|
|
||||||
|
context 'using pymysql driver' do
|
||||||
|
let :params do
|
||||||
|
{ :database_connection => 'mysql+pymysql://murano:murano@localhost/murano', }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'install the proper backend package' do
|
||||||
|
is_expected.to contain_package('murano-backend-package').with(
|
||||||
|
:ensure => 'present',
|
||||||
|
:name => 'python-pymysql',
|
||||||
|
:tag => 'openstack'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'on Redhat platforms' do
|
context 'on Redhat platforms' do
|
||||||
@ -73,6 +103,14 @@ describe 'murano::db' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it_configures 'murano::db'
|
it_configures 'murano::db'
|
||||||
|
|
||||||
|
context 'using pymysql driver' do
|
||||||
|
let :params do
|
||||||
|
{ :database_connection => 'mysql+pymysql://murano:murano@localhost/murano', }
|
||||||
|
end
|
||||||
|
|
||||||
|
it { is_expected.not_to contain_package('murano-backend-package') }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user