Support of PyMySQL driver for MySQL backend
Add the ability to use python-pymysql library as backend for MySQL connections. Update acceptance tests to use pyMySQL. Change-Id: Ia47aa99ade73ae63da0e00e32a4f87cefaaa9bda Docs: https://wiki.openstack.org/wiki/PyMySQL_evaluation
This commit is contained in:
parent
5cd02fea78
commit
b3667a28e5
@ -43,6 +43,8 @@ class manila::db (
|
||||
$database_max_overflow = $::os_service_default,
|
||||
) {
|
||||
|
||||
include ::manila::params
|
||||
|
||||
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
|
||||
# to use manila::<myparam> if manila::db::<myparam> isn't specified.
|
||||
$database_connection_real = pick($::manila::sql_connection, $database_connection)
|
||||
@ -54,13 +56,17 @@ class manila::db (
|
||||
$database_max_overflow_real = pick($::manila::database_max_overflow, $database_max_overflow)
|
||||
|
||||
validate_re($database_connection_real,
|
||||
'(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
case $database_connection_real {
|
||||
/^mysql:\/\//: {
|
||||
$backend_package = false
|
||||
/^mysql(\+pymysql)?:\/\//: {
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
if $database_connection_real =~ /^mysql\+pymysql/ {
|
||||
$backend_package = $::manila::params::pymysql_package_name
|
||||
} else {
|
||||
$backend_package = false
|
||||
}
|
||||
}
|
||||
/^postgresql:\/\//: {
|
||||
$backend_package = false
|
||||
|
@ -22,6 +22,7 @@ class manila::params {
|
||||
$gluster_client_package_name = 'glusterfs-client'
|
||||
$gluster_package_name = 'glusterfs-common'
|
||||
$sqlite_package_name = 'python-pysqlite2'
|
||||
$pymysql_package_name = 'python-pymysql'
|
||||
|
||||
} elsif($::osfamily == 'RedHat') {
|
||||
|
||||
@ -41,6 +42,7 @@ class manila::params {
|
||||
$gluster_client_package_name = 'glusterfs-fuse'
|
||||
$gluster_package_name = 'glusterfs'
|
||||
$sqlite_package_name = undef
|
||||
$pymysql_package_name = undef
|
||||
|
||||
if $::operatingsystem == 'RedHat' and (versioncmp($::operatingsystemmajrelease, '7') >= 0) {
|
||||
$iscsi_helper = 'lioadm'
|
||||
|
@ -29,7 +29,7 @@ describe 'basic manila' do
|
||||
|
||||
# Manila resources
|
||||
class { '::manila':
|
||||
sql_connection => 'mysql://manila:a_big_secret@127.0.0.1/manila?charset=utf8',
|
||||
sql_connection => 'mysql+pymysql://manila:a_big_secret@127.0.0.1/manila?charset=utf8',
|
||||
rabbit_userid => 'manila',
|
||||
rabbit_password => 'an_even_bigger_secret',
|
||||
rabbit_host => '127.0.0.1',
|
||||
|
@ -18,7 +18,7 @@ describe 'manila::db' do
|
||||
|
||||
context 'with specific parameters' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql://manila:manila@localhost/manila',
|
||||
{ :database_connection => 'mysql+pymysql://manila:manila@localhost/manila',
|
||||
:database_idle_timeout => '3601',
|
||||
:database_min_pool_size => '2',
|
||||
:database_max_pool_size => '21',
|
||||
@ -27,7 +27,7 @@ describe 'manila::db' do
|
||||
:database_retry_interval => '11', }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_manila_config('database/connection').with_value('mysql://manila:manila@localhost/manila').with_secret(true) }
|
||||
it { is_expected.to contain_manila_config('database/connection').with_value('mysql+pymysql://manila:manila@localhost/manila').with_secret(true) }
|
||||
it { is_expected.to contain_manila_config('database/idle_timeout').with_value('3601') }
|
||||
it { is_expected.to contain_manila_config('database/min_pool_size').with_value('2') }
|
||||
it { is_expected.to contain_manila_config('database/max_retries').with_value('11') }
|
||||
@ -37,6 +37,14 @@ describe 'manila::db' do
|
||||
|
||||
end
|
||||
|
||||
context 'with MySQL-python library as backend package' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql://manila:manila@localhost/manila' }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_manila_config('database/connection').with_value('mysql://manila:manila@localhost/manila').with_secret(true) }
|
||||
end
|
||||
|
||||
context 'with postgresql backend' do
|
||||
let :params do
|
||||
{ :database_connection => 'postgresql://manila:manila@localhost/manila', }
|
||||
@ -56,6 +64,14 @@ describe 'manila::db' do
|
||||
it_raises 'a Puppet::Error', /validate_re/
|
||||
end
|
||||
|
||||
context 'with incorrect database_connection string' do
|
||||
let :params do
|
||||
{ :database_connection => 'foo+pymysql://manila:manila@localhost/manila', }
|
||||
end
|
||||
|
||||
it_raises 'a Puppet::Error', /validate_re/
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
@ -67,6 +83,14 @@ describe 'manila::db' do
|
||||
end
|
||||
|
||||
it_configures 'manila::db'
|
||||
|
||||
context 'using pymysql driver' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql+pymysql://manila:manila@localhost/manila' }
|
||||
end
|
||||
|
||||
it { is_expected.to contain_package('manila-backend-package').with({ :ensure => 'present', :name => 'python-pymysql' }) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat platforms' do
|
||||
@ -77,6 +101,14 @@ describe 'manila::db' do
|
||||
end
|
||||
|
||||
it_configures 'manila::db'
|
||||
|
||||
context 'using pymysql driver' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql+pymysql://manila:manila@localhost/manila' }
|
||||
end
|
||||
|
||||
it { is_expected.not_to contain_package('manila-backend-package') }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
require 'spec_helper'
|
||||
describe 'manila' do
|
||||
let :req_params do
|
||||
{:rabbit_password => 'guest', :sql_connection => 'mysql://user:password@host/database'}
|
||||
{:rabbit_password => 'guest', :sql_connection => 'mysql+pymysql://user:password@host/database'}
|
||||
end
|
||||
|
||||
let :facts do
|
||||
@ -254,7 +254,7 @@ describe 'manila' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:sql_connection => 'mysql://user:password@host/database',
|
||||
:sql_connection => 'mysql+pymysql://user:password@host/database',
|
||||
:rpc_backend => 'zmq',
|
||||
}
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user