Files
puppet-nova/spec/defines/nova_compute_libvirt_secret_ceph_spec.rb
Tobias Urdin a7498d6dbc Add nova::compute::libvirt::secret_ceph resource
This adds the nova::compute::libvirt::secret_ceph
resource definition that can be used to define
libvirt secrets of ceph type.

Before this patch one could only handle one libvirt
secret by configuring the parameters in the
nova::compute::rbd class and with this one can
configure multiple.

This adds a new manage_libvirt_secret parameter
defaulting to true in the nova::compute::rbd class
so that one can disable the creation of the libvirt
secret from that class.

Change-Id: Ief031f5dd4b0648d5629789cb7d6d2f6f946fbf8
2024-04-23 11:09:51 +02:00

92 lines
3.1 KiB
Ruby

require 'spec_helper'
describe 'nova::compute::libvirt::secret_ceph' do
shared_examples 'nova::compute::libvirt::secret_ceph' do
describe 'with required parameters' do
let :pre_condition do
"include nova"
end
let :params do
{
:uuid => '4f515eff-47e4-425c-b24d-9c6adc56401c',
:value => 'AQBHCbtT6APDHhAA5W00cBchwkQjh3dkKsyPjw==',
:secret_name => 'client.openstack',
:secret_path => '/tmp',
}
end
let :title do
'random'
end
it { is_expected.to contain_file('/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.xml').with(
:ensure => 'present',
:owner => 'root',
:group => 'root',
:mode => '0600',
:require => 'Anchor[nova::config::begin]',
)}
it {
verify_contents(catalogue, '/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.xml', [
"<secret ephemeral=\'no\' private=\'no\'>",
" <usage type=\'ceph\'>",
" <name>client.openstack</name>",
" </usage>",
" <uuid>4f515eff-47e4-425c-b24d-9c6adc56401c</uuid>",
"</secret>"
])
}
it { is_expected.to contain_file('/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.secret').with(
:ensure => 'present',
:owner => 'root',
:group => 'root',
:mode => '0600',
:show_diff => false,
:require => 'Anchor[nova::config::begin]',
)}
it {
verify_contents(catalogue, '/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.secret', [
"AQBHCbtT6APDHhAA5W00cBchwkQjh3dkKsyPjw==",
])
}
it { is_expected.to contain_exec('get-or-set virsh secret 4f515eff-47e4-425c-b24d-9c6adc56401c').with(
:command => [
'/usr/bin/virsh', 'secret-define', '--file', '/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.xml',
],
:unless => "/usr/bin/virsh secret-list | grep -i 4f515eff-47e4-425c-b24d-9c6adc56401c",
:require => 'File[/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.xml]',
)}
it { is_expected.to contain_exec('set-secret-value virsh secret 4f515eff-47e4-425c-b24d-9c6adc56401c').with(
:command => [
'/usr/bin/virsh', 'secret-set-value', '--secret', '4f515eff-47e4-425c-b24d-9c6adc56401c',
'--file', '/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.secret',
],
:unless => "/usr/bin/virsh secret-get-value 4f515eff-47e4-425c-b24d-9c6adc56401c | grep -f /tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.secret",
:logoutput => false,
:require => [
'File[/tmp/libvirt-secret-4f515eff-47e4-425c-b24d-9c6adc56401c.secret]',
'Exec[get-or-set virsh secret 4f515eff-47e4-425c-b24d-9c6adc56401c]',
],
)}
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_behaves_like 'nova::compute::libvirt::secret_ceph'
end
end
end