Skip to content

Commit

Permalink
Merge pull request #1093 from yast/bsc-1174643-import-hosts
Browse files Browse the repository at this point in the history
bsc#1174643: do not crash AutoYaST when <host> is present
  • Loading branch information
imobachgs committed Jul 29, 2020
2 parents 00f05b6 + fe2e591 commit 7539782
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 70 deletions.
7 changes: 7 additions & 0 deletions package/yast2-network.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Jul 29 10:47:01 UTC 2020 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- AutoYaST: do not crash when the <host> section is present
(bsc#1174643).
- 4.3.15

-------------------------------------------------------------------
Tue Jul 28 08:45:12 UTC 2020 - Knut Anderssen <kanderssen@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-network.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-network
Version: 4.3.14
Version: 4.3.15
Release: 0
Summary: YaST2 - Network Configuration
License: GPL-2.0-only
Expand Down
69 changes: 2 additions & 67 deletions src/lib/network/network_autoyast.rb
Expand Up @@ -138,25 +138,8 @@ def activate_s390_devices(section = nil)
#
# If the installer is running in 1st stage mode only, then the configuration
# is also written
#
# @param [Boolean] write forces instant writing of the configuration
# @return [Boolean] true when configuration was present and loaded from the profile
def configure_hosts(write: false)
log.info("NetworkAutoYast: Hosts configuration")

if ay_host_section.empty?
Host.Write(gui: false)

return true
end

hosts_config = (ay_host_section["hosts"] || {}).map do |host|
# we need to guarantee order of the items here
[host["host_address"] || "", host["names"] || []]
end
hosts_config = hosts_config.to_h.delete_if { |k, v| k.empty? || v.empty? }

configure_submodule(Host, "hosts" => hosts_config, write: write)
def configure_hosts
Host.Write(gui: false)
end

# Checks if the profile asks for keeping installation network configuration
Expand All @@ -172,10 +155,6 @@ def keep_net_config?
# @return [Hash] networking section hash
attr_writer :ay_networking_section

# setter for host section. Should be done during import.
# @return [Hash] host section hash
attr_writer :ay_host_section

private

# Merges two maps with dns related values.
Expand Down Expand Up @@ -222,49 +201,5 @@ def merge_routing(instsys_routing, ay_routing)
def ay_networking_section
@ay_networking_section || {}
end

# Returns host section of the current AY profile
#
# Note that autoyast transforms the host's subsection
# into:
# {
# hosts => [
# # first <host_entry>
# {
# "host_address" => <ip>,
# "names" => [list, of, names]
# }
# # second <host_entry>
# ...
# ]
# }
#
# return <Hash> with hosts configuration
def ay_host_section
@ay_host_section || {}
end

# Configures given yast submodule according AY configuration
#
# It takes data from AY profile transformed into a format expected by the YaST
# sub module's Import method.
#
# It imports the profile, configures the module and writes the configuration.
# Writing the configuration is optional when second stage is available and mandatory
# when running autoyast installation with first stage only.
def configure_submodule(yast_module, ay_config, write: false)
return false if !ay_config

yast_module.Import(ay_config)

# Results of imported values semantic check.
# Return true in order to not call the NetworkAutoconfiguration.configure_hosts
return true unless AutoInstall.valid_imported_values

log.info("Write configuration instantly: #{write}")
yast_module.Write(gui: false) if write

true
end
end
end
2 changes: 0 additions & 2 deletions src/modules/Host.rb
Expand Up @@ -160,8 +160,6 @@ def Import(settings)
set_names(ip, names)
end

NetworkAutoYast.instance.ay_host_section = settings

true
end

Expand Down

0 comments on commit 7539782

Please sign in to comment.