Class: Y2Network::NetworkManager::ConnectionConfigWriters::Base

Inherits:
Object
  • Object
show all
Defined in:
src/lib/y2network/network_manager/connection_config_writers/base.rb

Overview

Base class for connection config writers.

The derived classes should implement a #update_file method.

Direct Known Subclasses

Bonding, Bridge, Ethernet, Vlan, Wireless

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Base

Constructor

Parameters:



36
37
38
# File 'src/lib/y2network/network_manager/connection_config_writers/base.rb', line 36

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileCFA::NmConnection (readonly)

Returns Connection configuration file.

Returns:



31
32
33
# File 'src/lib/y2network/network_manager/connection_config_writers/base.rb', line 31

def file
  @file
end

Instance Method Details

#write(conn, opts = {}) ⇒ Object

Writes connection information to the interface configuration file

Parameters:

  • conn (Y2Network::ConnectionConfig::Base)

    Connection to take settings from

  • opts (Hash) (defaults to: {})

    additional options needed to write properly the connection config

Options Hash (opts):



48
49
50
51
52
53
54
55
56
57
58
# File 'src/lib/y2network/network_manager/connection_config_writers/base.rb', line 48

def write(conn, opts = {})
  file.connection["id"] = conn.name
  file.connection["autoconnect"] = "false" if ["manual", "off"].include? conn.startmode.name
  file.connection["permissions"] = nil
  file.connection["interface-name"] = conn.interface
  file.connection["zone"] = conn.firewall_zone unless ["", nil].include? conn.firewall_zone
  conn.bootproto.dhcp? ? configure_dhcp(conn) : configure_ips(conn)
  configure_routes(opts[:routes] || [])
  configure_as_port(opts[:parent]) if opts[:parent]
  update_file(conn)
end