Put all the logging related parameters to the logging class
Currently logging configuration is splitted in two distinct classes, the init.pp and the logging.pp classes. This review aims to centralize all logging related parameters in a single class, the logging.pp one. The impacted parameters are : * use_syslog * use_stderr * log_facility * verbose * debug * log_dir * log_file This change remains backward compatible with what is currently in place Change-Id: Ic268104fd9bc77bc142fc635285b0459f3d4314f
This commit is contained in:
parent
ed1425897f
commit
3231e35320
@ -14,11 +14,11 @@
|
||||
#
|
||||
# [*verbose*]
|
||||
# (optional) Rather to log the glance api service at verbose level.
|
||||
# Default: false
|
||||
# Default: undef
|
||||
#
|
||||
# [*debug*]
|
||||
# (optional) Rather to log the glance api service at debug level.
|
||||
# Default: false
|
||||
# Default: undef
|
||||
#
|
||||
# [*bind_host*]
|
||||
# (optional) The address of the host to bind to.
|
||||
@ -39,12 +39,12 @@
|
||||
# [*log_file*]
|
||||
# (optional) The path of file used for logging
|
||||
# If set to boolean false, it will not log to any file.
|
||||
# Default: /var/log/glance/api.log
|
||||
# Default: undef
|
||||
#
|
||||
# [*log_dir*]
|
||||
# (optional) directory to which glance logs are sent.
|
||||
# If set to boolean false, it will not log to any directory.
|
||||
# Defaults to '/var/log/glance'
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*registry_host*]
|
||||
# (optional) The address used to connect to the registry service.
|
||||
@ -123,15 +123,15 @@
|
||||
#
|
||||
# [*use_syslog*]
|
||||
# (optional) Use syslog for logging.
|
||||
# Defaults to false.
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*use_stderr*]
|
||||
# (optional) Use stderr for logging
|
||||
# Defaults to true
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*log_facility*]
|
||||
# (optional) Syslog facility to receive log lines.
|
||||
# Defaults to 'LOG_USER'.
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*show_image_direct_url*]
|
||||
# (optional) Expose image location to trusted clients.
|
||||
@ -194,14 +194,14 @@
|
||||
class glance::api(
|
||||
$keystone_password,
|
||||
$package_ensure = 'present',
|
||||
$verbose = false,
|
||||
$debug = false,
|
||||
$verbose = undef,
|
||||
$debug = undef,
|
||||
$bind_host = '0.0.0.0',
|
||||
$bind_port = '9292',
|
||||
$backlog = '4096',
|
||||
$workers = $::processorcount,
|
||||
$log_file = '/var/log/glance/api.log',
|
||||
$log_dir = '/var/log/glance',
|
||||
$log_file = undef,
|
||||
$log_dir = undef,
|
||||
$registry_host = '0.0.0.0',
|
||||
$registry_port = '9191',
|
||||
$registry_client_protocol = 'http',
|
||||
@ -213,9 +213,9 @@ class glance::api(
|
||||
$keystone_user = 'glance',
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$use_syslog = false,
|
||||
$use_stderr = true,
|
||||
$log_facility = 'LOG_USER',
|
||||
$use_syslog = undef,
|
||||
$use_stderr = undef,
|
||||
$log_facility = undef,
|
||||
$show_image_direct_url = false,
|
||||
$purge_config = false,
|
||||
$cert_file = false,
|
||||
@ -238,6 +238,7 @@ class glance::api(
|
||||
) inherits glance {
|
||||
|
||||
include ::glance::policy
|
||||
include ::glance::api::logging
|
||||
require keystone::python
|
||||
|
||||
if $mysql_module {
|
||||
@ -291,9 +292,6 @@ class glance::api(
|
||||
|
||||
# basic service config
|
||||
glance_api_config {
|
||||
'DEFAULT/verbose': value => $verbose;
|
||||
'DEFAULT/debug': value => $debug;
|
||||
'DEFAULT/use_stderr': value => $use_stderr;
|
||||
'DEFAULT/bind_host': value => $bind_host;
|
||||
'DEFAULT/bind_port': value => $bind_port;
|
||||
'DEFAULT/backlog': value => $backlog;
|
||||
@ -315,8 +313,8 @@ class glance::api(
|
||||
}
|
||||
|
||||
glance_cache_config {
|
||||
'DEFAULT/verbose': value => $verbose;
|
||||
'DEFAULT/debug': value => $debug;
|
||||
'DEFAULT/verbose': value => pick($verbose, false);
|
||||
'DEFAULT/debug': value => pick($debug, false);
|
||||
'glance_store/os_region_name': value => $os_region_name;
|
||||
}
|
||||
|
||||
@ -443,39 +441,6 @@ class glance::api(
|
||||
}
|
||||
}
|
||||
|
||||
# Logging
|
||||
if $log_file {
|
||||
glance_api_config {
|
||||
'DEFAULT/log_file': value => $log_file;
|
||||
}
|
||||
} else {
|
||||
glance_api_config {
|
||||
'DEFAULT/log_file': ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $log_dir {
|
||||
glance_api_config {
|
||||
'DEFAULT/log_dir': value => $log_dir;
|
||||
}
|
||||
} else {
|
||||
glance_api_config {
|
||||
'DEFAULT/log_dir': ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
# Syslog
|
||||
if $use_syslog {
|
||||
glance_api_config {
|
||||
'DEFAULT/use_syslog' : value => true;
|
||||
'DEFAULT/syslog_log_facility' : value => $log_facility;
|
||||
}
|
||||
} else {
|
||||
glance_api_config {
|
||||
'DEFAULT/use_syslog': value => false;
|
||||
}
|
||||
}
|
||||
|
||||
resources { 'glance_api_config':
|
||||
purge => $purge_config,
|
||||
}
|
||||
|
264
manifests/api/logging.pp
Normal file
264
manifests/api/logging.pp
Normal file
@ -0,0 +1,264 @@
|
||||
# Class glance::api::logging
|
||||
#
|
||||
# glance-api logging configuration
|
||||
#
|
||||
# == parameters
|
||||
#
|
||||
# [*verbose*]
|
||||
# (Optional) Should the daemons log verbose messages
|
||||
# Defaults to 'false'
|
||||
#
|
||||
# [*debug*]
|
||||
# (Optional) Should the daemons log debug messages
|
||||
# Defaults to 'false'
|
||||
#
|
||||
# [*use_syslog*]
|
||||
# (Optional) Use syslog for logging.
|
||||
# Defaults to 'false'
|
||||
#
|
||||
# [*use_stderr*]
|
||||
# (optional) Use stderr for logging
|
||||
# Defaults to 'true'
|
||||
#
|
||||
# [*log_facility*]
|
||||
# (Optional) Syslog facility to receive log lines.
|
||||
# Defaults to 'LOG_USER'
|
||||
#
|
||||
# [*log_dir*]
|
||||
# (optional) Directory where logs should be stored.
|
||||
# If set to boolean false, it will not log to any directory.
|
||||
# Defaults to '/var/log/glance'
|
||||
#
|
||||
# [*log_file*]
|
||||
# (optional) File where logs should be stored.
|
||||
# Defaults to '/var/log/glance/api.log'
|
||||
#
|
||||
# [*logging_context_format_string*]
|
||||
# (optional) Format string to use for log messages with context.
|
||||
# Defaults to undef.
|
||||
# Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
|
||||
# [%(request_id)s %(user_identity)s] %(instance)s%(message)s'
|
||||
#
|
||||
# [*logging_default_format_string*]
|
||||
# (optional) Format string to use for log messages without context.
|
||||
# Defaults to undef.
|
||||
# Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
|
||||
# [-] %(instance)s%(message)s'
|
||||
#
|
||||
# [*logging_debug_format_suffix*]
|
||||
# (optional) Formatted data to append to log format when level is DEBUG.
|
||||
# Defaults to undef.
|
||||
# Example: '%(funcName)s %(pathname)s:%(lineno)d'
|
||||
#
|
||||
# [*logging_exception_prefix*]
|
||||
# (optional) Prefix each line of exception output with this format.
|
||||
# Defaults to undef.
|
||||
# Example: '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s'
|
||||
#
|
||||
# [*log_config_append*]
|
||||
# The name of an additional logging configuration file.
|
||||
# Defaults to undef.
|
||||
# See https://docs.python.org/2/howto/logging.html
|
||||
#
|
||||
# [*default_log_levels*]
|
||||
# (optional) Hash of logger (keys) and level (values) pairs.
|
||||
# Defaults to undef.
|
||||
# Example:
|
||||
# { 'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
|
||||
# 'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO',
|
||||
# 'iso8601' => 'WARN',
|
||||
# 'requests.packages.urllib3.connectionpool' => 'WARN' }
|
||||
#
|
||||
# [*publish_errors*]
|
||||
# (optional) Publish error events (boolean value).
|
||||
# Defaults to undef (false if unconfigured).
|
||||
#
|
||||
# [*fatal_deprecations*]
|
||||
# (optional) Make deprecations fatal (boolean value)
|
||||
# Defaults to undef (false if unconfigured).
|
||||
#
|
||||
# [*instance_format*]
|
||||
# (optional) If an instance is passed with the log message, format it
|
||||
# like this (string value).
|
||||
# Defaults to undef.
|
||||
# Example: '[instance: %(uuid)s] '
|
||||
#
|
||||
# [*instance_uuid_format*]
|
||||
# (optional) If an instance UUID is passed with the log message, format
|
||||
# it like this (string value).
|
||||
# Defaults to undef.
|
||||
# Example: instance_uuid_format='[instance: %(uuid)s] '
|
||||
#
|
||||
# [*log_date_format*]
|
||||
# (optional) Format string for %%(asctime)s in log records.
|
||||
# Defaults to undef.
|
||||
# Example: 'Y-%m-%d %H:%M:%S'
|
||||
|
||||
class glance::api::logging(
|
||||
$use_syslog = false,
|
||||
$use_stderr = true,
|
||||
$log_facility = 'LOG_USER',
|
||||
$log_dir = '/var/log/glance',
|
||||
$log_file = '/var/log/glance/api.log',
|
||||
$verbose = false,
|
||||
$debug = false,
|
||||
$logging_context_format_string = undef,
|
||||
$logging_default_format_string = undef,
|
||||
$logging_debug_format_suffix = undef,
|
||||
$logging_exception_prefix = undef,
|
||||
$log_config_append = undef,
|
||||
$default_log_levels = undef,
|
||||
$publish_errors = undef,
|
||||
$fatal_deprecations = undef,
|
||||
$instance_format = undef,
|
||||
$instance_uuid_format = undef,
|
||||
$log_date_format = undef,
|
||||
) {
|
||||
|
||||
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
|
||||
# to use glance::<myparam> first then glance::logging::<myparam>.
|
||||
$use_syslog_real = pick($::glance::api::use_syslog,$use_syslog)
|
||||
$use_stderr_real = pick($::glance::api::use_stderr,$use_stderr)
|
||||
$log_facility_real = pick($::glance::api::log_facility,$log_facility)
|
||||
$log_dir_real = pick($::glance::api::log_dir,$log_dir)
|
||||
$log_file_real = pick($::glance::api::log_file,$log_file)
|
||||
$verbose_real = pick($::glance::api::verbose,$verbose)
|
||||
$debug_real = pick($::glance::api::debug,$debug)
|
||||
|
||||
glance_api_config {
|
||||
'DEFAULT/debug' : value => $debug_real;
|
||||
'DEFAULT/verbose' : value => $verbose_real;
|
||||
'DEFAULT/use_stderr' : value => $use_stderr_real;
|
||||
'DEFAULT/use_syslog' : value => $use_syslog_real;
|
||||
'DEFAULT/log_dir' : value => $log_dir_real;
|
||||
'DEFAULT/log_file' : value => $log_file_real;
|
||||
'DEFAULT/syslog_log_facility': value => $log_facility_real;
|
||||
}
|
||||
|
||||
if $logging_context_format_string {
|
||||
glance_api_config {
|
||||
'DEFAULT/logging_context_format_string' :
|
||||
value => $logging_context_format_string;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_api_config {
|
||||
'DEFAULT/logging_context_format_string' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $logging_default_format_string {
|
||||
glance_api_config {
|
||||
'DEFAULT/logging_default_format_string' :
|
||||
value => $logging_default_format_string;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_api_config {
|
||||
'DEFAULT/logging_default_format_string' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $logging_debug_format_suffix {
|
||||
glance_api_config {
|
||||
'DEFAULT/logging_debug_format_suffix' :
|
||||
value => $logging_debug_format_suffix;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_api_config {
|
||||
'DEFAULT/logging_debug_format_suffix' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $logging_exception_prefix {
|
||||
glance_api_config {
|
||||
'DEFAULT/logging_exception_prefix' : value => $logging_exception_prefix;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_api_config {
|
||||
'DEFAULT/logging_exception_prefix' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $log_config_append {
|
||||
glance_api_config {
|
||||
'DEFAULT/log_config_append' : value => $log_config_append;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_api_config {
|
||||
'DEFAULT/log_config_append' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $default_log_levels {
|
||||
glance_api_config {
|
||||
'DEFAULT/default_log_levels' :
|
||||
value => join(sort(join_keys_to_values($default_log_levels, '=')), ',');
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_api_config {
|
||||
'DEFAULT/default_log_levels' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $publish_errors {
|
||||
glance_api_config {
|
||||
'DEFAULT/publish_errors' : value => $publish_errors;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_api_config {
|
||||
'DEFAULT/publish_errors' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $fatal_deprecations {
|
||||
glance_api_config {
|
||||
'DEFAULT/fatal_deprecations' : value => $fatal_deprecations;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_api_config {
|
||||
'DEFAULT/fatal_deprecations' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $instance_format {
|
||||
glance_api_config {
|
||||
'DEFAULT/instance_format' : value => $instance_format;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_api_config {
|
||||
'DEFAULT/instance_format' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $instance_uuid_format {
|
||||
glance_api_config {
|
||||
'DEFAULT/instance_uuid_format' : value => $instance_uuid_format;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_api_config {
|
||||
'DEFAULT/instance_uuid_format' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $log_date_format {
|
||||
glance_api_config {
|
||||
'DEFAULT/log_date_format' : value => $log_date_format;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_api_config {
|
||||
'DEFAULT/log_date_format' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -13,10 +13,10 @@
|
||||
# used because there is only one glance package.
|
||||
#
|
||||
# [*verbose*]
|
||||
# (optional) Enable verbose logs (true|false). Defaults to false.
|
||||
# (optional) Enable verbose logs (true|false). Defaults to undef.
|
||||
#
|
||||
# [*debug*]
|
||||
# (optional) Enable debug logs (true|false). Defaults to false.
|
||||
# (optional) Enable debug logs (true|false). Defaults to undef.
|
||||
#
|
||||
# [*bind_host*]
|
||||
# (optional) The address of the host to bind to. Defaults to '0.0.0.0'.
|
||||
@ -32,12 +32,12 @@
|
||||
# [*log_file*]
|
||||
# (optional) Log file for glance-registry.
|
||||
# If set to boolean false, it will not log to any file.
|
||||
# Defaults to '/var/log/glance/registry.log'.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*log_dir*]
|
||||
# (optional) directory to which glance logs are sent.
|
||||
# If set to boolean false, it will not log to any directory.
|
||||
# Defaults to '/var/log/glance'
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*database_connection*]
|
||||
# (optional) Connection url to connect to nova database.
|
||||
@ -89,15 +89,15 @@
|
||||
#
|
||||
# [*use_syslog*]
|
||||
# (optional) Use syslog for logging.
|
||||
# Defaults to false.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*use_stderr*]
|
||||
# (optional) Use stderr for logging
|
||||
# Defaults to true
|
||||
# [*use_stderr*]
|
||||
# (optional) Use stderr for logging
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*log_facility*]
|
||||
# (optional) Syslog facility to receive log lines.
|
||||
# Defaults to LOG_USER.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (optional) If Puppet should manage service startup / shutdown.
|
||||
@ -134,13 +134,13 @@
|
||||
class glance::registry(
|
||||
$keystone_password,
|
||||
$package_ensure = 'present',
|
||||
$verbose = false,
|
||||
$debug = false,
|
||||
$verbose = undef,
|
||||
$debug = undef,
|
||||
$bind_host = '0.0.0.0',
|
||||
$bind_port = '9191',
|
||||
$workers = $::processorcount,
|
||||
$log_file = '/var/log/glance/registry.log',
|
||||
$log_dir = '/var/log/glance',
|
||||
$log_file = undef,
|
||||
$log_dir = undef,
|
||||
$database_connection = 'sqlite:///var/lib/glance/glance.sqlite',
|
||||
$database_idle_timeout = 3600,
|
||||
$auth_type = 'keystone',
|
||||
@ -149,9 +149,9 @@ class glance::registry(
|
||||
$keystone_tenant = 'services',
|
||||
$keystone_user = 'glance',
|
||||
$pipeline = 'keystone',
|
||||
$use_syslog = false,
|
||||
$use_stderr = true,
|
||||
$log_facility = 'LOG_USER',
|
||||
$use_syslog = undef,
|
||||
$use_stderr = undef,
|
||||
$log_facility = undef,
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$purge_config = false,
|
||||
@ -167,6 +167,7 @@ class glance::registry(
|
||||
$auth_protocol = 'http',
|
||||
) inherits glance {
|
||||
|
||||
include ::glance::registry::logging
|
||||
require keystone::python
|
||||
|
||||
if $mysql_module {
|
||||
@ -213,12 +214,9 @@ class glance::registry(
|
||||
}
|
||||
|
||||
glance_registry_config {
|
||||
'DEFAULT/verbose': value => $verbose;
|
||||
'DEFAULT/debug': value => $debug;
|
||||
'DEFAULT/workers': value => $workers;
|
||||
'DEFAULT/bind_host': value => $bind_host;
|
||||
'DEFAULT/bind_port': value => $bind_port;
|
||||
'DEFAULT/use_stderr': value => $use_stderr;
|
||||
}
|
||||
|
||||
if $identity_uri {
|
||||
@ -326,39 +324,6 @@ class glance::registry(
|
||||
}
|
||||
}
|
||||
|
||||
# Logging
|
||||
if $log_file {
|
||||
glance_registry_config {
|
||||
'DEFAULT/log_file': value => $log_file;
|
||||
}
|
||||
} else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/log_file': ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $log_dir {
|
||||
glance_registry_config {
|
||||
'DEFAULT/log_dir': value => $log_dir;
|
||||
}
|
||||
} else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/log_dir': ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
# Syslog
|
||||
if $use_syslog {
|
||||
glance_registry_config {
|
||||
'DEFAULT/use_syslog': value => true;
|
||||
'DEFAULT/syslog_log_facility': value => $log_facility;
|
||||
}
|
||||
} else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/use_syslog': value => false;
|
||||
}
|
||||
}
|
||||
|
||||
resources { 'glance_registry_config':
|
||||
purge => $purge_config
|
||||
}
|
||||
|
264
manifests/registry/logging.pp
Normal file
264
manifests/registry/logging.pp
Normal file
@ -0,0 +1,264 @@
|
||||
# Class glance::registry::logging
|
||||
#
|
||||
# glance-registry logging configuration
|
||||
#
|
||||
# == parameters
|
||||
#
|
||||
# [*verbose*]
|
||||
# (Optional) Should the daemons log verbose messages
|
||||
# Defaults to 'false'
|
||||
#
|
||||
# [*debug*]
|
||||
# (Optional) Should the daemons log debug messages
|
||||
# Defaults to 'false'
|
||||
#
|
||||
# [*use_syslog*]
|
||||
# (Optional) Use syslog for logging.
|
||||
# Defaults to 'false'
|
||||
#
|
||||
# [*use_stderr*]
|
||||
# (optional) Use stderr for logging
|
||||
# Defaults to 'true'
|
||||
#
|
||||
# [*log_facility*]
|
||||
# (Optional) Syslog facility to receive log lines.
|
||||
# Defaults to 'LOG_USER'
|
||||
#
|
||||
# [*log_dir*]
|
||||
# (optional) Directory where logs should be stored.
|
||||
# If set to boolean false, it will not log to any directory.
|
||||
# Defaults to '/var/log/glance'
|
||||
#
|
||||
# [*log_file*]
|
||||
# (optional) File where logs should be stored.
|
||||
# Defaults to '/var/log/glance/registry.log'
|
||||
#
|
||||
# [*logging_context_format_string*]
|
||||
# (optional) Format string to use for log messages with context.
|
||||
# Defaults to undef.
|
||||
# Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
|
||||
# [%(request_id)s %(user_identity)s] %(instance)s%(message)s'
|
||||
#
|
||||
# [*logging_default_format_string*]
|
||||
# (optional) Format string to use for log messages without context.
|
||||
# Defaults to undef.
|
||||
# Example: '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s\
|
||||
# [-] %(instance)s%(message)s'
|
||||
#
|
||||
# [*logging_debug_format_suffix*]
|
||||
# (optional) Formatted data to append to log format when level is DEBUG.
|
||||
# Defaults to undef.
|
||||
# Example: '%(funcName)s %(pathname)s:%(lineno)d'
|
||||
#
|
||||
# [*logging_exception_prefix*]
|
||||
# (optional) Prefix each line of exception output with this format.
|
||||
# Defaults to undef.
|
||||
# Example: '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s'
|
||||
#
|
||||
# [*log_config_append*]
|
||||
# The name of an additional logging configuration file.
|
||||
# Defaults to undef.
|
||||
# See https://docs.python.org/2/howto/logging.html
|
||||
#
|
||||
# [*default_log_levels*]
|
||||
# (optional) Hash of logger (keys) and level (values) pairs.
|
||||
# Defaults to undef.
|
||||
# Example:
|
||||
# { 'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
|
||||
# 'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO',
|
||||
# 'iso8601' => 'WARN',
|
||||
# 'requests.packages.urllib3.connectionpool' => 'WARN' }
|
||||
#
|
||||
# [*publish_errors*]
|
||||
# (optional) Publish error events (boolean value).
|
||||
# Defaults to undef (false if unconfigured).
|
||||
#
|
||||
# [*fatal_deprecations*]
|
||||
# (optional) Make deprecations fatal (boolean value)
|
||||
# Defaults to undef (false if unconfigured).
|
||||
#
|
||||
# [*instance_format*]
|
||||
# (optional) If an instance is passed with the log message, format it
|
||||
# like this (string value).
|
||||
# Defaults to undef.
|
||||
# Example: '[instance: %(uuid)s] '
|
||||
#
|
||||
# [*instance_uuid_format*]
|
||||
# (optional) If an instance UUID is passed with the log message, format
|
||||
# it like this (string value).
|
||||
# Defaults to undef.
|
||||
# Example: instance_uuid_format='[instance: %(uuid)s] '
|
||||
#
|
||||
# [*log_date_format*]
|
||||
# (optional) Format string for %%(asctime)s in log records.
|
||||
# Defaults to undef.
|
||||
# Example: 'Y-%m-%d %H:%M:%S'
|
||||
|
||||
class glance::registry::logging(
|
||||
$use_syslog = false,
|
||||
$use_stderr = true,
|
||||
$log_facility = 'LOG_USER',
|
||||
$log_dir = '/var/log/glance',
|
||||
$log_file = '/var/log/glance/registry.log',
|
||||
$verbose = false,
|
||||
$debug = false,
|
||||
$logging_context_format_string = undef,
|
||||
$logging_default_format_string = undef,
|
||||
$logging_debug_format_suffix = undef,
|
||||
$logging_exception_prefix = undef,
|
||||
$log_config_append = undef,
|
||||
$default_log_levels = undef,
|
||||
$publish_errors = undef,
|
||||
$fatal_deprecations = undef,
|
||||
$instance_format = undef,
|
||||
$instance_uuid_format = undef,
|
||||
$log_date_format = undef,
|
||||
) {
|
||||
|
||||
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
|
||||
# to use glance::<myparam> first, then glance::logging::<myparam>.
|
||||
$use_syslog_real = pick($::glance::registry::use_syslog,$use_syslog)
|
||||
$use_stderr_real = pick($::glance::registry::use_stderr,$use_stderr)
|
||||
$log_facility_real = pick($::glance::registry::log_facility,$log_facility)
|
||||
$log_dir_real = pick($::glance::registry::log_dir,$log_dir)
|
||||
$log_file_real = pick($::glance::registry::log_file,$log_file)
|
||||
$verbose_real = pick($::glance::registry::verbose,$verbose)
|
||||
$debug_real = pick($::glance::registry::debug,$debug)
|
||||
|
||||
glance_registry_config {
|
||||
'DEFAULT/debug' : value => $debug_real;
|
||||
'DEFAULT/verbose' : value => $verbose_real;
|
||||
'DEFAULT/use_stderr' : value => $use_stderr_real;
|
||||
'DEFAULT/use_syslog' : value => $use_syslog_real;
|
||||
'DEFAULT/log_dir' : value => $log_dir_real;
|
||||
'DEFAULT/log_file' : value => $log_file_real;
|
||||
'DEFAULT/syslog_log_facility': value => $log_facility_real;
|
||||
}
|
||||
|
||||
if $logging_context_format_string {
|
||||
glance_registry_config {
|
||||
'DEFAULT/logging_context_format_string' :
|
||||
value => $logging_context_format_string;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/logging_context_format_string' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $logging_default_format_string {
|
||||
glance_registry_config {
|
||||
'DEFAULT/logging_default_format_string' :
|
||||
value => $logging_default_format_string;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/logging_default_format_string' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $logging_debug_format_suffix {
|
||||
glance_registry_config {
|
||||
'DEFAULT/logging_debug_format_suffix' :
|
||||
value => $logging_debug_format_suffix;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/logging_debug_format_suffix' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $logging_exception_prefix {
|
||||
glance_registry_config {
|
||||
'DEFAULT/logging_exception_prefix' : value => $logging_exception_prefix;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/logging_exception_prefix' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $log_config_append {
|
||||
glance_registry_config {
|
||||
'DEFAULT/log_config_append' : value => $log_config_append;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/log_config_append' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $default_log_levels {
|
||||
glance_registry_config {
|
||||
'DEFAULT/default_log_levels' :
|
||||
value => join(sort(join_keys_to_values($default_log_levels, '=')), ',');
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/default_log_levels' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $publish_errors {
|
||||
glance_registry_config {
|
||||
'DEFAULT/publish_errors' : value => $publish_errors;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/publish_errors' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $fatal_deprecations {
|
||||
glance_registry_config {
|
||||
'DEFAULT/fatal_deprecations' : value => $fatal_deprecations;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/fatal_deprecations' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $instance_format {
|
||||
glance_registry_config {
|
||||
'DEFAULT/instance_format' : value => $instance_format;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/instance_format' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $instance_uuid_format {
|
||||
glance_registry_config {
|
||||
'DEFAULT/instance_uuid_format' : value => $instance_uuid_format;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/instance_uuid_format' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
if $log_date_format {
|
||||
glance_registry_config {
|
||||
'DEFAULT/log_date_format' : value => $log_date_format;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glance_registry_config {
|
||||
'DEFAULT/log_date_format' : ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
146
spec/classes/glance_api_logging_spec.rb
Normal file
146
spec/classes/glance_api_logging_spec.rb
Normal file
@ -0,0 +1,146 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'glance::api::logging' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
}
|
||||
end
|
||||
|
||||
let :log_params do
|
||||
{
|
||||
:logging_context_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s',
|
||||
:logging_default_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s',
|
||||
:logging_debug_format_suffix => '%(funcName)s %(pathname)s:%(lineno)d',
|
||||
:logging_exception_prefix => '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s',
|
||||
:log_config_append => '/etc/glance/logging.conf',
|
||||
:publish_errors => true,
|
||||
:default_log_levels => {
|
||||
'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
|
||||
'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO',
|
||||
'iso8601' => 'WARN',
|
||||
'requests.packages.urllib3.connectionpool' => 'WARN' },
|
||||
:fatal_deprecations => true,
|
||||
:instance_format => '[instance: %(uuid)s] ',
|
||||
:instance_uuid_format => '[instance: %(uuid)s] ',
|
||||
:log_date_format => '%Y-%m-%d %H:%M:%S',
|
||||
:use_syslog => true,
|
||||
:use_stderr => false,
|
||||
:log_facility => 'LOG_FOO',
|
||||
:log_dir => '/var/log',
|
||||
:log_file => '/var/tmp/glance_api_random.log',
|
||||
:verbose => true,
|
||||
:debug => true,
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'glance-api-logging' do
|
||||
|
||||
context 'with basic logging options and default settings' do
|
||||
it_configures 'basic default logging settings'
|
||||
end
|
||||
|
||||
context 'with basic logging options and non-default settings' do
|
||||
before { params.merge!( log_params ) }
|
||||
it_configures 'basic non-default logging settings'
|
||||
end
|
||||
|
||||
context 'with extended logging options' do
|
||||
before { params.merge!( log_params ) }
|
||||
it_configures 'logging params set'
|
||||
end
|
||||
|
||||
context 'without extended logging options' do
|
||||
it_configures 'logging params unset'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples 'basic default logging settings' do
|
||||
it 'configures glance logging settins with default values' do
|
||||
is_expected.to contain_glance_api_config('DEFAULT/use_syslog').with(:value => 'false')
|
||||
is_expected.to contain_glance_api_config('DEFAULT/use_stderr').with(:value => 'true')
|
||||
is_expected.to contain_glance_api_config('DEFAULT/log_dir').with(:value => '/var/log/glance')
|
||||
is_expected.to contain_glance_api_config('DEFAULT/log_file').with(:value => '/var/log/glance/api.log')
|
||||
is_expected.to contain_glance_api_config('DEFAULT/verbose').with(:value => 'false')
|
||||
is_expected.to contain_glance_api_config('DEFAULT/debug').with(:value => 'false')
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'basic non-default logging settings' do
|
||||
it 'configures glance logging settins with non-default values' do
|
||||
is_expected.to contain_glance_api_config('DEFAULT/use_syslog').with(:value => 'true')
|
||||
is_expected.to contain_glance_api_config('DEFAULT/use_stderr').with(:value => 'false')
|
||||
is_expected.to contain_glance_api_config('DEFAULT/syslog_log_facility').with(:value => 'LOG_FOO')
|
||||
is_expected.to contain_glance_api_config('DEFAULT/log_dir').with(:value => '/var/log')
|
||||
is_expected.to contain_glance_api_config('DEFAULT/log_file').with(:value => '/var/tmp/glance_api_random.log')
|
||||
is_expected.to contain_glance_api_config('DEFAULT/verbose').with(:value => 'true')
|
||||
is_expected.to contain_glance_api_config('DEFAULT/debug').with(:value => 'true')
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'logging params set' do
|
||||
it 'enables logging params' do
|
||||
is_expected.to contain_glance_api_config('DEFAULT/logging_context_format_string').with_value(
|
||||
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s')
|
||||
|
||||
is_expected.to contain_glance_api_config('DEFAULT/logging_default_format_string').with_value(
|
||||
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s')
|
||||
|
||||
is_expected.to contain_glance_api_config('DEFAULT/logging_debug_format_suffix').with_value(
|
||||
'%(funcName)s %(pathname)s:%(lineno)d')
|
||||
|
||||
is_expected.to contain_glance_api_config('DEFAULT/logging_exception_prefix').with_value(
|
||||
'%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s')
|
||||
|
||||
is_expected.to contain_glance_api_config('DEFAULT/log_config_append').with_value(
|
||||
'/etc/glance/logging.conf')
|
||||
is_expected.to contain_glance_api_config('DEFAULT/publish_errors').with_value(
|
||||
true)
|
||||
|
||||
is_expected.to contain_glance_api_config('DEFAULT/default_log_levels').with_value(
|
||||
'amqp=WARN,amqplib=WARN,boto=WARN,iso8601=WARN,qpid=WARN,requests.packages.urllib3.connectionpool=WARN,sqlalchemy=WARN,suds=INFO')
|
||||
|
||||
is_expected.to contain_glance_api_config('DEFAULT/fatal_deprecations').with_value(
|
||||
true)
|
||||
|
||||
is_expected.to contain_glance_api_config('DEFAULT/instance_format').with_value(
|
||||
'[instance: %(uuid)s] ')
|
||||
|
||||
is_expected.to contain_glance_api_config('DEFAULT/instance_uuid_format').with_value(
|
||||
'[instance: %(uuid)s] ')
|
||||
|
||||
is_expected.to contain_glance_api_config('DEFAULT/log_date_format').with_value(
|
||||
'%Y-%m-%d %H:%M:%S')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
shared_examples_for 'logging params unset' do
|
||||
[ :logging_context_format_string, :logging_default_format_string,
|
||||
:logging_debug_format_suffix, :logging_exception_prefix,
|
||||
:log_config_append, :publish_errors,
|
||||
:default_log_levels, :fatal_deprecations,
|
||||
:instance_format, :instance_uuid_format,
|
||||
:log_date_format, ].each { |param|
|
||||
it { is_expected.to contain_glance_api_config("DEFAULT/#{param}").with_ensure('absent') }
|
||||
}
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_configures 'glance-api-logging'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'glance-api-logging'
|
||||
end
|
||||
|
||||
end
|
@ -83,6 +83,7 @@ describe 'glance::api' do
|
||||
|
||||
it { is_expected.to contain_class 'glance' }
|
||||
it { is_expected.to contain_class 'glance::policy' }
|
||||
it { is_expected.to contain_class 'glance::api::logging' }
|
||||
|
||||
it { is_expected.to contain_service('glance-api').with(
|
||||
'ensure' => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running': 'stopped',
|
||||
@ -97,8 +98,6 @@ describe 'glance::api' do
|
||||
|
||||
it 'is_expected.to lay down default api config' do
|
||||
[
|
||||
'verbose',
|
||||
'debug',
|
||||
'use_stderr',
|
||||
'bind_host',
|
||||
'bind_port',
|
||||
@ -113,8 +112,6 @@ describe 'glance::api' do
|
||||
|
||||
it 'is_expected.to lay down default cache config' do
|
||||
[
|
||||
'verbose',
|
||||
'debug',
|
||||
'registry_host',
|
||||
'registry_port',
|
||||
].each do |config|
|
||||
@ -265,60 +262,6 @@ describe 'glance::api' do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with syslog disabled by default' do
|
||||
let :params do
|
||||
default_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_glance_api_config('DEFAULT/use_syslog').with_value(false) }
|
||||
it { is_expected.to_not contain_glance_api_config('DEFAULT/syslog_log_facility') }
|
||||
end
|
||||
|
||||
describe 'with syslog enabled' do
|
||||
let :params do
|
||||
default_params.merge({
|
||||
:use_syslog => 'true',
|
||||
})
|
||||
end
|
||||
|
||||
it { is_expected.to contain_glance_api_config('DEFAULT/use_syslog').with_value(true) }
|
||||
it { is_expected.to contain_glance_api_config('DEFAULT/syslog_log_facility').with_value('LOG_USER') }
|
||||
end
|
||||
|
||||
describe 'with syslog enabled and custom settings' do
|
||||
let :params do
|
||||
default_params.merge({
|
||||
:use_syslog => 'true',
|
||||
:log_facility => 'LOG_LOCAL0'
|
||||
})
|
||||
end
|
||||
|
||||
it { is_expected.to contain_glance_api_config('DEFAULT/use_syslog').with_value(true) }
|
||||
it { is_expected.to contain_glance_api_config('DEFAULT/syslog_log_facility').with_value('LOG_LOCAL0') }
|
||||
end
|
||||
|
||||
describe 'with log_file enabled by default' do
|
||||
let(:params) { default_params }
|
||||
|
||||
it { is_expected.to contain_glance_api_config('DEFAULT/log_file').with_value(default_params[:log_file]) }
|
||||
|
||||
context 'with log_file disabled' do
|
||||
let(:params) { default_params.merge!({ :log_file => false }) }
|
||||
it { is_expected.to contain_glance_api_config('DEFAULT/log_file').with_ensure('absent') }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with log_dir enabled by default' do
|
||||
let(:params) { default_params }
|
||||
|
||||
it { is_expected.to contain_glance_api_config('DEFAULT/log_dir').with_value(default_params[:log_dir]) }
|
||||
|
||||
context 'with log_dir disabled' do
|
||||
let(:params) { default_params.merge!({ :log_dir => false }) }
|
||||
it { is_expected.to contain_glance_api_config('DEFAULT/log_dir').with_ensure('absent') }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with ssl options' do
|
||||
let :params do
|
||||
default_params.merge({
|
||||
|
146
spec/classes/glance_registry_logging_spec.rb
Normal file
146
spec/classes/glance_registry_logging_spec.rb
Normal file
@ -0,0 +1,146 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'glance::registry::logging' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
}
|
||||
end
|
||||
|
||||
let :log_params do
|
||||
{
|
||||
:logging_context_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s',
|
||||
:logging_default_format_string => '%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s',
|
||||
:logging_debug_format_suffix => '%(funcName)s %(pathname)s:%(lineno)d',
|
||||
:logging_exception_prefix => '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s',
|
||||
:log_config_append => '/etc/glance/logging.conf',
|
||||
:publish_errors => true,
|
||||
:default_log_levels => {
|
||||
'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN',
|
||||
'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO',
|
||||
'iso8601' => 'WARN',
|
||||
'requests.packages.urllib3.connectionpool' => 'WARN' },
|
||||
:fatal_deprecations => true,
|
||||
:instance_format => '[instance: %(uuid)s] ',
|
||||
:instance_uuid_format => '[instance: %(uuid)s] ',
|
||||
:log_date_format => '%Y-%m-%d %H:%M:%S',
|
||||
:use_syslog => true,
|
||||
:use_stderr => false,
|
||||
:log_facility => 'LOG_FOO',
|
||||
:log_dir => '/var/log',
|
||||
:log_file => '/var/tmp/glance_registry_random.log',
|
||||
:verbose => true,
|
||||
:debug => true,
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'glance-registry-logging' do
|
||||
|
||||
context 'with basic logging options and default settings' do
|
||||
it_configures 'basic default logging settings'
|
||||
end
|
||||
|
||||
context 'with basic logging options and non-default settings' do
|
||||
before { params.merge!( log_params ) }
|
||||
it_configures 'basic non-default logging settings'
|
||||
end
|
||||
|
||||
context 'with extended logging options' do
|
||||
before { params.merge!( log_params ) }
|
||||
it_configures 'logging params set'
|
||||
end
|
||||
|
||||
context 'without extended logging options' do
|
||||
it_configures 'logging params unset'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples 'basic default logging settings' do
|
||||
it 'configures glance logging settins with default values' do
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/use_syslog').with(:value => 'false')
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/use_stderr').with(:value => 'true')
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/log_dir').with(:value => '/var/log/glance')
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/log_file').with(:value => '/var/log/glance/registry.log')
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/verbose').with(:value => 'false')
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/debug').with(:value => 'false')
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'basic non-default logging settings' do
|
||||
it 'configures glance logging settins with non-default values' do
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/use_syslog').with(:value => 'true')
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/use_stderr').with(:value => 'false')
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/syslog_log_facility').with(:value => 'LOG_FOO')
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/log_dir').with(:value => '/var/log')
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/log_file').with(:value => '/var/tmp/glance_registry_random.log')
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/verbose').with(:value => 'true')
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/debug').with(:value => 'true')
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'logging params set' do
|
||||
it 'enables logging params' do
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/logging_context_format_string').with_value(
|
||||
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s')
|
||||
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/logging_default_format_string').with_value(
|
||||
'%(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s')
|
||||
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/logging_debug_format_suffix').with_value(
|
||||
'%(funcName)s %(pathname)s:%(lineno)d')
|
||||
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/logging_exception_prefix').with_value(
|
||||
'%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s')
|
||||
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/log_config_append').with_value(
|
||||
'/etc/glance/logging.conf')
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/publish_errors').with_value(
|
||||
true)
|
||||
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/default_log_levels').with_value(
|
||||
'amqp=WARN,amqplib=WARN,boto=WARN,iso8601=WARN,qpid=WARN,requests.packages.urllib3.connectionpool=WARN,sqlalchemy=WARN,suds=INFO')
|
||||
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/fatal_deprecations').with_value(
|
||||
true)
|
||||
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/instance_format').with_value(
|
||||
'[instance: %(uuid)s] ')
|
||||
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/instance_uuid_format').with_value(
|
||||
'[instance: %(uuid)s] ')
|
||||
|
||||
is_expected.to contain_glance_registry_config('DEFAULT/log_date_format').with_value(
|
||||
'%Y-%m-%d %H:%M:%S')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
shared_examples_for 'logging params unset' do
|
||||
[ :logging_context_format_string, :logging_default_format_string,
|
||||
:logging_debug_format_suffix, :logging_exception_prefix,
|
||||
:log_config_append, :publish_errors,
|
||||
:default_log_levels, :fatal_deprecations,
|
||||
:instance_format, :instance_uuid_format,
|
||||
:log_date_format, ].each { |param|
|
||||
it { is_expected.to contain_glance_registry_config("DEFAULT/#{param}").with_ensure('absent') }
|
||||
}
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_configures 'glance-registry-logging'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'glance-registry-logging'
|
||||
end
|
||||
|
||||
end
|
@ -38,8 +38,6 @@ describe 'glance::registry' do
|
||||
[
|
||||
{:keystone_password => 'ChangeMe'},
|
||||
{
|
||||
:verbose => true,
|
||||
:debug => true,
|
||||
:bind_host => '127.0.0.1',
|
||||
:bind_port => '9111',
|
||||
:workers => '5',
|
||||
@ -68,6 +66,7 @@ describe 'glance::registry' do
|
||||
end
|
||||
|
||||
it { is_expected.to contain_class 'glance::registry' }
|
||||
it { is_expected.to contain_class 'glance::registry::logging' }
|
||||
|
||||
it { is_expected.to contain_service('glance-registry').with(
|
||||
'ensure' => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
|
||||
@ -87,8 +86,6 @@ describe 'glance::registry' do
|
||||
end
|
||||
it 'is_expected.to configure itself' do
|
||||
[
|
||||
'verbose',
|
||||
'debug',
|
||||
'workers',
|
||||
'bind_port',
|
||||
'bind_host',
|
||||
@ -217,74 +214,6 @@ describe 'glance::registry' do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with syslog disabled by default' do
|
||||
let :params do
|
||||
default_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_glance_registry_config('DEFAULT/use_syslog').with_value(false) }
|
||||
it { is_expected.to_not contain_glance_registry_config('DEFAULT/syslog_log_facility') }
|
||||
end
|
||||
|
||||
describe 'with syslog enabled' do
|
||||
let :params do
|
||||
default_params.merge({
|
||||
:use_syslog => 'true',
|
||||
})
|
||||
end
|
||||
|
||||
it { is_expected.to contain_glance_registry_config('DEFAULT/use_syslog').with_value(true) }
|
||||
it { is_expected.to contain_glance_registry_config('DEFAULT/syslog_log_facility').with_value('LOG_USER') }
|
||||
end
|
||||
|
||||
describe 'with syslog enabled and custom settings' do
|
||||
let :params do
|
||||
default_params.merge({
|
||||
:use_syslog => 'true',
|
||||
:log_facility => 'LOG_LOCAL0'
|
||||
})
|
||||
end
|
||||
|
||||
it { is_expected.to contain_glance_registry_config('DEFAULT/use_syslog').with_value(true) }
|
||||
it { is_expected.to contain_glance_registry_config('DEFAULT/syslog_log_facility').with_value('LOG_LOCAL0') }
|
||||
end
|
||||
|
||||
describe 'with log_file enabled by default' do
|
||||
let(:params) { default_params }
|
||||
|
||||
it { is_expected.to contain_glance_registry_config('DEFAULT/log_file').with_value(default_params[:log_file]) }
|
||||
|
||||
context 'with log_file disabled' do
|
||||
let(:params) { default_params.merge!({ :log_file => false }) }
|
||||
it { is_expected.to contain_glance_registry_config('DEFAULT/log_file').with_ensure('absent') }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with log_dir enabled by default' do
|
||||
let(:params) { default_params }
|
||||
|
||||
it { is_expected.to contain_glance_registry_config('DEFAULT/log_dir').with_value(default_params[:log_dir]) }
|
||||
|
||||
context 'with log_dir disabled' do
|
||||
let(:params) { default_params.merge!({ :log_dir => false }) }
|
||||
it { is_expected.to contain_glance_registry_config('DEFAULT/log_dir').with_ensure('absent') }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with no ssl options (default)' do
|
||||
let(:params) { default_params }
|
||||
|
||||
it { is_expected.to contain_glance_registry_config('DEFAULT/ca_file').with_ensure('absent')}
|
||||
it { is_expected.to contain_glance_registry_config('DEFAULT/cert_file').with_ensure('absent')}
|
||||
it { is_expected.to contain_glance_registry_config('DEFAULT/key_file').with_ensure('absent')}
|
||||
end
|
||||
|
||||
describe 'with use_stderr enabled (default)' do
|
||||
let(:params) { default_params }
|
||||
|
||||
it { is_expected.to contain_glance_registry_config('DEFAULT/use_stderr').with_value('true')}
|
||||
end
|
||||
|
||||
describe 'with ssl options' do
|
||||
let :params do
|
||||
default_params.merge({
|
||||
|
Loading…
Reference in New Issue
Block a user