Skip to content

Commit

Permalink
add zone to ifcfg file
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Sep 3, 2019
1 parent 68f45e9 commit f03bb36
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/lib/y2network/connection_config/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class Base
attr_accessor :lladdress
# @return [String] configuration for ethtools when initializing
attr_accessor :ethtool_options
# @return [String] assigned firewall zone to interface
attr_accessor :firewall_zone

# Constructor
def initialize
Expand All @@ -65,6 +67,7 @@ def initialize
@startmode = Startmode.create("manual")
@description = ""
@ethtool_options = ""
@firewall_zone = ""
end

# Propose reasonable defaults for given config. Useful for newly created devices.
Expand Down
4 changes: 3 additions & 1 deletion src/lib/y2network/interface_config_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def save
yast_config.connections.add_or_update(@connection_config)
yast_config.rename_interface(@old_name, name, renaming_mechanism) if renamed_interface?

# write to ifcfg always and to firewalld only when available
@connection_config.firewall_zone = firewall_zone
# create new instance as name can change
firewall_interface = Y2Firewall::Firewalld::Interface.new(name)
if Y2Firewall::Firewalld.instance.installed?
Expand Down Expand Up @@ -191,7 +193,7 @@ def firewall_zone

# TODO: handle renaming
firewall_interface = Y2Firewall::Firewalld::Interface.new(name)
@firewall_zone = firewall_interface.zone && firewall_interface.zone.name
@firewall_zone = (firewall_interface.zone && firewall_interface.zone.name) || @connection_config.firewall_zone
end

# sets assigned firewall zone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def connection_config
conn.startmode = Startmode.create(file.startmode || "manual")
conn.startmode.priority = file.ifplugd_priority if conn.startmode.name == "ifplugd"
conn.ethtool_options = file.ethtool_options
conn.firewall_zone = file.zone
update_connection_config(conn)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def write(conn)
file.startmode = conn.startmode.to_s
file.ifplugd_priority = conn.startmode.priority if conn.startmode.name == "ifplugd"
file.ethtool_options = conn.ethtool_options unless conn.ethtool_options.empty?
file.zone = conn.firewall_zone
add_ips(conn)
update_file(conn)
end
Expand Down
4 changes: 4 additions & 0 deletions src/lib/y2network/sysconfig/interface_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ def variable_name(param_name)
# @return [String] setting variables on device activation. See man ethtool
define_variable(:ethtool_options)

# !@attribute [r] zone
# @return [String] assign zone to interface. Extensions then can handle it
define_variable(:zone)

# !@attribute [r] wireless_key_length
# @return [Integer] Length in bits for all keys used
define_variable(:wireless_key_length, :integer)
Expand Down

0 comments on commit f03bb36

Please sign in to comment.