1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
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
|