openstackconfig idempotency fix
- fixed idempotency issues with single string values - fixed deletion of multiple values This patch is required for I95cf32c3211bc4498eaa68e6e748a27dfd9af0fa to pass acceptance tests Change-Id: I619de3038cd2690bebe47cd601c085692506ac3d
This commit is contained in:
parent
b3f0b0a810
commit
3e43f5ddcf
@ -53,7 +53,12 @@ Puppet::Type.type(:openstack_config).provide(:ruby) do
|
||||
end
|
||||
|
||||
def value
|
||||
config.get_value(section, setting)
|
||||
val = config.get_value(section, setting)
|
||||
if !val.kind_of?(Array)
|
||||
[val]
|
||||
else
|
||||
val
|
||||
end
|
||||
end
|
||||
|
||||
def section
|
||||
|
@ -102,7 +102,7 @@ class OpenStackConfig
|
||||
if value.nil? or @settings[setting_name] == value
|
||||
@settings.delete(setting_name)
|
||||
else
|
||||
value.eafach do |val|
|
||||
value.each do |val|
|
||||
@settings[setting_name].delete(val)
|
||||
end
|
||||
end
|
||||
@ -134,13 +134,19 @@ class OpenStackConfig
|
||||
end
|
||||
|
||||
def remove_lines(setting_name, value=nil)
|
||||
@lines.each_with_index do |line, index|
|
||||
if (match = @@SETTING_REGEX.match(line))
|
||||
if match[2] == setting_name
|
||||
if value.nil? or (
|
||||
value.kind_of?(Array) and value.include?(match[4])
|
||||
)
|
||||
lines.delete_at(index)
|
||||
if value.kind_of?(Array)
|
||||
val_arr = value
|
||||
else
|
||||
val_arr = [value]
|
||||
end
|
||||
val_arr.each do |val|
|
||||
@lines.each_with_index do |line, index|
|
||||
if (match = @@SETTING_REGEX.match(line))
|
||||
if match[2] == setting_name
|
||||
if val.nil? or val_arr.include?(match[4])
|
||||
@lines.delete_at(index)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user