Class: Y2Network::Sysconfig::ConnectionConfigReaders::Base

Inherits:
Object
  • Object
show all
Defined in:
src/lib/y2network/sysconfig/connection_config_readers/base.rb

Overview

This is the base class for connection config readers.

The derived classes should implement #update_connection_config method. methods.

Direct Known Subclasses

Bonding, Bridge, Ctc, Dummy, Ethernet, Hsi, Infiniband, Lcs, Qeth, Tap, Tun, Usb, Vlan, Wireless

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Base

Constructor


41
42
43
# File 'src/lib/y2network/sysconfig/connection_config_readers/base.rb', line 41

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileY2Network::Sysconfig::InterfaceFile (readonly)


36
37
38
# File 'src/lib/y2network/sysconfig/connection_config_readers/base.rb', line 36

def file
  @file
end

Instance Method Details

#connection_configY2Network::ConnectionConfig::Base

Builds a connection configuration object


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'src/lib/y2network/sysconfig/connection_config_readers/base.rb', line 48

def connection_config
  connection_class.new.tap do |conn|
    conn.bootproto = BootProtocol.from_name(file.bootproto || "static")
    conn.description = file.name
    conn.interface = file.interface
    conn.ip = all_ips.find { |i| i.id.empty? }
    conn.ip_aliases = all_ips.reject { |i| i.id.empty? }
    conn.name = file.interface
    conn.lladdress = file.lladdr
    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
    conn.hostname = hostname(conn)
    update_connection_config(conn)
  end
end