diff options
author | James Shubin <james@shubin.ca> | 2014-01-24 18:50:20 -0500 |
---|---|---|
committer | James Shubin <james@shubin.ca> | 2014-01-24 18:50:20 -0500 |
commit | 7448b4712fda8c0a9c982d5b3a66846b2e92d0e6 (patch) | |
tree | 120e7b7614cc5555f06278a4ac82f5c0539f1439 /manifests/volume/property.pp | |
parent | 221e3049f04fb608d013d7092bcfb258010b2d6d (diff) | |
download | puppet-gluster-7448b4712fda8c0a9c982d5b3a66846b2e92d0e6.tar.gz puppet-gluster-7448b4712fda8c0a9c982d5b3a66846b2e92d0e6.tar.xz puppet-gluster-7448b4712fda8c0a9c982d5b3a66846b2e92d0e6.zip |
Add support for more volume options.
Diffstat (limited to 'manifests/volume/property.pp')
-rw-r--r-- | manifests/volume/property.pp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/manifests/volume/property.pp b/manifests/volume/property.pp index f0b8add..d7650f1 100644 --- a/manifests/volume/property.pp +++ b/manifests/volume/property.pp @@ -56,6 +56,52 @@ define gluster::volume::property( } $safe_value = shellquote($value) # TODO: is this the safe thing? + # if it's a special offon type and of an acceptable value + } elsif ($etype == 'offon') { # default is off + if type($value) == 'boolean' { + $safe_value = $value ? { + true => 'on', + default => 'off', + } + + } elsif type($value) == 'string' { + $downcase_value = inline_template('<%= @value.downcase %>') + $safe_value = $downcase_value ? { + 'on' => 'on', + #'off' => 'off', + default => 'off', + } + + } else { + fail("Gluster::Volume::Property[${key}] must be type: ${etype}.") + } + + # if it's a special onoff type and of an acceptable value + } elsif ($etype == 'onoff') { # default is on + if type($value) == 'boolean' { + $safe_value = $value ? { + false => 'off', + default => 'on', + } + + } elsif type($value) == 'string' { + $downcase_value = inline_template('<%= @value.downcase %>') + $safe_value = $downcase_value ? { + 'off' => 'off', + #'on' => 'on', + default => 'on', + } + + } else { + fail("Gluster::Volume::Property[${key}] must be type: ${etype}.") + } + } elsif $etype == 'integer' { + # TODO: we could also add range and/or set validation + $safe_value = inline_template('<%= [Fixnum, String].include?(@value.class) ? @value.to_i : "null" %>') + if "${safe_value}" == 'null' { # value was of an invalid type! + fail("Gluster::Volume::Property[${key}] must be type: ${etype}.") + } + # if it's not a string and it's not the expected type, fail } elsif ( type($value) != $etype ) { # type() from puppetlabs-stdlib fail("Gluster::Volume::Property[${key}] must be type: ${etype}.") |