Skip to content

Commit

Permalink
Made DNS::Write in 1st stage dependent on "second_stage" option
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Jul 11, 2017
1 parent 4bcc266 commit be868cb
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions src/lib/network/network_autoyast.rb
Expand Up @@ -106,24 +106,26 @@ def set_network_service

# Initializates DNS setup according AY profile
#
# FIXME: it currently doesn't write DNS configuration. It is used for initialization
# of DNS setup according AY profile in 1st stage as part of network setup was moved
# here already and some parts of network configuration needs to know it. DNS write
# is still done in 2nd stage.
# 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_dns
def configure_dns(write: false)
ay_dns_config = ay_networking_section["dns"]

return false if !ay_dns_config

DNS.Import(ay_dns_config)

write ||= !ay_general_section.fetch("mode", { "second_stage" => true })["second_stage"]

log.info("NetworkAutoYast: DNS / Hostname configuration")
log.info("dhcp hostname: #{DNS.dhcp_hostname}")
log.info("write hostname: #{DNS.write_hostname}")
log.info("Write configuration instantly: #{write}")

DNS.Write(gui: false)
DNS.Write(gui: false) if write

true
end
Expand Down Expand Up @@ -208,16 +210,30 @@ def merge_routing(instsys_routing, ay_routing)
instsys_routing.merge(ay_routing)
end

# Returns networking section of current AY profile
def ay_networking_section
# Returns current AY profile in the internal representation
#
# @return [Hash] hash representing current profile or empty hash
def ay_current_profile
Yast.import "Profile"

ay_profile = Profile.current

return {} if ay_profile.nil? || ay_profile.empty?
return {} if ay_profile["networking"].nil?
return ay_profile
end

# Returns networking section of current AY profile
def ay_networking_section
return {} if ay_current_profile["networking"].nil?

ay_current_profile["networking"]
end

# Returns global section of current AY profile
def ay_general_section
return {} if ay_current_profile["general"].nil?

ay_profile["networking"]
ay_current_profile["general"]
end

# Checks if the udev rule is valid for renaming a NIC
Expand Down

0 comments on commit be868cb

Please sign in to comment.