Refactor is_public handling
Consistently use sym instead of mixing string/boolean. Change-Id: I0253a4fb7b13c0425203dddd5df1766ddc673192 Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
@@ -8,8 +8,4 @@ class Puppet::Provider::Glance < Puppet::Provider::Openstack
|
||||
|
||||
extend Puppet::Provider::Openstack::Auth
|
||||
|
||||
def bool_to_sym(bool)
|
||||
bool == true ? :true : :false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -74,7 +74,7 @@ Puppet::Type.type(:glance_image).provide(
|
||||
@property_hash = {
|
||||
:ensure => :present,
|
||||
:name => attrs[:name],
|
||||
:is_public => attrs[:visibility].downcase.chomp == 'public'? true : false,
|
||||
:is_public => attrs[:visibility].downcase.chomp == 'public'? :true : :false,
|
||||
:container_format => attrs[:container_format],
|
||||
:id => attrs[:id],
|
||||
:disk_format => attrs[:disk_format],
|
||||
@@ -100,12 +100,12 @@ Puppet::Type.type(:glance_image).provide(
|
||||
@property_hash.clear
|
||||
end
|
||||
|
||||
mk_resource_methods
|
||||
|
||||
def is_public
|
||||
bool_to_sym(@property_hash[:is_public])
|
||||
@property_hash[:is_public]
|
||||
end
|
||||
|
||||
mk_resource_methods
|
||||
|
||||
[
|
||||
:is_public,
|
||||
:disk_format,
|
||||
@@ -134,7 +134,7 @@ Puppet::Type.type(:glance_image).provide(
|
||||
new(
|
||||
:ensure => :present,
|
||||
:name => attrs[:name],
|
||||
:is_public => attrs[:visibility].downcase.chomp == 'public'? true : false,
|
||||
:is_public => attrs[:visibility].downcase.chomp == 'public'? :true : :false,
|
||||
:container_format => attrs[:container_format],
|
||||
:id => attrs[:id],
|
||||
:disk_format => attrs[:disk_format],
|
||||
|
||||
@@ -41,14 +41,13 @@ Puppet::Type.newtype(:glance_image) do
|
||||
newproperty(:is_public) do
|
||||
desc "Whether the image is public or not. Default true"
|
||||
newvalues(/(y|Y)es/, /(n|N)o/, /(t|T)rue/, /(f|F)alse/, true, false)
|
||||
defaultto(true)
|
||||
munge do |v|
|
||||
if v =~ /^(y|Y)es$/
|
||||
defaultto(:true)
|
||||
munge do |value|
|
||||
case value.to_s.downcase
|
||||
when 'true', 'yes'
|
||||
:true
|
||||
elsif v =~ /^(n|N)o$/
|
||||
:false
|
||||
else
|
||||
v.to_s.downcase.to_sym
|
||||
:false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user