File: nova_compute_pci_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 (98 lines) | stat: -rw-r--r-- 2,778 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
require 'spec_helper'

describe 'nova::compute::pci' do

  shared_examples_for 'nova-compute-pci' do
    context 'with default parameters' do
      it 'configures default values' do
        is_expected.to contain_nova_config('pci/device_spec').with(:value => '<SERVICE DEFAULT>')
        is_expected.to contain_nova_config('pci/report_in_placement').with(:value => '<SERVICE DEFAULT>')
      end
    end

    context 'with parameters' do
      let :params do
        {
          :report_in_placement => true
        }
      end

      it 'configures given values' do
        is_expected.to contain_nova_config('pci/report_in_placement').with(:value => true)
      end
    end

    context 'with passthrough array' do
      let :params do
        {
            :passthrough => [
            {
              "vendor_id"  => "8086",
              "product_id" => "0126"
            },
            {
              "vendor_id"        => "9096",
              "product_id"       => "1520",
              "physical_network" => "physnet1"
            }
          ],
        }
      end
      it 'configures nova pci device_spec entries' do
        is_expected.to contain_nova_config('pci/device_spec').with(
          'value' => ['{"vendor_id":"8086","product_id":"0126"}','{"vendor_id":"9096","product_id":"1520","physical_network":"physnet1"}']
        )
      end
    end

    context 'with passthrough JSON encoded string' do
      let :params do
        {
          :passthrough => "[{\"vendor_id\":\"8086\",\"product_id\":\"0126\"},{\"vendor_id\":\"9096\",\"product_id\":\"1520\",\"physical_network\":\"physnet1\"}]",
        }
      end

      it 'configures nova pci device_spec entries' do
        is_expected.to contain_nova_config('pci/device_spec').with(
          'value' => ['{"vendor_id":"8086","product_id":"0126"}','{"vendor_id":"9096","product_id":"1520","physical_network":"physnet1"}']
        )
      end
    end

    context 'when passthrough is empty' do
      let :params do
        {
          :passthrough => []
        }
      end

      it 'clears pci device_spec configuration' do
        is_expected.to contain_nova_config('pci/device_spec').with(:value => '<SERVICE DEFAULT>')
      end
    end

    context 'when passthrough is empty string' do
      let :params do
        {
          :passthrough => ""
        }
      end

      it 'clears pci device_spec configuration' do
        is_expected.to contain_nova_config('pci/device_spec').with(:value => '<SERVICE DEFAULT>')
      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

      it_configures 'nova-compute-pci'
    end
  end
end