Update connection string generation

This change leverages the os_database_connection function from
openstacklib to generate the connection strings for our services. As
part of this change, we are moving the database connection string
generation to the osnailyfacter modular tasks and updating the
openstack classes to consume a connection string rather than the
seperate host, user, password, database name and database type.

Additionally as part of this change, we are updating the mysql
connection strings to only include read_time=60 if debian based packages
are used. This is due to the fact that python-pymysql, which is used by
Ubuntu packages, does not support the read_timeout option as part of the
connection string.

Change-Id: I45c51a05ba7cf9648b0202cc3c2216d185bd7eda
Closes-Bug: #1526938
Related-Blueprint: deploy-with-uca-packages
This commit is contained in:
Alex Schultz 2015-12-17 14:38:47 -07:00
parent 010c4759ee
commit 739a5a611c
34 changed files with 558 additions and 166 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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) {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}"
}
###############################################################################

View File

@ -27,6 +27,24 @@ $default_log_levels = hiera_hash('default_log_levels')
$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,

View File

@ -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)

View File

@ -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,

View File

@ -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, ','),

View File

@ -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,

View File

@ -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,15 +116,11 @@ $external_lb = hiera('external_lb', false)
###############################################################################
####### KEYSTONE ###########
class { 'openstack::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,
db_connection => $db_connection,
admin_token => $admin_token,
public_address => $public_address,
public_ssl => $public_ssl_hash['services'],

View File

@ -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,

View File

@ -13,18 +13,34 @@ $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')
$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'],

View File

@ -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',

View File

@ -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_type = 'mysql'
$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_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,

View File

@ -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,
}

View File

@ -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,

View File

@ -1,4 +1,5 @@
test_tasks:
- globals/globals
- roles/cinder
user_node_name: Untitled (79:d2)

View File

@ -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 != ''

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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', {} }

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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