Class: Y2Network::ConfigWriter
- Inherits:
-
Object
- Object
- Y2Network::ConfigWriter
- Includes:
- Yast::I18n, Yast::Logger
- Defined in:
- src/lib/y2network/config_writer.rb
Overview
This class is responsible for writing the configuration to the system
It implements a #write method which receives a configuration object and apply the changes to the system. Moreover, it is possible to write partial configurations (the so-called 'sections'). For example, you might want to just write the DNS configuration but keep the rest as it is.
It is expect that a configuration writer exists for each supported backend by inheriting from this class. It implements support for the common bits: drivers, intefaces (udev rules), DNS and hostname settings. Of course, you are not forced to use this class as a base.
Direct Known Subclasses
Constant Summary collapse
- SECTIONS =
Returns The different sections handled by the writer.
[:routing, :drivers, :interfaces, :connections, :dns, :hostname].freeze
Class Method Summary collapse
-
.for(source) ⇒ Y2Network::ConfigWriters::ConfigWriter
Returns a configuration writer for a given source.
Instance Method Summary collapse
-
#write(config, old_config = nil, only: nil) ⇒ IssuesResult
Writes the configuration into YaST network related modules.
Class Method Details
.for(source) ⇒ Y2Network::ConfigWriters::ConfigWriter
Returns a configuration writer for a given source
53 54 55 56 57 58 |
# File 'src/lib/y2network/config_writer.rb', line 53 def for(source) require "y2network/#{source}/config_writer" modname = source.to_s.split("_").map(&:capitalize).join klass = Y2Network.const_get("#{modname}::ConfigWriter") klass.new end |
Instance Method Details
#write(config, old_config = nil, only: nil) ⇒ IssuesResult
Writes the configuration into YaST network related modules
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'src/lib/y2network/config_writer.rb', line 72 def write(config, old_config = nil, only: nil) sections = only || SECTIONS # TODO: Improve the loging using better format log.info "Writing configuration: #{config.inspect}\n" log.info "Old configuration: #{old_config.inspect}\n" log.info("Writing sections: #{sections.inspect}") if only issues_list = Y2Issues::List.new SECTIONS.each do |s| send(:"write_#{s}", config, old_config, issues_list) if sections.include?(s) end Yast::Host.Write(gui: false) IssuesResult.new(config, issues_list) end |