File: nova_compute_libvirt_services_spec.rb

package info (click to toggle)
puppet-module-nova 25.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,100 kB
  • sloc: ruby: 11,433; python: 38; sh: 10; makefile: 10
file content (275 lines) | stat: -rw-r--r-- 9,995 bytes parent folder | download
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
require 'spec_helper'

describe 'nova::compute::libvirt::services' do

  shared_examples_for 'nova compute libvirt services' do
    context 'with default parameters' do
      it 'installs ovmf' do
        is_expected.to contain_package('ovmf').with(
          :ensure => 'present',
          :name   => platform_params[:ovmf_package_name],
          :tag    => ['openstack', 'nova-support-package'],
        )
      end

      it 'skips installs swtpm' do
        is_expected.to_not contain_package('swtpm')
      end
    end

    context 'when libvirt service is not managed' do
      before :each do
        params.merge!({
          :libvirt_service_name => false,
        })
      end

      it 'skips installing libvirt' do
        is_expected.not_to contain_package('libvirt')
        is_expected.not_to contain_package('libvirt-daemon')
        is_expected.not_to contain_service('libvirt')
      end
    end

    context 'when ovmf package is not managed' do
      before :each do
        params.merge!({
          :manage_ovmf => false,
        })
      end

      it 'skips installing ovmf' do
        is_expected.not_to contain_package('ovmf')
      end
    end

    context 'when swtpm package is managed' do
      before :each do
        params.merge!({
          :manage_swtpm => true,
        })
      end

      it 'installs swtpm' do
        is_expected.to contain_package('swtpm').with(
          :ensure => 'present',
          :name   => platform_params[:swtpm_package_name],
          :tag    => ['openstack', 'nova-support-package'],
        )
      end
    end
  end

  shared_examples_for 'nova compute libvirt services with monolithic libvirt' do
    context 'with default parameters' do
      it 'deploys libvirt service' do
        is_expected.to contain_package('libvirt').with(
          :ensure => 'present',
          :name   => platform_params[:libvirt_package_name],
          :tag    => ['openstack', 'nova-support-package'],
        )
        if facts[:os]['family'] == 'RedHat'
          is_expected.to contain_package('libvirt-daemon').with(
            :ensure => 'present',
            :name   => platform_params[:libvirt_daemon_package_name],
            :tag    => ['openstack', 'nova-support-package'],
          )
        end

        is_expected.to contain_service('libvirt').with(
          :ensure => 'running',
          :enable => true,
          :name   => platform_params[:libvirt_service_name],
          :tag    => ['libvirt-service', 'libvirt-qemu-service'],
        )
        is_expected.to contain_service('virtlogd').with(
          :ensure => 'running',
          :enable => true,
          :name   => platform_params[:virtlog_service_name],
          :tag    => ['libvirt-service'],
        )
        is_expected.to contain_service('virtlockd').with(
          :ensure => 'running',
          :enable => true,
          :name   => platform_params[:virtlock_service_name],
          :tag    => ['libvirt-service'],
        )
      end

      it 'does not deploy modular libvirt services' do
        is_expected.to_not contain_package('virtsecret')
        is_expected.to_not contain_package('virtnodedev')
        is_expected.to_not contain_package('virtqemu')
        is_expected.to_not contain_package('virtstorage')

        is_expected.to_not contain_service('virtsecretd')
        is_expected.to_not contain_service('virtnodedevd')
        is_expected.to_not contain_service('virtqemud')
        is_expected.to_not contain_service('virtproxyd')
        is_expected.to_not contain_service('virtstoraged')
      end
    end
  end

  shared_examples_for 'nova compute libvirt services with modular libvirt' do
    context 'with default parameters' do
      before :each do
        params.merge!({
          :modular_libvirt => true
        })
      end

      it 'deploys libvirt service' do
        is_expected.to contain_package('libvirt').with(
          :ensure => 'present',
          :name   => platform_params[:libvirt_package_name],
          :tag    => ['openstack', 'nova-support-package'],
        )
        is_expected.to_not contain_package('libvirt-daemon')

        is_expected.to contain_service('libvirt').with(
          :ensure => 'stopped',
          :enable => false,
          :name   => platform_params[:libvirt_service_name],
          :tag    => ['libvirt-service', 'libvirt-qemu-service'],
        )
        is_expected.to contain_service('virtlogd').with(
          :ensure => 'running',
          :enable => true,
          :name   => platform_params[:virtlog_service_name],
          :tag    => ['libvirt-service'],
        )
        is_expected.to contain_service('virtlockd').with(
          :ensure => 'running',
          :enable => true,
          :name   => platform_params[:virtlock_service_name],
          :tag    => ['libvirt-service'],
        )
      end

      it 'deploys modular libvirt services' do
        is_expected.to contain_package('virtsecret').with(
          :ensure => 'present',
          :name   => platform_params[:virtsecret_package_name],
          :tag    => ['openstack', 'nova-support-package'],
        )
        is_expected.to contain_package('virtnodedev').with(
          :ensure => 'present',
          :name   => platform_params[:virtnodedev_package_name],
          :tag    => ['openstack', 'nova-support-package'],
        )
        is_expected.to contain_package('virtqemu').with(
          :ensure => 'present',
          :name   => platform_params[:virtqemu_package_name],
          :tag    => ['openstack', 'nova-support-package'],
        )
        is_expected.to contain_package('virtstorage').with(
          :ensure => 'present',
          :name   => platform_params[:virtstorage_package_name],
          :tag    => ['openstack', 'nova-support-package'],
        )

        is_expected.to contain_service('virtsecretd').with(
          :ensure => 'running',
          :enable => true,
          :name   => platform_params[:virtsecret_service_name],
          :tag    => ['libvirt-service', 'libvirt-modular-service'],
        )
        is_expected.to contain_service('virtnodedevd').with(
          :ensure => 'running',
          :enable => true,
          :name   => platform_params[:virtnodedev_service_name],
          :tag    => ['libvirt-service', 'libvirt-modular-service'],
        )
        is_expected.to contain_service('virtqemud').with(
          :ensure => 'running',
          :enable => true,
          :name   => platform_params[:virtqemu_service_name],
          :tag    => ['libvirt-service', 'libvirt-qemu-service', 'libvirt-modular-service'],
        )
        is_expected.to contain_service('virtproxyd').with(
          :ensure => 'running',
          :enable => true,
          :name   => platform_params[:virtproxy_service_name],
          :tag    => ['libvirt-service', 'libvirt-modular-service'],
        )
        is_expected.to contain_service('virtnodedevd').with(
          :ensure => 'running',
          :enable => true,
          :name   => platform_params[:virtnodedev_service_name],
          :tag    => ['libvirt-service', 'libvirt-modular-service'],
        )
        is_expected.to contain_service('virtstoraged').with(
          :ensure => 'running',
          :enable => true,
          :name   => platform_params[:virtstorage_service_name],
          :tag    => ['libvirt-service', 'libvirt-modular-service'],
        )
      end
    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

      let :platform_params do
        case facts[:os]['family']
        when 'Debian'
          {
            :libvirt_package_name        => 'libvirt-daemon-system',
            :libvirt_service_name        => 'libvirtd',
            :virtlock_service_name       => 'virtlockd',
            :virtlog_service_name        => 'virtlogd',
            :ovmf_package_name           => 'ovmf',
            :swtpm_package_name          => 'swtpm'
          }
        when 'RedHat'
          {
            :libvirt_package_name          => 'libvirt-daemon-kvm',
            :libvirt_daemon_package_name   => 'libvirt-daemon',
            :libvirt_service_name          => 'libvirtd',
            :virtlock_service_name         => 'virtlockd',
            :virtlog_service_name          => 'virtlogd',
            :virtsecret_package_name       => 'libvirt-daemon-driver-secret',
            :virtnodedev_package_name      => 'libvirt-daemon-driver-nodedev',
            :virtqemu_package_name         => 'libvirt-daemon-driver-qemu',
            :virtstorage_package_name      => 'libvirt-daemon-driver-storage',
            :virtsecret_service_name       => 'virtsecretd.socket',
            :virtnodedev_service_name      => 'virtnodedevd.socket',
            :virtqemu_service_name         => 'virtqemud.socket',
            :virtproxy_service_name        => 'virtproxyd.socket',
            :virtstorage_service_name      => 'virtstoraged.socket',
            :ovmf_package_name             => 'edk2-ovmf',
            :swtpm_package_name            => 'swtpm'
          }
        end
      end

      let :params do
        {}
      end

      it_configures 'nova compute libvirt services'
      if facts[:os]['family'] == 'Debian'
        # NOTE(tkajinam): Debian family uses monolithic libvirt by default, and
        #                 does not support modular libvirt
        it_configures 'nova compute libvirt services with monolithic libvirt'
      else
        # NOTE(tkajinam): RedHat family uses modular libvirt by default
        it_configures 'nova compute libvirt services with modular libvirt'

        context 'with modular libvirt disabled' do
          before :each do
            params.merge!({ :modular_libvirt => false })
          end
          it_configures 'nova compute libvirt services with monolithic libvirt'
        end
      end
    end
  end
end