Skip to content

Commit

Permalink
Use current sysconfig readers and infer type from config
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Jul 10, 2019
1 parent fd638d4 commit 1195980
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
14 changes: 8 additions & 6 deletions src/lib/network/clients/save_network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,15 @@ def configure_hosts
# It creates a proposal in case of common installation. In case of AY
# installation it does full import of <networking> section
def configure_lan
NetworkAutoconfiguration.instance.configure_virtuals
NetworkAutoYast.instance.configure_lan if Mode.autoinst

if Mode.autoinst
NetworkAutoYast.instance.configure_lan
else
NetworkAutoconfiguration.instance.configure_dns
end
# FIXME: Really make sense to configure it in autoinst mode? At least the
# proposal should be done and checked after lan configuration and in case
# that a bridge configuratio is present in the profile it should be
# skipped or even only done in case of missing `networking -> interfaces`
# section
NetworkAutoconfiguration.instance.configure_virtuals
NetworkAutoconfiguration.instance.configure_dns unless Mode.autoinst

# this depends on DNS configuration
configure_hosts
Expand Down
20 changes: 8 additions & 12 deletions src/lib/y2network/autoinst/config_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
require "y2network/autoinst/routing_reader"
require "y2network/autoinst/dns_reader"
require "y2network/autoinst_profile/networking_section"
require "y2network/sysconfig/interfaces_reader"

Yast.import "Lan"

Expand All @@ -43,26 +44,21 @@ def initialize(section)
# @return [Y2Network::Config] Network configuration
def config
attrs = { source: :sysconfig }
attrs[:interfaces] = find_interfaces
# FIXME: implement prper readers for AutoYaST
attrs[:interfaces] = interfaces_reader.interfaces
attrs[:connections] = interfaces_reader.connections
attrs[:routing] = RoutingReader.new(section.routing).config if section.routing
attrs[:dns] = DNSReader.new(section.dns).config if section.dns
Y2Network::Config.new(attrs)
end

private

# Find configured network interfaces
# Returns an interfaces reader instance
#
# Configured interfaces have a configuration (ifcfg file) assigned.
#
# @return [Array<Interface>] Detected interfaces
# @see Yast::NetworkInterfaces.Read
def find_interfaces
Yast::NetworkInterfaces.Read
# TODO: for the time being, we are just relying in the underlying stuff.
Yast::NetworkInterfaces.List("").map do |name|
Y2Network::Interface.new(name)
end
# @return [SysconfigInterfaces] Interfaces reader
def interfaces_reader
@interfaces_reader ||= Y2Network::Sysconfig::InterfacesReader.new
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Lan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ def FromAY(input)
Builtins.foreach(interfaces) do |devname, if_data|
# devname can be in old-style fashion (eth-bus-<pci_id>). So, convert it
devname = LanItems.getDeviceName(devname)
type = NetworkInterfaces.GetType(devname)
type = NetworkInterfaces.GetTypeFromIfcfgOrName(devname, if_data)
d = Ops.get(devices, type, {})
Ops.set(d, devname, if_data)
Ops.set(devices, type, d)
Expand Down

0 comments on commit 1195980

Please sign in to comment.