Skip to content

Commit

Permalink
Merge pull request #1117 from mchf/bnc1175360
Browse files Browse the repository at this point in the history
Minor fixes in AY import
  • Loading branch information
mchf committed Nov 3, 2020
2 parents 8aea1f3 + bc4c976 commit 0c0d9d3
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 9 deletions.
11 changes: 11 additions & 0 deletions package/yast2-network.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
-------------------------------------------------------------------
Tue Oct 13 12:57:36 UTC 2020 - Michal Filka <mfilka@suse.com>

- bnc#1175360
- more robust AY profile parser. Do not crash with internal error
on unknown node in interfaces section
- support for static configurations without ip address
- bnc#1175206
- support for defined default when missing bootproto in AY
- 4.2.83

-------------------------------------------------------------------
Wed Oct 7 11:45:04 UTC 2020 - Knut Anderssen <kanderssen@suse.com>

Expand Down
2 changes: 1 addition & 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.2.82
Version: 4.2.83
Release: 0
Summary: YaST2 - Network Configuration
License: GPL-2.0-only
Expand Down
10 changes: 8 additions & 2 deletions src/lib/y2network/autoinst/interfaces_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,14 @@ def load_generic(config, interface_section)
config.name = name_from_section(interface_section)
config.interface = config.name # in autoyast name and interface is same
if config.bootproto == BootProtocol::STATIC
# TODO: report if ipaddr missing for static config
ipaddr = IPAddress.from_string(interface_section.ipaddr)
if !interface_section.ipaddr
msg = "Configuration for #{config.name} is invalid #{interface_section.inspect}"
raise ArgumentError, msg
end

if !interface_section.ipaddr.empty?
ipaddr = IPAddress.from_string(interface_section.ipaddr)
end
# Assign first netmask, as prefixlen has precedence so it will overwrite it
ipaddr.netmask = interface_section.netmask if !interface_section.netmask.to_s.empty?
if !interface_section.prefixlen.to_s.empty?
Expand Down
8 changes: 5 additions & 3 deletions src/lib/y2network/autoinst_profile/interface_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,13 @@ def init_from_hashes(hash)
# @param config [Y2Network::ConnectionConfig]
# @return [Boolean]
def init_from_config(config)
@bootproto = config.bootproto.name
# nil bootproto is valid use case (missing explicit setup) - wicked defaults to static then
@bootproto = config.bootproto&.name
@name = config.name
if config.bootproto == BootProtocol::STATIC && config.ip
@ipaddr = config.ip.address.address.to_s
@prefixlen = config.ip.address.prefix.to_s
# missing ip is valid scenario for wicked - so use empty string here
@ipaddr = config.ip.address&.address.to_s
@prefixlen = config.ip.address&.prefix.to_s
@remote_ipaddr = config.ip.remote_address.address.to_s if config.ip.remote_address
@broadcast = config.ip.broadcast.address.to_s if config.ip.broadcast
end
Expand Down
4 changes: 3 additions & 1 deletion src/lib/y2network/autoinst_profile/interfaces_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def initialize(*_args)
#
# @param hash [Array] see {.new_from_hashes}. In this case it is array of interfaces
def init_from_hashes(hash)
@interfaces = interfaces_from_hash(hash)
# we expect list of hashes here, remove everything else
h = hash.delete_if { |v| !v.is_a?(Hash) }
@interfaces = interfaces_from_hash(h)
end

# Method used by {.new_from_network} to populate the attributes when cloning routing settings
Expand Down
2 changes: 1 addition & 1 deletion src/lib/y2network/boot_protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def all
# Returns the boot protocol with a given name
#
# @param name [String]
# @return [BootProtocol,nil] Boot protocol or nil is not found
# @return [BootProtocol,nil] Boot protocol or nil if not found
def from_name(name)
all.find { |t| t.name == name }
end
Expand Down
1 change: 1 addition & 0 deletions src/lib/y2network/clients/auto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def import(profile)
end

Yast::Lan.Import(modified_profile)

true
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def initialize(file)
#
# @param conn [Y2Network::ConnectionConfig::Base] Connection to take settings from
def write(conn)
file.bootproto = conn.bootproto.name
file.bootproto = conn.bootproto&.name
file.name = conn.description
file.lladdr = conn.lladdress
file.startmode = conn.startmode.to_s
Expand Down

0 comments on commit 0c0d9d3

Please sign in to comment.