diff --git a/deployment/puppet/openstack/manifests/glance.pp b/deployment/puppet/openstack/manifests/glance.pp index ba4734a934..7ef5e3b5b3 100644 --- a/deployment/puppet/openstack/manifests/glance.pp +++ b/deployment/puppet/openstack/manifests/glance.pp @@ -10,16 +10,15 @@ # # === Parameters # -# [db_host] Host where DB resides. Required. +# [*db_connection*] +# Database connection for glance +# Defaults to 'mysql://glance:glance@localhost/glance' +# # [glance_user_password] Password for glance auth user. Required. -# [glance_db_password] Password for glance DB. Required. # [glance_protocol] Protocol glance used to speak with registry. # Optional. Defaults to 'http' # [auth_uri] URI used for auth. Optional. Defaults to "http://127.0.0.1:5000/" # [identity_uri] URI used for keyston admin endpoint. Optional. Defaults to "http://127.0.0.1:35357/" -# [db_type] Type of sql databse to use. Optional. Defaults to 'mysql' -# [glance_db_user] Name of glance DB user. Optional. Defaults to 'glance' -# [glance_db_dbname] Name of glance DB. Optional. Defaults to 'glance' # [verbose] Rather to print more verbose (INFO+) output. Optional. Defaults to false. # [debug] Rather to print even more verbose (DEBUG+) output. If true, would ignore verbose option. # Optional. Defaults to false. @@ -35,13 +34,10 @@ # # class { 'openstack::glance': # glance_user_password => 'changeme', -# db_password => 'changeme', -# db_host => '127.0.0.1', # } class openstack::glance ( - $db_host = 'localhost', - $glance_db_password = false, + $db_connection = 'mysql://glance:glance@localhost/glance', $glance_user = 'glance', $glance_user_password = false, $glance_tenant = 'services', @@ -51,9 +47,6 @@ class openstack::glance ( $identity_uri = 'http://127.0.0.1:35357/', $region = 'RegionOne', $glance_protocol = 'http', - $db_type = 'mysql', - $glance_db_user = 'glance', - $glance_db_dbname = 'glance', $glance_backend = 'file', $glance_vcenter_host = undef, $glance_vcenter_user = undef, @@ -97,19 +90,8 @@ class openstack::glance ( $service_workers = $::processorcount, ) { validate_string($glance_user_password) - validate_string($glance_db_password) validate_string($rabbit_password) - # Configure the db string - case $db_type { - 'mysql': { - $sql_connection = "mysql://${glance_db_user}:${glance_db_password}@${db_host}/${glance_db_dbname}?read_timeout=60" - } - default: { - fail("Wrong db_type: ${db_type}") - } - } - # Install and configure glance-api class { 'glance::api': verbose => $verbose, @@ -121,7 +103,7 @@ class openstack::glance ( keystone_user => $glance_user, keystone_password => $glance_user_password, keystone_tenant => $glance_tenant, - database_connection => $sql_connection, + database_connection => $db_connection, enabled => $enabled, workers => $service_workers, registry_host => $registry_host, @@ -191,7 +173,7 @@ class openstack::glance ( keystone_user => $glance_user, keystone_password => $glance_user_password, keystone_tenant => $glance_tenant, - database_connection => $sql_connection, + database_connection => $db_connection, enabled => $enabled, use_syslog => $use_syslog, use_stderr => $use_stderr, diff --git a/deployment/puppet/openstack/manifests/heat.pp b/deployment/puppet/openstack/manifests/heat.pp index 3eb5ea8551..0af45b5c55 100644 --- a/deployment/puppet/openstack/manifests/heat.pp +++ b/deployment/puppet/openstack/manifests/heat.pp @@ -23,6 +23,10 @@ # Should be used instead of keystone_{host,port,protocol} # Defaults to false # +# [*db_connection*] +# (optional) Connection string for database backend. +# Defaults to 'mysql://heat:heat@localhost/heat' +# # === Deprecated # # [*keystone_host*] @@ -70,11 +74,7 @@ class openstack::heat ( $heat_watch_server_url = false, $auth_encryption_key = '%ENCRYPTION_KEY%', - $sql_connection = false, - $db_user = 'heat', - $db_password = false, - $db_host = '127.0.0.1', - $db_name = 'heat', + $db_connection = 'mysql://heat:heat@localhost/heat', $db_allowed_hosts = ['localhost','%'], $idle_timeout = '3600', $max_pool_size = '10', @@ -149,7 +149,7 @@ class openstack::heat ( keystone_password => $keystone_password, region_name => $region, - sql_connection => $sql_connection, + database_connection => $db_connection, database_idle_timeout => $idle_timeout, sync_db => $primary_controller, diff --git a/deployment/puppet/openstack/manifests/keystone.pp b/deployment/puppet/openstack/manifests/keystone.pp index b9690a14e5..e596302e75 100644 --- a/deployment/puppet/openstack/manifests/keystone.pp +++ b/deployment/puppet/openstack/manifests/keystone.pp @@ -9,9 +9,11 @@ # [keystone_db_password] Password for keystone DB. Required. # [keystone_admin_token]. Auth token for keystone admin. Required. # [public_address] Public address where keystone can be accessed. Required. -# [db_type] Type of DB used. Currently only supports mysql. Optional. Defaults to 'mysql' -# [keystone_db_user] Name of keystone db user. Optional. Defaults to 'keystone' -# [keystone_db_dbname] Name of keystone DB. Optional. Defaults to 'keystone' +# +# [*db_connection*] +# Database connection string. +# Defaults to 'mysql://keystone:keystone@localhost/keystone' +# # [verbose] Rather to print more verbose (INFO+) output. Optional. Defaults to false. # [debug] Rather to print even more verbose (DEBUG+) output. If true, would ignore verbose option. # Optional. Defaults to false. @@ -32,25 +34,19 @@ # === Example # # class { 'openstack::keystone': -# db_host => '127.0.0.1', -# keystone_db_password => 'changeme', # admin_password => 'changeme', # public_address => '192.168.1.1', # } - +# class openstack::keystone ( $public_url, $admin_url, $internal_url, - $db_host, - $db_password, $admin_token, $public_address, $public_ssl = false, $public_hostname = false, - $db_type = 'mysql', - $db_user = 'keystone', - $db_name = 'keystone', + $db_connection = 'mysql://keystone:keystone@localhost/keystone', $verbose = false, $debug = false, $default_log_levels = undef, @@ -86,13 +82,6 @@ class openstack::keystone ( $fernet_key_repository = '/etc/keystone/fernet-keys', ) { - # Install and configure Keystone - if $db_type == 'mysql' { - $database_connection = "mysql://${$db_user}:${db_password}@${db_host}/${db_name}?read_timeout=60" - } else { - fail("db_type ${db_type} is not supported") - } - # I have to do all of this crazy munging b/c parameters are not # set procedurally in Pupet if $internal_address { @@ -136,7 +125,7 @@ class openstack::keystone ( catalog_type => 'sql', admin_token => $admin_token, enabled => false, - database_connection => $database_connection, + database_connection => $db_connection, public_bind_host => $public_bind_host, admin_bind_host => $admin_bind_host, admin_workers => $service_workers, diff --git a/deployment/puppet/openstack/manifests/nova/controller.pp b/deployment/puppet/openstack/manifests/nova/controller.pp index f7947dbeae..0b44fc31e3 100644 --- a/deployment/puppet/openstack/manifests/nova/controller.pp +++ b/deployment/puppet/openstack/manifests/nova/controller.pp @@ -112,18 +112,33 @@ class openstack::nova::controller ( # Configure the db string case $db_type { 'mysql': { - $nova_db = "mysql://${nova_db_user}:${nova_db_password}@${db_host}/${nova_db_dbname}\ -?read_timeout=60" + # TODO(aschultz): update this class to accept a connection string rather + # than use host/user/pass/dbname/type + # LP#1526938 - python-mysqldb supports this, python-pymysql does not + if $::os_package_type == 'debian' { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } + } else { + $extra_params = { 'charset' => 'utf8' } + } + $db_connection = os_database_connection({ + 'dialect' => $db_type, + 'host' => $db_host, + 'database' => $nova_db_dbname, + 'username' => $nova_db_user, + 'password' => $nova_db_password, + 'extra' => $extra_params + }) } } + if ($glance_api_servers == undef) { $real_glance_api_servers = "${public_address}:9292" } else { $real_glance_api_servers = $glance_api_servers } - $sql_connection = $nova_db + $sql_connection = $db_connection $glance_connection = $real_glance_api_servers if ($debug) { diff --git a/deployment/puppet/openstack/spec/classes/openstack_glance_spec.rb b/deployment/puppet/openstack/spec/classes/openstack_glance_spec.rb index fd32db91ec..df260e7596 100644 --- a/deployment/puppet/openstack/spec/classes/openstack_glance_spec.rb +++ b/deployment/puppet/openstack/spec/classes/openstack_glance_spec.rb @@ -7,7 +7,6 @@ describe 'openstack::glance' do :auth_uri => 'https://192.168.10.1:5000/', :identity_uri => 'https://192.168.10.1:35357/', :glance_user_password => "glance_password", - :glance_db_password => "db_password", :rabbit_password => "rabbit_password", :rabbit_hosts => "10.0.0.1, 10.0.0.2", } @@ -20,6 +19,9 @@ describe 'openstack::glance' do end it 'configures with the default params' do + should contain_class('glance::api').with( + :database_connection => 'mysql://glance:glance@localhost/glance' + ) end context 'with keystone configured' do diff --git a/deployment/puppet/openstack/spec/classes/openstack_heat_spec.rb b/deployment/puppet/openstack/spec/classes/openstack_heat_spec.rb new file mode 100644 index 0000000000..260df9e616 --- /dev/null +++ b/deployment/puppet/openstack/spec/classes/openstack_heat_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper' + +describe 'openstack::heat' do + + let :params do + { + :amqp_password => "rabbit_password", + } + end + + shared_examples_for 'heat configuration' do + + it 'contains openstack::heat' do + should contain_class('openstack::heat') + end + + it 'configures with the default params' do + should contain_class('heat').with( + :database_connection => 'mysql://heat:heat@localhost/heat' + ) + end + + end + + context 'on Debian platforms' do + let :facts do + { :osfamily => 'Debian', + :operatingsystem => 'Debian', + :hostname => 'hostname.example.com', + :physicalprocessorcount => 2, + :memorysize_mb => 1024, + :openstack_version => {'nova' => 'present' }, + } + end + + it_configures 'heat configuration' + end + + context 'on RedHat platforms' do + let :facts do + { :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :operatingsystemrelease => '7.1', + :operatingsystemmajrelease => '7', + :hostname => 'hostname.example.com', + :physicalprocessorcount => 2, + :memorysize_mb => 1024, + :openstack_version => {'nova' => 'present' }, + } + end + + it_configures 'heat configuration' + end + +end diff --git a/deployment/puppet/openstack/spec/classes/openstack_keystone_spec.rb b/deployment/puppet/openstack/spec/classes/openstack_keystone_spec.rb index 597d8f4882..442a017d79 100644 --- a/deployment/puppet/openstack/spec/classes/openstack_keystone_spec.rb +++ b/deployment/puppet/openstack/spec/classes/openstack_keystone_spec.rb @@ -8,8 +8,6 @@ describe 'openstack::keystone' do :internal_url => "http://10.0.0.1/5000/", :public_url => "http://10.0.0.1/5000/", :public_address => "10.0.0.1", - :db_host => "10.0.0.1", - :db_password => "dbpass", :admin_token => "$token", } end @@ -21,6 +19,9 @@ describe 'openstack::keystone' do end it 'configures with the default params' do + should contain_class('keystone').with( + :database_connection => 'mysql://keystone:keystone@localhost/keystone' + ) end diff --git a/deployment/puppet/osnailyfacter/modular/ceilometer/controller.pp b/deployment/puppet/osnailyfacter/modular/ceilometer/controller.pp index da31e42227..e97ec69fbc 100644 --- a/deployment/puppet/osnailyfacter/modular/ceilometer/controller.pp +++ b/deployment/puppet/osnailyfacter/modular/ceilometer/controller.pp @@ -31,7 +31,6 @@ $primary_controller = hiera('primary_controller') $ceilometer_enabled = $ceilometer_hash['enabled'] $ceilometer_user_password = $ceilometer_hash['user_password'] $ceilometer_metering_secret = $ceilometer_hash['metering_secret'] -$ceilometer_db_type = 'mongodb' $swift_rados_backend = $storage_hash['objects_ceph'] $amqp_password = $rabbit_hash['password'] $amqp_user = $rabbit_hash['user'] @@ -51,7 +50,6 @@ $keystone_endpoint = get_ssl_property($ssl_hash, {}, 'keystone', 'internal', 'ho $default_mongo_hash = { 'enabled' => false, } - $mongo_hash = hiera_hash('mongo', $default_mongo_hash) $db_type = 'mongodb' @@ -75,7 +73,41 @@ if $mongo_hash['enabled'] and $ceilometer_hash['enabled'] { $mongo_replicaset = 'ceilometer' } -$db_connection = "${db_type}://${db_user}:${db_password}@${db_host}/${db_name}?readpreference=primaryPreferred" +# TODO(aschultz): currently mysql is not supported for ceilometer, but this +# should be configurable some day +if ($dbtype == 'mysql') { + # LP#1526938 - python-mysqldb supports this, python-pymysql does not + if ($::os_package_type == 'debian') { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } + } else { + $extra_params = { 'charset' => 'utf8'} + } + $db_connection = os_database_connection({ + 'dialect' => $db_type, + 'host' => $db_host, + 'database' => $db_name, + 'username' => $db_user, + 'password' => $db_password, + 'extra' => $extra_params + }) +} else { + $mongo_default_params = { + 'readPreference' => 'primaryPreferred', + } + if $mongo_replicaset { + $replica_params = { + 'replicaSet' => $mongo_replicaset + } + } else { + $replica_params = { } + } + $extra_params = merge($mongo_default_params, $replica_params) + + $params = inline_template("?<%= @extra_params.map{ |k,v| \"#{k}=#{v}\" }.join('&') %>") + # NOTE(aschultz): os_database_connection does not currently support the + # mongodb syntax for mongodb://user:pass@host,host,host/dbname + $db_connection = "${db_type}://${db_user}:${db_password}@${db_host}/${db_name}${params}" +} ############################################################################### diff --git a/deployment/puppet/osnailyfacter/modular/glance/glance.pp b/deployment/puppet/osnailyfacter/modular/glance/glance.pp index dd16e1fccc..81a8e91f7c 100644 --- a/deployment/puppet/osnailyfacter/modular/glance/glance.pp +++ b/deployment/puppet/osnailyfacter/modular/glance/glance.pp @@ -25,8 +25,26 @@ $primary_controller = hiera('primary_controller') $default_log_levels = hiera_hash('default_log_levels') -$db_type = 'mysql' -$db_host = pick($glance_hash['db_host'], $database_vip) +$db_type = 'mysql' +$db_host = pick($glance_hash['db_host'], $database_vip) +$db_user = pick($glance_hash['db_user'], 'glance') +$db_password = $glance_hash['db_password'] +$db_name = pick($glance_hash['db_name'], 'glance') +# LP#1526938 - python-mysqldb supports this, python-pymysql does not +if $::os_package_type == 'debian' { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } +} else { + $extra_params = { 'charset' => 'utf8' } +} +$db_connection = os_database_connection({ + 'dialect' => $db_type, + 'host' => $db_host, + 'database' => $db_name, + 'username' => $db_user, + 'password' => $db_password, + 'extra' => $extra_params +}) + $api_bind_address = get_network_role_property('glance/api', 'ipaddr') $enabled = true $max_retries = '-1' @@ -37,9 +55,6 @@ $rabbit_user = $rabbit_hash['user'] $rabbit_hosts = split(hiera('amqp_hosts',''), ',') $rabbit_virtual_host = '/' -$glance_db_user = pick($glance_hash['db_user'], 'glance') -$glance_db_dbname = pick($glance_hash['db_name'], 'glance') -$glance_db_password = $glance_hash['db_password'] $glance_user = pick($glance_hash['user'],'glance') $glance_user_password = $glance_hash['user_password'] $glance_tenant = pick($glance_hash['tenant'],'services') @@ -90,11 +105,7 @@ class { 'openstack::glance': verbose => $verbose, debug => $debug, default_log_levels => $default_log_levels, - db_type => $db_type, - db_host => $db_host, - glance_db_user => $glance_db_user, - glance_db_dbname => $glance_db_dbname, - glance_db_password => $glance_db_password, + db_connection => $db_connection, glance_user => $glance_user, glance_user_password => $glance_user_password, glance_tenant => $glance_tenant, diff --git a/deployment/puppet/osnailyfacter/modular/globals/globals.pp b/deployment/puppet/osnailyfacter/modular/globals/globals.pp index 6c586e353c..f87b0c1954 100644 --- a/deployment/puppet/osnailyfacter/modular/globals/globals.pp +++ b/deployment/puppet/osnailyfacter/modular/globals/globals.pp @@ -300,7 +300,23 @@ $max_overflow = hiera('max_overflow', min($::processorcount * 5 + 0, $max_retries = hiera('max_retries', '-1') $idle_timeout = hiera('idle_timeout','3600') $nova_db_password = $nova_hash['db_password'] -$sql_connection = "mysql://nova:${nova_db_password}@${database_vip}/nova?read_timeout = 6 0" +# LP#1526938 - python-mysqldb supports this, python-pymysql does not +if $::os_package_type == 'debian' { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } +} else { + $extra_params = { 'charset' => 'utf8' } +} +# TODO(aschultz): I don't think this is used so it should probably be +# deprecated and removed. +$sql_connection = os_database_connection({ + 'dialect' => 'mysql', + 'host' => $database_vip, + 'database' => 'nova', + 'username' => 'nova', + 'password' => $nova_db_password, + 'extra' => $extra_params +}) + $mirror_type = hiera('mirror_type', 'external') $multi_host = hiera('multi_host', true) diff --git a/deployment/puppet/osnailyfacter/modular/heat/heat.pp b/deployment/puppet/osnailyfacter/modular/heat/heat.pp index 20feb9c7ab..890fa1753d 100644 --- a/deployment/puppet/osnailyfacter/modular/heat/heat.pp +++ b/deployment/puppet/osnailyfacter/modular/heat/heat.pp @@ -40,17 +40,31 @@ $syslog_log_facility_heat = hiera('syslog_log_facility_heat') $deployment_mode = hiera('deployment_mode') $bind_address = get_network_role_property('heat/api', 'ipaddr') $memcache_address = get_network_role_property('mgmt/memcache', 'ipaddr') -$database_password = $heat_hash['db_password'] $keystone_user = pick($heat_hash['user'], 'heat') $keystone_tenant = pick($heat_hash['tenant'], 'services') -$db_host = pick($heat_hash['db_host'], hiera('database_vip')) -$database_user = pick($heat_hash['db_user'], 'heat') -$database_name = hiera('heat_db_name', 'heat') -$read_timeout = '60' -$sql_connection = "mysql://${database_user}:${database_password}@${db_host}/${database_name}?read_timeout=${read_timeout}" $region = hiera('region', 'RegionOne') $external_lb = hiera('external_lb', false) +$db_type = 'mysql' +$db_host = pick($heat_hash['db_host'], hiera('database_vip')) +$db_user = pick($heat_hash['db_user'], 'heat') +$db_password = $heat_hash['db_password'] +$db_name = hiera('heat_db_name', 'heat') +# LP#1526938 - python-mysqldb supports this, python-pymysql does not +if $::os_package_type == 'debian' { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } +} else { + $extra_params = { 'charset' => 'utf8' } +} +$db_connection = os_database_connection({ + 'dialect' => $db_type, + 'host' => $db_host, + 'database' => $db_name, + 'username' => $db_user, + 'password' => $db_password, + 'extra' => $extra_params +}) + ####### Disable upstart startup on install ####### if $::operatingsystem == 'Ubuntu' { tweaks::ubuntu_service_override { 'heat-api-cloudwatch': @@ -92,9 +106,7 @@ class { 'openstack::heat' : heat_protocol => $heat_protocol, amqp_user => $rabbit_hash['user'], amqp_password => $rabbit_hash['password'], - sql_connection => $sql_connection, - db_host => $db_host, - db_password => $database_password, + db_connection => $db_connection, max_retries => $max_retries, max_pool_size => $max_pool_size, max_overflow => $max_overflow, diff --git a/deployment/puppet/osnailyfacter/modular/ironic/ironic-compute.pp b/deployment/puppet/osnailyfacter/modular/ironic/ironic-compute.pp index 1bb9045049..2eebe06b50 100644 --- a/deployment/puppet/osnailyfacter/modular/ironic/ironic-compute.pp +++ b/deployment/puppet/osnailyfacter/modular/ironic/ironic-compute.pp @@ -29,11 +29,25 @@ $ironic_tenant = pick($ironic_hash['tenant'],'services') $ironic_user = pick($ironic_hash['auth_name'],'ironic') $ironic_user_password = pick($ironic_hash['user_password'],'ironic') +$db_type = 'mysql' $db_host = pick($nova_hash['db_host'], $database_vip) $db_user = pick($nova_hash['db_user'], 'nova') $db_name = pick($nova_hash['db_name'], 'nova') $db_password = pick($nova_hash['db_password'], 'nova') -$database_connection = "mysql://${db_name}:${db_password}@${db_host}/${db_name}?read_timeout=60" +# LP#1526938 - python-mysqldb supports this, python-pymysql does not +if $::os_package_type == 'debian' { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } +} else { + $extra_params = { 'charset' => 'utf8' } +} +$db_connection = os_database_connection({ + 'dialect' => $db_type, + 'host' => $db_host, + 'database' => $db_name, + 'username' => $db_user, + 'password' => $db_password, + 'extra' => $extra_params +}) $memcached_servers = hiera('memcached_addresses') $memcached_port = hiera('memcache_server_port', '11211') @@ -54,7 +68,7 @@ tweaks::ubuntu_service_override { 'nova-compute': class { '::nova': install_utilities => false, ensure_package => installed, - database_connection => $database_connection, + database_connection => $db_connection, rpc_backend => 'nova.openstack.common.rpc.impl_kombu', #FIXME(bogdando) we have to split amqp_hosts until all modules synced rabbit_hosts => split($amqp_hosts, ','), diff --git a/deployment/puppet/osnailyfacter/modular/ironic/ironic.pp b/deployment/puppet/osnailyfacter/modular/ironic/ironic.pp index 3c739ae28c..346447b618 100644 --- a/deployment/puppet/osnailyfacter/modular/ironic/ironic.pp +++ b/deployment/puppet/osnailyfacter/modular/ironic/ironic.pp @@ -23,11 +23,25 @@ $neutron_config = hiera_hash('quantum_settings') $primary_controller = hiera('primary_controller') $amqp_durable_queues = pick($ironic_hash['amqp_durable_queues'], false) +$db_type = 'mysql' $db_host = pick($ironic_hash['db_host'], $database_vip) $db_user = pick($ironic_hash['db_user'], 'ironic') $db_name = pick($ironic_hash['db_name'], 'ironic') $db_password = pick($ironic_hash['db_password'], 'ironic') -$database_connection = "mysql://${db_name}:${db_password}@${db_host}/${db_name}?charset=utf8&read_timeout=60" +# LP#1526938 - python-mysqldb supports this, python-pymysql does not +if $::os_package_type == 'debian' { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } +} else { + $extra_params = { 'charset' => 'utf8' } +} +$db_connection = os_database_connection({ + 'dialect' => $db_type, + 'host' => $db_host, + 'database' => $db_name, + 'username' => $db_user, + 'password' => $db_password, + 'extra' => $extra_params +}) $ironic_tenant = pick($ironic_hash['tenant'],'services') $ironic_user = pick($ironic_hash['auth_name'],'ironic') @@ -48,7 +62,7 @@ class { 'ironic': control_exchange => 'ironic', use_syslog => $use_syslog, log_facility => $syslog_log_facility_ironic, - database_connection => $database_connection, + database_connection => $db_connection, database_max_retries => '-1', glance_api_servers => $glance_api_servers, sync_db => $primary_controller, diff --git a/deployment/puppet/osnailyfacter/modular/keystone/keystone.pp b/deployment/puppet/osnailyfacter/modular/keystone/keystone.pp index 5f854c4f08..9d37ee8d74 100644 --- a/deployment/puppet/osnailyfacter/modular/keystone/keystone.pp +++ b/deployment/puppet/osnailyfacter/modular/keystone/keystone.pp @@ -34,6 +34,21 @@ $db_host = pick($keystone_hash['db_host'], $database_vip) $db_password = $keystone_hash['db_password'] $db_name = pick($keystone_hash['db_name'], 'keystone') $db_user = pick($keystone_hash['db_user'], 'keystone') +# LP#1526938 - python-mysqldb supports this, python-pymysql does not +if $::os_package_type == 'debian' { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } +} else { + $extra_params = { 'charset' => 'utf8' } +} +$db_connection = os_database_connection({ + 'dialect' => $db_type, + 'host' => $db_host, + 'database' => $db_name, + 'username' => $db_user, + 'password' => $db_password, + 'extra' => $extra_params +}) + $admin_token = $keystone_hash['admin_token'] $admin_tenant = $access_hash['tenant'] @@ -101,48 +116,44 @@ $external_lb = hiera('external_lb', false) ############################################################################### ####### KEYSTONE ########### -class { 'openstack::keystone': - verbose => $verbose, - debug => $debug, - default_log_levels => $default_log_levels, - db_type => $db_type, - db_host => $db_host, - db_password => $db_password, - db_name => $db_name, - db_user => $db_user, - admin_token => $admin_token, - public_address => $public_address, - public_ssl => $public_ssl_hash['services'], - public_hostname => $public_ssl_hash['hostname'], - internal_address => $service_endpoint, - admin_address => $admin_address, - public_bind_host => $local_address_for_bind, - admin_bind_host => $local_address_for_bind, - primary_controller => $primary_controller, - enabled => $enabled, - use_syslog => $use_syslog, - use_stderr => $use_stderr, - syslog_log_facility => $syslog_log_facility, - region => $region, - memcache_servers => $memcached_server, - memcache_server_port => $memcache_server_port, - memcache_pool_maxsize => $memcache_pool_maxsize, - max_retries => $max_retries, - max_pool_size => $max_pool_size, - max_overflow => $max_overflow, - rabbit_password => $rabbit_password, - rabbit_userid => $rabbit_user, - rabbit_hosts => $rabbit_hosts, - rabbit_virtual_host => $rabbit_virtual_host, - database_idle_timeout => $database_idle_timeout, - revoke_driver => $revoke_driver, - public_url => $public_url, - admin_url => $admin_url, - internal_url => $internal_url, - notification_driver => $ceilometer_hash['notification_driver'], - service_workers => $service_workers, - token_provider => $token_provider, - fernet_src_repository => '/var/lib/astute/keystone', +class { '::openstack::keystone': + verbose => $verbose, + debug => $debug, + default_log_levels => $default_log_levels, + db_connection => $db_connection, + admin_token => $admin_token, + public_address => $public_address, + public_ssl => $public_ssl_hash['services'], + public_hostname => $public_ssl_hash['hostname'], + internal_address => $service_endpoint, + admin_address => $admin_address, + public_bind_host => $local_address_for_bind, + admin_bind_host => $local_address_for_bind, + primary_controller => $primary_controller, + enabled => $enabled, + use_syslog => $use_syslog, + use_stderr => $use_stderr, + syslog_log_facility => $syslog_log_facility, + region => $region, + memcache_servers => $memcached_server, + memcache_server_port => $memcache_server_port, + memcache_pool_maxsize => $memcache_pool_maxsize, + max_retries => $max_retries, + max_pool_size => $max_pool_size, + max_overflow => $max_overflow, + rabbit_password => $rabbit_password, + rabbit_userid => $rabbit_user, + rabbit_hosts => $rabbit_hosts, + rabbit_virtual_host => $rabbit_virtual_host, + database_idle_timeout => $database_idle_timeout, + revoke_driver => $revoke_driver, + public_url => $public_url, + admin_url => $admin_url, + internal_url => $internal_url, + notification_driver => $ceilometer_hash['notification_driver'], + service_workers => $service_workers, + token_provider => $token_provider, + fernet_src_repository => '/var/lib/astute/keystone', } ####### WSGI ########### diff --git a/deployment/puppet/osnailyfacter/modular/murano/murano.pp b/deployment/puppet/osnailyfacter/modular/murano/murano.pp index 9738f5310e..ee393af62f 100644 --- a/deployment/puppet/osnailyfacter/modular/murano/murano.pp +++ b/deployment/puppet/osnailyfacter/modular/murano/murano.pp @@ -51,12 +51,26 @@ if $murano_hash['enabled'] { $murano_user = pick($murano_hash['user'], 'murano') $tenant = pick($murano_hash['tenant'], 'services') + + $db_type = 'mysql' $db_user = pick($murano_hash['db_user'], 'murano') $db_name = pick($murano_hash['db_name'], 'murano') $db_password = pick($murano_hash['db_password']) $db_host = pick($murano_hash['db_host'], $database_ip) - $read_timeout = '60' - $sql_connection = "mysql://${db_user}:${db_password}@${db_host}/${db_name}?read_timeout=${read_timeout}" + # LP#1526938 - python-mysqldb supports this, python-pymysql does not + if $::os_package_type == 'debian' { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } + } else { + $extra_params = { 'charset' => 'utf8' } + } + $db_connection = os_database_connection({ + 'dialect' => $db_type, + 'host' => $db_host, + 'database' => $db_name, + 'username' => $db_user, + 'password' => $db_password, + 'extra' => $extra_params + }) $external_network = $use_neutron ? { true => get_ext_net_name($neutron_config['predefined_networks']), @@ -85,7 +99,7 @@ if $murano_hash['enabled'] { use_syslog => $use_syslog, use_stderr => $use_stderr, log_facility => $syslog_log_facility_murano, - database_connection => $sql_connection, + database_connection => $db_connection, sync_db => $primary_controller, auth_uri => "${public_auth_protocol}://${public_auth_address}:5000/v2.0/", admin_user => $murano_user, diff --git a/deployment/puppet/osnailyfacter/modular/openstack-cinder/openstack-cinder.pp b/deployment/puppet/osnailyfacter/modular/openstack-cinder/openstack-cinder.pp index 11cdeb0a57..a7444aa96f 100644 --- a/deployment/puppet/osnailyfacter/modular/openstack-cinder/openstack-cinder.pp +++ b/deployment/puppet/osnailyfacter/modular/openstack-cinder/openstack-cinder.pp @@ -13,17 +13,33 @@ $sahara_hash = hiera_hash('sahara_hash',{}) $rabbit_hash = hiera_hash('rabbit_hash', {}) $service_endpoint = hiera('service_endpoint') $service_workers = pick($cinder_hash['workers'], min(max($::processorcount, 2), 16)) -$cinder_db_password = $cinder_hash[db_password] $cinder_user_password = $cinder_hash[user_password] $keystone_user = pick($cinder_hash['user'], 'cinder') $keystone_tenant = pick($cinder_hash['tenant'], 'services') $region = hiera('region', 'RegionOne') -$db_host = pick($cinder_hash['db_host'], hiera('database_vip')) -$cinder_db_user = pick($cinder_hash['db_user'], 'cinder') -$cinder_db_name = pick($cinder_hash['db_name'], 'cinder') $roles = node_roles($nodes_hash, hiera('uid')) $ssl_hash = hiera_hash('use_ssl', {}) -$primary_controller = hiera('primary_controller') +$primary_controller = hiera('primary_controller') + +$db_type = 'mysql' +$db_host = pick($cinder_hash['db_host'], hiera('database_vip')) +$db_user = pick($cinder_hash['db_user'], 'cinder') +$db_password = $cinder_hash[db_password] +$db_name = pick($cinder_hash['db_name'], 'cinder') +# LP#1526938 - python-mysqldb supports this, python-pymysql does not +if $::os_package_type == 'debian' { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } +} else { + $extra_params = { 'charset' => 'utf8' } +} +$db_connection = os_database_connection({ + 'dialect' => $db_type, + 'host' => $db_host, + 'database' => $db_name, + 'username' => $db_user, + 'password' => $db_password, + 'extra' => $extra_params +}) $keystone_auth_protocol = get_ssl_property($ssl_hash, {}, 'keystone', 'internal', 'protocol', 'http') $keystone_auth_host = get_ssl_property($ssl_hash, {}, 'keystone', 'internal', 'hostname', [hiera('keystone_endpoint', ''), $service_endpoint, $management_vip]) @@ -68,7 +84,7 @@ $openstack_version = { ######### Cinder Controller Services ######## class {'openstack::cinder': - sql_connection => "mysql://${cinder_db_user}:${cinder_db_password}@${db_host}/${cinder_db_name}?charset=utf8&read_timeout=60", + sql_connection => $db_connection, queue_provider => $queue_provider, amqp_hosts => hiera('amqp_hosts',''), amqp_user => $rabbit_hash['user'], diff --git a/deployment/puppet/osnailyfacter/modular/openstack-network/server-config.pp b/deployment/puppet/osnailyfacter/modular/openstack-network/server-config.pp index 6b9f53a98e..cca4842926 100644 --- a/deployment/puppet/osnailyfacter/modular/openstack-network/server-config.pp +++ b/deployment/puppet/osnailyfacter/modular/openstack-network/server-config.pp @@ -16,12 +16,25 @@ if $use_neutron { $nova_hash = hiera_hash('nova', { }) $primary_controller = hiera('primary_controller', false) - $neutron_db_password = $neutron_config['database']['passwd'] - $neutron_db_user = try_get_value($neutron_config, 'database/user', 'neutron') - $neutron_db_name = try_get_value($neutron_config, 'database/name', 'neutron') - $neutron_db_host = try_get_value($neutron_config, 'database/host', $database_vip) - - $neutron_db_uri = "mysql://${neutron_db_user}:${neutron_db_password}@${neutron_db_host}/${neutron_db_name}?&read_timeout=60" + $db_type = 'mysql' + $db_password = $neutron_config['database']['passwd'] + $db_user = try_get_value($neutron_config, 'database/user', 'neutron') + $db_name = try_get_value($neutron_config, 'database/name', 'neutron') + $db_host = try_get_value($neutron_config, 'database/host', $database_vip) + # LP#1526938 - python-mysqldb supports this, python-pymysql does not + if $::os_package_type == 'debian' { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } + } else { + $extra_params = { 'charset' => 'utf8' } + } + $db_connection = os_database_connection({ + 'dialect' => $db_type, + 'host' => $db_host, + 'database' => $db_name, + 'username' => $db_user, + 'password' => $db_password, + 'extra' => $extra_params + }) $auth_password = $neutron_config['keystone']['admin_password'] $auth_user = pick($neutron_config['keystone']['admin_user'], 'neutron') @@ -148,7 +161,7 @@ if $use_neutron { auth_uri => $identity_uri, database_retry_interval => '2', - database_connection => $neutron_db_uri, + database_connection => $db_connection, database_max_retries => '-1', agent_down_time => '30', diff --git a/deployment/puppet/osnailyfacter/modular/roles/cinder.pp b/deployment/puppet/osnailyfacter/modular/roles/cinder.pp index ed1dbd13e2..74bfdef5ef 100644 --- a/deployment/puppet/osnailyfacter/modular/roles/cinder.pp +++ b/deployment/puppet/osnailyfacter/modular/roles/cinder.pp @@ -40,12 +40,28 @@ $syslog_log_facility_murano = hiera('syslog_log_facility_murano', 'LOG_LOCAL $syslog_log_facility_sahara = hiera('syslog_log_facility_sahara','LOG_LOCAL0') $syslog_log_facility_ceph = hiera('syslog_log_facility_ceph','LOG_LOCAL0') -$cinder_db_password = $cinder_hash[db_password] $keystone_user = pick($cinder_hash['user'], 'cinder') $keystone_tenant = pick($cinder_hash['tenant'], 'services') -$db_host = pick($cinder_hash['db_host'], hiera('database_vip')) -$cinder_db_user = pick($cinder_hash['db_user'], 'cinder') -$cinder_db_name = pick($cinder_hash['db_name'], 'cinder') + +$db_type = 'mysql' +$db_host = pick($cinder_hash['db_host'], hiera('database_vip')) +$db_user = pick($cinder_hash['db_user'], 'cinder') +$db_password = $cinder_hash[db_password] +$db_name = pick($cinder_hash['db_name'], 'cinder') +# LP#1526938 - python-mysqldb supports this, python-pymysql does not +if $::os_package_type == 'debian' { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } +} else { + $extra_params = { 'charset' => 'utf8' } +} +$db_connection = os_database_connection({ + 'dialect' => $db_type, + 'host' => $db_host, + 'database' => $db_name, + 'username' => $db_user, + 'password' => $db_password, + 'extra' => $extra_params +}) $ssl_hash = hiera_hash('use_ssl', {}) $service_endpoint = hiera('service_endpoint') @@ -272,7 +288,7 @@ if member($roles, 'controller') or member($roles, 'primary-controller') { # after the deployment is done. class { '::openstack::cinder': enable_volumes => false, - sql_connection => "mysql://${cinder_db_user}:${cinder_db_password}@${db_host}/${cinder_db_name}?charset=utf8&read_timeout=60", + sql_connection => $db_connection, glance_api_servers => $glance_api_servers, bind_host => $bind_host, queue_provider => $queue_provider, diff --git a/deployment/puppet/osnailyfacter/modular/roles/ironic-conductor.pp b/deployment/puppet/osnailyfacter/modular/roles/ironic-conductor.pp index c25e986d45..bf39017bd1 100644 --- a/deployment/puppet/osnailyfacter/modular/roles/ironic-conductor.pp +++ b/deployment/puppet/osnailyfacter/modular/roles/ironic-conductor.pp @@ -29,11 +29,25 @@ $ironic_user = pick($ironic_hash['auth_name'],'ironic') $ironic_user_password = pick($ironic_hash['user_password'],'ironic') $ironic_swift_tempurl_key = pick($ironic_hash['swift_tempurl_key'],'ironic') +$db_type = 'mysql' $db_host = pick($ironic_hash['db_host'], $database_vip) $db_user = pick($ironic_hash['db_user'], 'ironic') $db_name = pick($ironic_hash['db_name'], 'ironic') $db_password = pick($ironic_hash['db_password'], 'ironic') -$database_connection = "mysql://${db_name}:${db_password}@${db_host}/${db_name}?charset=utf8&read_timeout=60" +# LP#1526938 - python-mysqldb supports this, python-pymysql does not +if $::os_package_type == 'debian' { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } +} else { + $extra_params = { 'charset' => 'utf8' } +} +$db_connection = os_database_connection({ + 'dialect' => $db_type, + 'host' => $db_host, + 'database' => $db_name, + 'username' => $db_user, + 'password' => $db_password, + 'extra' => $extra_params +}) $tftp_root = '/var/lib/ironic/tftpboot' @@ -57,7 +71,7 @@ class { '::ironic': control_exchange => 'ironic', use_syslog => $use_syslog, log_facility => $syslog_log_facility_ironic, - database_connection => $database_connection, + database_connection => $db_connection, database_max_retries => '-1', glance_api_servers => $glance_api_servers, } diff --git a/deployment/puppet/osnailyfacter/modular/sahara/sahara.pp b/deployment/puppet/osnailyfacter/modular/sahara/sahara.pp index ae954d3fc2..64a136db28 100644 --- a/deployment/puppet/osnailyfacter/modular/sahara/sahara.pp +++ b/deployment/puppet/osnailyfacter/modular/sahara/sahara.pp @@ -49,16 +49,30 @@ if $sahara_hash['enabled'] { $sahara_user = pick($sahara_hash['user'], 'sahara') $sahara_password = pick($sahara_hash['user_password']) $tenant = pick($sahara_hash['tenant'], 'services') - $db_user = pick($sahara_hash['db_user'], 'sahara') - $db_name = pick($sahara_hash['db_name'], 'sahara') - $db_password = pick($sahara_hash['db_password']) - $db_host = pick($sahara_hash['db_host'], $database_vip) $max_pool_size = min($::processorcount * 5 + 0, 30 + 0) $max_overflow = min($::processorcount * 5 + 0, 60 + 0) $max_retries = '-1' $idle_timeout = '3600' - $read_timeout = '60' - $sql_connection = "mysql://${db_user}:${db_password}@${db_host}/${db_name}?read_timeout=${read_timeout}" + + $db_type = 'mysql' + $db_user = pick($sahara_hash['db_user'], 'sahara') + $db_name = pick($sahara_hash['db_name'], 'sahara') + $db_password = pick($sahara_hash['db_password']) + $db_host = pick($sahara_hash['db_host'], $database_vip) + # LP#1526938 - python-mysqldb supports this, python-pymysql does not + if $::os_package_type == 'debian' { + $extra_params = { 'charset' => 'utf8', 'read_timeout' => 60 } + } else { + $extra_params = { 'charset' => 'utf8' } + } + $db_connection = os_database_connection({ + 'dialect' => $db_type, + 'host' => $db_host, + 'database' => $db_name, + 'username' => $db_user, + 'password' => $db_password, + 'extra' => $extra_params + }) ####### Disable upstart startup on install ####### tweaks::ubuntu_service_override { 'sahara-api': @@ -80,7 +94,7 @@ if $sahara_hash['enabled'] { use_stderr => $use_stderr, plugins => [ 'ambari', 'cdh', 'mapr', 'spark', 'vanilla' ], log_facility => $syslog_log_facility_sahara, - database_connection => $sql_connection, + database_connection => $db_connection, database_max_pool_size => $max_pool_size, database_max_overflow => $max_overflow, database_max_retries => $max_retries, diff --git a/tests/noop/astute.yaml/neut_vlan.cinder-block-device.compute.yaml b/tests/noop/astute.yaml/neut_vlan.cinder-block-device.compute.yaml index 7ce653ec1b..fb959d7dc7 100644 --- a/tests/noop/astute.yaml/neut_vlan.cinder-block-device.compute.yaml +++ b/tests/noop/astute.yaml/neut_vlan.cinder-block-device.compute.yaml @@ -1,4 +1,5 @@ test_tasks: + - globals/globals - roles/cinder user_node_name: Untitled (79:d2) diff --git a/tests/noop/spec/hosts/ceilometer/controller_spec.rb b/tests/noop/spec/hosts/ceilometer/controller_spec.rb index 64247fd055..005d80cdb2 100644 --- a/tests/noop/spec/hosts/ceilometer/controller_spec.rb +++ b/tests/noop/spec/hosts/ceilometer/controller_spec.rb @@ -45,8 +45,13 @@ describe manifest do # Ceilometer if ceilometer_hash['enabled'] - it 'should configure connection string with read reference set to primaryPreferred' do - should contain_ceilometer_config('database/connection').with(:value => "mongodb://#{ceilometer_db_user}:#{ceilometer_db_password}@#{db_hosts}/#{ceilometer_db_dbname}?readpreference=primaryPreferred") + it 'should properly build connection string' do + if mongo_replicaset and mongo_replicaset != '' + db_params = "?readPreference=primaryPreferred&replicaSet=#{mongo_replicaset}" + else + db_params = "?readPreference=primaryPreferred" + end + should contain_ceilometer_config('database/connection').with(:value => "mongodb://#{ceilometer_db_user}:#{ceilometer_db_password}@#{db_hosts}/#{ceilometer_db_dbname}#{db_params}") end if mongo_replicaset and mongo_replicaset != '' diff --git a/tests/noop/spec/hosts/glance/glance_spec.rb b/tests/noop/spec/hosts/glance/glance_spec.rb index aad7dae215..be84882569 100644 --- a/tests/noop/spec/hosts/glance/glance_spec.rb +++ b/tests/noop/spec/hosts/glance/glance_spec.rb @@ -24,6 +24,10 @@ describe manifest do pipeline = 'keystone' end murano_glance_artifacts_plugin = Noop.hiera('murano_glance_artifacts_plugin', {}) + database_vip = Noop.hiera('database_vip') + glance_db_password = Noop.hiera_structure 'glance/db_password', 'glance' + glance_db_user = Noop.hiera_structure 'glance/db_user', 'glance' + glance_db_name = Noop.hiera_structure 'glance/db_name', 'glance' let(:ssl_hash) { Noop.hiera_hash 'use_ssl', {} } @@ -52,6 +56,17 @@ describe manifest do should contain_class('glance::notify::rabbitmq') end + it 'should configure the database connection string' do + if facts[:os_package_type] == 'debian' + extra_params = '?charset=utf8&read_timeout=60' + else + extra_params = '?charset=utf8' + end + should contain_class('openstack::glance').with( + :db_connection => "mysql://#{glance_db_user}:#{glance_db_password}@#{database_vip}/#{glance_db_name}#{extra_params}" + ) + end + it 'should configure glance api config' do should contain_glance_api_config('database/max_pool_size').with_value(max_pool_size) should contain_glance_api_config('DEFAULT/use_stderr').with_value(use_stderr) diff --git a/tests/noop/spec/hosts/heat/heat_spec.rb b/tests/noop/spec/hosts/heat/heat_spec.rb index 9c83ef3098..5d1be03c43 100644 --- a/tests/noop/spec/hosts/heat/heat_spec.rb +++ b/tests/noop/spec/hosts/heat/heat_spec.rb @@ -39,6 +39,11 @@ describe manifest do primary_controller = Noop.hiera 'primary_controller' sahara = Noop.hiera_structure('sahara/enabled') + database_vip = Noop.hiera('database_vip') + heat_db_password = Noop.hiera_structure 'heat/db_password', 'heat' + heat_db_user = Noop.hiera_structure 'heat/db_user', 'heat' + heat_db_name = Noop.hiera('heat_db_name', 'heat') + it 'should install heat-docker package only after heat-engine' do if !facts.has_key?(:os_package_type) or facts[:os_package_type] != 'ubuntu' if facts[:osfamily] == 'RedHat' @@ -57,6 +62,17 @@ describe manifest do end end + it 'should configure the database connection string' do + if facts[:os_package_type] == 'debian' + extra_params = '?charset=utf8&read_timeout=60' + else + extra_params = '?charset=utf8' + end + should contain_class('openstack::heat').with( + :db_connection => "mysql://#{heat_db_user}:#{heat_db_password}@#{database_vip}/#{heat_db_name}#{extra_params}" + ) + end + it 'should configure default_log_levels' do should contain_heat_config('DEFAULT/default_log_levels').with_value(default_log_levels.sort.join(',')) end diff --git a/tests/noop/spec/hosts/ironic/ironic-compute_spec.rb b/tests/noop/spec/hosts/ironic/ironic-compute_spec.rb index 02c28c793b..47968570a0 100644 --- a/tests/noop/spec/hosts/ironic/ironic-compute_spec.rb +++ b/tests/noop/spec/hosts/ironic/ironic-compute_spec.rb @@ -12,6 +12,11 @@ describe manifest do memcache_addresses = Noop.hiera 'memcached_addresses', false memcache_server_port = Noop.hiera 'memcache_server_port', '11211' + database_vip = Noop.hiera('database_vip') + nova_db_password = Noop.hiera_structure 'nova/db_password', 'nova' + nova_db_user = Noop.hiera_structure 'nova/db_user', 'nova' + nova_db_name = Noop.hiera_structure 'nova/db_name', 'nova' + let(:memcache_nodes) do Noop.puppet_function 'get_nodes_hash_by_roles', network_metadata, memcache_roles end @@ -82,6 +87,17 @@ describe manifest do :enable => false, ) end + + it 'should configure the database connection string' do + if facts[:os_package_type] == 'debian' + extra_params = '?charset=utf8&read_timeout=60' + else + extra_params = '?charset=utf8' + end + should contain_class('nova').with( + :database_connection => "mysql://#{nova_db_user}:#{nova_db_password}@#{database_vip}/#{nova_db_name}#{extra_params}" + ) + end end end diff --git a/tests/noop/spec/hosts/ironic/ironic_spec.rb b/tests/noop/spec/hosts/ironic/ironic_spec.rb index bf022b7a29..76be6cdd54 100644 --- a/tests/noop/spec/hosts/ironic/ironic_spec.rb +++ b/tests/noop/spec/hosts/ironic/ironic_spec.rb @@ -14,6 +14,11 @@ if ironic_enabled primary_controller = Noop.hiera 'primary_controller' amqp_durable_queues = Noop.hiera_structure 'ironic/amqp_durable_queues', 'false' + database_vip = Noop.hiera('database_vip') + ironic_db_password = Noop.hiera_structure 'ironic/db_password', 'ironic' + ironic_db_user = Noop.hiera_structure 'ironic/db_user', 'ironic' + ironic_db_name = Noop.hiera_structure 'ironic/db_name', 'ironic' + it 'should configure default_log_levels' do should contain_ironic_config('DEFAULT/default_log_levels').with_value(default_log_levels.sort.join(',')) end @@ -29,6 +34,17 @@ if ironic_enabled ) end + it 'should configure the database connection string' do + if facts[:os_package_type] == 'debian' + extra_params = '?charset=utf8&read_timeout=60' + else + extra_params = '?charset=utf8' + end + should contain_class('ironic').with( + :database_connection => "mysql://#{ironic_db_user}:#{ironic_db_password}@#{database_vip}/#{ironic_db_name}#{extra_params}" + ) + end + # TODO (iberezovskiy): uncomment this test after ironic module update #it 'should configure default log levels' do # should contain_class('ironic::logging').with('default_log_levels' => default_log_levels) diff --git a/tests/noop/spec/hosts/keystone/keystone_spec.rb b/tests/noop/spec/hosts/keystone/keystone_spec.rb index 140597ec77..120cd7872a 100644 --- a/tests/noop/spec/hosts/keystone/keystone_spec.rb +++ b/tests/noop/spec/hosts/keystone/keystone_spec.rb @@ -73,6 +73,11 @@ describe manifest do token_provider = Noop.hiera('token_provider') primary_controller = Noop.hiera 'primary_controller' + database_vip = Noop.hiera('database_vip') + keystone_db_password = Noop.hiera_structure 'keystone/db_password', 'keystone' + keystone_db_user = Noop.hiera_structure 'keystone/db_user', 'keystone' + keystone_db_name = Noop.hiera_structure 'keystone/db_name', 'keystone' + default_log_levels_hash = Noop.hiera_hash 'default_log_levels' default_log_levels = Noop.puppet_function 'join_keys_to_values',default_log_levels_hash,'=' @@ -80,6 +85,18 @@ describe manifest do should contain_keystone_config('DEFAULT/default_log_levels').with_value(default_log_levels.sort.join(',')) end + it 'should configure the database connection string' do + if facts[:os_package_type] == 'debian' + extra_params = '?charset=utf8&read_timeout=60' + else + extra_params = '?charset=utf8' + end + should contain_class('openstack::keystone').with( + :db_connection => "mysql://#{keystone_db_user}:#{keystone_db_password}@#{database_vip}/#{keystone_db_name}#{extra_params}" + + ) + end + it 'should declare keystone class with admin_token' do should contain_class('keystone').with( 'admin_token' => admin_token diff --git a/tests/noop/spec/hosts/murano/murano_spec.rb b/tests/noop/spec/hosts/murano/murano_spec.rb index d70867d93c..e4b5f78fd2 100644 --- a/tests/noop/spec/hosts/murano/murano_spec.rb +++ b/tests/noop/spec/hosts/murano/murano_spec.rb @@ -60,8 +60,12 @@ describe manifest do let(:api_bind_port) { '8082' } let(:sql_connection) do - read_timeout = '60' - "mysql://#{db_user}:#{db_password}@#{db_host}/#{db_name}?read_timeout=#{read_timeout}" + if facts[:os_package_type] == 'debian' + extra_params = '?charset=utf8&read_timeout=60' + else + extra_params = '?charset=utf8' + end + "mysql://#{db_user}:#{db_password}@#{db_host}/#{db_name}#{extra_params}" end let(:ssl_hash) { Noop.hiera_hash 'use_ssl', {} } diff --git a/tests/noop/spec/hosts/openstack-cinder/openstack-cinder_spec.rb b/tests/noop/spec/hosts/openstack-cinder/openstack-cinder_spec.rb index 7682ebf536..ec440f61c9 100644 --- a/tests/noop/spec/hosts/openstack-cinder/openstack-cinder_spec.rb +++ b/tests/noop/spec/hosts/openstack-cinder/openstack-cinder_spec.rb @@ -16,10 +16,26 @@ describe manifest do default_log_levels = Noop.puppet_function 'join_keys_to_values',default_log_levels_hash,'=' primary_controller = Noop.hiera 'primary_controller' + database_vip = Noop.hiera('database_vip') + cinder_db_password = Noop.hiera_structure 'cinder/db_password', 'cinder' + cinder_db_user = Noop.hiera_structure 'cinder/db_user', 'cinder' + cinder_db_name = Noop.hiera_structure 'cinder/db_name', 'cinder' + it 'should configure default_log_levels' do should contain_cinder_config('DEFAULT/default_log_levels').with_value(default_log_levels.sort.join(',')) end + it 'should configure the database connection string' do + if facts[:os_package_type] == 'debian' + extra_params = '?charset=utf8&read_timeout=60' + else + extra_params = '?charset=utf8' + end + should contain_class('cinder').with( + :database_connection => "mysql://#{cinder_db_user}:#{cinder_db_password}@#{database_vip}/#{cinder_db_name}#{extra_params}" + ) + end + it 'ensures cinder_config contains "oslo_messaging_rabbit/rabbit_ha_queues" ' do should contain_cinder_config('oslo_messaging_rabbit/rabbit_ha_queues').with( 'value' => rabbit_ha_queues, diff --git a/tests/noop/spec/hosts/openstack-network/server-config_spec.rb b/tests/noop/spec/hosts/openstack-network/server-config_spec.rb index cd04cc2521..c7132d1fbe 100644 --- a/tests/noop/spec/hosts/openstack-network/server-config_spec.rb +++ b/tests/noop/spec/hosts/openstack-network/server-config_spec.rb @@ -75,15 +75,21 @@ describe manifest do it 'database options' do database_vip = Noop.hiera('database_vip') - neutron_db_password = neutron_config.fetch('database', {}).fetch('passwd') - neutron_db_user = neutron_config.fetch('database', {}).fetch('user', 'neutron') - neutron_db_name = neutron_config.fetch('database', {}).fetch('name', 'neutron') - neutron_db_host = neutron_config.fetch('database', {}).fetch('host', database_vip) - neutron_db_uri = "mysql://#{neutron_db_user}:#{neutron_db_password}@#{neutron_db_host}/#{neutron_db_name}?&read_timeout=60" + db_password = neutron_config.fetch('database', {}).fetch('passwd') + db_user = neutron_config.fetch('database', {}).fetch('user', 'neutron') + db_name = neutron_config.fetch('database', {}).fetch('name', 'neutron') + db_host = neutron_config.fetch('database', {}).fetch('host', database_vip) + if facts[:os_package_type] == 'debian' + extra_params = '?charset=utf8&read_timeout=60' + else + extra_params = '?charset=utf8' + end + db_connection = "mysql://#{db_user}:#{db_password}@#{db_host}/#{db_name}#{extra_params}" + should contain_class('neutron::server').with( 'sync_db' => 'false', 'database_retry_interval' => '2', - 'database_connection' => neutron_db_uri, + 'database_connection' => db_connection, 'database_max_retries' => '-1', ) end diff --git a/tests/noop/spec/hosts/roles/cinder_spec.rb b/tests/noop/spec/hosts/roles/cinder_spec.rb index 9be670b843..d8fea71990 100644 --- a/tests/noop/spec/hosts/roles/cinder_spec.rb +++ b/tests/noop/spec/hosts/roles/cinder_spec.rb @@ -8,6 +8,22 @@ describe manifest do storage_hash = Noop.hiera 'storage_hash' ceilometer_hash = Noop.hiera 'ceilometer_hash', { 'enabled' => false } + database_vip = Noop.hiera('database_vip') + cinder_db_password = Noop.hiera_structure 'cinder/db_password', 'cinder' + cinder_db_user = Noop.hiera_structure 'cinder/db_user', 'cinder' + cinder_db_name = Noop.hiera_structure 'cinder/db_name', 'cinder' + + it 'should configure the database connection string' do + if facts[:os_package_type] == 'debian' + extra_params = '?charset=utf8&read_timeout=60' + else + extra_params = '?charset=utf8' + end + should contain_class('openstack::cinder').with( + :sql_connection => "mysql://#{cinder_db_user}:#{cinder_db_password}@#{database_vip}/#{cinder_db_name}#{extra_params}" + ) + end + if Noop.hiera 'use_ceph' and !(storage_hash['volumes_lvm']) and !(member($roles, 'cinder-vmware')) it { should contain_class('ceph') } end diff --git a/tests/noop/spec/hosts/roles/ironic-conductor_spec.rb b/tests/noop/spec/hosts/roles/ironic-conductor_spec.rb index 26db185d85..53d0632b1b 100644 --- a/tests/noop/spec/hosts/roles/ironic-conductor_spec.rb +++ b/tests/noop/spec/hosts/roles/ironic-conductor_spec.rb @@ -10,6 +10,11 @@ describe manifest do storage_config = Noop.hiera_structure 'storage' amqp_durable_queues = Noop.hiera_structure 'ironic/amqp_durable_queues', 'false' + database_vip = Noop.hiera('database_vip') + ironic_db_password = Noop.hiera_structure 'ironic/db_password', 'ironic' + ironic_db_user = Noop.hiera_structure 'ironic/db_user', 'ironic' + ironic_db_name = Noop.hiera_structure 'ironic/db_name', 'ironic' + if ironic_enabled it 'should ensure that ironic-fa-deploy is installed' do should contain_package('ironic-fa-deploy').with('ensure' => 'present') @@ -26,6 +31,17 @@ describe manifest do ) end + it 'should configure the database connection string' do + if facts[:os_package_type] == 'debian' + extra_params = '?charset=utf8&read_timeout=60' + else + extra_params = '?charset=utf8' + end + should contain_class('ironic').with( + :database_connection => "mysql://#{ironic_db_user}:#{ironic_db_password}@#{database_vip}/#{ironic_db_name}#{extra_params}" + ) + end + management_vip = Noop.hiera 'management_vip' service_endpoint = Noop.hiera 'service_endpoint', management_vip neutron_endpoint = Noop.hiera 'neutron_endpoint', service_endpoint diff --git a/tests/noop/spec/hosts/sahara/sahara_spec.rb b/tests/noop/spec/hosts/sahara/sahara_spec.rb index 5e9c0db8c8..6a15d4a11a 100644 --- a/tests/noop/spec/hosts/sahara/sahara_spec.rb +++ b/tests/noop/spec/hosts/sahara/sahara_spec.rb @@ -95,7 +95,12 @@ describe manifest do max_retries = '-1' idle_timeout = '3600' read_timeout = '60' - sql_connection = "mysql://#{db_user}:#{db_password}@#{db_host}/#{db_name}?read_timeout=#{read_timeout}" + if facts[:os_package_type] == 'debian' + extra_params = '?charset=utf8&read_timeout=60' + else + extra_params = '?charset=utf8' + end + sql_connection = "mysql://#{db_user}:#{db_password}@#{db_host}/#{db_name}#{extra_params}" should contain_class('sahara').with( 'auth_uri' => auth_url, diff --git a/tests/noop/spec/lib/facts.rb b/tests/noop/spec/lib/facts.rb index 7f81246688..abddcc7049 100644 --- a/tests/noop/spec/lib/facts.rb +++ b/tests/noop/spec/lib/facts.rb @@ -37,6 +37,7 @@ class Noop :concat_basedir => '/tmp/', :l23_os => 'ubuntu', :lsbdistcodename => 'trusty', + :os_package_type => 'debian', }.merge override_facts end @@ -58,6 +59,7 @@ class Noop :l3_default_route => '172.16.1.1', :concat_basedir => '/tmp/', :l23_os => 'centos6', + :os_package_type => 'rpm', }.merge override_facts end