Skip to content

Commit

Permalink
Changes based on CR
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Apr 9, 2021
1 parent fe85147 commit 93171cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/lib/y2network/boot_protocol.rb
Expand Up @@ -43,6 +43,7 @@ def from_name(name)

# @return [String] Returns protocol name
attr_reader :name
alias_method :to_s, :name

# Constructor
#
Expand Down
14 changes: 10 additions & 4 deletions src/lib/y2network/wicked/connection_config_writers/base.rb
Expand Up @@ -43,12 +43,12 @@ def initialize(file)
#
# @param conn [Y2Network::ConnectionConfig::Base] Connection to take settings from
def write(conn)
file.bootproto = value_as_string(conn.bootproto&.name)
file.bootproto = value_as_string(conn.bootproto.to_s)
file.name = value_as_string(conn.description)
file.lladdr = value_as_string(conn.lladdress)
file.startmode = value_as_string(conn.startmode.to_s)
file.dhclient_set_hostname = value_as_string(dhclient_set_hostname(conn))
file.ifplugd_priority = conn.startmode.priority if conn.startmode&.name == "ifplugd"
file.ifplugd_priority = conn.startmode.priority if conn.startmode.to_s == "ifplugd"
file.ethtool_options = value_as_string(conn.ethtool_options)
file.zone = value_as_string(conn.firewall_zone)
file.mtu = value_as_string(conn.mtu)
Expand Down Expand Up @@ -83,7 +83,7 @@ def dhclient_set_hostname(conn)
def add_ips(conn)
file.ipaddrs.clear
ips_to_add = conn.ip_aliases.clone
ips_to_add << conn.ip if static_ip?(conn)
ips_to_add << conn.ip if static_valid_ip?(conn)
ips_to_add.each { |i| add_ip(i) }
end

Expand All @@ -107,8 +107,14 @@ def add_hostname(conn)
Yast::Host.Update("", conn.hostname, conn.ip.address.address.to_s)
end


# Convenience method to check whether a connection is configured using
# the static bootproto and a valid IP address.
#
# @param conn [Y2Network::ConnectionConfig::Base] Connection to take settings from
def static_ip?(conn)
# @return [Boolean] whether the connection is configured with a valid
# static IP address or not
def static_valid_ip?(conn)
return false unless conn.bootproto.static?

conn.ip && conn.ip.address.address.to_s != "0.0.0.0"
Expand Down

0 comments on commit 93171cb

Please sign in to comment.