From ae2044375198353f262148565d9afc8c703b9cd0 Mon Sep 17 00:00:00 2001 From: Mykyta Karpin Date: Tue, 24 Nov 2015 12:37:40 +0200 Subject: [PATCH] Switch Heat to $::os_service_default - part 1 Switching Heat to usage of os_service_default fact Change-Id: Iff9cda880bb938b1fff3bf217c7cbf233daaf68a Related-bug: #1515273 --- manifests/db.pp | 93 +++++----- manifests/init.pp | 152 ++++++---------- manifests/logging.pp | 227 ++++++------------------ spec/classes/heat_db_postgresql_spec.rb | 4 +- spec/classes/heat_db_spec.rb | 11 +- spec/classes/heat_init_spec.rb | 93 +++++----- spec/classes/heat_logging_spec.rb | 12 +- 7 files changed, 226 insertions(+), 366 deletions(-) diff --git a/manifests/db.pp b/manifests/db.pp index 957aa4b1..87837ae6 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -10,28 +10,28 @@ # # [*database_idle_timeout*] # Timeout when db connections should be reaped. -# (Optional) Defaults to 3600. +# (Optional) Defaults to $::os_service_default. # # [*database_min_pool_size*] # Minimum number of SQL connections to keep open in a pool. -# (Optional) Defaults to 1. +# (Optional) Defaults to $::os_service_default. # # [*database_max_pool_size*] # Maximum number of SQL connections to keep open in a pool. -# (Optional) Defaults to 10. +# (Optional) Defaults to $::os_service_default. # # [*database_max_retries*] # Maximum db connection retries during startup. # Setting -1 implies an infinite retry count. -# (Optional) Defaults to 10. +# (Optional) Defaults to $::os_service_default. # # [*database_retry_interval*] # Interval between retries of opening a sql connection. -# (Optional) Defaults to 10. +# (Optional) Defaults to $::os_service_default. # # [*database_max_overflow*] # If set, use this value for max_overflow with sqlalchemy. -# (Optional) Defaults to 20. +# (Optional) Defaults to $::os_service_default. # # [*sync_db*] # (Optional) Run db sync on nodes after connection setting has been set. @@ -39,12 +39,12 @@ # class heat::db ( $database_connection = 'sqlite:////var/lib/heat/heat.sqlite', - $database_idle_timeout = 3600, - $database_min_pool_size = 1, - $database_max_pool_size = 10, - $database_max_retries = 10, - $database_retry_interval = 10, - $database_max_overflow = 20, + $database_idle_timeout = $::os_service_default, + $database_min_pool_size = $::os_service_default, + $database_max_pool_size = $::os_service_default, + $database_max_retries = $::os_service_default, + $database_retry_interval = $::os_service_default, + $database_max_overflow = $::os_service_default, $sync_db = true, ) { @@ -64,47 +64,44 @@ class heat::db ( validate_re($database_connection_real, '(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?') - if $database_connection_real { - 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 = $::heat::params::sqlite_package_name - } - default: { - fail('Unsupported backend configured') - } + case $database_connection_real { + /^mysql:\/\//: { + $backend_package = false + require 'mysql::bindings' + require 'mysql::bindings::python' } - - if $backend_package and !defined(Package[$backend_package]) { - package {'heat-backend-package': - ensure => present, - name => $backend_package, - tag => 'openstack', - } + /^postgresql:\/\//: { + $backend_package = false + require 'postgresql::lib::python' } - - heat_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; + /^sqlite:\/\//: { + $backend_package = $::heat::params::sqlite_package_name } - - if $sync_db_real { - include ::heat::db::sync + default: { + fail('Unsupported backend configured') } + } + if $backend_package and !defined(Package[$backend_package]) { + package {'heat-backend-package': + ensure => present, + name => $backend_package, + tag => 'openstack', + } + } + + heat_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; + } + + if $sync_db_real { + include ::heat::db::sync } } diff --git a/manifests/init.pp b/manifests/init.pp index d119f0f9..e24b42e6 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -27,7 +27,7 @@ # # [*rpc_response_timeout*] # (Optional) Configure the timeout (in seconds) for rpc responses -# Defaults to 60 seconds +# Defaults to $::os_service_default. # # [*rabbit_host*] # (Optional) IP or hostname of the rabbit server. @@ -44,7 +44,7 @@ # # [*rabbit_userid*] # (Optional) User to connect to the rabbit server. -# Defaults to 'guest' +# Defaults to $::os_service_default. # # [*rabbit_password*] # (Optional) Password to connect to the rabbit_server. @@ -52,7 +52,7 @@ # # [*rabbit_virtual_host*] # (Optional) Virtual_host to use. -# Defaults to '/' +# Defaults to $::os_service_default. # # [*rabbit_ha_queues*] # (optional) Use HA queues in RabbitMQ (x-ha-policy: all). @@ -71,7 +71,7 @@ # check the heartbeat on RabbitMQ connection. (i.e. rabbit_heartbeat_rate=2 # when rabbit_heartbeat_timeout_threshold=60, the heartbeat will be checked # every 30 seconds. -# Defaults to 2 +# Defaults to $::os_service_default. # # [*rabbit_use_ssl*] # (Optional) Connect over SSL for RabbitMQ. @@ -79,21 +79,21 @@ # # [*kombu_ssl_ca_certs*] # (Optional) SSL certification authority file (valid only if SSL enabled). -# Defaults to undef +# Defaults to $::os_service_default. # # [*kombu_ssl_certfile*] # (Optional) SSL cert file (valid only if SSL enabled). -# Defaults to undef +# Defaults to $::os_service_default. # # [*kombu_ssl_keyfile*] # (Optional) SSL key file (valid only if SSL enabled). -# Defaults to undef +# Defaults to $::os_service_default. # # [*kombu_ssl_version*] # (Optional) SSL version to use (valid only if SSL enabled). # Valid values are TLSv1, SSLv23 and SSLv3. SSLv2 may be # available on some distributions. -# Defaults to 'TLSv1' +# Defaults to $::os_service_default. # # [*amqp_durable_queues*] # (Optional) Use durable queues in amqp. @@ -191,12 +191,12 @@ # (optional) Specifies the Authentication method. # Set to 'standalone' to get Heat to work with a remote OpenStack # Tested versions include 0.9 and 2.2 -# Defaults to undef +# Defaults to $::os_service_default. # # [*region_name*] # (Optional) Region name for services. This is the # default region name that heat talks to service endpoints on. -# Defaults to undef +# Defaults to $::os_service_default. # # [*instance_user*] # (Optional) The default user for new instances. Although heat claims that @@ -207,11 +207,11 @@ # # [*enable_stack_adopt*] # (Optional) Enable the stack-adopt feature. -# Defaults to undef +# Defaults to $::os_service_default. # # [*enable_stack_abandon*] # (Optional) Enable the stack-abandon feature. -# Defaults to undef +# Defaults to $::os_service_default. # # [*sync_db*] # (Optional) Run db sync on nodes after connection setting has been set. @@ -249,29 +249,29 @@ class heat( $keystone_password = false, $keystone_ec2_uri = 'http://127.0.0.1:5000/v2.0/ec2tokens', $rpc_backend = 'rabbit', - $rpc_response_timeout = 60, + $rpc_response_timeout = $::os_service_default, $rabbit_host = '127.0.0.1', $rabbit_port = 5672, $rabbit_hosts = undef, - $rabbit_userid = 'guest', + $rabbit_userid = $::os_service_default, $rabbit_password = '', - $rabbit_virtual_host = '/', + $rabbit_virtual_host = $::os_service_default, $rabbit_ha_queues = undef, $rabbit_heartbeat_timeout_threshold = 0, - $rabbit_heartbeat_rate = 2, + $rabbit_heartbeat_rate = $::os_service_default, $rabbit_use_ssl = false, - $kombu_ssl_ca_certs = undef, - $kombu_ssl_certfile = undef, - $kombu_ssl_keyfile = undef, - $kombu_ssl_version = 'TLSv1', + $kombu_ssl_ca_certs = $::os_service_default, + $kombu_ssl_certfile = $::os_service_default, + $kombu_ssl_keyfile = $::os_service_default, + $kombu_ssl_version = $::os_service_default, $amqp_durable_queues = false, $qpid_hostname = 'localhost', $qpid_port = 5672, $qpid_username = 'guest', $qpid_password = 'guest', - $qpid_heartbeat = 60, - $qpid_protocol = 'tcp', - $qpid_tcp_nodelay = true, + $qpid_heartbeat = $::os_service_default, + $qpid_protocol = $::os_service_default, + $qpid_tcp_nodelay = $::os_service_default, $qpid_reconnect = true, $qpid_reconnect_timeout = 0, $qpid_reconnect_limit = 0, @@ -288,10 +288,10 @@ class heat( $database_min_pool_size = undef, $database_max_pool_size = undef, $database_max_overflow = undef, - $flavor = undef, - $region_name = undef, - $enable_stack_adopt = undef, - $enable_stack_abandon = undef, + $flavor = $::os_service_default, + $region_name = $::os_service_default, + $enable_stack_adopt = $::os_service_default, + $enable_stack_abandon = $::os_service_default, $sync_db = undef, # Deprecated parameters $mysql_module = undef, @@ -307,16 +307,17 @@ class heat( include ::heat::deps include ::heat::params - if $kombu_ssl_ca_certs and !$rabbit_use_ssl { + if (!is_service_default($kombu_ssl_ca_certs)) and !$rabbit_use_ssl { fail('The kombu_ssl_ca_certs parameter requires rabbit_use_ssl to be set to true') } - if $kombu_ssl_certfile and !$rabbit_use_ssl { + if (!is_service_default($kombu_ssl_certfile)) and !$rabbit_use_ssl { fail('The kombu_ssl_certfile parameter requires rabbit_use_ssl to be set to true') } - if $kombu_ssl_keyfile and !$rabbit_use_ssl { + if (!is_service_default($kombu_ssl_keyfile)) and !$rabbit_use_ssl { fail('The kombu_ssl_keyfile parameter requires rabbit_use_ssl to be set to true') } - if ($kombu_ssl_certfile and !$kombu_ssl_keyfile) or ($kombu_ssl_keyfile and !$kombu_ssl_certfile) { + if ((!is_service_default($kombu_ssl_certfile)) and is_service_default($kombu_ssl_keyfile)) + or ((!is_service_default($kombu_ssl_keyfile)) and is_service_default($kombu_ssl_certfile)) { fail('The kombu_ssl_certfile and kombu_ssl_keyfile parameters must be used together') } if $mysql_module { @@ -363,41 +364,10 @@ class heat( 'oslo_messaging_rabbit/heartbeat_rate': value => $rabbit_heartbeat_rate; 'oslo_messaging_rabbit/rabbit_use_ssl': value => $rabbit_use_ssl; 'oslo_messaging_rabbit/amqp_durable_queues': value => $amqp_durable_queues; - } - - if $rabbit_use_ssl { - - if $kombu_ssl_ca_certs { - heat_config { 'oslo_messaging_rabbit/kombu_ssl_ca_certs': value => $kombu_ssl_ca_certs; } - } else { - heat_config { 'oslo_messaging_rabbit/kombu_ssl_ca_certs': ensure => absent; } - } - - if $kombu_ssl_certfile or $kombu_ssl_keyfile { - heat_config { - 'oslo_messaging_rabbit/kombu_ssl_certfile': value => $kombu_ssl_certfile; - 'oslo_messaging_rabbit/kombu_ssl_keyfile': value => $kombu_ssl_keyfile; - } - } else { - heat_config { - 'oslo_messaging_rabbit/kombu_ssl_certfile': ensure => absent; - 'oslo_messaging_rabbit/kombu_ssl_keyfile': ensure => absent; - } - } - - if $kombu_ssl_version { - heat_config { 'oslo_messaging_rabbit/kombu_ssl_version': value => $kombu_ssl_version; } - } else { - heat_config { 'oslo_messaging_rabbit/kombu_ssl_version': ensure => absent; } - } - - } else { - heat_config { - 'oslo_messaging_rabbit/kombu_ssl_version': ensure => absent; - 'oslo_messaging_rabbit/kombu_ssl_ca_certs': ensure => absent; - 'oslo_messaging_rabbit/kombu_ssl_certfile': ensure => absent; - 'oslo_messaging_rabbit/kombu_ssl_keyfile': ensure => absent; - } + 'oslo_messaging_rabbit/kombu_ssl_ca_certs': value => $kombu_ssl_ca_certs; + 'oslo_messaging_rabbit/kombu_ssl_certfile': value => $kombu_ssl_certfile; + 'oslo_messaging_rabbit/kombu_ssl_keyfile': value => $kombu_ssl_keyfile; + 'oslo_messaging_rabbit/kombu_ssl_version': value => $kombu_ssl_version; } } @@ -481,26 +451,25 @@ class heat( } } + if (!is_service_default($enable_stack_adopt)) { + validate_bool($enable_stack_adopt) + } + + if (!is_service_default($enable_stack_abandon)) { + validate_bool($enable_stack_abandon) + } + heat_config { - 'DEFAULT/rpc_backend' : value => $rpc_backend; - 'DEFAULT/rpc_response_timeout' : value => $rpc_response_timeout; - 'ec2authtoken/auth_uri' : value => $keystone_ec2_uri; - 'keystone_authtoken/admin_tenant_name' : value => $keystone_tenant; - 'keystone_authtoken/admin_user' : value => $keystone_user; - 'keystone_authtoken/admin_password' : value => $keystone_password, secret => true; - } - - if $flavor { - heat_config { 'paste_deploy/flavor': value => $flavor; } - } else { - heat_config { 'paste_deploy/flavor': ensure => absent; } - } - - # region name - if $region_name { - heat_config { 'DEFAULT/region_name_for_services': value => $region_name; } - } else { - heat_config { 'DEFAULT/region_name_for_services': ensure => absent; } + 'DEFAULT/rpc_backend': value => $rpc_backend; + 'DEFAULT/rpc_response_timeout': value => $rpc_response_timeout; + 'DEFAULT/region_name_for_services': value => $region_name; + 'DEFAULT/enable_stack_abandon': value => $enable_stack_abandon; + 'DEFAULT/enable_stack_adopt': value => $enable_stack_adopt; + 'ec2authtoken/auth_uri': value => $keystone_ec2_uri; + 'keystone_authtoken/admin_tenant_name': value => $keystone_tenant; + 'keystone_authtoken/admin_user': value => $keystone_user; + 'keystone_authtoken/admin_password': value => $keystone_password, secret => true; + 'paste_deploy/flavor': value => $flavor; } # instance_user @@ -513,17 +482,4 @@ class heat( heat_config { 'DEFAULT/instance_user': ensure => absent; } } - if $enable_stack_adopt != undef { - validate_bool($enable_stack_adopt) - heat_config { 'DEFAULT/enable_stack_adopt': value => $enable_stack_adopt; } - } else { - heat_config { 'DEFAULT/enable_stack_adopt': ensure => absent; } - } - - if $enable_stack_abandon != undef { - validate_bool($enable_stack_abandon) - heat_config { 'DEFAULT/enable_stack_abandon': value => $enable_stack_abandon; } - } else { - heat_config { 'DEFAULT/enable_stack_abandon': ensure => absent; } - } } diff --git a/manifests/logging.pp b/manifests/logging.pp index 426c14a6..8efa890b 100644 --- a/manifests/logging.pp +++ b/manifests/logging.pp @@ -5,24 +5,24 @@ # === Parameters # # [*verbose*] -# (Optional) Should the daemons log verbose messages -# Defaults to 'false' +# (Optional) Should the daemons log verbose messages. +# Defaults to $::os_service_default. # # [*debug*] -# (Optional) Should the daemons log debug messages -# Defaults to 'false' +# (Optional) Should the daemons log debug messages. +# Defaults to $::os_service_default. # # [*use_syslog*] # (Optional) Use syslog for logging. -# Defaults to 'false' +# Defaults to $::os_service_default. # # [*use_stderr*] -# (optional) Use stderr for logging -# Defaults to 'true' +# (optional) Use stderr for logging. +# Defaults to $::os_service_default. # # [*log_facility*] # (Optional) Syslog facility to receive log lines. -# Defaults to 'LOG_USER' +# Defaults to $::os_service_default. # # [*log_dir*] # (optional) Directory where logs should be stored. @@ -31,34 +31,34 @@ # # [*logging_context_format_string*] # (optional) Format string to use for log messages with context. -# Defaults to undef. +# Defaults to $::os_service_default # 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. +# Defaults to $::os_service_default. # 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. +# Defaults to $::os_service_default. # Example: '%(funcName)s %(pathname)s:%(lineno)d' # # [*logging_exception_prefix*] # (optional) Prefix each line of exception output with this format. -# Defaults to undef. +# Defaults to $::os_service_default. # 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. +# Defaults to $::os_service_default. # See https://docs.python.org/2/howto/logging.html # # [*default_log_levels*] # (optional) Hash of logger (keys) and level (values) pairs. -# Defaults to undef. +# Defaults to $::os_service_default. # Example: # {'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN', # 'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO', @@ -67,47 +67,47 @@ # # [*publish_errors*] # (optional) Publish error events (boolean value). -# Defaults to undef (false if unconfigured). +# Defaults to $::os_service_default. # # [*fatal_deprecations*] -# (optional) Make deprecations fatal (boolean value) -# Defaults to undef (false if unconfigured). +# (optional) Make deprecations fatal (boolean value). +# Defaults to $::os_service_default. # # [*instance_format*] # (optional) If an instance is passed with the log message, format it # like this (string value). -# Defaults to undef. +# Defaults to $::os_service_default. # 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. +# Defaults to $::os_service_default. # Example: instance_uuid_format='[instance: %(uuid)s] ' # [*log_date_format*] # (optional) Format string for %%(asctime)s in log records. -# Defaults to undef. +# Defaults to $::os_service_default. # Example: 'Y-%m-%d %H:%M:%S' # class heat::logging( - $use_syslog = false, - $use_stderr = true, - $log_facility = 'LOG_USER', + $use_syslog = $::os_service_default, + $use_stderr = $::os_service_default, + $log_facility = $::os_service_default, $log_dir = '/var/log/heat', - $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, + $verbose = $::os_service_default, + $debug = $::os_service_default, + $logging_context_format_string = $::os_service_default, + $logging_default_format_string = $::os_service_default, + $logging_debug_format_suffix = $::os_service_default, + $logging_exception_prefix = $::os_service_default, + $log_config_append = $::os_service_default, + $default_log_levels = $::os_service_default, + $publish_errors = $::os_service_default, + $fatal_deprecations = $::os_service_default, + $instance_format = $::os_service_default, + $instance_uuid_format = $::os_service_default, + $log_date_format = $::os_service_default, ) { include ::heat::deps @@ -121,139 +121,30 @@ class heat::logging( $verbose_real = pick($::heat::verbose,$verbose) $debug_real = pick($::heat::debug,$debug) - heat_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/syslog_log_facility': value => $log_facility_real; + 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, '=')), ',') } - if $logging_context_format_string { - heat_config { - 'DEFAULT/logging_context_format_string' : - value => $logging_context_format_string; - } - } - else { - heat_config { - 'DEFAULT/logging_context_format_string' : ensure => absent; - } - } - - if $logging_default_format_string { - heat_config { - 'DEFAULT/logging_default_format_string' : - value => $logging_default_format_string; - } - } - else { - heat_config { - 'DEFAULT/logging_default_format_string' : ensure => absent; - } - } - - if $logging_debug_format_suffix { - heat_config { - 'DEFAULT/logging_debug_format_suffix' : - value => $logging_debug_format_suffix; - } - } - else { - heat_config { - 'DEFAULT/logging_debug_format_suffix' : ensure => absent; - } - } - - if $logging_exception_prefix { - heat_config { - 'DEFAULT/logging_exception_prefix' : value => $logging_exception_prefix; - } - } - else { - heat_config { - 'DEFAULT/logging_exception_prefix' : ensure => absent; - } - } - - if $log_config_append { - heat_config { - 'DEFAULT/log_config_append' : value => $log_config_append; - } - } - else { - heat_config { - 'DEFAULT/log_config_append' : ensure => absent; - } - } - - if $default_log_levels { - heat_config { - 'DEFAULT/default_log_levels' : - value => join(sort(join_keys_to_values($default_log_levels, '=')), ','); - } - } - else { - heat_config { - 'DEFAULT/default_log_levels' : ensure => absent; - } - } - - if $publish_errors { - heat_config { - 'DEFAULT/publish_errors' : value => $publish_errors; - } - } - else { - heat_config { - 'DEFAULT/publish_errors' : ensure => absent; - } - } - - if $fatal_deprecations { - heat_config { - 'DEFAULT/fatal_deprecations' : value => $fatal_deprecations; - } - } - else { - heat_config { - 'DEFAULT/fatal_deprecations' : ensure => absent; - } - } - - if $instance_format { - heat_config { - 'DEFAULT/instance_format' : value => $instance_format; - } - } - else { - heat_config { - 'DEFAULT/instance_format' : ensure => absent; - } - } - - if $instance_uuid_format { - heat_config { - 'DEFAULT/instance_uuid_format' : value => $instance_uuid_format; - } - } - else { - heat_config { - 'DEFAULT/instance_uuid_format' : ensure => absent; - } - } - - if $log_date_format { - heat_config { - 'DEFAULT/log_date_format' : value => $log_date_format; - } - } - else { - heat_config { - 'DEFAULT/log_date_format' : ensure => absent; - } - } - + heat_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/syslog_log_facility': value => $log_facility_real; + 'DEFAULT/default_log_levels': value => $default_log_levels_real; + '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/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; + } } diff --git a/spec/classes/heat_db_postgresql_spec.rb b/spec/classes/heat_db_postgresql_spec.rb index 6767d01f..fe2cee00 100644 --- a/spec/classes/heat_db_postgresql_spec.rb +++ b/spec/classes/heat_db_postgresql_spec.rb @@ -14,11 +14,11 @@ describe 'heat::db::postgresql' do context 'on a RedHat osfamily' do let :facts do - { + @default_facts.merge({ :osfamily => 'RedHat', :operatingsystemrelease => '7.0', :concat_basedir => '/var/lib/puppet/concat' - } + }) end context 'with only required parameters' do diff --git a/spec/classes/heat_db_spec.rb b/spec/classes/heat_db_spec.rb index a138827a..de977df2 100644 --- a/spec/classes/heat_db_spec.rb +++ b/spec/classes/heat_db_spec.rb @@ -8,10 +8,11 @@ describe 'heat::db' do it { is_expected.to contain_class('heat::db::sync') } it { is_expected.to contain_heat_config('database/connection').with_value('sqlite:////var/lib/heat/heat.sqlite').with_secret(true) } - it { is_expected.to contain_heat_config('database/idle_timeout').with_value('3600') } - it { is_expected.to contain_heat_config('database/min_pool_size').with_value('1') } - it { is_expected.to contain_heat_config('database/max_retries').with_value('10') } - it { is_expected.to contain_heat_config('database/retry_interval').with_value('10') } + it { is_expected.to contain_heat_config('database/idle_timeout').with_value('') } + it { is_expected.to contain_heat_config('database/min_pool_size').with_value('') } + it { is_expected.to contain_heat_config('database/max_pool_size').with_value('') } + it { is_expected.to contain_heat_config('database/max_retries').with_value('') } + it { is_expected.to contain_heat_config('database/retry_interval').with_value('') } end @@ -20,6 +21,7 @@ describe 'heat::db' do { :database_connection => 'mysql://heat:heat@localhost/heat', :database_idle_timeout => '3601', :database_min_pool_size => '2', + :database_max_pool_size => '12', :database_max_retries => '11', :database_retry_interval => '11', :sync_db => false } @@ -29,6 +31,7 @@ describe 'heat::db' do it { is_expected.to contain_heat_config('database/connection').with_value('mysql://heat:heat@localhost/heat').with_secret(true) } it { is_expected.to contain_heat_config('database/idle_timeout').with_value('3601') } it { is_expected.to contain_heat_config('database/min_pool_size').with_value('2') } + it { is_expected.to contain_heat_config('database/max_pool_size').with_value('12') } it { is_expected.to contain_heat_config('database/max_retries').with_value('11') } it { is_expected.to contain_heat_config('database/retry_interval').with_value('11') } diff --git a/spec/classes/heat_init_spec.rb b/spec/classes/heat_init_spec.rb index 74bc6a90..9d39c731 100644 --- a/spec/classes/heat_init_spec.rb +++ b/spec/classes/heat_init_spec.rb @@ -11,9 +11,9 @@ describe 'heat' do :log_dir => '/var/log/heat', :rabbit_host => '127.0.0.1', :rabbit_port => 5672, - :rabbit_userid => 'guest', + :rabbit_userid => '', :rabbit_password => '', - :rabbit_virtual_host => '/', + :rabbit_virtual_host => '', :database_connection => 'mysql://user@host/database', :database_idle_timeout => 3600, :auth_uri => 'http://127.0.0.1:5000/v2.0', @@ -121,18 +121,18 @@ describe 'heat' do is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_password').with_secret( true ) is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] ) is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(false) - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_version').with_ensure('absent') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('') is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('0') - is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_rate').with_value('2') + is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_rate').with_value('') end it { is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_host').with_value( params[:rabbit_host] ) } it { is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_port').with_value( params[:rabbit_port] ) } it { is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_hosts').with_value( "#{params[:rabbit_host]}:#{params[:rabbit_port]}" ) } it { is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_ha_queues').with_value('false') } - it { is_expected.to contain_heat_config('DEFAULT/rpc_response_timeout').with_value('60') } + it { is_expected.to contain_heat_config('DEFAULT/rpc_response_timeout').with_value('') } it { is_expected.to contain_heat_config('oslo_messaging_rabbit/amqp_durable_queues').with_value(false) } end @@ -143,12 +143,12 @@ describe 'heat' do is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_password').with_value( params[:rabbit_password] ) is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] ) is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(false) - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_version').with_ensure('absent') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('') is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('0') - is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_rate').with_value('2') + is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_rate').with_value('') end it { is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_host').with_ensure('absent') } it { is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_port').with_ensure('absent') } @@ -164,12 +164,12 @@ describe 'heat' do is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_password').with_secret( true ) is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] ) is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(false) - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_version').with_ensure('absent') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('') is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('0') - is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_rate').with_value('2') + is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_rate').with_value('') end it { is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_host').with_ensure('absent') } it { is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_port').with_ensure('absent') } @@ -195,10 +195,10 @@ describe 'heat' do is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_password').with_secret( true ) is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] ) is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value(false) - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_version').with_ensure('absent') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('') end it { is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_timeout_threshold').with_value('60') } it { is_expected.to contain_heat_config('oslo_messaging_rabbit/heartbeat_rate').with_value('10') } @@ -212,10 +212,10 @@ describe 'heat' do it { is_expected.to contain_heat_config('oslo_messaging_qpid/qpid_reconnect_interval_min').with_value('0') } it { is_expected.to contain_heat_config('oslo_messaging_qpid/qpid_reconnect_interval_max').with_value('0') } it { is_expected.to contain_heat_config('oslo_messaging_qpid/qpid_reconnect_interval').with_value('0') } - it { is_expected.to contain_heat_config('oslo_messaging_qpid/qpid_heartbeat').with_value('60') } - it { is_expected.to contain_heat_config('oslo_messaging_qpid/qpid_protocol').with_value('tcp') } - it { is_expected.to contain_heat_config('oslo_messaging_qpid/qpid_tcp_nodelay').with_value(true) } - it { is_expected.to contain_heat_config('DEFAULT/rpc_response_timeout').with_value('60') } + it { is_expected.to contain_heat_config('oslo_messaging_qpid/qpid_heartbeat').with_value('') } + it { is_expected.to contain_heat_config('oslo_messaging_qpid/qpid_protocol').with_value('') } + it { is_expected.to contain_heat_config('oslo_messaging_qpid/qpid_tcp_nodelay').with_value('') } + it { is_expected.to contain_heat_config('DEFAULT/rpc_response_timeout').with_value('') } it { is_expected.to contain_heat_config('oslo_messaging_qpid/amqp_durable_queues').with_value(false) } end @@ -263,10 +263,10 @@ describe 'heat' do it do is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('true') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('TLSv1') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('') end end @@ -274,16 +274,15 @@ describe 'heat' do before do params.merge!( :rabbit_use_ssl => false, - :kombu_ssl_version => 'TLSv1' ) end it do is_expected.to contain_heat_config('oslo_messaging_rabbit/rabbit_use_ssl').with_value('false') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_ensure('absent') - is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_version').with_ensure('absent') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_ca_certs').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_certfile').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_keyfile').with_value('') + is_expected.to contain_heat_config('oslo_messaging_rabbit/kombu_ssl_version').with_value('') end end @@ -296,20 +295,34 @@ describe 'heat' do context 'without required parameters' do - context 'with rabbit_use_ssl => false and kombu_ssl_ca_certs parameter' do - before { params.merge!(:kombu_ssl_ca_certs => '/path/to/ssl/ca/certs') } + context 'with rabbit_use_ssl => false and kombu_ssl_ca_certs parameter' do + before { params.merge!(:kombu_ssl_ca_certs => '/path/to/ssl/ca/certs')} it_raises 'a Puppet::Error', /The kombu_ssl_ca_certs parameter requires rabbit_use_ssl to be set to true/ end context 'with rabbit_use_ssl => false and kombu_ssl_certfile parameter' do - before { params.merge!(:kombu_ssl_certfile => '/path/to/ssl/cert/file') } + before { params.merge!(:kombu_ssl_certfile => '/path/to/ssl/cert/file')} it_raises 'a Puppet::Error', /The kombu_ssl_certfile parameter requires rabbit_use_ssl to be set to true/ end context 'with rabbit_use_ssl => false and kombu_ssl_keyfile parameter' do - before { params.merge!(:kombu_ssl_keyfile => '/path/to/ssl/keyfile') } + before { params.merge!(:kombu_ssl_keyfile => '/path/to/ssl/keyfile')} it_raises 'a Puppet::Error', /The kombu_ssl_keyfile parameter requires rabbit_use_ssl to be set to true/ end + context 'with kombu_ssl_certfile set to default and custom kombu_ssl_keyfile parameter' do + before { params.merge!( + :rabbit_use_ssl => true, + :kombu_ssl_keyfile => '/path/to/ssl/keyfile', + )} + it_raises 'a Puppet::Error', /The kombu_ssl_certfile and kombu_ssl_keyfile parameters must be used together/ + end + context 'with kombu_ssl_keyfile set to default and custom kombu_ssl_certfile parameter' do + before { params.merge!( + :rabbit_use_ssl => true, + :kombu_ssl_certfile => '/path/to/ssl/cert/file', + )} + it_raises 'a Puppet::Error', /The kombu_ssl_certfile and kombu_ssl_keyfile parameters must be used together/ + end end end @@ -352,7 +365,7 @@ describe 'heat' do shared_examples_for 'without region_name set' do it 'doesnt have region_name set by default' do - is_expected.to contain_heat_config('DEFAULT/region_name_for_services').with_enure('absent') + is_expected.to contain_heat_config('DEFAULT/region_name_for_services').with_value('') end end diff --git a/spec/classes/heat_logging_spec.rb b/spec/classes/heat_logging_spec.rb index 7dae3754..b448c428 100644 --- a/spec/classes/heat_logging_spec.rb +++ b/spec/classes/heat_logging_spec.rb @@ -15,7 +15,7 @@ describe 'heat::logging' do :logging_exception_prefix => '%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s %(instance)s', :log_config_append => '/etc/heat/logging.conf', :publish_errors => true, - :default_log_levels => { + :default_log_levels => { 'amqp' => 'WARN', 'amqplib' => 'WARN', 'boto' => 'WARN', 'qpid' => 'WARN', 'sqlalchemy' => 'WARN', 'suds' => 'INFO', 'iso8601' => 'WARN', @@ -57,11 +57,11 @@ describe 'heat::logging' do shared_examples 'basic default logging settings' do it 'configures heat logging settins with default values' do - is_expected.to contain_heat_config('DEFAULT/use_syslog').with(:value => 'false') - is_expected.to contain_heat_config('DEFAULT/use_stderr').with(:value => 'true') + is_expected.to contain_heat_config('DEFAULT/use_syslog').with(:value => '') + is_expected.to contain_heat_config('DEFAULT/use_stderr').with(:value => '') is_expected.to contain_heat_config('DEFAULT/log_dir').with(:value => '/var/log/heat') - is_expected.to contain_heat_config('DEFAULT/verbose').with(:value => 'false') - is_expected.to contain_heat_config('DEFAULT/debug').with(:value => 'false') + is_expected.to contain_heat_config('DEFAULT/verbose').with(:value => '') + is_expected.to contain_heat_config('DEFAULT/debug').with(:value => '') end end @@ -120,7 +120,7 @@ describe 'heat::logging' do :default_log_levels, :fatal_deprecations, :instance_format, :instance_uuid_format, :log_date_format, ].each { |param| - it { is_expected.to contain_heat_config("DEFAULT/#{param}").with_ensure('absent') } + it { is_expected.to contain_heat_config("DEFAULT/#{param}").with_value('') } } end