Add native resource type for qemu.conf
This introduces the native resource type to manipulate qemu.conf, so that we can define the resources in the same way for all libvirt config files. This also updates all libvirt config resource types to convert boolean values automatically, because libvirt does not support raw boolean values and the values should be converted to 1/0. Change-Id: I562d19299e0377e02f2587f5ef36d35069b5a5cd
This commit is contained in:
10
lib/puppet/provider/qemu_config/ini_setting.rb
Normal file
10
lib/puppet/provider/qemu_config/ini_setting.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
Puppet::Type.type(:qemu_config).provide(
|
||||||
|
:ini_setting,
|
||||||
|
:parent => Puppet::Type.type(:libvirtd_config).provider(:ini_setting)
|
||||||
|
) do
|
||||||
|
|
||||||
|
def self.file_path
|
||||||
|
'/etc/libvirt/qemu.conf'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:libvirtd_config) do
|
|||||||
newproperty(:value) do
|
newproperty(:value) do
|
||||||
desc 'The value of the setting to be defined.'
|
desc 'The value of the setting to be defined.'
|
||||||
munge do |value|
|
munge do |value|
|
||||||
|
if [true, false].include?(value)
|
||||||
|
# NOTE(tkajinam): libvirt config file does not accept boolean values
|
||||||
|
# and the value should be converted to 1/0.
|
||||||
|
value = value ? '1' : '0'
|
||||||
|
else
|
||||||
value = value.to_s.strip
|
value = value.to_s.strip
|
||||||
|
end
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
63
lib/puppet/type/qemu_config.rb
Normal file
63
lib/puppet/type/qemu_config.rb
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
Puppet::Type.newtype(:qemu_config) do
|
||||||
|
|
||||||
|
ensurable
|
||||||
|
|
||||||
|
newparam(:name, :namevar => true) do
|
||||||
|
desc 'setting name to manage from qemu.conf'
|
||||||
|
newvalues(/\S+/)
|
||||||
|
end
|
||||||
|
|
||||||
|
newproperty(:value) do
|
||||||
|
desc 'The value of the setting to be defined.'
|
||||||
|
munge do |value|
|
||||||
|
if [true, false].include?(value)
|
||||||
|
# NOTE(tkajinam): libvirt config file does not accept boolean values
|
||||||
|
# and the value should be converted to 1/0.
|
||||||
|
value = value ? '1' : '0'
|
||||||
|
else
|
||||||
|
value = value.to_s.strip
|
||||||
|
end
|
||||||
|
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
|
||||||
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:virtlockd_config) do
|
|||||||
newproperty(:value) do
|
newproperty(:value) do
|
||||||
desc 'The value of the setting to be defined.'
|
desc 'The value of the setting to be defined.'
|
||||||
munge do |value|
|
munge do |value|
|
||||||
|
if [true, false].include?(value)
|
||||||
|
# NOTE(tkajinam): libvirt config file does not accept boolean values
|
||||||
|
# and the value should be converted to 1/0.
|
||||||
|
value = value ? '1' : '0'
|
||||||
|
else
|
||||||
value = value.to_s.strip
|
value = value.to_s.strip
|
||||||
|
end
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:virtlogd_config) do
|
|||||||
newproperty(:value) do
|
newproperty(:value) do
|
||||||
desc 'The value of the setting to be defined.'
|
desc 'The value of the setting to be defined.'
|
||||||
munge do |value|
|
munge do |value|
|
||||||
|
if [true, false].include?(value)
|
||||||
|
# NOTE(tkajinam): libvirt config file does not accept boolean values
|
||||||
|
# and the value should be converted to 1/0.
|
||||||
|
value = value ? '1' : '0'
|
||||||
|
else
|
||||||
value = value.to_s.strip
|
value = value.to_s.strip
|
||||||
|
end
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:virtnodedevd_config) do
|
|||||||
newproperty(:value) do
|
newproperty(:value) do
|
||||||
desc 'The value of the setting to be defined.'
|
desc 'The value of the setting to be defined.'
|
||||||
munge do |value|
|
munge do |value|
|
||||||
|
if [true, false].include?(value)
|
||||||
|
# NOTE(tkajinam): libvirt config file does not accept boolean values
|
||||||
|
# and the value should be converted to 1/0.
|
||||||
|
value = value ? '1' : '0'
|
||||||
|
else
|
||||||
value = value.to_s.strip
|
value = value.to_s.strip
|
||||||
|
end
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:virtproxyd_config) do
|
|||||||
newproperty(:value) do
|
newproperty(:value) do
|
||||||
desc 'The value of the setting to be defined.'
|
desc 'The value of the setting to be defined.'
|
||||||
munge do |value|
|
munge do |value|
|
||||||
|
if [true, false].include?(value)
|
||||||
|
# NOTE(tkajinam): libvirt config file does not accept boolean values
|
||||||
|
# and the value should be converted to 1/0.
|
||||||
|
value = value ? '1' : '0'
|
||||||
|
else
|
||||||
value = value.to_s.strip
|
value = value.to_s.strip
|
||||||
|
end
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:virtqemud_config) do
|
|||||||
newproperty(:value) do
|
newproperty(:value) do
|
||||||
desc 'The value of the setting to be defined.'
|
desc 'The value of the setting to be defined.'
|
||||||
munge do |value|
|
munge do |value|
|
||||||
|
if [true, false].include?(value)
|
||||||
|
# NOTE(tkajinam): libvirt config file does not accept boolean values
|
||||||
|
# and the value should be converted to 1/0.
|
||||||
|
value = value ? '1' : '0'
|
||||||
|
else
|
||||||
value = value.to_s.strip
|
value = value.to_s.strip
|
||||||
|
end
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:virtsecretd_config) do
|
|||||||
newproperty(:value) do
|
newproperty(:value) do
|
||||||
desc 'The value of the setting to be defined.'
|
desc 'The value of the setting to be defined.'
|
||||||
munge do |value|
|
munge do |value|
|
||||||
|
if [true, false].include?(value)
|
||||||
|
# NOTE(tkajinam): libvirt config file does not accept boolean values
|
||||||
|
# and the value should be converted to 1/0.
|
||||||
|
value = value ? '1' : '0'
|
||||||
|
else
|
||||||
value = value.to_s.strip
|
value = value.to_s.strip
|
||||||
|
end
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:virtstoraged_config) do
|
|||||||
newproperty(:value) do
|
newproperty(:value) do
|
||||||
desc 'The value of the setting to be defined.'
|
desc 'The value of the setting to be defined.'
|
||||||
munge do |value|
|
munge do |value|
|
||||||
|
if [true, false].include?(value)
|
||||||
|
# NOTE(tkajinam): libvirt config file does not accept boolean values
|
||||||
|
# and the value should be converted to 1/0.
|
||||||
|
value = value ? '1' : '0'
|
||||||
|
else
|
||||||
value = value.to_s.strip
|
value = value.to_s.strip
|
||||||
|
end
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,10 @@
|
|||||||
# (optional) Allow configuration of arbitrary virtstoraged configurations.
|
# (optional) Allow configuration of arbitrary virtstoraged configurations.
|
||||||
# The value is an hash of virtstoraged_config resources.
|
# The value is an hash of virtstoraged_config resources.
|
||||||
#
|
#
|
||||||
|
# [*qemu_config*]
|
||||||
|
# (optional) Allow configuration of arbitrary qemu configurations.
|
||||||
|
# The value is an hash of qemu_config resources.
|
||||||
|
#
|
||||||
# NOTE: The configuration MUST NOT be already handled by this module
|
# NOTE: The configuration MUST NOT be already handled by this module
|
||||||
# or Puppet catalog compilation will fail with duplicate resources.
|
# or Puppet catalog compilation will fail with duplicate resources.
|
||||||
#
|
#
|
||||||
@@ -57,6 +61,7 @@ class nova::compute::libvirt::config (
|
|||||||
$virtqemud_config = {},
|
$virtqemud_config = {},
|
||||||
$virtsecretd_config = {},
|
$virtsecretd_config = {},
|
||||||
$virtstoraged_config = {},
|
$virtstoraged_config = {},
|
||||||
|
$qemu_config = {},
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include nova::deps
|
include nova::deps
|
||||||
@@ -69,6 +74,7 @@ class nova::compute::libvirt::config (
|
|||||||
validate_legacy(Hash, 'validate_hash', $virtqemud_config)
|
validate_legacy(Hash, 'validate_hash', $virtqemud_config)
|
||||||
validate_legacy(Hash, 'validate_hash', $virtsecretd_config)
|
validate_legacy(Hash, 'validate_hash', $virtsecretd_config)
|
||||||
validate_legacy(Hash, 'validate_hash', $virtstoraged_config)
|
validate_legacy(Hash, 'validate_hash', $virtstoraged_config)
|
||||||
|
validate_legacy(Hash, 'validate_hash', $qemu_config)
|
||||||
|
|
||||||
create_resources('libvirtd_config', $libvirtd_config)
|
create_resources('libvirtd_config', $libvirtd_config)
|
||||||
create_resources('virtlogd_config', $virtlogd_config)
|
create_resources('virtlogd_config', $virtlogd_config)
|
||||||
@@ -78,4 +84,5 @@ class nova::compute::libvirt::config (
|
|||||||
create_resources('virtqemud_config', $virtqemud_config)
|
create_resources('virtqemud_config', $virtqemud_config)
|
||||||
create_resources('virtsecretd_config', $virtsecretd_config)
|
create_resources('virtsecretd_config', $virtsecretd_config)
|
||||||
create_resources('virtstoraged_config', $virtstoraged_config)
|
create_resources('virtstoraged_config', $virtstoraged_config)
|
||||||
|
create_resources('qemu_config', $qemu_config)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,84 +76,55 @@ class nova::compute::libvirt::qemu(
|
|||||||
fail('libvirt version < 4.5 is no longer supported')
|
fail('libvirt version < 4.5 is no longer supported')
|
||||||
}
|
}
|
||||||
|
|
||||||
Anchor['nova::config::begin']
|
Qemu_config<||> ~> Service<| tag == 'libvirt-qemu-service' |>
|
||||||
-> Augeas<| tag == 'qemu-conf-augeas'|>
|
|
||||||
-> Anchor['nova::config::end']
|
|
||||||
|
|
||||||
Augeas<| tag == 'qemu-conf-augeas'|>
|
|
||||||
~> Service<| tag == 'libvirt-qemu-service' |>
|
|
||||||
|
|
||||||
if $configure_qemu {
|
if $configure_qemu {
|
||||||
|
|
||||||
if $vnc_tls {
|
if $vnc_tls {
|
||||||
$vnc_tls_value = 1
|
$vnc_tls_verify_real = $vnc_tls_verify
|
||||||
$vnc_tls_verify_value = $vnc_tls_verify ? { true => 1, false => 0 }
|
|
||||||
} else {
|
} else {
|
||||||
$vnc_tls_value = 0
|
$vnc_tls_verify_real = false
|
||||||
$vnc_tls_verify_value = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$default_tls_verify_value = $default_tls_verify ? { true => 1, false => 0 }
|
qemu_config {
|
||||||
$nbd_tls_value = $nbd_tls ? { true => 1, false => 0 }
|
'max_files': value => $max_files;
|
||||||
|
'max_processes': value => $max_processes;
|
||||||
$augues_changes_default = [
|
'vnc_tls': value => $vnc_tls;
|
||||||
"set max_files ${max_files}",
|
'vnc_tls_x509_verify': value => $vnc_tls_verify_real;
|
||||||
"set max_processes ${max_processes}",
|
'default_tls_x509_verify': value => $default_tls_verify;
|
||||||
"set vnc_tls ${vnc_tls_value}",
|
}
|
||||||
"set vnc_tls_x509_verify ${vnc_tls_verify_value}",
|
|
||||||
"set default_tls_x509_verify ${default_tls_verify_value}",
|
|
||||||
]
|
|
||||||
|
|
||||||
if $user and !empty($user) {
|
if $user and !empty($user) {
|
||||||
$augues_user_changes = ["set user ${user}"]
|
qemu_config { 'user': value => $user, quote =>true }
|
||||||
} else {
|
} else {
|
||||||
$augues_user_changes = ['rm user']
|
qemu_config { 'user': ensure => absent }
|
||||||
}
|
}
|
||||||
|
|
||||||
if $group and !empty($group) {
|
if $group and !empty($group) {
|
||||||
$augues_group_changes = ["set group ${group}"]
|
qemu_config { 'group': value => $group, quote =>true }
|
||||||
} else {
|
} else {
|
||||||
$augues_group_changes = ['rm group']
|
qemu_config { 'group': ensure => absent }
|
||||||
}
|
}
|
||||||
|
|
||||||
if $memory_backing_dir and !empty($memory_backing_dir) {
|
if $memory_backing_dir and !empty($memory_backing_dir) {
|
||||||
$augues_memory_backing_dir_changes = ["set memory_backing_dir ${memory_backing_dir}"]
|
qemu_config { 'memory_backing_dir': value => $memory_backing_dir, quote =>true }
|
||||||
} else {
|
} else {
|
||||||
$augues_memory_backing_dir_changes = ['rm memory_backing_dir']
|
qemu_config { 'memory_backing_dir': ensure => absent }
|
||||||
}
|
}
|
||||||
$augues_nbd_tls_changes = ["set nbd_tls ${nbd_tls_value}"]
|
|
||||||
|
|
||||||
$augues_changes = concat(
|
qemu_config { 'nbd_tls': value => $nbd_tls }
|
||||||
$augues_changes_default,
|
|
||||||
$augues_user_changes,
|
|
||||||
$augues_group_changes,
|
|
||||||
$augues_memory_backing_dir_changes,
|
|
||||||
$augues_nbd_tls_changes
|
|
||||||
)
|
|
||||||
|
|
||||||
augeas { 'qemu-conf-limits':
|
|
||||||
context => '/files/etc/libvirt/qemu.conf',
|
|
||||||
changes => $augues_changes,
|
|
||||||
tag => 'qemu-conf-augeas',
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
qemu_config {
|
||||||
$augues_changes = [
|
'max_files': ensure => absent;
|
||||||
'rm max_files',
|
'max_processes': ensure => absent;
|
||||||
'rm max_processes',
|
'vnc_tls': ensure => absent;
|
||||||
'rm vnc_tls',
|
'vnc_tls_x509_verify': ensure => absent;
|
||||||
'rm vnc_tls_x509_verify',
|
'default_tls_x509_verify': ensure => absent;
|
||||||
'rm default_tls_x509_verify',
|
'user': ensure => absent;
|
||||||
'rm user',
|
'group': ensure => absent;
|
||||||
'rm group',
|
'memory_backing_dir': ensure => absent;
|
||||||
'rm memory_backing_dir',
|
'nbd_tls': ensure => absent;
|
||||||
'rm nbd_tls',
|
|
||||||
]
|
|
||||||
|
|
||||||
augeas { 'qemu-conf-limits':
|
|
||||||
context => '/files/etc/libvirt/qemu.conf',
|
|
||||||
changes => $augues_changes,
|
|
||||||
tag => 'qemu-conf-augeas',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ class nova::deps {
|
|||||||
Anchor['nova::config::begin'] -> Virtqemud_config<||> -> Anchor['nova::config::end']
|
Anchor['nova::config::begin'] -> Virtqemud_config<||> -> Anchor['nova::config::end']
|
||||||
Anchor['nova::config::begin'] -> Virtsecretd_config<||> -> Anchor['nova::config::end']
|
Anchor['nova::config::begin'] -> Virtsecretd_config<||> -> Anchor['nova::config::end']
|
||||||
Anchor['nova::config::begin'] -> Virtstoraged_config<||> -> Anchor['nova::config::end']
|
Anchor['nova::config::begin'] -> Virtstoraged_config<||> -> Anchor['nova::config::end']
|
||||||
|
Anchor['nova::config::begin'] -> Qemu_config<||> -> Anchor['nova::config::end']
|
||||||
|
|
||||||
# all cache settings should be applied and all packages should be installed
|
# all cache settings should be applied and all packages should be installed
|
||||||
# before service startup
|
# before service startup
|
||||||
|
|||||||
@@ -10,46 +10,33 @@
|
|||||||
#
|
#
|
||||||
# [*migration_port_min*]
|
# [*migration_port_min*]
|
||||||
# (optional) Lower limit of port range used for migration.
|
# (optional) Lower limit of port range used for migration.
|
||||||
# Defaults to 49152.
|
# Defaults to $facts['os_service_default'].
|
||||||
#
|
#
|
||||||
# [*migration_port_max*]
|
# [*migration_port_max*]
|
||||||
# (optional) Higher limit of port range used for migration.
|
# (optional) Higher limit of port range used for migration.
|
||||||
# Defaults to 49215.
|
# Defaults to $facts['os_service_default'].
|
||||||
#
|
#
|
||||||
class nova::migration::qemu(
|
class nova::migration::qemu(
|
||||||
$configure_qemu = false,
|
$configure_qemu = false,
|
||||||
$migration_port_min = 49152,
|
$migration_port_min = $facts['os_service_default'],
|
||||||
$migration_port_max = 49215,
|
$migration_port_max = $facts['os_service_default'],
|
||||||
){
|
){
|
||||||
|
|
||||||
include nova::deps
|
include nova::deps
|
||||||
|
|
||||||
validate_legacy(Boolean, 'validate_bool', $configure_qemu)
|
validate_legacy(Boolean, 'validate_bool', $configure_qemu)
|
||||||
|
|
||||||
Anchor['nova::config::begin']
|
Qemu_config<||> ~> Service<| tag == 'libvirt-qemu-service' |>
|
||||||
-> Augeas<| tag == 'qemu-conf-augeas'|>
|
|
||||||
-> Anchor['nova::config::end']
|
|
||||||
|
|
||||||
Augeas<| tag == 'qemu-conf-augeas'|>
|
|
||||||
~> Service<| tag == 'libvirt-qemu-service' |>
|
|
||||||
|
|
||||||
if $configure_qemu {
|
if $configure_qemu {
|
||||||
augeas { 'qemu-conf-migration-ports':
|
qemu_config {
|
||||||
context => '/files/etc/libvirt/qemu.conf',
|
'migration_port_min': value => $migration_port_min;
|
||||||
changes => [
|
'migration_port_max': value => $migration_port_max;
|
||||||
"set migration_port_min ${migration_port_min}",
|
|
||||||
"set migration_port_max ${migration_port_max}",
|
|
||||||
],
|
|
||||||
tag => 'qemu-conf-augeas',
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
augeas { 'qemu-conf-migration-ports':
|
qemu_config {
|
||||||
context => '/files/etc/libvirt/qemu.conf',
|
'migration_port_min': ensure => absent;
|
||||||
changes => [
|
'migration_port_max': ensure => absent;
|
||||||
'rm migration_port_min',
|
|
||||||
'rm migration_port_max',
|
|
||||||
],
|
|
||||||
tag => 'qemu-conf-augeas',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
releasenotes/notes/qemu_config-9c7a99cf69972152.yaml
Normal file
9
releasenotes/notes/qemu_config-9c7a99cf69972152.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The new ``qemu_config`` resource type has been added. This resource type
|
||||||
|
allows configuring options in `/etc/libvirt/qemu.conf`.
|
||||||
|
|
||||||
|
- |
|
||||||
|
The new ``nova::compute::libvirt::config::qemu_config`` parameter has been
|
||||||
|
added.
|
||||||
@@ -5,48 +5,36 @@ describe 'nova::compute::libvirt::qemu' do
|
|||||||
shared_examples_for 'nova compute libvirt with qemu' do
|
shared_examples_for 'nova compute libvirt with qemu' do
|
||||||
|
|
||||||
context 'when not configuring qemu' do
|
context 'when not configuring qemu' do
|
||||||
let :params do
|
it 'should remove all configuations' do
|
||||||
{
|
is_expected.to contain_qemu_config('max_files').with_ensure('absent')
|
||||||
:configure_qemu => false,
|
is_expected.to contain_qemu_config('max_processes').with_ensure('absent')
|
||||||
}
|
is_expected.to contain_qemu_config('vnc_tls').with_ensure('absent')
|
||||||
|
is_expected.to contain_qemu_config('vnc_tls_x509_verify').with_ensure('absent')
|
||||||
|
is_expected.to contain_qemu_config('default_tls_x509_verify').with_ensure('absent')
|
||||||
|
is_expected.to contain_qemu_config('user').with_ensure('absent')
|
||||||
|
is_expected.to contain_qemu_config('group').with_ensure('absent')
|
||||||
|
is_expected.to contain_qemu_config('memory_backing_dir').with_ensure('absent')
|
||||||
|
is_expected.to contain_qemu_config('nbd_tls').with_ensure('absent')
|
||||||
end
|
end
|
||||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
|
||||||
:context => '/files/etc/libvirt/qemu.conf',
|
|
||||||
:changes => [
|
|
||||||
"rm max_files",
|
|
||||||
"rm max_processes",
|
|
||||||
"rm vnc_tls",
|
|
||||||
"rm vnc_tls_x509_verify",
|
|
||||||
"rm default_tls_x509_verify",
|
|
||||||
"rm user",
|
|
||||||
"rm group",
|
|
||||||
"rm memory_backing_dir",
|
|
||||||
"rm nbd_tls",
|
|
||||||
],
|
|
||||||
}) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when configuring qemu by default' do
|
context 'when configuring qemu with defaults' do
|
||||||
let :params do
|
let :params do
|
||||||
{
|
{
|
||||||
:configure_qemu => true,
|
:configure_qemu => true,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
it 'should configure the default values' do
|
||||||
:context => '/files/etc/libvirt/qemu.conf',
|
is_expected.to contain_qemu_config('max_files').with_value(1024)
|
||||||
:changes => [
|
is_expected.to contain_qemu_config('max_processes').with_value(4096)
|
||||||
"set max_files 1024",
|
is_expected.to contain_qemu_config('vnc_tls').with_value(false)
|
||||||
"set max_processes 4096",
|
is_expected.to contain_qemu_config('vnc_tls_x509_verify').with_value(false)
|
||||||
"set vnc_tls 0",
|
is_expected.to contain_qemu_config('default_tls_x509_verify').with_value(true)
|
||||||
"set vnc_tls_x509_verify 0",
|
is_expected.to contain_qemu_config('user').with_ensure('absent')
|
||||||
"set default_tls_x509_verify 1",
|
is_expected.to contain_qemu_config('group').with_ensure('absent')
|
||||||
"rm user",
|
is_expected.to contain_qemu_config('memory_backing_dir').with_ensure('absent')
|
||||||
"rm group",
|
is_expected.to contain_qemu_config('nbd_tls').with_value(false)
|
||||||
"rm memory_backing_dir",
|
end
|
||||||
"set nbd_tls 0",
|
|
||||||
],
|
|
||||||
:tag => 'qemu-conf-augeas',
|
|
||||||
}) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when configuring qemu with overridden parameters' do
|
context 'when configuring qemu with overridden parameters' do
|
||||||
@@ -55,51 +43,18 @@ describe 'nova::compute::libvirt::qemu' do
|
|||||||
:configure_qemu => true,
|
:configure_qemu => true,
|
||||||
:max_files => 32768,
|
:max_files => 32768,
|
||||||
:max_processes => 131072,
|
:max_processes => 131072,
|
||||||
}
|
|
||||||
end
|
|
||||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
|
||||||
:context => '/files/etc/libvirt/qemu.conf',
|
|
||||||
:changes => [
|
|
||||||
"set max_files 32768",
|
|
||||||
"set max_processes 131072",
|
|
||||||
"set vnc_tls 0",
|
|
||||||
"set vnc_tls_x509_verify 0",
|
|
||||||
"set default_tls_x509_verify 1",
|
|
||||||
"rm user",
|
|
||||||
"rm group",
|
|
||||||
"rm memory_backing_dir",
|
|
||||||
"set nbd_tls 0",
|
|
||||||
],
|
|
||||||
:tag => 'qemu-conf-augeas',
|
|
||||||
}) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when configuring qemu with user/group parameter' do
|
|
||||||
let :params do
|
|
||||||
{
|
|
||||||
:configure_qemu => true,
|
|
||||||
:user => 'qemu-user',
|
:user => 'qemu-user',
|
||||||
:group => 'qemu-group',
|
:group => 'qemu-group',
|
||||||
:max_files => 32768,
|
|
||||||
:max_processes => 131072,
|
|
||||||
:memory_backing_dir => '/tmp',
|
:memory_backing_dir => '/tmp',
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
it 'should configure the given values' do
|
||||||
:context => '/files/etc/libvirt/qemu.conf',
|
is_expected.to contain_qemu_config('max_files').with_value(32768)
|
||||||
:changes => [
|
is_expected.to contain_qemu_config('max_processes').with_value(131072)
|
||||||
"set max_files 32768",
|
is_expected.to contain_qemu_config('user').with_value('qemu-user').with_quote(true)
|
||||||
"set max_processes 131072",
|
is_expected.to contain_qemu_config('group').with_value('qemu-group').with_quote(true)
|
||||||
"set vnc_tls 0",
|
is_expected.to contain_qemu_config('memory_backing_dir').with_value('/tmp').with_quote(true)
|
||||||
"set vnc_tls_x509_verify 0",
|
end
|
||||||
"set default_tls_x509_verify 1",
|
|
||||||
"set user qemu-user",
|
|
||||||
"set group qemu-group",
|
|
||||||
"set memory_backing_dir /tmp",
|
|
||||||
"set nbd_tls 0",
|
|
||||||
],
|
|
||||||
:tag => 'qemu-conf-augeas',
|
|
||||||
}) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when configuring qemu with vnc_tls' do
|
context 'when configuring qemu with vnc_tls' do
|
||||||
@@ -109,21 +64,10 @@ describe 'nova::compute::libvirt::qemu' do
|
|||||||
:vnc_tls => true,
|
:vnc_tls => true,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
it 'should configure vnc tls' do
|
||||||
:context => '/files/etc/libvirt/qemu.conf',
|
is_expected.to contain_qemu_config('vnc_tls').with_value(true)
|
||||||
:changes => [
|
is_expected.to contain_qemu_config('vnc_tls_x509_verify').with_value(true)
|
||||||
"set max_files 1024",
|
end
|
||||||
"set max_processes 4096",
|
|
||||||
"set vnc_tls 1",
|
|
||||||
"set vnc_tls_x509_verify 1",
|
|
||||||
"set default_tls_x509_verify 1",
|
|
||||||
"rm user",
|
|
||||||
"rm group",
|
|
||||||
"rm memory_backing_dir",
|
|
||||||
"set nbd_tls 0",
|
|
||||||
],
|
|
||||||
:tag => 'qemu-conf-augeas',
|
|
||||||
}) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when configuring qemu with default_tls_verify enabled' do
|
context 'when configuring qemu with default_tls_verify enabled' do
|
||||||
@@ -133,21 +77,9 @@ describe 'nova::compute::libvirt::qemu' do
|
|||||||
:default_tls_verify => true,
|
:default_tls_verify => true,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
it 'should enable default_tls_x509_verify' do
|
||||||
:context => '/files/etc/libvirt/qemu.conf',
|
is_expected.to contain_qemu_config('default_tls_x509_verify').with_value(true)
|
||||||
:changes => [
|
end
|
||||||
"set max_files 1024",
|
|
||||||
"set max_processes 4096",
|
|
||||||
"set vnc_tls 0",
|
|
||||||
"set vnc_tls_x509_verify 0",
|
|
||||||
"set default_tls_x509_verify 1",
|
|
||||||
"rm user",
|
|
||||||
"rm group",
|
|
||||||
"rm memory_backing_dir",
|
|
||||||
"set nbd_tls 0",
|
|
||||||
],
|
|
||||||
:tag => 'qemu-conf-augeas',
|
|
||||||
}) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when configuring qemu with vnc_tls_verify disabled' do
|
context 'when configuring qemu with vnc_tls_verify disabled' do
|
||||||
@@ -158,21 +90,10 @@ describe 'nova::compute::libvirt::qemu' do
|
|||||||
:vnc_tls_verify => false,
|
:vnc_tls_verify => false,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
it 'should disable vnc_tls_x509_veridy' do
|
||||||
:context => '/files/etc/libvirt/qemu.conf',
|
is_expected.to contain_qemu_config('vnc_tls').with_value(true)
|
||||||
:changes => [
|
is_expected.to contain_qemu_config('vnc_tls_x509_verify').with_value(false)
|
||||||
"set max_files 1024",
|
end
|
||||||
"set max_processes 4096",
|
|
||||||
"set vnc_tls 1",
|
|
||||||
"set vnc_tls_x509_verify 0",
|
|
||||||
"set default_tls_x509_verify 1",
|
|
||||||
"rm user",
|
|
||||||
"rm group",
|
|
||||||
"rm memory_backing_dir",
|
|
||||||
"set nbd_tls 0",
|
|
||||||
],
|
|
||||||
:tag => 'qemu-conf-augeas',
|
|
||||||
}) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when configuring qemu with default_tls_verify disabled' do
|
context 'when configuring qemu with default_tls_verify disabled' do
|
||||||
@@ -182,45 +103,21 @@ describe 'nova::compute::libvirt::qemu' do
|
|||||||
:default_tls_verify => false,
|
:default_tls_verify => false,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
it 'should disable default_tls_x509_verify' do
|
||||||
:context => '/files/etc/libvirt/qemu.conf',
|
is_expected.to contain_qemu_config('default_tls_x509_verify').with_value(false)
|
||||||
:changes => [
|
end
|
||||||
"set max_files 1024",
|
|
||||||
"set max_processes 4096",
|
|
||||||
"set vnc_tls 0",
|
|
||||||
"set vnc_tls_x509_verify 0",
|
|
||||||
"set default_tls_x509_verify 0",
|
|
||||||
"rm user",
|
|
||||||
"rm group",
|
|
||||||
"rm memory_backing_dir",
|
|
||||||
"set nbd_tls 0",
|
|
||||||
],
|
|
||||||
:tag => 'qemu-conf-augeas',
|
|
||||||
}) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when configuring qemu with nbd_tls and libvirt >= 4.5' do
|
context 'when configuring qemu with nbd_tls' do
|
||||||
let :params do
|
let :params do
|
||||||
{
|
{
|
||||||
:configure_qemu => true,
|
:configure_qemu => true,
|
||||||
:nbd_tls => true,
|
:nbd_tls => true,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
it 'should enable nbd_tls' do
|
||||||
:context => '/files/etc/libvirt/qemu.conf',
|
is_expected.to contain_qemu_config('nbd_tls').with_value(true)
|
||||||
:changes => [
|
end
|
||||||
"set max_files 1024",
|
|
||||||
"set max_processes 4096",
|
|
||||||
"set vnc_tls 0",
|
|
||||||
"set vnc_tls_x509_verify 0",
|
|
||||||
"set default_tls_x509_verify 1",
|
|
||||||
"rm user",
|
|
||||||
"rm group",
|
|
||||||
"rm memory_backing_dir",
|
|
||||||
"set nbd_tls 1",
|
|
||||||
],
|
|
||||||
:tag => 'qemu-conf-augeas',
|
|
||||||
}) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -236,5 +133,4 @@ describe 'nova::compute::libvirt::qemu' do
|
|||||||
it_configures 'nova compute libvirt with qemu'
|
it_configures 'nova compute libvirt with qemu'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,28 +11,22 @@ describe 'nova::migration::qemu' do
|
|||||||
shared_examples_for 'nova migration with qemu' do
|
shared_examples_for 'nova migration with qemu' do
|
||||||
|
|
||||||
context 'when not configuring qemu' do
|
context 'when not configuring qemu' do
|
||||||
let :params do
|
it 'should clear all configurations' do
|
||||||
{
|
is_expected.to contain_qemu_config('migration_port_min').with_ensure('absent')
|
||||||
:configure_qemu => false
|
is_expected.to contain_qemu_config('migration_port_max').with_ensure('absent')
|
||||||
}
|
|
||||||
end
|
end
|
||||||
it { is_expected.to contain_augeas('qemu-conf-migration-ports').with({
|
|
||||||
:context => '/files/etc/libvirt/qemu.conf',
|
|
||||||
:changes => [ "rm migration_port_min", "rm migration_port_max" ],
|
|
||||||
}) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when configuring qemu by default' do
|
context 'when configuring qemu with defaults' do
|
||||||
let :params do
|
let :params do
|
||||||
{
|
{
|
||||||
:configure_qemu => true
|
:configure_qemu => true
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
it { is_expected.to contain_augeas('qemu-conf-migration-ports').with({
|
it 'should configure the default values' do
|
||||||
:context => '/files/etc/libvirt/qemu.conf',
|
is_expected.to contain_qemu_config('migration_port_min').with_value('<SERVICE DEFAULT>')
|
||||||
:changes => [ "set migration_port_min 49152", "set migration_port_max 49215" ],
|
is_expected.to contain_qemu_config('migration_port_max').with_value('<SERVICE DEFAULT>')
|
||||||
:tag => 'qemu-conf-augeas',
|
end
|
||||||
}) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when configuring qemu with overridden parameters' do
|
context 'when configuring qemu with overridden parameters' do
|
||||||
@@ -43,11 +37,10 @@ describe 'nova::migration::qemu' do
|
|||||||
:migration_port_max => 61200,
|
:migration_port_max => 61200,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
it { is_expected.to contain_augeas('qemu-conf-migration-ports').with({
|
it 'should configure the given values' do
|
||||||
:context => '/files/etc/libvirt/qemu.conf',
|
is_expected.to contain_qemu_config('migration_port_min').with_value(61138)
|
||||||
:changes => [ "set migration_port_min 61138", "set migration_port_max 61200" ],
|
is_expected.to contain_qemu_config('migration_port_max').with_value(61200)
|
||||||
:tag => 'qemu-conf-augeas',
|
end
|
||||||
}) }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ describe 'Puppet::Type.type(:libvirtd_config)' do
|
|||||||
expect(@libvirtd_config[:value]).to eq('bar')
|
expect(@libvirtd_config[:value]).to eq('bar')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should convert a boolean value (true)' do
|
||||||
|
@libvirtd_config[:value] = true
|
||||||
|
expect(@libvirtd_config[:value]).to eq('1')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should convert a boolean value (false)' do
|
||||||
|
@libvirtd_config[:value] = false
|
||||||
|
expect(@libvirtd_config[:value]).to eq('0')
|
||||||
|
end
|
||||||
|
|
||||||
it 'should autorequire the package that install the file' do
|
it 'should autorequire the package that install the file' do
|
||||||
catalog = Puppet::Resource::Catalog.new
|
catalog = Puppet::Resource::Catalog.new
|
||||||
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
||||||
|
|||||||
34
spec/unit/type/qemu_config_spec.rb
Normal file
34
spec/unit/type/qemu_config_spec.rb
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
require 'puppet'
|
||||||
|
require 'puppet/type/qemu_config'
|
||||||
|
|
||||||
|
describe 'Puppet::Type.type(:qemu_config)' do
|
||||||
|
before :each do
|
||||||
|
@qemu_config = Puppet::Type.type(:qemu_config).new(:name => 'DEFAULT/foo', :value => 'bar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should accept a valid value' do
|
||||||
|
@qemu_config[:value] = 'bar'
|
||||||
|
expect(@qemu_config[:value]).to eq('bar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should accept a valid value' do
|
||||||
|
@qemu_config[:value] = 'bar'
|
||||||
|
expect(@qemu_config[:value]).to eq('bar')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should convert a boolean value (true)' do
|
||||||
|
@qemu_config[:value] = true
|
||||||
|
expect(@qemu_config[:value]).to eq('1')
|
||||||
|
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, @qemu_config
|
||||||
|
dependency = @qemu_config.autorequire
|
||||||
|
expect(dependency.size).to eq(1)
|
||||||
|
expect(dependency[0].target).to eq(@qemu_config)
|
||||||
|
expect(dependency[0].source).to eq(anchor)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -11,6 +11,16 @@ describe 'Puppet::Type.type(:virtlockd_config)' do
|
|||||||
expect(@virtlockd_config[:value]).to eq('bar')
|
expect(@virtlockd_config[:value]).to eq('bar')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should convert a boolean value (true)' do
|
||||||
|
@virtlockd_config[:value] = true
|
||||||
|
expect(@virtlockd_config[:value]).to eq('1')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should convert a boolean value (false)' do
|
||||||
|
@virtlockd_config[:value] = false
|
||||||
|
expect(@virtlockd_config[:value]).to eq('0')
|
||||||
|
end
|
||||||
|
|
||||||
it 'should autorequire the package that install the file' do
|
it 'should autorequire the package that install the file' do
|
||||||
catalog = Puppet::Resource::Catalog.new
|
catalog = Puppet::Resource::Catalog.new
|
||||||
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ describe 'Puppet::Type.type(:virtlogd_config)' do
|
|||||||
expect(@virtlogd_config[:value]).to eq('bar')
|
expect(@virtlogd_config[:value]).to eq('bar')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should convert a boolean value (true)' do
|
||||||
|
@virtlogd_config[:value] = true
|
||||||
|
expect(@virtlogd_config[:value]).to eq('1')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should convert a boolean value (false)' do
|
||||||
|
@virtlogd_config[:value] = false
|
||||||
|
expect(@virtlogd_config[:value]).to eq('0')
|
||||||
|
end
|
||||||
|
|
||||||
it 'should autorequire the package that install the file' do
|
it 'should autorequire the package that install the file' do
|
||||||
catalog = Puppet::Resource::Catalog.new
|
catalog = Puppet::Resource::Catalog.new
|
||||||
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ describe 'Puppet::Type.type(:virtnodedevd_config)' do
|
|||||||
expect(@virtnodedevd_config[:value]).to eq('bar')
|
expect(@virtnodedevd_config[:value]).to eq('bar')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should convert a boolean value (true)' do
|
||||||
|
@virtnodedevd_config[:value] = true
|
||||||
|
expect(@virtnodedevd_config[:value]).to eq('1')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should convert a boolean value (false)' do
|
||||||
|
@virtnodedevd_config[:value] = false
|
||||||
|
expect(@virtnodedevd_config[:value]).to eq('0')
|
||||||
|
end
|
||||||
|
|
||||||
it 'should autorequire the package that install the file' do
|
it 'should autorequire the package that install the file' do
|
||||||
catalog = Puppet::Resource::Catalog.new
|
catalog = Puppet::Resource::Catalog.new
|
||||||
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ describe 'Puppet::Type.type(:virtproxyd_config)' do
|
|||||||
expect(@virtproxyd_config[:value]).to eq('bar')
|
expect(@virtproxyd_config[:value]).to eq('bar')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should convert a boolean value (true)' do
|
||||||
|
@virtproxyd_config[:value] = true
|
||||||
|
expect(@virtproxyd_config[:value]).to eq('1')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should convert a boolean value (false)' do
|
||||||
|
@virtproxyd_config[:value] = false
|
||||||
|
expect(@virtproxyd_config[:value]).to eq('0')
|
||||||
|
end
|
||||||
|
|
||||||
it 'should autorequire the package that install the file' do
|
it 'should autorequire the package that install the file' do
|
||||||
catalog = Puppet::Resource::Catalog.new
|
catalog = Puppet::Resource::Catalog.new
|
||||||
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ describe 'Puppet::Type.type(:virtsecretd_config)' do
|
|||||||
expect(@virtsecretd_config[:value]).to eq('bar')
|
expect(@virtsecretd_config[:value]).to eq('bar')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should convert a boolean value (true)' do
|
||||||
|
@virtsecretd_config[:value] = true
|
||||||
|
expect(@virtsecretd_config[:value]).to eq('1')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should convert a boolean value (false)' do
|
||||||
|
@virtsecretd_config[:value] = false
|
||||||
|
expect(@virtsecretd_config[:value]).to eq('0')
|
||||||
|
end
|
||||||
|
|
||||||
it 'should autorequire the package that install the file' do
|
it 'should autorequire the package that install the file' do
|
||||||
catalog = Puppet::Resource::Catalog.new
|
catalog = Puppet::Resource::Catalog.new
|
||||||
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
||||||
|
|||||||
Reference in New Issue
Block a user