Skip to content

Commit

Permalink
Merge pull request #1086 from yast/remove_profile_current
Browse files Browse the repository at this point in the history
remove direct access to profile
  • Loading branch information
jreidinger committed Jul 16, 2020
2 parents 1441831 + 738b2fb commit 92600cd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
6 changes: 6 additions & 0 deletions package/yast2-network.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Jul 15 15:10:34 UTC 2020 - Josef Reidinger <jreidinger@suse.com>

- Do not use Profile.current (bsc#1174173)
- 4.3.12

-------------------------------------------------------------------
Wed Jul 01 08:52:44 UTC 2020 - Knut Anderssen <kanderssen@suse.com>

Expand Down
5 changes: 4 additions & 1 deletion package/yast2-network.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-network
Version: 4.3.11
Version: 4.3.12
Release: 0
Summary: YaST2 - Network Configuration
License: GPL-2.0-only
Expand Down Expand Up @@ -66,6 +66,9 @@ BuildRequires: rubygem(%rb_default_ruby_abi:rspec)
# carrier detection
Conflicts: yast2-core < 2.10.6

# new calls in AutoinstGeneral
Conflicts: autoyast2 < 4.3.23

Obsoletes: yast2-network-devel-doc <= 3.1.154
Provides: yast2-network-devel-doc = %{version}

Expand Down
38 changes: 11 additions & 27 deletions src/lib/network/network_autoyast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def activate_s390_devices(section = nil)
def configure_hosts(write: false)
log.info("NetworkAutoYast: Hosts configuration")

unless ay_current_profile.key? "host"
if ay_host_section.empty?
Host.Write(gui: false)

return true
Expand All @@ -168,6 +168,14 @@ def keep_net_config?
ret
end

# setter for networking section. Should be done during import.
# @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 @@ -210,31 +218,9 @@ def merge_routing(instsys_routing, ay_routing)
instsys_routing.merge(ay_routing)
end

# 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?

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_current_profile["general"]
@ay_networking_section || {}
end

# Returns host section of the current AY profile
Expand All @@ -255,9 +241,7 @@ def ay_general_section
#
# return <Hash> with hosts configuration
def ay_host_section
return {} if ay_current_profile["host"].nil?

ay_current_profile["host"]
@ay_host_section || {}
end

# Configures given yast submodule according AY configuration
Expand Down
2 changes: 2 additions & 0 deletions src/lib/y2network/clients/auto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def change
end

def import(profile)
Yast::NetworkAutoYast.instance.ay_networking_section = profile

modified_profile = Yast::Lan.FromAY(profile)

# see bnc#498993
Expand Down
3 changes: 3 additions & 0 deletions src/modules/Host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
require "yast2/execute"
require "cfa/hosts"
require "y2network/autoinst_profile/host_section"
require "network/network_autoyast"

module Yast
class HostClass < Module
Expand Down Expand Up @@ -159,6 +160,8 @@ def Import(settings)
set_names(ip, names)
end

NetworkAutoYast.instance.ay_host_section = settings

true
end

Expand Down

0 comments on commit 92600cd

Please sign in to comment.