Use oslo module for logging , database and policy configuration

Change-Id: I3ca0db893cdc819ca9349cae252bd2eb247c9fd9
This commit is contained in:
ZhongShengping 2016-05-06 09:40:09 +08:00
parent a6df0727b4
commit 47a3846d77
6 changed files with 31 additions and 62 deletions

View File

@ -54,40 +54,14 @@ class magnum::db (
validate_re($database_connection_real,
'(mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
case $database_connection_real {
/^mysql:\/\//: {
$backend_package = false
require 'mysql::bindings'
require 'mysql::bindings::python'
}
/^postgresql:\/\//: {
$backend_package = false
require 'postgresql::lib::python'
}
/^sqlite:\/\//: {
$backend_package = $::magnum::params::sqlite_package
}
default: {
fail('Unsupported backend configured')
}
}
if $backend_package and !defined(Package[$backend_package]) {
package {'magnum-backend-package':
ensure => present,
name => $backend_package,
tag => 'openstack',
}
}
magnum_config {
'database/connection': value => $database_connection_real, secret => true;
'database/idle_timeout': value => $database_idle_timeout_real;
'database/min_pool_size': value => $database_min_pool_size_real;
'database/max_retries': value => $database_max_retries_real;
'database/retry_interval': value => $database_retry_interval_real;
'database/max_pool_size': value => $database_max_pool_size_real;
'database/max_overflow': value => $database_max_overflow_real;
oslo::db { 'magnum_config':
connection => $database_connection_real,
idle_timeout => $database_idle_timeout_real,
min_pool_size => $database_min_pool_size_real,
max_pool_size => $database_max_pool_size_real,
max_retries => $database_max_retries_real,
retry_interval => $database_retry_interval_real,
max_overflow => $database_max_overflow_real,
}
}

View File

@ -113,31 +113,24 @@ class magnum::logging(
$log_date_format = $::os_service_default,
) {
if is_service_default($default_log_levels) {
$default_log_levels_real = $default_log_levels
} else {
$default_log_levels_real = join(sort(join_keys_to_values($default_log_levels, '=')), ',')
oslo::log { 'magnum_config':
debug => $debug,
verbose => $verbose,
use_syslog => $use_syslog,
use_stderr => $use_stderr,
log_dir => $log_dir,
syslog_log_facility => $log_facility,
logging_context_format_string => $logging_context_format_string,
logging_default_format_string => $logging_default_format_string,
logging_debug_format_suffix => $logging_debug_format_suffix,
logging_exception_prefix => $logging_exception_prefix,
log_config_append => $log_config_append,
default_log_levels => $default_log_levels,
publish_errors => $publish_errors,
fatal_deprecations => $fatal_deprecations,
log_date_format => $log_date_format,
instance_format => $instance_format,
instance_uuid_format => $instance_uuid_format,
}
magnum_config {
'DEFAULT/use_syslog': value => $use_syslog;
'DEFAULT/use_stderr': value => $use_stderr;
'DEFAULT/log_dir': value => $log_dir;
'DEFAULT/verbose': value => $verbose;
'DEFAULT/debug': value => $debug;
'DEFAULT/syslog_log_facility': value => $log_facility;
'DEFAULT/logging_context_format_string': value => $logging_context_format_string;
'DEFAULT/logging_default_format_string': value => $logging_default_format_string;
'DEFAULT/logging_debug_format_suffix': value => $logging_debug_format_suffix;
'DEFAULT/logging_exception_prefix': value => $logging_exception_prefix;
'DEFAULT/log_config_append': value => $log_config_append;
'DEFAULT/default_log_levels': value => $default_log_levels_real;
'DEFAULT/publish_errors': value => $publish_errors;
'DEFAULT/fatal_deprecations': value => $fatal_deprecations;
'DEFAULT/instance_format': value => $instance_format;
'DEFAULT/instance_uuid_format': value => $instance_uuid_format;
'DEFAULT/log_date_format': value => $log_date_format;
}
}

View File

@ -8,7 +8,6 @@ class magnum::params {
$common_package = 'openstack-magnum-common'
$api_package = 'openstack-magnum-api'
$conductor_package = 'openstack-magnum-conductor'
$sqlite_package = undef
# service names
$api_service = 'openstack-magnum-api'
$conductor_service = 'openstack-magnum-conductor'
@ -18,7 +17,6 @@ class magnum::params {
$common_package = 'magnum-common'
$api_package = 'magnum-api'
$conductor_package = 'magnum-conductor'
$sqlite_package = 'python-pysqlite2'
# service names
$api_service = 'magnum-api'
$conductor_service = 'magnum-conductor'

View File

@ -36,4 +36,6 @@ class magnum::policy (
create_resources('openstacklib::policy::base', $policies)
oslo::policy { 'magnum_config': policy_file => $policy_path}
}

View File

@ -29,6 +29,7 @@
"dependencies": [
{ "name": "puppetlabs/inifile", "version_requirement": ">=1.0.0 <2.0.0" },
{ "name": "puppetlabs/stdlib", "version_requirement": ">= 4.2.0 <5.0.0" },
{ "name": "openstack/openstacklib", "version_requirement": ">=5.0.0 <6.0.0" }
{ "name": "openstack/openstacklib", "version_requirement": ">=8.0.0 <9.0.0" },
{ "name": "openstack/oslo", "version_requirement": "<9.0.0" }
]
}

View File

@ -20,6 +20,7 @@ describe 'magnum::policy' do
:key => 'context_is_admin',
:value => 'foo:bar'
})
is_expected.to contain_magnum_config('oslo_policy/policy_file').with_value('/etc/magnum/policy.json')
end
end