Merge "Support of PyMySQL driver for MySQL backend"
This commit is contained in:
@@ -81,13 +81,17 @@ class nova::db (
|
|||||||
if $database_connection_real {
|
if $database_connection_real {
|
||||||
|
|
||||||
validate_re($database_connection_real,
|
validate_re($database_connection_real,
|
||||||
'(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
'^(sqlite|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 = $::nova::params::pymysql_package_name
|
||||||
|
} else {
|
||||||
|
$backend_package = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/^postgresql:\/\//: {
|
/^postgresql:\/\//: {
|
||||||
$backend_package = false
|
$backend_package = false
|
||||||
|
@@ -27,6 +27,7 @@ class nova::params {
|
|||||||
$serialproxy_package_name = 'openstack-nova-serialproxy'
|
$serialproxy_package_name = 'openstack-nova-serialproxy'
|
||||||
$spicehtml5proxy_package_name = 'openstack-nova-console'
|
$spicehtml5proxy_package_name = 'openstack-nova-console'
|
||||||
$sqlite_package_name = undef
|
$sqlite_package_name = undef
|
||||||
|
$pymysql_package_name = 'python2-PyMySQL'
|
||||||
# service names
|
# service names
|
||||||
$api_service_name = 'openstack-nova-api'
|
$api_service_name = 'openstack-nova-api'
|
||||||
$cells_service_name = 'openstack-nova-cells'
|
$cells_service_name = 'openstack-nova-cells'
|
||||||
@@ -82,6 +83,7 @@ class nova::params {
|
|||||||
$tgt_package_name = 'tgt'
|
$tgt_package_name = 'tgt'
|
||||||
$serialproxy_package_name = 'nova-serialproxy'
|
$serialproxy_package_name = 'nova-serialproxy'
|
||||||
$sqlite_package_name = 'python-pysqlite2'
|
$sqlite_package_name = 'python-pysqlite2'
|
||||||
|
$pymysql_package_name = 'python-pymysql'
|
||||||
# service names
|
# service names
|
||||||
$api_service_name = 'nova-api'
|
$api_service_name = 'nova-api'
|
||||||
$cells_service_name = 'nova-cells'
|
$cells_service_name = 'nova-cells'
|
||||||
|
@@ -29,7 +29,7 @@ describe 'basic nova' do
|
|||||||
|
|
||||||
# Nova resources
|
# Nova resources
|
||||||
class { '::nova':
|
class { '::nova':
|
||||||
database_connection => 'mysql://nova:a_big_secret@127.0.0.1/nova?charset=utf8',
|
database_connection => 'mysql+pymysql://nova:a_big_secret@127.0.0.1/nova?charset=utf8',
|
||||||
rabbit_userid => 'nova',
|
rabbit_userid => 'nova',
|
||||||
rabbit_password => 'an_even_bigger_secret',
|
rabbit_password => 'an_even_bigger_secret',
|
||||||
image_service => 'nova.image.glance.GlanceImageService',
|
image_service => 'nova.image.glance.GlanceImageService',
|
||||||
|
@@ -20,17 +20,18 @@ describe 'nova::db' do
|
|||||||
context 'with overriden parameters' do
|
context 'with overriden parameters' do
|
||||||
before :each do
|
before :each do
|
||||||
params.merge!(
|
params.merge!(
|
||||||
:database_connection => 'mysql://user:pass@db/db',
|
:database_connection => 'mysql+pymysql://user:pass@db/db',
|
||||||
:slave_connection => 'mysql://user:pass@slave/db',
|
:slave_connection => 'mysql+pymysql://user:pass@slave/db',
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to contain_nova_config('database/connection').with_value('mysql://user:pass@db/db').with_secret(true) }
|
it { is_expected.to contain_nova_config('database/connection').with_value('mysql+pymysql://user:pass@db/db').with_secret(true) }
|
||||||
it { is_expected.to contain_nova_config('database/slave_connection').with_value('mysql://user:pass@slave/db').with_secret(true) }
|
it { is_expected.to contain_nova_config('database/slave_connection').with_value('mysql+pymysql://user:pass@slave/db').with_secret(true) }
|
||||||
it { is_expected.to contain_nova_config('database/idle_timeout').with_value('3600') }
|
it { is_expected.to contain_nova_config('database/idle_timeout').with_value('3600') }
|
||||||
it { is_expected.to contain_nova_config('database/min_pool_size').with_value('1') }
|
it { is_expected.to contain_nova_config('database/min_pool_size').with_value('1') }
|
||||||
it { is_expected.to contain_nova_config('database/max_retries').with_value('10') }
|
it { is_expected.to contain_nova_config('database/max_retries').with_value('10') }
|
||||||
it { is_expected.to contain_nova_config('database/retry_interval').with_value('10') }
|
it { is_expected.to contain_nova_config('database/retry_interval').with_value('10') }
|
||||||
|
it { is_expected.to contain_package('nova-backend-package').with({ :ensure => 'present', :name => platform_params[:pymysql_package_name] }) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -45,6 +46,14 @@ describe 'nova::db' do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with MySQL-python library as backend package' do
|
||||||
|
let :params do
|
||||||
|
{ :database_connection => 'mysql://user:pass@db/db', }
|
||||||
|
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 => 'redis://nova:nova@localhost/nova', }
|
{ :database_connection => 'redis://nova:nova@localhost/nova', }
|
||||||
@@ -53,6 +62,13 @@ describe 'nova::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://user:pass@db/db', }
|
||||||
|
end
|
||||||
|
|
||||||
|
it_raises 'a Puppet::Error', /validate_re/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'on Debian platforms' do
|
context 'on Debian platforms' do
|
||||||
@@ -63,6 +79,10 @@ describe 'nova::db' do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let :platform_params do
|
||||||
|
{ :pymysql_package_name => 'python-pymysql' }
|
||||||
|
end
|
||||||
|
|
||||||
it_configures 'nova::db'
|
it_configures 'nova::db'
|
||||||
|
|
||||||
context 'with sqlite backend' do
|
context 'with sqlite backend' do
|
||||||
@@ -88,6 +108,10 @@ describe 'nova::db' do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let :platform_params do
|
||||||
|
{ :pymysql_package_name => 'python2-PyMySQL' }
|
||||||
|
end
|
||||||
|
|
||||||
it_configures 'nova::db'
|
it_configures 'nova::db'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user