Skip to content

Commit

Permalink
Canonicalize the ZONE attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Feb 6, 2019
1 parent 4a8ead1 commit 5de3cb9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions library/network/src/modules/NetworkInterfaces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,8 @@ def ConcealSecrets(devs)
deep_copy(out)
end

# Canonicalize IPADDR and STARTMODE of given config
# and nested _aliases
# Canonicalize IPADDR, ZONE and STARTMODE of given config
# and also the IPADRR of nested _aliases
#
# @param [Hash] config a map with netconfig (ifcfg) configuration
# @return [Hash] ifcfg with canonicalized IP addresses
Expand All @@ -606,9 +606,19 @@ def canonicalize_config(config)
end

config = CanonicalizeIP(config)
canonicalize_firewall_zone!(config)
CanonicalizeStartmode(config)
end

# Convenient method to canonicalize the ZONE attribute using the :default
# key when ZONE is defined and empty
#
# @param config [Hash] netconfig (ifcfg) configuration
def canonicalize_firewall_zone!(config)
config["ZONE"] = :default if config.has_key?("ZONE") && config["ZONE"].to_s.strip.empty?
config
end

# Variables which could be suffixed and thus duplicated
LOCALS = [
"IPADDR",
Expand Down Expand Up @@ -866,6 +876,7 @@ def Write(devregex)
end
end
# write all keys to config
devmap["ZONE"] = "" if devmap.dig("ZONE") == :default
Builtins.maplist(
Convert.convert(
Map.Keys(devmap),
Expand Down Expand Up @@ -982,6 +993,7 @@ def Import(devregex, devices)
) do |num, config|
config = CanonicalizeIP(config)
config = CanonicalizeStartmode(config)
canonicalize_firewall_zone!(config)
{ num => config }
end
}
Expand Down

0 comments on commit 5de3cb9

Please sign in to comment.