Class: Y2Network::Sysconfig::ConnectionConfigWriter

Inherits:
Object
  • Object
show all
Includes:
Yast::Logger
Defined in:
src/lib/y2network/sysconfig/connection_config_writer.rb

Overview

This class is responsible for writing interfaces changes

Instance Method Summary collapse

Instance Method Details

#remove(conn) ⇒ Object

Removes connection config from the underlying system


51
52
53
54
55
# File 'src/lib/y2network/sysconfig/connection_config_writer.rb', line 51

def remove(conn)
  ifcfg = Y2Network::Sysconfig::InterfaceFile.find(conn.interface)
  ifcfg && ifcfg.remove
  Yast::Host.remove_ip(conn.ip.address.address.to_s) if conn.ip
end

#write(conn, old_conn = nil) ⇒ Object

Writes connection config to the underlying system

The method can receive the old configuration in order to perform clean-up tasks.


37
38
39
40
41
42
43
44
45
46
# File 'src/lib/y2network/sysconfig/connection_config_writer.rb', line 37

def write(conn, old_conn = nil)
  return if conn == old_conn
  file = Y2Network::Sysconfig::InterfaceFile.new(conn.interface)
  handler_class = find_handler_class(conn.type)
  return nil if handler_class.nil?
  remove(old_conn) if old_conn
  file.clean
  handler_class.new(file).write(conn)
  file.save
end