Class: Y2Network::Autoinst::ConfigReader

Inherits:
Object
  • Object
show all
Defined in:
src/lib/y2network/autoinst/config_reader.rb

Overview

This class is responsible of importing Autoyast configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(section, original_config) ⇒ ConfigReader

Constructor

Parameters:


45
46
47
48
# File 'src/lib/y2network/autoinst/config_reader.rb', line 45

def initialize(section, original_config)
  @section = section
  @original_config = original_config
end

Instance Attribute Details

#sectionAutoinstProfile::NetworkingSection (readonly)


39
40
41
# File 'src/lib/y2network/autoinst/config_reader.rb', line 39

def section
  @section
end

Instance Method Details

#readIssuesResult

Returns Network configuration.

Returns:


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'src/lib/y2network/autoinst/config_reader.rb', line 51

def read
  config = Y2Network::Config.new(source: :autoinst)
  # We need the current interfaces in order to rewrite the config
  # properly but the rest should be imported from the profile
  config.interfaces = @original_config.interfaces.copy
  # merge devices definitions obtained from inst-sys
  # and those which were read from AY profile. bnc#874259
  config.connections = @original_config.connections.copy if keep_configured_network?

  # apply at first udev rules, so interfaces names are correct
  UdevRulesReader.new(section.udev_rules).apply(config) if section.udev_rules
  config.routing = RoutingReader.new(section.routing).config if section.routing
  config.dns = DNSReader.new(section.dns).config if section.dns
  config.hostname = HostnameReader.new(section.dns).config if section.dns

  if section.interfaces
    interfaces = InterfacesReader.new(section.interfaces).config
    interfaces.each do |interface|
      # add or update system configuration, this will also create all missing interfaces
      config.add_or_update_connection_config(interface)
    end
  end

  config.backend = ay_backend

  Y2Network::IssuesResult.new(config)
end