File: provider.pp

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 (103 lines) | stat: -rw-r--r-- 3,271 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
# == Class: nova::compute::provider
#
# Managing Resource Providers Using Config File
#
# === Parameters
#
# [*schema_version*]
#   (optional) Version ($Major, $minor) of the schema must successfully
#   parse documents conforming to ($Major, *)
#   Default to '1.0'
#
# [*custom_inventories*]
#   Array of hashes describing the custom provider inventory added via
#   the $config_file config file.
#   Format:
#   name/uuid - Resource providers to target can be identified by either
#   UUID or name. In addition, the value $COMPUTE_NODE can be used in
#   the UUID field to identify all nodes managed by the service.
#   Exactly one of uuid or name is mandatory. If neither uuid or name
#   is provided, the special uuid $COMPUTE_NODE gets set in the template
#
#   inventories - (Optional) Hash of custom provider inventories. 'total' is
#   a mandatory property. Any other optional properties not populated will
#   be given a default value by placement. If overriding a pre-existing
#   provider values will not be preserved from the existing inventory.
#
#   traits - (Optional) Array of additional traits.
#
#   Example :
#   [
#     {
#       uuid => '$COMPUTE_NODE',
#       inventories => {
#         'CUSTOM_EXAMPLE_RESOURCE_CLASS' => {
#           total            => '100',
#           reserved         => '0',
#           min_unit         => '1',
#           max_unit         => '10',
#           step_size        => '1',
#           allocation_ratio => '1.0'
#         },
#         'CUSTOM_ANOTHER_EXAMPLE_RESOURCE_CLASS' => {
#           total            => '100',
#         },
#       },
#       traits => ['CUSTOM_P_STATE_ENABLED','CUSTOM_C_STATE_ENABLED'],
#     },
#     {
#       name => 'EXAMPLE_RESOURCE_PROVIDER',
#       inventories => {
#         'CUSTOM_EXAMPLE_RESOURCE_CLASS' => {
#           total            => '10000',
#           reserved         => '100',
#         },
#       },
#     },
#   ]
#   Defaults to [].
#
# [*config_location*]
#   (Optional) Location of YAML files containing resource provider
#   configuration data.
#   Defaults to /etc/nova/provider_config
#
# [*config_file*]
#   (Optional) File name of the provider YAML file.
#   Defaults to 'provider.yaml'
#
class nova::compute::provider (
  $schema_version                                 = '1.0',
  Array[Hash[String[1], Any]] $custom_inventories = [],
  Stdlib::Absolutepath $config_location           = '/etc/nova/provider_config',
  String[1] $config_file                          = 'provider.yaml',
) {

  include nova::deps
  include nova::params

  nova_config {
    'compute/provider_config_location':  value => $config_location;
  }

  file { "${config_location}":
    ensure  => directory,
    mode    => '0750',
    owner   => $::nova::params::user,
    group   => $::nova::params::group,
    require => Anchor['nova::config::begin'],
    before  => Anchor['nova::config::end'],
  }

  if !empty($custom_inventories) {
    file { "${config_location}/${config_file}":
      ensure  => file,
      mode    => '0640',
      owner   => $::nova::params::user,
      group   => $::nova::params::group,
      content => template('nova/provider.yaml.erb'),
      require => Anchor['nova::config::begin'],
      notify  => Anchor['nova::config::end'],
    }
  }
}