File: policy.pp

package info (click to toggle)
puppet-module-swift 25.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,400 kB
  • sloc: ruby: 9,593; python: 38; sh: 10; makefile: 10
file content (99 lines) | stat: -rw-r--r-- 3,115 bytes parent folder | download | duplicates (3)
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
# Class swift::storage::policy
#
# Setting any optional parameter to undef will remove it
# from the storage policy defined in swift.conf.
#
# == Parameters
#  [*ensure*]
#    (optional) To ensure a storage policy exists in swift.conf
#    set to 'present'.  To remove a storage policy from swift.conf
#    set to 'absent'.
#    Defaults to 'present'
#
#  [*policy_name*]
#    (required) Storage policy name in swift.conf
#    Names and aliases must be unique across all policies.
#
#  [*default_policy*]
#    (optional) Boolean to specify if this is the default storage policy
#    Defaults to true
#
#  [*policy_aliases*]
#    (optional) A comma separated string of aliases to use for this storage
#    policy. ex: 'gold, silver, taco' Names and aliases must be unique across
#    all policies.
#    Defaults to undef.
#
#  [*policy_index*]
#    (required) storage policy index. Becomes a storage policy section
#    header in swift.conf.
#    Defaults to '0'
#
#  [*policy_type*]
#    (required) Storage policy type. Can be 'replication' or 'erasure_coding'
#    Defaults 'replication'.
#
#  [*deprecated*]
#    (optional) Any policy may be deprecated by setting deprecated = yes.
#    Choices are 'yes', 'no', undef
#    Defaults to undef
#
#  [*ec_type*]
#    (optional) Specifies the EC scheme that is to be used
#    Defaults to undef
#
#  [*ec_num_data_fragments*]
#    (optional) The total number of fragments that will be
#    comprised of data.
#    Defaults to undef
#
#  [*ec_num_parity_fragments*]
#    (optional) The total number of fragments that will be
#    comprised of parity.
#    Defaults to undef
#
#  [*ec_object_segment_size*]
#    (optional) The amount of data that will be buffered up before
#    feeding a segment into the encoder/decoder in bytes.
#    Defaults to undef
#
define swift::storage::policy(
  $policy_name,
  $default_policy,
  $ensure                  = 'present',
  $policy_aliases          = undef,
  $policy_index            = $name,
  $policy_type             = 'replication',
  $deprecated              = undef,
  $ec_type                 = undef,
  $ec_num_data_fragments   = undef,
  $ec_num_parity_fragments = undef,
  $ec_object_segment_size  = undef,
) {

  include swift::deps

  Swift_storage_policy<| |> ~> Service<| tag == 'swift-service' |>

  if (downcase($policy_name) == 'policy-0') and ($policy_index != '0') {
    fail('The name Policy-0 can only be used with policy index 0')
  }

  if ($default_policy == true) and ($deprecated == 'yes') {
    fail('a deprecated policy may not also be declared the default')
  }

  swift_storage_policy { $policy_index:
    ensure                  => $ensure,
    policy_name             => $policy_name,
    aliases                 => $policy_aliases,
    policy_type             => $policy_type,
    default                 => bool2str($default_policy),
    deprecated              => $deprecated,
    ec_type                 => $ec_type,
    ec_num_data_fragments   => $ec_num_data_fragments,
    ec_num_parity_fragments => $ec_num_parity_fragments,
    ec_object_segment_size  => $ec_object_segment_size,
  }

}