Enable support for Libvirt modular daemons

This change enables support for modular libvirt
daemon configurations.

NOTE: As of now, this change doesn't handle any modular daemons
socket configuration.

Change-Id: I90c3dd7bd63f9f54e43eee7bc2f58d165ca80e57
This commit is contained in:
Rajesh Tailor
2021-02-22 16:06:41 +05:30
committed by Takashi Kajinami
parent 4af91bddca
commit 448c9d3517
38 changed files with 1967 additions and 58 deletions

View File

@@ -0,0 +1,38 @@
Puppet::Type.type(:virtnodedevd_config).provide(
:ini_setting,
: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
def setting
resource[:name]
end
def separator
'='
end
def ensure_absent_val
resource[:ensure_absent_val]
end
def self.file_path
'/etc/libvirt/virtnodedevd.conf'
end
end

View File

@@ -0,0 +1,38 @@
Puppet::Type.type(:virtproxyd_config).provide(
:ini_setting,
: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
def setting
resource[:name]
end
def separator
'='
end
def ensure_absent_val
resource[:ensure_absent_val]
end
def self.file_path
'/etc/libvirt/virtproxyd.conf'
end
end

View File

@@ -0,0 +1,38 @@
Puppet::Type.type(:virtqemud_config).provide(
:ini_setting,
: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
def setting
resource[:name]
end
def separator
'='
end
def ensure_absent_val
resource[:ensure_absent_val]
end
def self.file_path
'/etc/libvirt/virtqemud.conf'
end
end

View File

@@ -0,0 +1,37 @@
Puppet::Type.type(:virtsecretd_config).provide(
:ini_setting,
: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
def setting
resource[:name]
end
def separator
'='
end
def ensure_absent_val
resource[:ensure_absent_val]
end
def self.file_path
'/etc/libvirt/virtsecretd.conf'
end
end

View File

@@ -0,0 +1,38 @@
Puppet::Type.type(:virtstoraged_config).provide(
:ini_setting,
: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
def setting
resource[:name]
end
def separator
'='
end
def ensure_absent_val
resource[:ensure_absent_val]
end
def self.file_path
'/etc/libvirt/virtstoraged.conf'
end
end

View File

@@ -0,0 +1,57 @@
Puppet::Type.newtype(:virtnodedevd_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'setting name to manage from virtnodedevd.conf'
newvalues(/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value
end
def is_to_s( currentvalue )
if resource.secret?
return '[old secret redacted]'
else
return currentvalue
end
end
def should_to_s( newvalue )
if resource.secret?
return '[new secret redacted]'
else
return newvalue
end
end
end
newparam(:secret, :boolean => true) do
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
newvalues(:true, :false)
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
end

View File

@@ -0,0 +1,57 @@
Puppet::Type.newtype(:virtproxyd_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'setting name to manage from virtproxyd.conf'
newvalues(/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value
end
def is_to_s( currentvalue )
if resource.secret?
return '[old secret redacted]'
else
return currentvalue
end
end
def should_to_s( newvalue )
if resource.secret?
return '[new secret redacted]'
else
return newvalue
end
end
end
newparam(:secret, :boolean => true) do
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
newvalues(:true, :false)
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
end

View File

@@ -0,0 +1,57 @@
Puppet::Type.newtype(:virtqemud_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'setting name to manage from virtqemud.conf'
newvalues(/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value
end
def is_to_s( currentvalue )
if resource.secret?
return '[old secret redacted]'
else
return currentvalue
end
end
def should_to_s( newvalue )
if resource.secret?
return '[new secret redacted]'
else
return newvalue
end
end
end
newparam(:secret, :boolean => true) do
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
newvalues(:true, :false)
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
end

View File

@@ -0,0 +1,57 @@
Puppet::Type.newtype(:virtsecretd_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'setting name to manage from virtsecretd.conf'
newvalues(/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value
end
def is_to_s( currentvalue )
if resource.secret?
return '[old secret redacted]'
else
return currentvalue
end
end
def should_to_s( newvalue )
if resource.secret?
return '[new secret redacted]'
else
return newvalue
end
end
end
newparam(:secret, :boolean => true) do
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
newvalues(:true, :false)
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
end

View File

@@ -0,0 +1,58 @@
Puppet::Type.newtype(:virtstoraged_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'setting name to manage from virtstoraged.conf'
newvalues(/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value
end
def is_to_s( currentvalue )
if resource.secret?
return '[old secret redacted]'
else
return currentvalue
end
end
def should_to_s( newvalue )
if resource.secret?
return '[new secret redacted]'
else
return newvalue
end
end
end
newparam(:secret, :boolean => true) do
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
newvalues(:true, :false)
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
end

View File

@@ -110,6 +110,11 @@
# (optional) virtlog service name.
# Defaults to $::nova::params::virtlog_service_name
#
# [*modular_libvirt*]
# (optional) Whether to enable modular libvirt daemons or use monolithic
# libvirt daemon.
# Defaults to $::nova::params::modular_libvirt
#
# [*compute_driver*]
# (optional) Compute driver.
# Defaults to 'libvirt.LibvirtDriver'
@@ -248,6 +253,7 @@ class nova::compute::libvirt (
$libvirt_service_name = $::nova::params::libvirt_service_name,
$virtlock_service_name = $::nova::params::virtlock_service_name,
$virtlog_service_name = $::nova::params::virtlog_service_name,
$modular_libvirt = $::nova::params::modular_libvirt,
$compute_driver = 'libvirt.LibvirtDriver',
$preallocate_images = $::os_service_default,
$manage_libvirt_services = true,
@@ -310,11 +316,13 @@ class nova::compute::libvirt (
}
}
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);
if !$modular_libvirt {
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] {

View File

@@ -21,19 +21,54 @@
# (optional) Allow configuration of arbitrary virtlogd configurations.
# The value is an hash of virtlogd_config resources.
#
# [*virtnodedevd_config*]
# (optional) Allow configuration of arbitrary virtnodedevd configurations.
# The value is an hash of virtnodedevd_config resources.
#
# [*virtproxyd_config*]
# (optional) Allow configuration of arbitrary virtproxyd configurations.
# The value is an hash of virtproxyd_config resources.
#
# [*virtqemud_config*]
# (optional) Allow configuration of arbitrary virtqemud configurations.
# The value is an hash of virtqemud_config resources.
#
# [*virtsecretd_config*]
# (optional) Allow configuration of arbitrary virtsecretd configurations.
# The value is an hash of virtsecretd_config resources.
#
# [*virtstoraged_config*]
# (optional) Allow configuration of arbitrary virtstoraged configurations.
# The value is an hash of virtstoraged_config resources.
#
# NOTE: The configuration MUST NOT be already handled by this module
# or Puppet catalog compilation will fail with duplicate resources.
#
class nova::compute::libvirt::config (
$libvirtd_config = {},
$virtlogd_config = {},
$libvirtd_config = {},
$virtlogd_config = {},
$virtnodedevd_config = {},
$virtproxyd_config = {},
$virtqemud_config = {},
$virtsecretd_config = {},
$virtstoraged_config = {},
) {
include nova::deps
validate_legacy(Hash, 'validate_hash', $libvirtd_config)
validate_legacy(Hash, 'validate_hash', $virtlogd_config)
validate_legacy(Hash, 'validate_hash', $virtnodedevd_config)
validate_legacy(Hash, 'validate_hash', $virtproxyd_config)
validate_legacy(Hash, 'validate_hash', $virtqemud_config)
validate_legacy(Hash, 'validate_hash', $virtsecretd_config)
validate_legacy(Hash, 'validate_hash', $virtstoraged_config)
create_resources('libvirtd_config', $libvirtd_config)
create_resources('virtlogd_config', $virtlogd_config)
create_resources('virtnodedevd_config', $virtnodedevd_config)
create_resources('virtproxyd_config', $virtproxyd_config)
create_resources('virtqemud_config', $virtqemud_config)
create_resources('virtsecretd_config', $virtsecretd_config)
create_resources('virtstoraged_config', $virtstoraged_config)
}

View File

@@ -20,11 +20,42 @@
# (optional) Libvirt domain type. Options are: kvm, lxc, qemu, parallels
# Defaults to 'kvm'
#
# [*modular_libvirt*]
# (optional) Whether to enable modular libvirt daemons or use monolithic
# libvirt daemon.
# Defaults to $::nova::params::modular_libvirt
#
# [*virtsecret_service_name*]
# (optional) virtsecret service name.
# Defaults to $::nova::params::virtsecret_service_name
#
# [*virtnodedev_service_name*]
# (optional) virtnodedev service name.
# Defaults to $::nova::params::virtnodedevd_service_name
#
# [*virtqemu_service_name*]
# (optional) virtqemu service name.
# Defaults to $::nova::params::virtqemu_service_name
#
# [*virtproxy_service_name*]
# (optional) virtproxy service name.
# Defaults to $::nova::params::virtproxy_service_name
#
# [*virtstorage_service_name*]
# (optional) virtstorage service name.
# Defaults to $::nova::params::virtstorage_service_name
#
class nova::compute::libvirt::services (
$libvirt_service_name = $::nova::params::libvirt_service_name,
$virtlock_service_name = $::nova::params::virtlock_service_name,
$virtlog_service_name = $::nova::params::virtlog_service_name,
$libvirt_virt_type = 'kvm',
$libvirt_service_name = $::nova::params::libvirt_service_name,
$virtlock_service_name = $::nova::params::virtlock_service_name,
$virtlog_service_name = $::nova::params::virtlog_service_name,
$libvirt_virt_type = 'kvm',
$modular_libvirt = $::nova::params::modular_libvirt,
$virtsecret_service_name = $::nova::params::virtsecret_service_name,
$virtnodedev_service_name = $::nova::params::virtnodedev_service_name,
$virtqemu_service_name = $::nova::params::virtqemu_service_name,
$virtproxy_service_name = $::nova::params::virtproxy_service_name,
$virtstorage_service_name = $::nova::params::virtstorage_service_name
) inherits nova::params {
include nova::deps
@@ -60,9 +91,19 @@ class nova::compute::libvirt::services (
name => $libvirt_package_name_real,
tag => ['openstack', 'nova-support-package'],
}
service { 'libvirt' :
ensure => running,
enable => true,
# Stop and disable libvirt service when modular_libvirt is enabled
if $modular_libvirt {
$libvirt_service_ensure = 'stopped'
$libvirt_service_enable = false
} else {
$libvirt_service_ensure = 'running'
$libvirt_service_enable = true
}
service { 'libvirt':
ensure => $libvirt_service_ensure,
enable => $libvirt_service_enable,
name => $libvirt_service_name,
require => Anchor['nova::install::end'],
}
@@ -74,14 +115,10 @@ class nova::compute::libvirt::services (
enable => true,
name => $::nova::params::messagebus_service_name,
}
Package['libvirt'] -> Service['messagebus'] -> Service['libvirt']
Package['libvirt'] -> Service['messagebus']
}
# when nova-compute & libvirt run together
Service['libvirt'] -> Service<| title == 'nova-compute'|>
}
if $virtlock_service_name {
service { 'virtlockd':
ensure => running,
@@ -99,8 +136,88 @@ class nova::compute::libvirt::services (
}
Package<| title == 'libvirt' |> -> Service['virtlogd']
}
if $libvirt_service_name and $virtlog_service_name {
Service['virtlogd'] -> Service['libvirt']
}
if ! $modular_libvirt {
Service<| title == 'messagebus' |> -> Service<| title == 'libvirt' |>
Service<| title == 'virtlogd' |>
-> Service<| title == 'libvirt' |>
-> Service<| title == 'nova-compute'|>
} else {
# NOTE(tkajinam): libvirt should be stopped before starting modular daemons
Service<| title == 'libvirt' |> -> Service<| tag == 'libvirt-modular-service' |>
Service<| title == 'messagebus' |> -> Service<| tag == 'libvirt-modular-service' |>
Service<| title == 'virtlogd' |>
-> Service<| tag == 'libvirt-modular-service' |>
-> Service<| title == 'nova-compute'|>
if $virtsecret_service_name {
package { 'virtsecret':
ensure => present,
name => "${::nova::params::libvirt_daemon_package_prefix}driver-secret"
}
service { 'virtsecretd':
ensure => running,
enable => true,
name => $virtsecret_service_name,
require => Package['virtsecret'],
tag => 'libvirt-modular-service',
}
}
if $virtnodedev_service_name {
package { 'virtnodedev':
ensure => present,
name => "${::nova::params::libvirt_daemon_package_prefix}driver-nodedev"
}
service { 'virtnodedevd':
ensure => running,
enable => true,
name => $virtnodedev_service_name,
require => Package['virtnodedev'],
tag => 'libvirt-modular-service',
}
}
if $virtqemu_service_name {
package { 'virtqemu':
ensure => present,
name => "${::nova::params::libvirt_daemon_package_prefix}driver-qemu"
}
service { 'virtqemud':
ensure => running,
enable => true,
name => $virtqemu_service_name,
require => Package['virtqemu'],
tag => 'libvirt-modular-service',
}
}
if $virtproxy_service_name {
service { 'virtproxyd':
ensure => running,
enable => true,
name => $virtproxy_service_name,
tag => 'libvirt-modular-service',
}
Package<| title == 'libvirt' |> -> Service['virtproxyd']
}
if $virtstorage_service_name {
package { 'virtstorage':
ensure => present,
name => "${::nova::params::libvirt_daemon_package_prefix}driver-storage"
}
service { 'virtstoraged':
ensure => running,
enable => true,
name => $virtstorage_service_name,
require => Package['virtstorage'],
tag => 'libvirt-modular-service',
}
}
}
}

View File

@@ -0,0 +1,59 @@
# == Class: nova::compute::libvirt::virtnodedevd
#
# virtnodedevd configuration
#
# === Parameters:
#
# [*log_level*]
# Defines a log level to filter log outputs.
# 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 $::os_service_default
#
# [*log_outputs*]
# (optional) Defines log outputs, as specified in
# https://libvirt.org/logging.html
# Defaults to $::os_service_default
#
# [*max_clients*]
# The maximum number of concurrent client connections to allow
# on primary socket.
# Defaults to $::os_service_default
#
# [*admin_max_clients*]
# The maximum number of concurrent client connections to allow
# on administrative socket.
# Defaults to $::os_service_default
#
# [*ovs_timeout*]
# (optional) A timeout for openvswitch calls made by libvirt
# Defaults to $::os_service_default
#
class nova::compute::libvirt::virtnodedevd (
$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,
$ovs_timeout = $::os_service_default,
) {
include nova::deps
require nova::compute::libvirt
virtnodedevd_config {
'log_level': value => $log_level;
'log_filters': value => $log_filters, quote => true;
'log_outputs': value => $log_outputs, quote => true;
'max_clients': value => $max_clients;
'admin_max_clients': value => $admin_max_clients;
'ovs_timeout': value => $ovs_timeout;
}
Anchor['nova::config::begin']
-> Virtnodedevd_config<||>
-> Anchor['nova::config::end']
}

View File

@@ -0,0 +1,68 @@
# == Class: nova::compute::libvirt::virtproxyd
#
# virtproxyd configuration
#
# === Parameters:
#
# [*log_level*]
# Defines a log level to filter log outputs.
# 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 $::os_service_default
#
# [*log_outputs*]
# (optional) Defines log outputs, as specified in
# https://libvirt.org/logging.html
# Defaults to $::os_service_default
#
# [*max_clients*]
# The maximum number of concurrent client connections to allow
# on primary socket.
# Defaults to $::os_service_default
#
# [*admin_max_clients*]
# The maximum number of concurrent client connections to allow
# on administrative socket.
# Defaults to $::os_service_default
#
# [*ovs_timeout*]
# (optional) A timeout for openvswitch calls made by libvirt
# 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 $::os_service_default
#
class nova::compute::libvirt::virtproxyd (
$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,
$ovs_timeout = $::os_service_default,
$tls_priority = $::os_service_default,
) {
include nova::deps
require nova::compute::libvirt
virtproxyd_config {
'log_level': value => $log_level;
'log_filters': value => $log_filters, quote => true;
'log_outputs': value => $log_outputs, quote => true;
'max_clients': value => $max_clients;
'admin_max_clients': value => $admin_max_clients;
'ovs_timeout': value => $ovs_timeout;
'tls_priority': value => $tls_priority, quote => true;
}
Anchor['nova::config::begin']
-> Virtproxyd_config<||>
-> Anchor['nova::config::end']
}

View File

@@ -0,0 +1,60 @@
# == Class: nova::compute::libvirt::virtqemud
#
# virtqemud configuration
#
# === Parameters:
#
# [*log_level*]
# Defines a log level to filter log outputs.
# 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 $::os_service_default
#
# [*log_outputs*]
# (optional) Defines log outputs, as specified in
# https://libvirt.org/logging.html
# Defaults to $::os_service_default
#
# [*max_clients*]
# The maximum number of concurrent client connections to allow
# on primary socket.
# Defaults to $::os_service_default
#
# [*admin_max_clients*]
# The maximum number of concurrent client connections to allow
# on administrative socket.
# Defaults to $::os_service_default
#
# [*ovs_timeout*]
# (optional) A timeout for openvswitch calls made by libvirt
# Defaults to $::os_service_default
#
#
class nova::compute::libvirt::virtqemud (
$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,
$ovs_timeout = $::os_service_default,
) {
include nova::deps
require nova::compute::libvirt
virtqemud_config {
'log_level': value => $log_level;
'log_filters': value => $log_filters, quote => true;
'log_outputs': value => $log_outputs, quote => true;
'max_clients': value => $max_clients;
'admin_max_clients': value => $admin_max_clients;
'ovs_timeout': value => $ovs_timeout;
}
Anchor['nova::config::begin']
-> Virtqemud_config<||>
-> Anchor['nova::config::end']
}

View File

@@ -0,0 +1,59 @@
# == Class: nova::compute::libvirt::virtsecretd
#
# virtsecretd configuration
#
# === Parameters:
#
# [*log_level*]
# Defines a log level to filter log outputs.
# 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 $::os_service_default
#
# [*log_outputs*]
# (optional) Defines log outputs, as specified in
# https://libvirt.org/logging.html
# Defaults to $::os_service_default
#
# [*max_clients*]
# The maximum number of concurrent client connections to allow
# on primary socket.
# Defaults to $::os_service_default
#
# [*admin_max_clients*]
# The maximum number of concurrent client connections to allow
# on administrative socket.
# Defaults to $::os_service_default
#
# [*ovs_timeout*]
# (optional) A timeout for openvswitch calls made by libvirt
# Defaults to $::os_service_default
#
class nova::compute::libvirt::virtsecretd (
$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,
$ovs_timeout = $::os_service_default,
) {
include nova::deps
require nova::compute::libvirt
virtsecretd_config {
'log_level': value => $log_level;
'log_filters': value => $log_filters, quote => true;
'log_outputs': value => $log_outputs, quote => true;
'max_clients': value => $max_clients;
'admin_max_clients': value => $admin_max_clients;
'ovs_timeout': value => $ovs_timeout;
}
Anchor['nova::config::begin']
-> Virtsecretd_config<||>
-> Anchor['nova::config::end']
}

View File

@@ -0,0 +1,46 @@
# == Class: nova::compute::libvirt::virtstoraged
#
# virtstoraged configuration
#
# === Parameters:
#
# [*log_level*]
# Defines a log level to filter log outputs.
# 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 $::os_service_default
#
# [*log_outputs*]
# (optional) Defines log outputs, as specified in
# https://libvirt.org/logging.html
# Defaults to $::os_service_default
#
# [*ovs_timeout*]
# (optional) A timeout for openvswitch calls made by libvirt
# Defaults to $::os_service_default
#
class nova::compute::libvirt::virtstoraged (
$log_level = $::os_service_default,
$log_filters = $::os_service_default,
$log_outputs = $::os_service_default,
$ovs_timeout = $::os_service_default,
) {
include nova::deps
require nova::compute::libvirt
virtstoraged_config {
'log_level': value => $log_level;
'log_filters': value => $log_filters, quote => true;
'log_outputs': value => $log_outputs, quote => true;
'ovs_timeout': value => $ovs_timeout;
}
Anchor['nova::config::begin']
-> Virtstoraged_config<||>
-> Anchor['nova::config::end']
}

View File

@@ -123,6 +123,11 @@
# of the used OS installed via ::nova::compute::libvirt::version::default .
# Defaults to ::nova::compute::libvirt::version::default
#
# [*modular_libvirt*]
# (optional) Whether to enable modular libvirt daemons or use monolithic
# libvirt daemon.
# Defaults to undef
#
class nova::migration::libvirt(
$transport = undef,
$auth = 'none',
@@ -144,9 +149,11 @@ class nova::migration::libvirt(
$ca_file = $::os_service_default,
$crl_file = $::os_service_default,
$libvirt_version = $::nova::compute::libvirt::version::default,
$modular_libvirt = undef,
) inherits nova::compute::libvirt::version {
include nova::deps
include nova::params
if $transport {
$transport_real = $transport
@@ -154,6 +161,9 @@ class nova::migration::libvirt(
$transport_real = 'tcp'
}
$modular_libvirt_real = pick($modular_libvirt, $nova::params::modular_libvirt)
validate_legacy(Enum['tcp', 'tls', 'ssh'], 'validate_re', $transport_real,
[['^tcp$', '^tls$', '^ssh$'], 'Valid options for transport are tcp, tls, ssh.'])
validate_legacy(Enum['sasl', 'none'], 'validate_re', $auth,
@@ -234,13 +244,22 @@ class nova::migration::libvirt(
$host_uuid_real = $::libvirt_uuid
}
augeas { 'libvirt-conf-uuid':
context => '/files/etc/libvirt/libvirtd.conf',
changes => [
"set host_uuid ${host_uuid_real}",
],
notify => Service['libvirt'],
require => Package['libvirt'],
if $modular_libvirt_real {
['virtqemud', 'virtproxyd', 'virtsecretd', 'virtnodedevd', 'virtstoraged'].each |String $daemon| {
augeas { "${daemon}-conf-uuid":
context => "/files/etc/libvirt/${daemon}.conf",
changes => ["set host_uuid ${host_uuid_real}"],
notify => Service[$daemon],
require => Package['libvirt'],
}
}
} else {
augeas { 'libvirt-conf-uuid':
context => '/files/etc/libvirt/libvirtd.conf',
changes => ["set host_uuid ${host_uuid_real}"],
notify => Service['libvirt'],
require => Package['libvirt'],
}
}
}
@@ -272,23 +291,28 @@ class nova::migration::libvirt(
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;
$libvirt_listen_config = $modular_libvirt_real ? {
true => 'virtproxyd_config',
default => 'libvirtd_config'
}
create_resources( $libvirt_listen_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' {
if versioncmp($libvirt_version, '5.6') >= 0 {
# Since libvirt >= 5.6 and libvirtd is managed by systemd,
# system socket should be activated by systemd, not by --listen option
$manage_services = pick($::nova::compute::libvirt::manage_libvirt_services, true)
if $manage_services {
if $manage_services and !$modular_libvirt_real {
# libvirtd.service should be stopped before socket service is started.
# Otherwise, socket service fails to start.
exec { 'stop libvirtd.service':

View File

@@ -38,6 +38,11 @@ class nova::params {
$libvirt_guests_service_name = 'libvirt-guests'
$virtlock_service_name = 'virtlockd'
$virtlog_service_name = 'virtlogd'
$virtsecret_service_name = 'virtsecretd'
$virtnodedev_service_name = 'virtnodedevd'
$virtqemu_service_name = 'virtqemud'
$virtproxy_service_name = 'virtproxyd'
$virtstorage_service_name = 'virtstoraged'
$scheduler_service_name = 'openstack-nova-scheduler'
$tgt_service_name = 'tgtd'
$novajoin_service_name = 'novajoin-server'
@@ -45,6 +50,7 @@ class nova::params {
$vncproxy_service_name = 'openstack-nova-novncproxy'
$serialproxy_service_name = 'openstack-nova-serialproxy'
$spicehtml5proxy_service_name = 'openstack-nova-spicehtml5proxy'
$modular_libvirt = false
# redhat specific config defaults
$root_helper = 'sudo nova-rootwrap'
$lock_path = '/var/lib/nova/tmp'
@@ -87,24 +93,36 @@ class nova::params {
$lock_path = '/var/lock/nova'
case $::os_package_type {
'debian': {
$api_metadata_service_name = 'nova-api-metadata'
$spicehtml5proxy_package_name = 'nova-consoleproxy'
$spicehtml5proxy_service_name = 'nova-spicehtml5proxy'
$vncproxy_package_name = 'nova-consoleproxy'
$serialproxy_package_name = 'nova-consoleproxy'
$api_metadata_service_name = 'nova-api-metadata'
$spicehtml5proxy_package_name = 'nova-consoleproxy'
$spicehtml5proxy_service_name = 'nova-spicehtml5proxy'
$vncproxy_package_name = 'nova-consoleproxy'
$serialproxy_package_name = 'nova-consoleproxy'
# Use default provider on Debian
$virtlock_service_name = 'virtlockd'
$virtlog_service_name = 'virtlogd'
$virtlock_service_name = 'virtlockd'
$virtlog_service_name = 'virtlogd'
$virtsecret_service_name = 'virtsecretd'
$virtnodedev_service_name = 'virtnodedevd'
$virtqemu_service_name = 'virtqemud'
$virtproxy_service_name = 'virtproxyd'
$virtstorage_service_name = 'virtstoraged'
$modular_libvirt = false
}
default: {
$api_metadata_service_name = undef
$spicehtml5proxy_package_name = 'nova-spiceproxy'
$spicehtml5proxy_service_name = 'nova-spiceproxy'
$vncproxy_package_name = 'nova-novncproxy'
$serialproxy_package_name = 'nova-serialproxy'
$api_metadata_service_name = undef
$spicehtml5proxy_package_name = 'nova-spiceproxy'
$spicehtml5proxy_service_name = 'nova-spiceproxy'
$vncproxy_package_name = 'nova-novncproxy'
$serialproxy_package_name = 'nova-serialproxy'
# Use default provider on Debian
$virtlock_service_name = 'virtlockd'
$virtlog_service_name = 'virtlogd'
$virtlock_service_name = 'virtlockd'
$virtlog_service_name = 'virtlogd'
$virtsecret_service_name = 'virtsecretd'
$virtnodedev_service_name = 'virtnodedevd'
$virtqemu_service_name = 'virtqemud'
$virtproxy_service_name = 'virtproxyd'
$virtstorage_service_name = 'virtstoraged'
$modular_libvirt = false
}
}
$libvirt_service_name = 'libvirtd'

View File

@@ -0,0 +1,14 @@
---
features:
- |
This modules now supports modular libvirt daemons. Here is the list of
daemons currently supported.
- virtnodedevd
- virtproxyd
- virtqemud
- virtsecretd
- virtstoraged
More information regarding modular libvirt daemons is available here.
`Libvirt Daemons <https://libvirt.org/daemons.html>` _.

View File

@@ -13,7 +13,10 @@ describe 'nova::compute::libvirt::services' do
context 'with overridden parameters' do
let :params do
{ :libvirt_service_name => false }
{
:libvirt_service_name => false,
:modular_libvirt => false,
}
end
it 'disable libvirt service' do
@@ -21,6 +24,28 @@ describe 'nova::compute::libvirt::services' do
is_expected.not_to contain_service('libvirt')
end
end
context 'with default parameters and modular-libvirt true' do
let :params do
{
:modular_libvirt => true
}
end
it 'deploys libvirt packages and services with modular-libvirt' do
is_expected.to contain_package('libvirt')
is_expected.to contain_package('virtqemu')
is_expected.to contain_package('virtsecret')
is_expected.to contain_package('virtstorage')
is_expected.to contain_package('virtnodedev')
is_expected.to contain_service('virtlogd')
is_expected.to contain_service('virtproxyd')
is_expected.to contain_service('virtnodedevd')
is_expected.to contain_service('virtsecretd')
is_expected.to contain_service('virtstoraged')
is_expected.to contain_service('virtqemud')
end
end
end
on_supported_os({

View File

@@ -117,6 +117,7 @@ describe 'nova::compute::libvirt' do
:ovs_timeout => 10,
:max_queues => 4,
:num_memory_encrypted_guests => 255,
:modular_libvirt => true,
}
end
@@ -152,10 +153,6 @@ 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').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(
:name => 'custom_service',

View File

@@ -0,0 +1,68 @@
# Unit tests for nova::compute::libvirt::virtnodedevd class
#
require 'spec_helper'
describe 'nova::compute::libvirt::virtnodedevd' do
let :pre_condition do
<<-eos
include nova
include nova::compute
include nova::compute::libvirt
eos
end
shared_examples_for 'nova-compute-libvirt-virtnodedevd' do
context 'with default parameters' do
let :params do
{}
end
it { is_expected.to contain_class('nova::deps')}
it { is_expected.to contain_class('nova::compute::libvirt::virtnodedevd')}
it { is_expected.to contain_virtnodedevd_config('log_level').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtnodedevd_config('log_outputs').with_value('<SERVICE DEFAULT>').with_quote(true)}
it { is_expected.to contain_virtnodedevd_config('log_filters').with_value('<SERVICE DEFAULT>').with_quote(true)}
it { is_expected.to contain_virtnodedevd_config('max_clients').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtnodedevd_config('admin_max_clients').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtnodedevd_config('ovs_timeout').with_value('<SERVICE DEFAULT>')}
end
context 'with specified parameters' do
let :params do
{ :log_level => 3,
:log_outputs => '3:syslog',
:log_filters => '1:logging 4:object 4:json 4:event 1:util',
:max_clients => 1024,
:admin_max_clients => 5,
:ovs_timeout => 10,
}
end
it { is_expected.to contain_class('nova::deps')}
it { is_expected.to contain_class('nova::compute::libvirt::virtnodedevd')}
it { is_expected.to contain_virtnodedevd_config('log_level').with_value(params[:log_level])}
it { is_expected.to contain_virtnodedevd_config('log_outputs').with_value(params[:log_outputs]).with_quote(true)}
it { is_expected.to contain_virtnodedevd_config('log_filters').with_value(params[:log_filters]).with_quote(true)}
it { is_expected.to contain_virtnodedevd_config('max_clients').with_value(params[:max_clients])}
it { is_expected.to contain_virtnodedevd_config('admin_max_clients').with_value(params[:admin_max_clients])}
it { is_expected.to contain_virtnodedevd_config('ovs_timeout').with_value(params[:ovs_timeout])}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'nova-compute-libvirt-virtnodedevd'
end
end
end

View File

@@ -0,0 +1,71 @@
# Unit tests for nova::compute::libvirt::virtproxyd class
#
require 'spec_helper'
describe 'nova::compute::libvirt::virtproxyd' do
let :pre_condition do
<<-eos
include nova
include nova::compute
include nova::compute::libvirt
eos
end
shared_examples_for 'nova-compute-libvirt-virtproxyd' do
context 'with default parameters' do
let :params do
{}
end
it { is_expected.to contain_class('nova::deps')}
it { is_expected.to contain_class('nova::compute::libvirt::virtproxyd')}
it { is_expected.to contain_virtproxyd_config('log_level').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtproxyd_config('log_outputs').with_value('<SERVICE DEFAULT>').with_quote(true)}
it { is_expected.to contain_virtproxyd_config('log_filters').with_value('<SERVICE DEFAULT>').with_quote(true)}
it { is_expected.to contain_virtproxyd_config('max_clients').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtproxyd_config('admin_max_clients').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtproxyd_config('ovs_timeout').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtproxyd_config('tls_priority').with_value('<SERVICE DEFAULT>').with_quote(true)}
end
context 'with specified parameters' do
let :params do
{ :log_level => 3,
:log_outputs => '3:syslog',
:log_filters => '1:logging 4:object 4:json 4:event 1:util',
:max_clients => 1024,
:admin_max_clients => 5,
:ovs_timeout => 10,
:tls_priority => 'NORMAL:-VERS-SSL3.0',
}
end
it { is_expected.to contain_class('nova::deps')}
it { is_expected.to contain_class('nova::compute::libvirt::virtproxyd')}
it { is_expected.to contain_virtproxyd_config('log_level').with_value(params[:log_level])}
it { is_expected.to contain_virtproxyd_config('log_outputs').with_value(params[:log_outputs]).with_quote(true)}
it { is_expected.to contain_virtproxyd_config('log_filters').with_value(params[:log_filters]).with_quote(true)}
it { is_expected.to contain_virtproxyd_config('max_clients').with_value(params[:max_clients])}
it { is_expected.to contain_virtproxyd_config('admin_max_clients').with_value(params[:admin_max_clients])}
it { is_expected.to contain_virtproxyd_config('ovs_timeout').with_value(params[:ovs_timeout])}
it { is_expected.to contain_virtproxyd_config('tls_priority').with_value(params[:tls_priority]).with_quote(true)}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'nova-compute-libvirt-virtproxyd'
end
end
end

View File

@@ -0,0 +1,68 @@
# Unit tests for nova::compute::libvirt::virtqemud class
#
require 'spec_helper'
describe 'nova::compute::libvirt::virtqemud' do
let :pre_condition do
<<-eos
include nova
include nova::compute
include nova::compute::libvirt
eos
end
shared_examples_for 'nova-compute-libvirt-virtqemud' do
context 'with default parameters' do
let :params do
{}
end
it { is_expected.to contain_class('nova::deps')}
it { is_expected.to contain_class('nova::compute::libvirt::virtqemud')}
it { is_expected.to contain_virtqemud_config('log_level').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtqemud_config('log_outputs').with_value('<SERVICE DEFAULT>').with_quote(true)}
it { is_expected.to contain_virtqemud_config('log_filters').with_value('<SERVICE DEFAULT>').with_quote(true)}
it { is_expected.to contain_virtqemud_config('max_clients').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtqemud_config('admin_max_clients').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtqemud_config('ovs_timeout').with_value('<SERVICE DEFAULT>')}
end
context 'with specified parameters' do
let :params do
{ :log_level => 3,
:log_outputs => '3:syslog',
:log_filters => '1:logging 4:object 4:json 4:event 1:util',
:max_clients => 1024,
:admin_max_clients => 5,
:ovs_timeout => 10,
}
end
it { is_expected.to contain_class('nova::deps')}
it { is_expected.to contain_class('nova::compute::libvirt::virtqemud')}
it { is_expected.to contain_virtqemud_config('log_level').with_value(params[:log_level])}
it { is_expected.to contain_virtqemud_config('log_outputs').with_value(params[:log_outputs]).with_quote(true)}
it { is_expected.to contain_virtqemud_config('log_filters').with_value(params[:log_filters]).with_quote(true)}
it { is_expected.to contain_virtqemud_config('max_clients').with_value(params[:max_clients])}
it { is_expected.to contain_virtqemud_config('admin_max_clients').with_value(params[:admin_max_clients])}
it { is_expected.to contain_virtqemud_config('ovs_timeout').with_value(params[:ovs_timeout])}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'nova-compute-libvirt-virtqemud'
end
end
end

View File

@@ -0,0 +1,68 @@
# Unit tests for nova::compute::libvirt::virtsecretd class
#
require 'spec_helper'
describe 'nova::compute::libvirt::virtsecretd' do
let :pre_condition do
<<-eos
include nova
include nova::compute
include nova::compute::libvirt
eos
end
shared_examples_for 'nova-compute-libvirt-virtsecretd' do
context 'with default parameters' do
let :params do
{}
end
it { is_expected.to contain_class('nova::deps')}
it { is_expected.to contain_class('nova::compute::libvirt::virtsecretd')}
it { is_expected.to contain_virtsecretd_config('log_level').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtsecretd_config('log_outputs').with_value('<SERVICE DEFAULT>').with_quote(true)}
it { is_expected.to contain_virtsecretd_config('log_filters').with_value('<SERVICE DEFAULT>').with_quote(true)}
it { is_expected.to contain_virtsecretd_config('max_clients').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtsecretd_config('admin_max_clients').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtsecretd_config('ovs_timeout').with_value('<SERVICE DEFAULT>')}
end
context 'with specified parameters' do
let :params do
{ :log_level => 3,
:log_outputs => '3:syslog',
:log_filters => '1:logging 4:object 4:json 4:event 1:util',
:max_clients => 1024,
:admin_max_clients => 5,
:ovs_timeout => 10,
}
end
it { is_expected.to contain_class('nova::deps')}
it { is_expected.to contain_class('nova::compute::libvirt::virtsecretd')}
it { is_expected.to contain_virtsecretd_config('log_level').with_value(params[:log_level])}
it { is_expected.to contain_virtsecretd_config('log_outputs').with_value(params[:log_outputs]).with_quote(true)}
it { is_expected.to contain_virtsecretd_config('log_filters').with_value(params[:log_filters]).with_quote(true)}
it { is_expected.to contain_virtsecretd_config('max_clients').with_value(params[:max_clients])}
it { is_expected.to contain_virtsecretd_config('admin_max_clients').with_value(params[:admin_max_clients])}
it { is_expected.to contain_virtsecretd_config('ovs_timeout').with_value(params[:ovs_timeout])}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'nova-compute-libvirt-virtsecretd'
end
end
end

View File

@@ -0,0 +1,62 @@
# Unit tests for nova::compute::libvirt::virtstoraged class
#
require 'spec_helper'
describe 'nova::compute::libvirt::virtstoraged' do
let :pre_condition do
<<-eos
include nova
include nova::compute
include nova::compute::libvirt
eos
end
shared_examples_for 'nova-compute-libvirt-virtstoraged' do
context 'with default parameters' do
let :params do
{}
end
it { is_expected.to contain_class('nova::deps')}
it { is_expected.to contain_class('nova::compute::libvirt::virtstoraged')}
it { is_expected.to contain_virtstoraged_config('log_level').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_virtstoraged_config('log_outputs').with_value('<SERVICE DEFAULT>').with_quote(true)}
it { is_expected.to contain_virtstoraged_config('log_filters').with_value('<SERVICE DEFAULT>').with_quote(true)}
it { is_expected.to contain_virtstoraged_config('ovs_timeout').with_value('<SERVICE DEFAULT>')}
end
context 'with specified parameters' do
let :params do
{ :log_level => 3,
:log_outputs => '3:syslog',
:log_filters => '1:logging 4:object 4:json 4:event 1:util',
:ovs_timeout => 10,
}
end
it { is_expected.to contain_class('nova::deps')}
it { is_expected.to contain_class('nova::compute::libvirt::virtstoraged')}
it { is_expected.to contain_virtstoraged_config('log_level').with_value(params[:log_level])}
it { is_expected.to contain_virtstoraged_config('log_outputs').with_value(params[:log_outputs]).with_quote(true)}
it { is_expected.to contain_virtstoraged_config('log_filters').with_value(params[:log_filters]).with_quote(true)}
it { is_expected.to contain_virtstoraged_config('ovs_timeout').with_value(params[:ovs_timeout])}
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'nova-compute-libvirt-virtstoraged'
end
end
end

View File

@@ -49,6 +49,25 @@ describe 'nova::migration::libvirt' do
it { is_expected.to contain_nova_config('libvirt/live_migration_permit_auto_converge').with_value('<SERVICE DEFAULT>')}
end
context 'with modular_libvirt set to true' do
let(:params) { { :modular_libvirt => true} }
it { is_expected.to contain_virtproxyd_config('listen_tls').with_value('0') }
it { is_expected.to contain_virtproxyd_config('listen_tcp').with_value('1') }
it { is_expected.to contain_virtproxyd_config('auth_tls').with_value('<SERVICE DEFAULT>').with_quote(true) }
it { is_expected.to contain_virtproxyd_config('auth_tcp').with_value('none').with_quote(true) }
it { is_expected.to contain_virtproxyd_config('ca_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
it { is_expected.to contain_virtproxyd_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>') }
it { is_expected.to contain_nova_config('libvirt/live_migration_timeout_action').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_nova_config('libvirt/live_migration_uri').with_value('qemu+tcp://%s/system') }
it { is_expected.to contain_nova_config('libvirt/live_migration_inbound_addr').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_nova_config('libvirt/live_migration_permit_post_copy').with_value('<SERVICE DEFAULT>')}
it { is_expected.to contain_nova_config('libvirt/live_migration_permit_auto_converge').with_value('<SERVICE DEFAULT>')}
end
context 'with override_uuid enabled' do
let :params do
{
@@ -99,6 +118,23 @@ describe 'nova::migration::libvirt' do
it { is_expected.to contain_nova_config('libvirt/live_migration_uri').with_value('qemu+tls://%s/system')}
end
context 'with tls enabled and modular-libvirt set to true' do
let :params do
{
:transport => 'tls',
:modular_libvirt => true,
}
end
it { is_expected.to contain_virtproxyd_config('listen_tls').with_value('1') }
it { is_expected.to contain_virtproxyd_config('listen_tcp').with_value('0') }
it { is_expected.to contain_virtproxyd_config('auth_tls').with_value('none').with_quote(true) }
it { is_expected.to contain_virtproxyd_config('auth_tcp').with_value('<SERVICE DEFAULT>').with_quote(true) }
it { is_expected.to contain_virtproxyd_config('ca_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
it { is_expected.to contain_virtproxyd_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
context 'with tls enabled and inbound addr set' do
let :params do
{
@@ -119,7 +155,7 @@ describe 'nova::migration::libvirt' do
context 'with live_migration_with_native_tls flags set' do
let :params do
{
:live_migration_with_native_tls => true,
:live_migration_with_native_tls => true,
}
end
it { is_expected.to contain_nova_config('libvirt/live_migration_with_native_tls').with(:value => true) }
@@ -161,6 +197,20 @@ describe 'nova::migration::libvirt' do
it { is_expected.to contain_libvirtd_config('crl_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
end
context 'with auth set to sasl and modular_libvirt is true' do
let :params do
{
:auth => 'sasl',
:modular_libvirt => true,
}
end
it { is_expected.to contain_virtproxyd_config('auth_tls').with_value('<SERVICE DEFAULT>').with_quote(true) }
it { is_expected.to contain_virtproxyd_config('auth_tcp').with_value('sasl').with_quote(true) }
it { is_expected.to contain_virtproxyd_config('ca_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
it { is_expected.to contain_virtproxyd_config('crl_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
end
context 'with auth set to sasl and tls enabled' do
let :params do
{
@@ -174,6 +224,21 @@ describe 'nova::migration::libvirt' do
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 and modular_libvirt set to true' do
let :params do
{
:auth => 'sasl',
:transport => 'tls',
:modular_libvirt => true,
}
end
it { is_expected.to contain_virtproxyd_config('auth_tls').with_value('sasl').with_quote(true) }
it { is_expected.to contain_virtproxyd_config('auth_tcp').with_value('<SERVICE DEFAULT>').with_quote(true) }
it { is_expected.to contain_virtproxyd_config('ca_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
it { is_expected.to contain_virtproxyd_config('crl_file').with_value('<SERVICE DEFAULT>').with_quote(true) }
end
context 'with certificates set and tls enabled' do
let :params do
{
@@ -188,6 +253,21 @@ describe 'nova::migration::libvirt' do
it { is_expected.to contain_libvirtd_config('crl_file').with_value('/crl').with_quote(true) }
end
context 'with certificates set and tls enabled and modular_libvirt set to true' do
let :params do
{
:transport => 'tls',
:ca_file => '/ca',
:crl_file => '/crl',
:modular_libvirt => true,
}
end
it { is_expected.to contain_virtproxyd_config('auth_tls').with_value('none').with_quote(true) }
it { is_expected.to contain_virtproxyd_config('auth_tcp').with_value('<SERVICE DEFAULT>').with_quote(true) }
it { is_expected.to contain_virtproxyd_config('ca_file').with_value('/ca').with_quote(true) }
it { is_expected.to contain_virtproxyd_config('crl_file').with_value('/crl').with_quote(true) }
end
context 'with auth set to an invalid setting' do
let :params do
{
@@ -227,6 +307,16 @@ describe 'nova::migration::libvirt' do
it { is_expected.to contain_libvirtd_config('listen_addr').with_value('127.0.0.1').with_quote(true) }
end
context 'with listen_address set and modular_libvirt set to true' do
let :params do
{
:listen_address => "127.0.0.1",
:modular_libvirt => true,
}
end
it { is_expected.to contain_virtproxyd_config('listen_addr').with_value('127.0.0.1').with_quote(true) }
end
context 'with ssh transport' do
let :params do
{
@@ -238,6 +328,18 @@ describe 'nova::migration::libvirt' do
it { is_expected.to contain_libvirtd_config('listen_tcp').with_value('0') }
end
context 'with ssh transport and modular_libvirt set to true' do
let :params do
{
:transport => 'ssh',
:modular_libvirt => true,
}
end
it { is_expected.to contain_nova_config('libvirt/live_migration_uri').with_value('qemu+ssh://%s/system')}
it { is_expected.to contain_virtproxyd_config('listen_tls').with_value('0') }
it { is_expected.to contain_virtproxyd_config('listen_tcp').with_value('0') }
end
context 'with ssh transport with user' do
let :params do
{
@@ -250,6 +352,19 @@ describe 'nova::migration::libvirt' do
it { is_expected.to contain_libvirtd_config('listen_tcp').with_value('0') }
end
context 'with ssh transport with user and modular_libvirt set to true' do
let :params do
{
:transport => 'ssh',
:client_user => 'foobar',
:modular_libvirt => true,
}
end
it { is_expected.to contain_nova_config('libvirt/live_migration_uri').with_value('qemu+ssh://foobar@%s/system')}
it { is_expected.to contain_virtproxyd_config('listen_tls').with_value('0') }
it { is_expected.to contain_virtproxyd_config('listen_tcp').with_value('0') }
end
context 'with ssh transport with port' do
let :params do
{
@@ -262,6 +377,19 @@ describe 'nova::migration::libvirt' do
it { is_expected.to contain_libvirtd_config('listen_tcp').with_value('0') }
end
context 'with ssh transport with port and modular_libvirt set to true' do
let :params do
{
:transport => 'ssh',
:client_port => 1234,
:modular_libvirt => true,
}
end
it { is_expected.to contain_nova_config('libvirt/live_migration_uri').with_value('qemu+ssh://%s:1234/system')}
it { is_expected.to contain_virtproxyd_config('listen_tls').with_value('0') }
it { is_expected.to contain_virtproxyd_config('listen_tcp').with_value('0') }
end
context 'with ssh transport with extraparams' do
let :params do
{
@@ -274,6 +402,19 @@ describe 'nova::migration::libvirt' do
it { is_expected.to contain_libvirtd_config('listen_tcp').with_value('0') }
end
context 'with ssh transport with extraparams and modular_libvirt set to true' do
let :params do
{
:transport => 'ssh',
:client_extraparams => {'foo' => '%', 'bar' => 'baz'},
:modular_libvirt => true,
}
end
it { is_expected.to contain_nova_config('libvirt/live_migration_uri').with_value('qemu+ssh://%s/system?foo=%%25&bar=baz')}
it { is_expected.to contain_virtproxyd_config('listen_tls').with_value('0') }
it { is_expected.to contain_virtproxyd_config('listen_tcp').with_value('0') }
end
end
shared_examples_for 'nova migration with libvirt in Debian' do

View File

@@ -0,0 +1,66 @@
#
# 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(:virtnodedevd_config).provider(:ini_setting)
describe provider_class do
it 'should allow setting to be set explicitly' do
resource = Puppet::Type::Virtnodedevd_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::Virtnodedevd_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::Virtnodedevd_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::Virtnodedevd_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::Virtnodedevd_config.new(
{:name => 'foo', :value => '<SERVICE DEFAULT>', :quote => true}
)
provider = provider_class.new(resource)
provider.exists?
expect(resource[:ensure]).to eq :absent
end
end

View File

@@ -0,0 +1,66 @@
#
# 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(:virtproxyd_config).provider(:ini_setting)
describe provider_class do
it 'should allow setting to be set explicitly' do
resource = Puppet::Type::Virtproxyd_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::Virtproxyd_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::Virtproxyd_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::Virtproxyd_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::Virtproxyd_config.new(
{:name => 'foo', :value => '<SERVICE DEFAULT>', :quote => true}
)
provider = provider_class.new(resource)
provider.exists?
expect(resource[:ensure]).to eq :absent
end
end

View File

@@ -0,0 +1,66 @@
#
# 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(:virtqemud_config).provider(:ini_setting)
describe provider_class do
it 'should allow setting to be set explicitly' do
resource = Puppet::Type::Virtqemud_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::Virtqemud_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::Virtqemud_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::Virtqemud_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::Virtqemud_config.new(
{:name => 'foo', :value => '<SERVICE DEFAULT>', :quote => true}
)
provider = provider_class.new(resource)
provider.exists?
expect(resource[:ensure]).to eq :absent
end
end

View File

@@ -0,0 +1,66 @@
#
# 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(:virtsecretd_config).provider(:ini_setting)
describe provider_class do
it 'should allow setting to be set explicitly' do
resource = Puppet::Type::Virtsecretd_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::Virtsecretd_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::Virtsecretd_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::Virtsecretd_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::Virtsecretd_config.new(
{:name => 'foo', :value => '<SERVICE DEFAULT>', :quote => true}
)
provider = provider_class.new(resource)
provider.exists?
expect(resource[:ensure]).to eq :absent
end
end

View File

@@ -0,0 +1,66 @@
#
# 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(:virtstoraged_config).provider(:ini_setting)
describe provider_class do
it 'should allow setting to be set explicitly' do
resource = Puppet::Type::Virtstoraged_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::Virtstoraged_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::Virtstoraged_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::Virtstoraged_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::Virtstoraged_config.new(
{:name => 'foo', :value => '<SERVICE DEFAULT>', :quote => true}
)
provider = provider_class.new(resource)
provider.exists?
expect(resource[:ensure]).to eq :absent
end
end

View File

@@ -0,0 +1,24 @@
require 'puppet'
require 'puppet/type/virtnodedevd_config'
describe 'Puppet::Type.type(:virtnodedevd_config)' do
before :each do
@virtnodedevd_config = Puppet::Type.type(:virtnodedevd_config).new(:name => 'DEFAULT/foo', :value => 'bar')
end
it 'should accept a valid value' do
@virtnodedevd_config[:value] = 'bar'
expect(@virtnodedevd_config[:value]).to eq('bar')
end
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
catalog.add_resource anchor, @virtnodedevd_config
dependency = @virtnodedevd_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@virtnodedevd_config)
expect(dependency[0].source).to eq(anchor)
end
end

View File

@@ -0,0 +1,24 @@
require 'puppet'
require 'puppet/type/virtproxyd_config'
describe 'Puppet::Type.type(:virtproxyd_config)' do
before :each do
@virtproxyd_config = Puppet::Type.type(:virtproxyd_config).new(:name => 'DEFAULT/foo', :value => 'bar')
end
it 'should accept a valid value' do
@virtproxyd_config[:value] = 'bar'
expect(@virtproxyd_config[:value]).to eq('bar')
end
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
catalog.add_resource anchor, @virtproxyd_config
dependency = @virtproxyd_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@virtproxyd_config)
expect(dependency[0].source).to eq(anchor)
end
end

View File

@@ -0,0 +1,24 @@
require 'puppet'
require 'puppet/type/virtqemud_config'
describe 'Puppet::Type.type(:virtqemud_config)' do
before :each do
@virtqemud_config = Puppet::Type.type(:virtqemud_config).new(:name => 'DEFAULT/foo', :value => 'bar')
end
it 'should accept a valid value' do
@virtqemud_config[:value] = 'bar'
expect(@virtqemud_config[:value]).to eq('bar')
end
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
catalog.add_resource anchor, @virtqemud_config
dependency = @virtqemud_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@virtqemud_config)
expect(dependency[0].source).to eq(anchor)
end
end

View File

@@ -0,0 +1,24 @@
require 'puppet'
require 'puppet/type/virtsecretd_config'
describe 'Puppet::Type.type(:virtsecretd_config)' do
before :each do
@virtsecretd_config = Puppet::Type.type(:virtsecretd_config).new(:name => 'DEFAULT/foo', :value => 'bar')
end
it 'should accept a valid value' do
@virtsecretd_config[:value] = 'bar'
expect(@virtsecretd_config[:value]).to eq('bar')
end
it 'should autorequire the package that install the file' do
catalog = Puppet::Resource::Catalog.new
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
catalog.add_resource anchor, @virtsecretd_config
dependency = @virtsecretd_config.autorequire
expect(dependency.size).to eq(1)
expect(dependency[0].target).to eq(@virtsecretd_config)
expect(dependency[0].source).to eq(anchor)
end
end