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
|
end
|
||||||
|
|
||||||
def value
|
def value
|
||||||
config.get_value(section, setting)
|
val = config.get_value(section, setting)
|
||||||
|
if !val.kind_of?(Array)
|
||||||
|
[val]
|
||||||
|
else
|
||||||
|
val
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def section
|
def section
|
||||||
|
@ -102,7 +102,7 @@ class OpenStackConfig
|
|||||||
if value.nil? or @settings[setting_name] == value
|
if value.nil? or @settings[setting_name] == value
|
||||||
@settings.delete(setting_name)
|
@settings.delete(setting_name)
|
||||||
else
|
else
|
||||||
value.eafach do |val|
|
value.each do |val|
|
||||||
@settings[setting_name].delete(val)
|
@settings[setting_name].delete(val)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -134,13 +134,19 @@ class OpenStackConfig
|
|||||||
end
|
end
|
||||||
|
|
||||||
def remove_lines(setting_name, value=nil)
|
def remove_lines(setting_name, value=nil)
|
||||||
@lines.each_with_index do |line, index|
|
if value.kind_of?(Array)
|
||||||
if (match = @@SETTING_REGEX.match(line))
|
val_arr = value
|
||||||
if match[2] == setting_name
|
else
|
||||||
if value.nil? or (
|
val_arr = [value]
|
||||||
value.kind_of?(Array) and value.include?(match[4])
|
end
|
||||||
)
|
val_arr.each do |val|
|
||||||
lines.delete_at(index)
|
@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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user