Libvirt: quote config parameters in resource types
This change implements the quote parameter in libvirtd_config and virtlogd_config, so that we can quote the value by that simple parameter instead of implementing a logic in each manifests. Also, with this change libvirtd_config and virtlogd_config supports $::os_service_default, so that we can define absence of parameters more easily. Depends-on: https://review.opendev.org/792735 Change-Id: I3030ca34088019be932a9cc33344f7fb473a9aea
This commit is contained in:
parent
ee78d8557f
commit
26dbd52717
@ -3,6 +3,17 @@ Puppet::Type.type(:libvirtd_config).provide(
|
||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
||||
) do
|
||||
|
||||
def exists?
|
||||
if resource[:value] == ensure_absent_val
|
||||
resource[:ensure] = :absent
|
||||
elsif resource[:quote]
|
||||
unless resource[:value].start_with?('"')
|
||||
resource[:value] = '"' + resource[:value] + '"'
|
||||
end
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def section
|
||||
''
|
||||
end
|
||||
@ -15,6 +26,10 @@ Puppet::Type.type(:libvirtd_config).provide(
|
||||
'='
|
||||
end
|
||||
|
||||
def ensure_absent_val
|
||||
resource[:ensure_absent_val]
|
||||
end
|
||||
|
||||
def self.file_path
|
||||
'/etc/libvirt/libvirtd.conf'
|
||||
end
|
||||
|
@ -3,6 +3,17 @@ Puppet::Type.type(:virtlogd_config).provide(
|
||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
||||
) do
|
||||
|
||||
def exists?
|
||||
if resource[:value] == ensure_absent_val
|
||||
resource[:ensure] = :absent
|
||||
elsif resource[:quote]
|
||||
unless resource[:value].start_with?('"')
|
||||
resource[:value] = '"' + resource[:value] + '"'
|
||||
end
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def section
|
||||
''
|
||||
end
|
||||
@ -15,6 +26,10 @@ Puppet::Type.type(:virtlogd_config).provide(
|
||||
'='
|
||||
end
|
||||
|
||||
def ensure_absent_val
|
||||
resource[:ensure_absent_val]
|
||||
end
|
||||
|
||||
def self.file_path
|
||||
'/etc/libvirt/virtlogd.conf'
|
||||
end
|
||||
|
@ -39,6 +39,17 @@ Puppet::Type.newtype(:libvirtd_config) do
|
||||
defaultto false
|
||||
end
|
||||
|
||||
newparam(:quote, :boolean => true) do
|
||||
desc 'Whether to quote the value. Defauls to `false`.'
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
|
||||
newparam(:ensure_absent_val) do
|
||||
desc 'A value that is specified as the value property will behave as if ensure => absent was specified'
|
||||
defaultto('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
autorequire(:anchor) do
|
||||
['nova::install::end']
|
||||
end
|
||||
|
@ -39,6 +39,17 @@ Puppet::Type.newtype(:virtlogd_config) do
|
||||
defaultto false
|
||||
end
|
||||
|
||||
newparam(:quote, :boolean => true) do
|
||||
desc 'Whether to quote the value. Defauls to `false`.'
|
||||
newvalues(:true, :false)
|
||||
defaultto false
|
||||
end
|
||||
|
||||
newparam(:ensure_absent_val) do
|
||||
desc 'A value that is specified as the value property will behave as if ensure => absent was specified'
|
||||
defaultto('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
autorequire(:anchor) do
|
||||
['nova::install::end']
|
||||
end
|
||||
|
@ -169,24 +169,24 @@
|
||||
# [*log_outputs*]
|
||||
# (optional) Defines log outputs, as specified in
|
||||
# https://libvirt.org/logging.html
|
||||
# Defaults to undef
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*log_filters*]
|
||||
# (optional) Defines a filter to select a different logging level
|
||||
# for a given category log outputs, as specified in
|
||||
# https://libvirt.org/logging.html
|
||||
# Defaults to undef
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*tls_priority*]
|
||||
# (optional) Override the compile time default TLS priority string. The
|
||||
# default is usually "NORMAL" unless overridden at build time.
|
||||
# Only set this if it is desired for libvirt to deviate from
|
||||
# the global default settings.
|
||||
# Defaults to undef
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*ovs_timeout*]
|
||||
# (optional) A timeout for openvswitch calls made by libvirt
|
||||
# Defaults to undef
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*swtpm_enabled*]
|
||||
# (optional) Enable emulated Trusted Platform Module (TPM) for guests.
|
||||
@ -250,10 +250,10 @@ class nova::compute::libvirt (
|
||||
$swtpm_enabled = $::os_service_default,
|
||||
$swtpm_user = $::os_service_default,
|
||||
$swtpm_group = $::os_service_default,
|
||||
$log_outputs = undef,
|
||||
$log_filters = undef,
|
||||
$tls_priority = undef,
|
||||
$ovs_timeout = undef,
|
||||
$log_outputs = $::os_service_default,
|
||||
$log_filters = $::os_service_default,
|
||||
$tls_priority = $::os_service_default,
|
||||
$ovs_timeout = $::os_service_default,
|
||||
$max_queues = $::os_service_default,
|
||||
$num_memory_encrypted_guests = $::os_service_default,
|
||||
) inherits nova::params {
|
||||
@ -286,44 +286,22 @@ class nova::compute::libvirt (
|
||||
include nova::migration::libvirt
|
||||
}
|
||||
|
||||
if $log_outputs {
|
||||
libvirtd_config {
|
||||
'log_outputs': value => "\"${log_outputs}\"";
|
||||
}
|
||||
} else {
|
||||
libvirtd_config {
|
||||
'log_outputs': ensure => 'absent';
|
||||
[
|
||||
'log_outputs',
|
||||
'log_filters',
|
||||
'tls_priority',
|
||||
'ovs_timeout',
|
||||
].each |String $libvirtd_opt| {
|
||||
if getvar($libvirtd_opt) == undef {
|
||||
warning("Usage of undef for ${libvirtd_opt} has been deprecated.")
|
||||
}
|
||||
}
|
||||
|
||||
if $log_filters {
|
||||
libvirtd_config {
|
||||
'log_filters': value => "\"${log_filters}\"";
|
||||
}
|
||||
} else {
|
||||
libvirtd_config {
|
||||
'log_filters': ensure => 'absent';
|
||||
}
|
||||
}
|
||||
|
||||
if $tls_priority {
|
||||
libvirtd_config {
|
||||
'tls_priority': value => "\"${tls_priority}\"";
|
||||
}
|
||||
} else {
|
||||
libvirtd_config {
|
||||
'tls_priority': ensure => 'absent';
|
||||
}
|
||||
}
|
||||
|
||||
if $ovs_timeout {
|
||||
libvirtd_config {
|
||||
'ovs_timeout': value => $ovs_timeout;
|
||||
}
|
||||
} else {
|
||||
libvirtd_config {
|
||||
'ovs_timeout': ensure => 'absent';
|
||||
}
|
||||
libvirtd_config {
|
||||
'log_outputs': value => pick($log_outputs, $::os_service_default), quote => true;
|
||||
'log_filters': value => pick($log_filters, $::os_service_default), quote => true;
|
||||
'tls_priority': value => pick($tls_priority, $::os_service_default), quote => true;
|
||||
'ovs_timeout': value => pick($ovs_timeout, $::os_service_default);
|
||||
}
|
||||
|
||||
unless $rx_queue_size == $::os_service_default or $rx_queue_size in [256, 512, 1024] {
|
||||
|
@ -6,124 +6,71 @@
|
||||
#
|
||||
# [*log_level*]
|
||||
# Defines a log level to filter log outputs.
|
||||
# Defaults to undef
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*log_filters*]
|
||||
# Defines a log filter to select a different logging level for
|
||||
# for a given category log outputs.
|
||||
# Defaults to undef
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*log_outputs*]
|
||||
# (optional) Defines log outputs, as specified in
|
||||
# https://libvirt.org/logging.html
|
||||
# Defaults to undef
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*max_clients*]
|
||||
# The maximum number of concurrent client connections to allow
|
||||
# on primary socket.
|
||||
# Defaults to undef
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*admin_max_clients*]
|
||||
# The maximum number of concurrent client connections to allow
|
||||
# on administrative socket.
|
||||
# Defaults to undef
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*max_size*]
|
||||
# Maximum file size before rolling over.
|
||||
# Defaults to undef
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*max_backups*]
|
||||
# Maximum nuber of backup files to keep.
|
||||
# Defaults to undef
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
class nova::compute::libvirt::virtlogd (
|
||||
$log_level = undef,
|
||||
$log_filters = undef,
|
||||
$log_outputs = undef,
|
||||
$max_clients = undef,
|
||||
$admin_max_clients = undef,
|
||||
$max_size = undef,
|
||||
$max_backups = undef,
|
||||
$log_level = $::os_service_default,
|
||||
$log_filters = $::os_service_default,
|
||||
$log_outputs = $::os_service_default,
|
||||
$max_clients = $::os_service_default,
|
||||
$admin_max_clients = $::os_service_default,
|
||||
$max_size = $::os_service_default,
|
||||
$max_backups = $::os_service_default,
|
||||
) {
|
||||
|
||||
include nova::deps
|
||||
require nova::compute::libvirt
|
||||
|
||||
if $log_level {
|
||||
virtlogd_config {
|
||||
'log_level': value => $log_level;
|
||||
}
|
||||
}
|
||||
else {
|
||||
virtlogd_config {
|
||||
'log_level': ensure => 'absent';
|
||||
[
|
||||
'log_level',
|
||||
'log_filters',
|
||||
'log_outputs',
|
||||
'max_clients',
|
||||
'admin_max_clients',
|
||||
'max_size',
|
||||
'max_backups',
|
||||
].each |String $virtlogd_opt| {
|
||||
if getvar($virtlogd_opt) == undef {
|
||||
warning("Usage of undef for ${virtlogd_opt} has been deprecated.")
|
||||
}
|
||||
}
|
||||
|
||||
if $log_filters {
|
||||
virtlogd_config {
|
||||
'log_filters': value => "\"${log_filters}\"";
|
||||
}
|
||||
}
|
||||
else {
|
||||
virtlogd_config {
|
||||
'log_filters': ensure => 'absent';
|
||||
}
|
||||
}
|
||||
|
||||
if $log_outputs {
|
||||
virtlogd_config {
|
||||
'log_outputs': value => "\"${log_outputs}\"";
|
||||
}
|
||||
}
|
||||
else {
|
||||
virtlogd_config {
|
||||
'log_outputs': ensure => 'absent';
|
||||
}
|
||||
}
|
||||
|
||||
if $max_clients {
|
||||
virtlogd_config {
|
||||
'max_clients': value => $max_clients;
|
||||
}
|
||||
}
|
||||
else {
|
||||
virtlogd_config {
|
||||
'max_clients': ensure => 'absent';
|
||||
}
|
||||
}
|
||||
|
||||
if $admin_max_clients {
|
||||
virtlogd_config {
|
||||
'admin_max_clients': value => $admin_max_clients;
|
||||
}
|
||||
}
|
||||
else {
|
||||
virtlogd_config {
|
||||
'admin_max_clients': ensure => 'absent';
|
||||
}
|
||||
}
|
||||
|
||||
if $max_size {
|
||||
virtlogd_config {
|
||||
'max_size': value => $max_size;
|
||||
}
|
||||
}
|
||||
else {
|
||||
virtlogd_config {
|
||||
'max_size': ensure => 'absent';
|
||||
}
|
||||
}
|
||||
|
||||
if $max_backups {
|
||||
virtlogd_config {
|
||||
'max_backups': value => $max_backups;
|
||||
}
|
||||
}
|
||||
else {
|
||||
virtlogd_config {
|
||||
'max_backups': ensure => 'absent';
|
||||
}
|
||||
virtlogd_config {
|
||||
'log_level': value => pick($log_level, $::os_service_default);
|
||||
'log_filters': value => pick($log_filters, $::os_service_default), quote => true;
|
||||
'log_outputs': value => pick($log_outputs, $::os_service_default), quote => true;
|
||||
'max_clients': value => pick($max_clients, $::os_service_default);
|
||||
'admin_max_clients': value => pick($admin_max_clients, $::os_service_default);
|
||||
'max_size': value => pick($max_size, $::os_service_default);
|
||||
'max_backups': value => pick($max_backups, $::os_service_default);
|
||||
}
|
||||
|
||||
Anchor['nova::config::begin']
|
||||
|
@ -16,7 +16,7 @@
|
||||
#
|
||||
# [*listen_address*]
|
||||
# (optional) Bind libvirtd tcp/tls socket to the given address.
|
||||
# Defaults to undef (bind to all addresses)
|
||||
# Defaults to $::os_service_default (bind to all addresses)
|
||||
#
|
||||
# [*live_migration_inbound_addr*]
|
||||
# (optional) The IP address or hostname to be used as the target for live
|
||||
@ -110,13 +110,13 @@
|
||||
# (optional) Specifies the CA certificate that the TLS transport will use.
|
||||
# Note that this is only used if the TLS transport is enabled via the
|
||||
# "transport" option.
|
||||
# Defaults to undef
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*crl_file*]
|
||||
# (optional) Specifies the CRL file that the TLS transport will use.
|
||||
# Note that this is only used if the TLS transport is enabled via the
|
||||
# "transport" option.
|
||||
# Defaults to undef
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*libvirt_version*]
|
||||
# (optional) installed libvirt version. Default is automatic detected depending
|
||||
@ -126,7 +126,7 @@
|
||||
class nova::migration::libvirt(
|
||||
$transport = undef,
|
||||
$auth = 'none',
|
||||
$listen_address = undef,
|
||||
$listen_address = $::os_service_default,
|
||||
$live_migration_inbound_addr = $::os_service_default,
|
||||
$live_migration_tunnelled = $::os_service_default,
|
||||
$live_migration_with_native_tls = $::os_service_default,
|
||||
@ -141,8 +141,8 @@ class nova::migration::libvirt(
|
||||
$client_user = undef,
|
||||
$client_port = undef,
|
||||
$client_extraparams = {},
|
||||
$ca_file = undef,
|
||||
$crl_file = undef,
|
||||
$ca_file = $::os_service_default,
|
||||
$crl_file = $::os_service_default,
|
||||
$libvirt_version = $::nova::compute::libvirt::version::default,
|
||||
) inherits nova::compute::libvirt::version {
|
||||
|
||||
@ -244,35 +244,42 @@ class nova::migration::libvirt(
|
||||
}
|
||||
}
|
||||
|
||||
libvirtd_config {
|
||||
'listen_tls': value => $listen_tls;
|
||||
'listen_tcp': value => $listen_tcp;
|
||||
}
|
||||
|
||||
if $transport_real == 'tls' {
|
||||
libvirtd_config {
|
||||
'auth_tls': value => "\"${auth}\"";
|
||||
$auth_tls_real = $auth
|
||||
$auth_tcp_real = $::os_service_default
|
||||
$ca_file_real = pick($ca_file, $::os_service_default)
|
||||
$crl_file_real = pick($crl_file, $::os_service_default)
|
||||
|
||||
if $ca_file == undef {
|
||||
warning('Usage of undef for the ca_file parameter has been deprecated')
|
||||
}
|
||||
if $ca_file {
|
||||
libvirtd_config {
|
||||
'ca_file': value => "\"${ca_file}\"";
|
||||
}
|
||||
}
|
||||
if $crl_file {
|
||||
libvirtd_config {
|
||||
'crl_file': value => "\"${crl_file}\"";
|
||||
}
|
||||
if $crl_file == undef {
|
||||
warning('Usage of undef for the crl_file parameter has been deprecated')
|
||||
}
|
||||
} elsif $transport_real == 'tcp' {
|
||||
libvirtd_config {
|
||||
'auth_tcp': value => "\"${auth}\"";
|
||||
}
|
||||
$auth_tls_real = $::os_service_default
|
||||
$auth_tcp_real = $auth
|
||||
$ca_file_real = $::os_service_default
|
||||
$crl_file_real = $::os_service_default
|
||||
} else {
|
||||
$auth_tls_real = $::os_service_default
|
||||
$auth_tcp_real = $::os_service_default
|
||||
$ca_file_real = $::os_service_default
|
||||
$crl_file_real = $::os_service_default
|
||||
}
|
||||
|
||||
if $listen_address {
|
||||
libvirtd_config {
|
||||
'listen_addr': value => "\"${listen_address}\"";
|
||||
}
|
||||
if $listen_address == undef {
|
||||
warning('Usage of undef for the listen_addrss parameter has been deprecated')
|
||||
}
|
||||
|
||||
libvirtd_config {
|
||||
'listen_tls': value => $listen_tls;
|
||||
'listen_tcp': value => $listen_tcp;
|
||||
'auth_tls': value => $auth_tls_real, quote => true;
|
||||
'auth_tcp': value => $auth_tcp_real, quote => true;
|
||||
'ca_file': value => $ca_file_real, quote => true;
|
||||
'crl_file': value => $crl_file_real, quote => true;
|
||||
'listen_addr': value => pick($listen_address, $::os_service_default), quote => true;
|
||||
}
|
||||
|
||||
if $transport_real == 'tls' or $transport_real == 'tcp' {
|
||||
|
@ -0,0 +1,30 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Now ``libvirtd_config`` and ``virtlogd_config`` supports the ``quote``
|
||||
parameter. Setting this parameter quotes the value by ``" "``.
|
||||
|
||||
- |
|
||||
Now ``libvirtd_config`` and ``virtlogd_config`` accepts
|
||||
``$::os_service_default`` as a mark to unset the parameter.
|
||||
|
||||
deprecations:
|
||||
- |
|
||||
The default values of the following parameter have been changed from
|
||||
``undef`` to ``$::os_service_default``. Using ``undef`` is still supported
|
||||
but that usage is deprecated.
|
||||
|
||||
- ``nova::compute::libvirt::log_outputs``
|
||||
- ``nova::compute::libvirt::log_filters``
|
||||
- ``nova::compute::libvirt::tls_priority``
|
||||
- ``nova::compute::libvirt::ovs_timeout``
|
||||
- ``nova::compute::libvirt::virtlogd::log_level``
|
||||
- ``nova::compute::libvirt::virtlogd::log_filters``
|
||||
- ``nova::compute::libvirt::virtlogd::log_outputs``
|
||||
- ``nova::compute::libvirt::virtlogd::max_clients``
|
||||
- ``nova::compute::libvirt::virtlogd::admin_max_clients``
|
||||
- ``nova::compute::libvirt::virtlogd::max_size``
|
||||
- ``nova::compute::libvirt::virtlogd::max_backups``
|
||||
- ``nova::migration::libvirt::listen_address``
|
||||
- ``nova::migration::libvirt::ca_file``
|
||||
- ``nova::migration::libvirt::crl_file``
|
@ -70,10 +70,10 @@ describe 'nova::compute::libvirt' do
|
||||
it { is_expected.to contain_nova_config('libvirt/swtpm_group').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_nova_config('libvirt/max_queues').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_nova_config('libvirt/num_memory_encrypted_guests').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_libvirtd_config('log_outputs').with_ensure('absent')}
|
||||
it { is_expected.to contain_libvirtd_config('log_filters').with_ensure('absent')}
|
||||
it { is_expected.to contain_libvirtd_config('tls_priority').with_ensure('absent')}
|
||||
it { is_expected.to contain_libvirtd_config('ovs_timeout').with_ensure('absent')}
|
||||
it { is_expected.to contain_libvirtd_config('log_outputs').with_value('<SERVICE DEFAULT>').with_quote(true)}
|
||||
it { is_expected.to contain_libvirtd_config('log_filters').with_value('<SERVICE DEFAULT>').with_quote(true)}
|
||||
it { is_expected.to contain_libvirtd_config('tls_priority').with_value('<SERVICE DEFAULT>').with_quote(true)}
|
||||
it { is_expected.to contain_libvirtd_config('ovs_timeout').with_value('<SERVICE DEFAULT>')}
|
||||
end
|
||||
|
||||
describe 'with params' do
|
||||
@ -145,9 +145,9 @@ describe 'nova::compute::libvirt' do
|
||||
it { is_expected.to contain_nova_config('libvirt/swtpm_group').with_value('libvirt')}
|
||||
it { is_expected.to contain_nova_config('libvirt/max_queues').with_value(4)}
|
||||
it { is_expected.to contain_nova_config('libvirt/num_memory_encrypted_guests').with_value(255)}
|
||||
it { is_expected.to contain_libvirtd_config('log_outputs').with_value('"1:file:/var/log/libvirt/libvirtd.log"')}
|
||||
it { is_expected.to contain_libvirtd_config('log_filters').with_value('"1:qemu"')}
|
||||
it { is_expected.to contain_libvirtd_config('tls_priority').with_value('"NORMAL:-VERS-SSL3.0"')}
|
||||
it { is_expected.to contain_libvirtd_config('log_outputs').with_value('1:file:/var/log/libvirt/libvirtd.log').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('log_filters').with_value('1:qemu').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('tls_priority').with_value('NORMAL:-VERS-SSL3.0').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('ovs_timeout').with_value(10)}
|
||||
it {
|
||||
is_expected.to contain_service('libvirt').with(
|
||||
|
@ -22,13 +22,13 @@ eos
|
||||
it { is_expected.to contain_class('nova::deps')}
|
||||
it { is_expected.to contain_class('nova::compute::libvirt::virtlogd')}
|
||||
|
||||
it { is_expected.to contain_virtlogd_config('log_level').with_ensure('absent')}
|
||||
it { is_expected.to contain_virtlogd_config('log_outputs').with_ensure('absent')}
|
||||
it { is_expected.to contain_virtlogd_config('log_filters').with_ensure('absent')}
|
||||
it { is_expected.to contain_virtlogd_config('max_clients').with_ensure('absent')}
|
||||
it { is_expected.to contain_virtlogd_config('admin_max_clients').with_ensure('absent')}
|
||||
it { is_expected.to contain_virtlogd_config('max_size').with_ensure('absent')}
|
||||
it { is_expected.to contain_virtlogd_config('max_backups').with_ensure('absent')}
|
||||
it { is_expected.to contain_virtlogd_config('log_level').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_virtlogd_config('log_outputs').with_value('<SERVICE DEFAULT>').with_quote(true)}
|
||||
it { is_expected.to contain_virtlogd_config('log_filters').with_value('<SERVICE DEFAULT>').with_quote(true)}
|
||||
it { is_expected.to contain_virtlogd_config('max_clients').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_virtlogd_config('admin_max_clients').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_virtlogd_config('max_size').with_value('<SERVICE DEFAULT>')}
|
||||
it { is_expected.to contain_virtlogd_config('max_backups').with_value('<SERVICE DEFAULT>')}
|
||||
end
|
||||
|
||||
context 'with specified parameters' do
|
||||
@ -47,8 +47,8 @@ eos
|
||||
it { is_expected.to contain_class('nova::compute::libvirt::virtlogd')}
|
||||
|
||||
it { is_expected.to contain_virtlogd_config('log_level').with_value(params[:log_level])}
|
||||
it { is_expected.to contain_virtlogd_config('log_outputs').with_value("\"#{params[:log_outputs]}\"")}
|
||||
it { is_expected.to contain_virtlogd_config('log_filters').with_value("\"#{params[:log_filters]}\"")}
|
||||
it { is_expected.to contain_virtlogd_config('log_outputs').with_value(params[:log_outputs]).with_quote(true)}
|
||||
it { is_expected.to contain_virtlogd_config('log_filters').with_value(params[:log_filters]).with_quote(true)}
|
||||
it { is_expected.to contain_virtlogd_config('max_clients').with_value(params[:max_clients])}
|
||||
it { is_expected.to contain_virtlogd_config('admin_max_clients').with_value(params[:admin_max_clients])}
|
||||
it { is_expected.to contain_virtlogd_config('max_size').with_value(params[:max_size])}
|
||||
|
@ -35,8 +35,10 @@ describe 'nova::migration::libvirt' do
|
||||
context 'with default params' do
|
||||
it { is_expected.to contain_libvirtd_config('listen_tls').with_value('0') }
|
||||
it { is_expected.to contain_libvirtd_config('listen_tcp').with_value('1') }
|
||||
it { is_expected.not_to contain_libvirtd_config('auth_tls') }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tcp').with_value("\"none\"") }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tls').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tcp').with_value('none').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('ca_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('crl_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_nova_config('libvirt/live_migration_tunnelled').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_nova_config('libvirt/live_migration_with_native_tls').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_nova_config('libvirt/live_migration_completion_timeout').with_value('<SERVICE DEFAULT>') }
|
||||
@ -90,8 +92,10 @@ describe 'nova::migration::libvirt' do
|
||||
end
|
||||
it { is_expected.to contain_libvirtd_config('listen_tls').with_value('1') }
|
||||
it { is_expected.to contain_libvirtd_config('listen_tcp').with_value('0') }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tls').with_value("\"none\"") }
|
||||
it { is_expected.not_to contain_libvirtd_config('auth_tcp') }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tls').with_value('none').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tcp').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('ca_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('crl_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_nova_config('libvirt/live_migration_uri').with_value('qemu+tls://%s/system')}
|
||||
end
|
||||
|
||||
@ -104,8 +108,10 @@ describe 'nova::migration::libvirt' do
|
||||
end
|
||||
it { is_expected.to contain_libvirtd_config('listen_tls').with_value('1') }
|
||||
it { is_expected.to contain_libvirtd_config('listen_tcp').with_value('0') }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tls').with_value("\"none\"") }
|
||||
it { is_expected.not_to contain_libvirtd_config('auth_tcp') }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tls').with_value('none').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tcp').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('ca_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('crl_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_nova_config('libvirt/live_migration_uri').with_value('qemu+tls://%s/system')}
|
||||
it { is_expected.to contain_nova_config('libvirt/live_migration_inbound_addr').with_value('host1.example.com')}
|
||||
end
|
||||
@ -149,19 +155,23 @@ describe 'nova::migration::libvirt' do
|
||||
:auth => 'sasl',
|
||||
}
|
||||
end
|
||||
it { is_expected.not_to contain_libvirtd_config('auth_tls') }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tcp').with_value("\"sasl\"") }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tls').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tcp').with_value('sasl').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('ca_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('crl_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
end
|
||||
|
||||
context 'with auth set to sasl and tls enabled' do
|
||||
let :params do
|
||||
{
|
||||
:auth => 'sasl',
|
||||
:auth => 'sasl',
|
||||
:transport => 'tls'
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_libvirtd_config('auth_tls').with_value("\"sasl\"") }
|
||||
it { is_expected.not_to contain_libvirtd_config('auth_tcp') }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tls').with_value('sasl').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tcp').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('ca_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('crl_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
end
|
||||
|
||||
context 'with certificates set and tls enabled' do
|
||||
@ -172,8 +182,10 @@ describe 'nova::migration::libvirt' do
|
||||
:crl_file => '/crl',
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_libvirtd_config('ca_file').with_value("\"/ca\"") }
|
||||
it { is_expected.to contain_libvirtd_config('crl_file').with_value("\"/crl\"") }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tls').with_value('none').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('auth_tcp').with_value('<SERVICE DEFAULT>').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('ca_file').with_value('/ca').with_quote(true) }
|
||||
it { is_expected.to contain_libvirtd_config('crl_file').with_value('/crl').with_quote(true) }
|
||||
end
|
||||
|
||||
context 'with auth set to an invalid setting' do
|
||||
@ -212,7 +224,7 @@ describe 'nova::migration::libvirt' do
|
||||
:listen_address => "127.0.0.1"
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_libvirtd_config('listen_addr').with_value("\"127.0.0.1\"") }
|
||||
it { is_expected.to contain_libvirtd_config('listen_addr').with_value('127.0.0.1').with_quote(true) }
|
||||
end
|
||||
|
||||
context 'with ssh transport' do
|
||||
|
69
spec/unit/provider/libvirtd_config/ini_setting_spec.rb
Normal file
69
spec/unit/provider/libvirtd_config/ini_setting_spec.rb
Normal file
@ -0,0 +1,69 @@
|
||||
#
|
||||
# these tests are a little concerning b/c they are hacking around the
|
||||
# modulepath, so these tests will not catch issues that may eventually arise
|
||||
# related to loading these plugins.
|
||||
# I could not, for the life of me, figure out how to programatcally set the modulepath
|
||||
$LOAD_PATH.push(
|
||||
File.join(
|
||||
File.dirname(__FILE__),
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'fixtures',
|
||||
'modules',
|
||||
'inifile',
|
||||
'lib')
|
||||
)
|
||||
require 'spec_helper'
|
||||
provider_class = Puppet::Type.type(:libvirtd_config).provider(:ini_setting)
|
||||
describe provider_class do
|
||||
|
||||
it 'should allow setting to be set explicitly' do
|
||||
resource = Puppet::Type::Libvirtd_config.new(
|
||||
{:name => 'foo', :value => 'bar'}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
expect(provider.section).to eq('')
|
||||
expect(provider.setting).to eq('foo')
|
||||
end
|
||||
|
||||
it 'should quote the value when quote is true' do
|
||||
resource = Puppet::Type::Libvirtd_config.new(
|
||||
{:name => 'foo', :value => 'baa', :quote => true }
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(provider.section).to eq('')
|
||||
expect(provider.setting).to eq('foo')
|
||||
expect(resource[:value]).to eq('"baa"')
|
||||
end
|
||||
|
||||
it 'should not quote the value when quote is true but the value is quoted' do
|
||||
resource = Puppet::Type::Libvirtd_config.new(
|
||||
{:name => 'foo', :value => '"baa"', :quote => true }
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(provider.section).to eq('')
|
||||
expect(provider.setting).to eq('foo')
|
||||
expect(resource[:value]).to eq('"baa"')
|
||||
end
|
||||
|
||||
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
|
||||
resource = Puppet::Type::Libvirtd_config.new(
|
||||
{:name => 'foo', :value => '<SERVICE DEFAULT>'}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(resource[:ensure]).to eq :absent
|
||||
end
|
||||
|
||||
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value and quote is true' do
|
||||
resource = Puppet::Type::Libvirtd_config.new(
|
||||
{:name => 'foo', :value => '<SERVICE DEFAULT>', :quote => true}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(resource[:ensure]).to eq :absent
|
||||
end
|
||||
end
|
69
spec/unit/provider/virtlogd_config/ini_setting_spec.rb
Normal file
69
spec/unit/provider/virtlogd_config/ini_setting_spec.rb
Normal file
@ -0,0 +1,69 @@
|
||||
#
|
||||
# these tests are a little concerning b/c they are hacking around the
|
||||
# modulepath, so these tests will not catch issues that may eventually arise
|
||||
# related to loading these plugins.
|
||||
# I could not, for the life of me, figure out how to programatcally set the modulepath
|
||||
$LOAD_PATH.push(
|
||||
File.join(
|
||||
File.dirname(__FILE__),
|
||||
'..',
|
||||
'..',
|
||||
'..',
|
||||
'fixtures',
|
||||
'modules',
|
||||
'inifile',
|
||||
'lib')
|
||||
)
|
||||
require 'spec_helper'
|
||||
provider_class = Puppet::Type.type(:virtlogd_config).provider(:ini_setting)
|
||||
describe provider_class do
|
||||
|
||||
it 'should allow setting to be set explicitly' do
|
||||
resource = Puppet::Type::Virtlogd_config.new(
|
||||
{:name => 'foo', :value => 'bar'}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
expect(provider.section).to eq('')
|
||||
expect(provider.setting).to eq('foo')
|
||||
end
|
||||
|
||||
it 'should quote the value when quote is true' do
|
||||
resource = Puppet::Type::Virtlogd_config.new(
|
||||
{:name => 'foo', :value => 'baa', :quote => true }
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(provider.section).to eq('')
|
||||
expect(provider.setting).to eq('foo')
|
||||
expect(resource[:value]).to eq('"baa"')
|
||||
end
|
||||
|
||||
it 'should not quote the value when quote is true but the value is quoted' do
|
||||
resource = Puppet::Type::Virtlogd_config.new(
|
||||
{:name => 'foo', :value => '"baa"', :quote => true }
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(provider.section).to eq('')
|
||||
expect(provider.setting).to eq('foo')
|
||||
expect(resource[:value]).to eq('"baa"')
|
||||
end
|
||||
|
||||
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
|
||||
resource = Puppet::Type::Virtlogd_config.new(
|
||||
{:name => 'foo', :value => '<SERVICE DEFAULT>'}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(resource[:ensure]).to eq :absent
|
||||
end
|
||||
|
||||
it 'should ensure absent when <SERVICE DEFAULT> is specified as a value and quote is true' do
|
||||
resource = Puppet::Type::Virtlogd_config.new(
|
||||
{:name => 'foo', :value => '<SERVICE DEFAULT>', :quote => true}
|
||||
)
|
||||
provider = provider_class.new(resource)
|
||||
provider.exists?
|
||||
expect(resource[:ensure]).to eq :absent
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user