Merge "Add native resource type for qemu.conf"
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
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
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
|
||||
|
||||
|
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
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
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
|
||||
|
||||
|
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:virtlogd_config) do
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
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
|
||||
|
||||
|
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:virtnodedevd_config) do
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
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
|
||||
|
||||
|
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:virtproxyd_config) do
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
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
|
||||
|
||||
|
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:virtqemud_config) do
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
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
|
||||
|
||||
|
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:virtsecretd_config) do
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
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
|
||||
|
||||
|
@@ -10,7 +10,13 @@ Puppet::Type.newtype(:virtstoraged_config) do
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
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
|
||||
|
||||
|
@@ -45,6 +45,10 @@
|
||||
# (optional) Allow configuration of arbitrary virtstoraged configurations.
|
||||
# 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
|
||||
# or Puppet catalog compilation will fail with duplicate resources.
|
||||
#
|
||||
@@ -57,6 +61,7 @@ class nova::compute::libvirt::config (
|
||||
$virtqemud_config = {},
|
||||
$virtsecretd_config = {},
|
||||
$virtstoraged_config = {},
|
||||
$qemu_config = {},
|
||||
) {
|
||||
|
||||
include nova::deps
|
||||
@@ -69,6 +74,7 @@ class nova::compute::libvirt::config (
|
||||
validate_legacy(Hash, 'validate_hash', $virtqemud_config)
|
||||
validate_legacy(Hash, 'validate_hash', $virtsecretd_config)
|
||||
validate_legacy(Hash, 'validate_hash', $virtstoraged_config)
|
||||
validate_legacy(Hash, 'validate_hash', $qemu_config)
|
||||
|
||||
create_resources('libvirtd_config', $libvirtd_config)
|
||||
create_resources('virtlogd_config', $virtlogd_config)
|
||||
@@ -78,4 +84,5 @@ class nova::compute::libvirt::config (
|
||||
create_resources('virtqemud_config', $virtqemud_config)
|
||||
create_resources('virtsecretd_config', $virtsecretd_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')
|
||||
}
|
||||
|
||||
Anchor['nova::config::begin']
|
||||
-> Augeas<| tag == 'qemu-conf-augeas'|>
|
||||
-> Anchor['nova::config::end']
|
||||
|
||||
Augeas<| tag == 'qemu-conf-augeas'|>
|
||||
~> Service<| tag == 'libvirt-qemu-service' |>
|
||||
Qemu_config<||> ~> Service<| tag == 'libvirt-qemu-service' |>
|
||||
|
||||
if $configure_qemu {
|
||||
|
||||
if $vnc_tls {
|
||||
$vnc_tls_value = 1
|
||||
$vnc_tls_verify_value = $vnc_tls_verify ? { true => 1, false => 0 }
|
||||
$vnc_tls_verify_real = $vnc_tls_verify
|
||||
} else {
|
||||
$vnc_tls_value = 0
|
||||
$vnc_tls_verify_value = 0
|
||||
$vnc_tls_verify_real = false
|
||||
}
|
||||
|
||||
$default_tls_verify_value = $default_tls_verify ? { true => 1, false => 0 }
|
||||
$nbd_tls_value = $nbd_tls ? { true => 1, false => 0 }
|
||||
|
||||
$augues_changes_default = [
|
||||
"set max_files ${max_files}",
|
||||
"set max_processes ${max_processes}",
|
||||
"set vnc_tls ${vnc_tls_value}",
|
||||
"set vnc_tls_x509_verify ${vnc_tls_verify_value}",
|
||||
"set default_tls_x509_verify ${default_tls_verify_value}",
|
||||
]
|
||||
qemu_config {
|
||||
'max_files': value => $max_files;
|
||||
'max_processes': value => $max_processes;
|
||||
'vnc_tls': value => $vnc_tls;
|
||||
'vnc_tls_x509_verify': value => $vnc_tls_verify_real;
|
||||
'default_tls_x509_verify': value => $default_tls_verify;
|
||||
}
|
||||
|
||||
if $user and !empty($user) {
|
||||
$augues_user_changes = ["set user ${user}"]
|
||||
qemu_config { 'user': value => $user, quote =>true }
|
||||
} else {
|
||||
$augues_user_changes = ['rm user']
|
||||
qemu_config { 'user': ensure => absent }
|
||||
}
|
||||
|
||||
if $group and !empty($group) {
|
||||
$augues_group_changes = ["set group ${group}"]
|
||||
qemu_config { 'group': value => $group, quote =>true }
|
||||
} else {
|
||||
$augues_group_changes = ['rm group']
|
||||
qemu_config { 'group': ensure => absent }
|
||||
}
|
||||
|
||||
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 {
|
||||
$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(
|
||||
$augues_changes_default,
|
||||
$augues_user_changes,
|
||||
$augues_group_changes,
|
||||
$augues_memory_backing_dir_changes,
|
||||
$augues_nbd_tls_changes
|
||||
)
|
||||
qemu_config { 'nbd_tls': value => $nbd_tls }
|
||||
|
||||
augeas { 'qemu-conf-limits':
|
||||
context => '/files/etc/libvirt/qemu.conf',
|
||||
changes => $augues_changes,
|
||||
tag => 'qemu-conf-augeas',
|
||||
}
|
||||
} else {
|
||||
|
||||
$augues_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',
|
||||
]
|
||||
|
||||
augeas { 'qemu-conf-limits':
|
||||
context => '/files/etc/libvirt/qemu.conf',
|
||||
changes => $augues_changes,
|
||||
tag => 'qemu-conf-augeas',
|
||||
qemu_config {
|
||||
'max_files': ensure => absent;
|
||||
'max_processes': ensure => absent;
|
||||
'vnc_tls': ensure => absent;
|
||||
'vnc_tls_x509_verify': ensure => absent;
|
||||
'default_tls_x509_verify': ensure => absent;
|
||||
'user': ensure => absent;
|
||||
'group': ensure => absent;
|
||||
'memory_backing_dir': ensure => absent;
|
||||
'nbd_tls': ensure => absent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -72,6 +72,7 @@ class nova::deps {
|
||||
Anchor['nova::config::begin'] -> Virtqemud_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'] -> Qemu_config<||> -> Anchor['nova::config::end']
|
||||
|
||||
# all cache settings should be applied and all packages should be installed
|
||||
# before service startup
|
||||
|
@@ -10,46 +10,33 @@
|
||||
#
|
||||
# [*migration_port_min*]
|
||||
# (optional) Lower limit of port range used for migration.
|
||||
# Defaults to 49152.
|
||||
# Defaults to $facts['os_service_default'].
|
||||
#
|
||||
# [*migration_port_max*]
|
||||
# (optional) Higher limit of port range used for migration.
|
||||
# Defaults to 49215.
|
||||
# Defaults to $facts['os_service_default'].
|
||||
#
|
||||
class nova::migration::qemu(
|
||||
$configure_qemu = false,
|
||||
$migration_port_min = 49152,
|
||||
$migration_port_max = 49215,
|
||||
$migration_port_min = $facts['os_service_default'],
|
||||
$migration_port_max = $facts['os_service_default'],
|
||||
){
|
||||
|
||||
include nova::deps
|
||||
|
||||
validate_legacy(Boolean, 'validate_bool', $configure_qemu)
|
||||
|
||||
Anchor['nova::config::begin']
|
||||
-> Augeas<| tag == 'qemu-conf-augeas'|>
|
||||
-> Anchor['nova::config::end']
|
||||
|
||||
Augeas<| tag == 'qemu-conf-augeas'|>
|
||||
~> Service<| tag == 'libvirt-qemu-service' |>
|
||||
Qemu_config<||> ~> Service<| tag == 'libvirt-qemu-service' |>
|
||||
|
||||
if $configure_qemu {
|
||||
augeas { 'qemu-conf-migration-ports':
|
||||
context => '/files/etc/libvirt/qemu.conf',
|
||||
changes => [
|
||||
"set migration_port_min ${migration_port_min}",
|
||||
"set migration_port_max ${migration_port_max}",
|
||||
],
|
||||
tag => 'qemu-conf-augeas',
|
||||
qemu_config {
|
||||
'migration_port_min': value => $migration_port_min;
|
||||
'migration_port_max': value => $migration_port_max;
|
||||
}
|
||||
} else {
|
||||
augeas { 'qemu-conf-migration-ports':
|
||||
context => '/files/etc/libvirt/qemu.conf',
|
||||
changes => [
|
||||
'rm migration_port_min',
|
||||
'rm migration_port_max',
|
||||
],
|
||||
tag => 'qemu-conf-augeas',
|
||||
qemu_config {
|
||||
'migration_port_min': ensure => absent;
|
||||
'migration_port_max': ensure => absent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
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,101 +5,56 @@ describe 'nova::compute::libvirt::qemu' do
|
||||
shared_examples_for 'nova compute libvirt with qemu' do
|
||||
|
||||
context 'when not configuring qemu' do
|
||||
let :params do
|
||||
{
|
||||
:configure_qemu => false,
|
||||
}
|
||||
it 'should remove all configuations' do
|
||||
is_expected.to contain_qemu_config('max_files').with_ensure('absent')
|
||||
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
|
||||
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
|
||||
|
||||
context 'when configuring qemu by default' do
|
||||
context 'when configuring qemu with defaults' do
|
||||
let :params do
|
||||
{
|
||||
:configure_qemu => true,
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
||||
:context => '/files/etc/libvirt/qemu.conf',
|
||||
:changes => [
|
||||
"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',
|
||||
}) }
|
||||
it 'should configure the default values' do
|
||||
is_expected.to contain_qemu_config('max_files').with_value(1024)
|
||||
is_expected.to contain_qemu_config('max_processes').with_value(4096)
|
||||
is_expected.to contain_qemu_config('vnc_tls').with_value(false)
|
||||
is_expected.to contain_qemu_config('vnc_tls_x509_verify').with_value(false)
|
||||
is_expected.to contain_qemu_config('default_tls_x509_verify').with_value(true)
|
||||
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_value(false)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when configuring qemu with overridden parameters' do
|
||||
let :params do
|
||||
{
|
||||
:configure_qemu => true,
|
||||
:max_files => 32768,
|
||||
: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',
|
||||
:group => 'qemu-group',
|
||||
:max_files => 32768,
|
||||
:max_processes => 131072,
|
||||
:user => 'qemu-user',
|
||||
:group => 'qemu-group',
|
||||
:memory_backing_dir => '/tmp',
|
||||
}
|
||||
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",
|
||||
"set user qemu-user",
|
||||
"set group qemu-group",
|
||||
"set memory_backing_dir /tmp",
|
||||
"set nbd_tls 0",
|
||||
],
|
||||
:tag => 'qemu-conf-augeas',
|
||||
}) }
|
||||
it 'should configure the given values' do
|
||||
is_expected.to contain_qemu_config('max_files').with_value(32768)
|
||||
is_expected.to contain_qemu_config('max_processes').with_value(131072)
|
||||
is_expected.to contain_qemu_config('user').with_value('qemu-user').with_quote(true)
|
||||
is_expected.to contain_qemu_config('group').with_value('qemu-group').with_quote(true)
|
||||
is_expected.to contain_qemu_config('memory_backing_dir').with_value('/tmp').with_quote(true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when configuring qemu with vnc_tls' do
|
||||
@@ -109,21 +64,10 @@ describe 'nova::compute::libvirt::qemu' do
|
||||
:vnc_tls => true,
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
||||
:context => '/files/etc/libvirt/qemu.conf',
|
||||
:changes => [
|
||||
"set max_files 1024",
|
||||
"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',
|
||||
}) }
|
||||
it 'should configure vnc tls' do
|
||||
is_expected.to contain_qemu_config('vnc_tls').with_value(true)
|
||||
is_expected.to contain_qemu_config('vnc_tls_x509_verify').with_value(true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when configuring qemu with default_tls_verify enabled' do
|
||||
@@ -133,21 +77,9 @@ describe 'nova::compute::libvirt::qemu' do
|
||||
:default_tls_verify => true,
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
||||
:context => '/files/etc/libvirt/qemu.conf',
|
||||
:changes => [
|
||||
"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',
|
||||
}) }
|
||||
it 'should enable default_tls_x509_verify' do
|
||||
is_expected.to contain_qemu_config('default_tls_x509_verify').with_value(true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when configuring qemu with vnc_tls_verify disabled' do
|
||||
@@ -158,21 +90,10 @@ describe 'nova::compute::libvirt::qemu' do
|
||||
:vnc_tls_verify => false,
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
||||
:context => '/files/etc/libvirt/qemu.conf',
|
||||
:changes => [
|
||||
"set max_files 1024",
|
||||
"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',
|
||||
}) }
|
||||
it 'should disable vnc_tls_x509_veridy' do
|
||||
is_expected.to contain_qemu_config('vnc_tls').with_value(true)
|
||||
is_expected.to contain_qemu_config('vnc_tls_x509_verify').with_value(false)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when configuring qemu with default_tls_verify disabled' do
|
||||
@@ -182,45 +103,21 @@ describe 'nova::compute::libvirt::qemu' do
|
||||
:default_tls_verify => false,
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
||||
:context => '/files/etc/libvirt/qemu.conf',
|
||||
:changes => [
|
||||
"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',
|
||||
}) }
|
||||
it 'should disable default_tls_x509_verify' do
|
||||
is_expected.to contain_qemu_config('default_tls_x509_verify').with_value(false)
|
||||
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
|
||||
{
|
||||
:configure_qemu => true,
|
||||
:nbd_tls => true,
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_augeas('qemu-conf-limits').with({
|
||||
:context => '/files/etc/libvirt/qemu.conf',
|
||||
:changes => [
|
||||
"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',
|
||||
}) }
|
||||
it 'should enable nbd_tls' do
|
||||
is_expected.to contain_qemu_config('nbd_tls').with_value(true)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -236,5 +133,4 @@ describe 'nova::compute::libvirt::qemu' do
|
||||
it_configures 'nova compute libvirt with qemu'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@@ -11,43 +11,36 @@ describe 'nova::migration::qemu' do
|
||||
shared_examples_for 'nova migration with qemu' do
|
||||
|
||||
context 'when not configuring qemu' do
|
||||
let :params do
|
||||
{
|
||||
:configure_qemu => false
|
||||
}
|
||||
it 'should clear all configurations' do
|
||||
is_expected.to contain_qemu_config('migration_port_min').with_ensure('absent')
|
||||
is_expected.to contain_qemu_config('migration_port_max').with_ensure('absent')
|
||||
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
|
||||
|
||||
context 'when configuring qemu by default' do
|
||||
context 'when configuring qemu with defaults' do
|
||||
let :params do
|
||||
{
|
||||
:configure_qemu => true
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_augeas('qemu-conf-migration-ports').with({
|
||||
:context => '/files/etc/libvirt/qemu.conf',
|
||||
:changes => [ "set migration_port_min 49152", "set migration_port_max 49215" ],
|
||||
:tag => 'qemu-conf-augeas',
|
||||
}) }
|
||||
it 'should configure the default values' do
|
||||
is_expected.to contain_qemu_config('migration_port_min').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_qemu_config('migration_port_max').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when configuring qemu with overridden parameters' do
|
||||
let :params do
|
||||
{
|
||||
:configure_qemu => true,
|
||||
:configure_qemu => true,
|
||||
:migration_port_min => 61138,
|
||||
:migration_port_max => 61200,
|
||||
}
|
||||
end
|
||||
it { is_expected.to contain_augeas('qemu-conf-migration-ports').with({
|
||||
:context => '/files/etc/libvirt/qemu.conf',
|
||||
:changes => [ "set migration_port_min 61138", "set migration_port_max 61200" ],
|
||||
:tag => 'qemu-conf-augeas',
|
||||
}) }
|
||||
it 'should configure the given values' do
|
||||
is_expected.to contain_qemu_config('migration_port_min').with_value(61138)
|
||||
is_expected.to contain_qemu_config('migration_port_max').with_value(61200)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -11,6 +11,16 @@ describe 'Puppet::Type.type(:libvirtd_config)' do
|
||||
expect(@libvirtd_config[:value]).to eq('bar')
|
||||
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
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
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')
|
||||
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
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
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')
|
||||
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
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
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')
|
||||
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
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
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')
|
||||
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
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
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')
|
||||
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
|
||||
catalog = Puppet::Resource::Catalog.new
|
||||
anchor = Puppet::Type.type(:anchor).new(:name => 'nova::install::end')
|
||||
|
Reference in New Issue
Block a user