Skip to content

Commit

Permalink
Merge pull request #1146 from yast/sysconfig-to-wicked
Browse files Browse the repository at this point in the history
Rename "Sysconfig" backend to "Wicked"
  • Loading branch information
imobachgs committed Jan 21, 2021
2 parents 2334a87 + 6984f50 commit 67ad5d2
Show file tree
Hide file tree
Showing 108 changed files with 270 additions and 266 deletions.
22 changes: 11 additions & 11 deletions doc/network-ng.md
Expand Up @@ -25,7 +25,7 @@ written in the filesystem by using a *configuration writer*.
+--------+

Obviously, we should implement configuration readers and writers for whathever backend we would like
to support. At this point of time, only `Sysconfig` and `Autoinst` are supported.
to support. At this point of time, only `Wicked` and `Autoinst` are supported.

### The Configuration Classes

Expand Down Expand Up @@ -59,11 +59,11 @@ As a developer, you rarely will need to access to readers/writers because `Yast:
an API to read and write the configuration. See the [Accessing the
Configuration](#accessing-the-configuration) section for further details.

#### Sysconfig
#### Wicked

The sysconfig backend support is composed by these files:
The Wicked backend support is composed by these files:

src/lib/y2network/sysconfig
src/lib/y2network/wicked
├── config_reader.rb <- READER
├── config_writer.rb <- WRITER
├── connection_config_reader.rb
Expand All @@ -79,19 +79,19 @@ The sysconfig backend support is composed by these files:
├── dns_reader.rb
└── interfaces_reader.rb

{Y2Network::Sysconfig::ConfigReader} and {Y2Network::Sysconfig::ConfigWriter} are the reader and
{Y2Network::Wicked::ConfigReader} and {Y2Network::Wicked::ConfigWriter} are the reader and
writer classes. Each of them cooperates with a set of ancillary classes in order to get the job
done.

{Y2Network::Sysconfig::DNSReader}, {Y2Network::Sysconfig::InterfacesReader} and
{Y2Network::Sysconfig::ConnectionConfigReader} are involved in reading the configuration. The logic
{Y2Network::Wicked::DNSReader}, {Y2Network::Wicked::InterfacesReader} and
{Y2Network::Wicked::ConnectionConfigReader} are involved in reading the configuration. The logic
to read the configuration for a connection (e.g., `ifcfg-eth0`, `ifcfg-wlan0`, etc.) is implemented
in a set of smaller classes (one for each time of connection) under
{Y2Network::Sysconfig::ConnectionConfigReaders}.
{Y2Network::Wicked::ConnectionConfigReaders}.

{Y2Network::ConfigWriters::InterfacesWriter}, {Y2Network::ConfigWriters::DNSWriter} and
{Y2Network::Sysconfig::ConnectionConfigWriter}, including smaller classes under
{Y2Network::Sysconfig::ConnectionConfigWriters}, are involved in writing the configuration.
{Y2Network::Wicked::ConnectionConfigWriter}, including smaller classes under
{Y2Network::Wicked::ConnectionConfigWriters}, are involved in writing the configuration.

Last but not least, there are additional classes like {CFA::RoutesFile} and {CFA::InterfaceFile}
which abstract the details of reading/writing `ifroute` and `ifcfg` files.
Expand All @@ -100,7 +100,7 @@ which abstract the details of reading/writing `ifroute` and `ifcfg` files.

AutoYaST is a special case in the sense that it reads the information from a profile, instead of
using the running system as reference. Additionally, it does not implement a writer because the
configuration will be written using a different backend (like `sysconfig`).
configuration will be written using a different backend (like `wicked`).

src/lib/y2network/autoinst/
├── config_reader.rb
Expand Down
2 changes: 1 addition & 1 deletion examples/connection.rb
Expand Up @@ -43,7 +43,7 @@

# given an interfaces list (interfaces)

config = Y2Network::Config.from(:sysconfig)
config = Y2Network::Config.from(:wicked)

eth0 = config.interfaces.by_name("eth0")
eth_conn = Y2Network::ConnectionConfig::Ethernet.new
Expand Down
2 changes: 1 addition & 1 deletion src/include/network/lan/complex.rb
Expand Up @@ -175,7 +175,7 @@ def ReadDialog
# Currently just a smoketest for new config storage -
# something what should replace Lan module in the bright future
# TODO: find a suitable place for this config storage
Y2Network::Config.from(:sysconfig)
Y2Network::Config.from(:wicked)

if Lan.HaveXenBridge
if !Popup.ContinueCancel(
Expand Down
2 changes: 1 addition & 1 deletion src/lib/y2network/autoinst/config_reader.rb
Expand Up @@ -26,7 +26,7 @@
require "y2network/autoinst/interfaces_reader"
require "y2network/autoinst/udev_rules_reader"
require "y2network/autoinst_profile/networking_section"
require "y2network/sysconfig/interfaces_reader"
require "y2network/wicked/interfaces_reader"

Yast.import "Lan"

Expand Down
6 changes: 3 additions & 3 deletions src/lib/y2network/autoinst/hostname_reader.rb
Expand Up @@ -19,7 +19,7 @@

require "yast"
require "y2network/hostname"
require "y2network/sysconfig/hostname_reader"
require "y2network/wicked/hostname_reader"

module Y2Network
module Autoinst
Expand Down Expand Up @@ -51,7 +51,7 @@ def config
#
# @return [String]
def static_hostname
Y2Network::Sysconfig::HostnameReader.new.static_hostname
Y2Network::Wicked::HostnameReader.new.static_hostname
end

# Returns the value for the dhcp_hostname option selected in the profile.
Expand All @@ -63,7 +63,7 @@ def dhcp_hostname_for(section_value)
# config, but we do not want to override current config if the value is
# not present and the merge is missing for whatever reason, for example
# in case AutoYaST is called in config mode
return Y2Network::Sysconfig::HostnameReader.new.dhcp_hostname if section_value.nil?
return Y2Network::Wicked::HostnameReader.new.dhcp_hostname if section_value.nil?

section_value ? :any : :none
end
Expand Down
6 changes: 3 additions & 3 deletions src/lib/y2network/clients/routing.rb
Expand Up @@ -30,7 +30,7 @@

require "yast"
require "y2network/config"
require "y2network/sysconfig/config_writer"
require "y2network/wicked/config_writer"
require "y2network/serializer/route_sysconfig"

Yast.import "Lan"
Expand Down Expand Up @@ -342,7 +342,7 @@ def DeleteHandler(options)
#
# @return [Boolean]
def read
system_config = Y2Network::Config.from(:sysconfig)
system_config = Y2Network::Config.from(:wicked)
Yast::Lan.add_config(:system, system_config)
Yast::Lan.add_config(:yast, system_config.copy)

Expand All @@ -354,7 +354,7 @@ def read
# @return [Boolean]
def write
if modified?
Y2Network::Sysconfig::ConfigWriter.new.write(yast_config)
Y2Network::Wicked::ConfigWriter.new.write(yast_config)
log.info("Writing routing configuration: #{yast_config.routing.inspect}")
end

Expand Down
6 changes: 3 additions & 3 deletions src/lib/y2network/config.rb
Expand Up @@ -33,11 +33,11 @@ module Y2Network
# routes, etc.
#
# @example Reading from wicked
# config = Y2Network::Config.from(:sysconfig)
# config = Y2Network::Config.from(:wicked)
# config.interfaces.map(&:name) #=> ["lo", eth0", "wlan0"]
#
# @example Adding a default route to the first routing table
# config = Y2Network::Config.from(:sysconfig)
# config = Y2Network::Config.from(:wicked)
# route = Y2Network::Route.new(to: :default)
# config.routing.tables.first << route
# config.write
Expand Down Expand Up @@ -131,7 +131,7 @@ def initialize(source:, **opts)
# is provided
#
# @param original [Y2Network::Config] configuration used for detecting changes
# @param target [Symbol] Target to write the configuration to (:sysconfig)
# @param target [Symbol] Target to write the configuration to (:wicked)
# @param only [Array<symbol>, nil] explicit sections to be written, by default if no
# parameter is given then all changes will be written.
#
Expand Down
4 changes: 2 additions & 2 deletions src/lib/y2network/config_reader.rb
Expand Up @@ -20,9 +20,9 @@ module Y2Network
module ConfigReader
# Config reader for a given source
#
# @param source [Symbol] Source name (e.g., :sysconfig)
# @param source [Symbol] Source name (e.g., :wicked)
# @param opts [Array<Object>] Reader options
# @return [Y2Network::Autoinst::ConfigReader,Y2Network::Sysconfig::ConfigReader]
# @return [Y2Network::Autoinst::ConfigReader,Y2Network::Wicked::ConfigReader]
def self.for(source, *opts)
require "y2network/#{source}/config_reader"
modname = source.to_s.split("_").map(&:capitalize).join
Expand Down
2 changes: 1 addition & 1 deletion src/lib/y2network/config_writer.rb
Expand Up @@ -43,7 +43,7 @@ class ConfigWriter
class << self
# Returns a configuration writer for a given source
#
# @param source [Symbol] Source name (e.g., :sysconfig)
# @param source [Symbol] Source name (e.g., :wicked)
# @return [Y2Network::ConfigWriters::ConfigWriter]
#
# @see Y2Network::ConfigWriters::ConfigWriter
Expand Down
4 changes: 2 additions & 2 deletions src/lib/y2network/dialogs/s390_device_activation.rb
Expand Up @@ -21,7 +21,7 @@
require "y2network/s390_device_activator"
require "y2network/widgets/s390_common"
require "y2network/widgets/s390_channels"
require "y2network/sysconfig/interfaces_reader"
require "y2network/wicked/interfaces_reader"
require "yast2/popup"

Yast.import "Lan"
Expand Down Expand Up @@ -117,7 +117,7 @@ def show_activation_error(message)
end

def reader
@reader ||= Y2Network::Sysconfig::InterfacesReader.new
@reader ||= Y2Network::Wicked::InterfacesReader.new
end

def config
Expand Down
2 changes: 1 addition & 1 deletion src/lib/y2network/hostname.rb
Expand Up @@ -18,7 +18,7 @@
# find current contact information at www.suse.com.

require "yast"
require "y2network/sysconfig/hostname_reader"
require "y2network/wicked/hostname_reader"

Yast.import "Stage"

Expand Down
Expand Up @@ -23,16 +23,16 @@
require "y2network/routing"
require "y2network/routing_table"
require "cfa/routes_file"
require "y2network/sysconfig/dns_reader"
require "y2network/sysconfig/hostname_reader"
require "y2network/sysconfig/interfaces_reader"
require "y2network/wicked/dns_reader"
require "y2network/wicked/hostname_reader"
require "y2network/wicked/interfaces_reader"
require "y2network/interfaces_collection"

Yast.import "NetworkInterfaces"
Yast.import "Host"

module Y2Network
module Sysconfig
module Wicked
# This class reads the current configuration from `/etc/sysconfig` files
class ConfigReader
include Yast::Logger
Expand Down Expand Up @@ -60,7 +60,7 @@ def config
routing: routing,
dns: dns,
hostname: hostname,
source: :sysconfig
source: :wicked
)

log.info "Sysconfig reader result: #{result.inspect}"
Expand All @@ -73,7 +73,7 @@ def config
#
# @return [SysconfigInterfaces] Interfaces reader
def interfaces_reader
@interfaces_reader ||= Y2Network::Sysconfig::InterfacesReader.new
@interfaces_reader ||= Y2Network::Wicked::InterfacesReader.new
end

# Reads routes
Expand Down Expand Up @@ -127,14 +127,14 @@ def link_routes_to_interfaces(routes, interfaces)
#
# @return [Y2Network::DNS]
def dns
Y2Network::Sysconfig::DNSReader.new.config
Y2Network::Wicked::DNSReader.new.config
end

# Returns the Hostname configuration
#
# @return [Y2Network::Hostname]
def hostname
Y2Network::Sysconfig::HostnameReader.new.config
Y2Network::Wicked::HostnameReader.new.config
end

# Returns the Sysctl_Config file class
Expand Down
Expand Up @@ -21,11 +21,11 @@
require "y2network/config"
require "cfa/routes_file"
require "y2network/config_writer"
require "y2network/sysconfig/connection_config_writer"
require "y2network/wicked/connection_config_writer"
require "cfa/sysctl_config"

module Y2Network
module Sysconfig
module Wicked
# This class configures Wicked (through sysconfig) according to a given configuration
class ConfigWriter < Y2Network::ConfigWriter
private # rubocop:disable Layout/IndentationWidth
Expand Down Expand Up @@ -122,7 +122,7 @@ def routes_file_for(iface)
# @param old_config [Y2Network::Config,nil] Config object with original configuration
def write_connections(config, old_config)
# FIXME: this code might live in its own class
writer = Y2Network::Sysconfig::ConnectionConfigWriter.new
writer = Y2Network::Wicked::ConnectionConfigWriter.new
remove_old_connections(config.connections, old_config.connections, writer) if old_config
config.connections.each do |conn|
old_conn = old_config ? old_config.connections.by_ids(conn.id).first : nil
Expand All @@ -134,7 +134,7 @@ def write_connections(config, old_config)
#
# @param conns [ConnectionConfigsCollection] New connections
# @param old_conns [ConnectionConfigsCollection] Old connections
# @param writer [Sysconfig::ConnectionConfigWriter] Writer instance to save changes
# @param writer [Wicked::ConnectionConfigWriter] Writer instance to save changes
def remove_old_connections(conns, old_conns, writer)
ids_to_remove = old_conns.map(&:id) - conns.map(&:id)
to_remove = old_conns.by_ids(*ids_to_remove)
Expand Down
Expand Up @@ -20,7 +20,7 @@
require "cfa/interface_file"

module Y2Network
module Sysconfig
module Wicked
# Reads a connection configuration for a given interface
class ConnectionConfigReader
include Yast::Logger
Expand Down Expand Up @@ -55,7 +55,7 @@ def find_handler_class(type)
raise "Unknown type #{type.inspect} #{type.class.inspect}"
type = t
end
require "y2network/sysconfig/connection_config_readers/#{type.file_name}"
require "y2network/wicked/connection_config_readers/#{type.file_name}"
ConnectionConfigReaders.const_get(type.class_name)
rescue LoadError, NameError => e
log.info "Unknown connection type: '#{type}'. " \
Expand Down
Expand Up @@ -25,7 +25,7 @@
Yast.import "Host"

module Y2Network
module Sysconfig
module Wicked
module ConnectionConfigReaders
# This is the base class for connection config readers.
#
Expand Down
Expand Up @@ -17,15 +17,15 @@
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "y2network/sysconfig/connection_config_readers/base"
require "y2network/wicked/connection_config_readers/base"

module Y2Network
module Sysconfig
module Wicked
module ConnectionConfigReaders
# This class is able to build a ConnectionConfig::Bonding object given a
# SysconfigInterfaceFile object.
class Bonding < Base
# @see Y2Network::Sysconfig::ConnectionConfigReaders::Base#update_connection_config
# @see Y2Network::Wicked::ConnectionConfigReaders::Base#update_connection_config
def update_connection_config(conn)
conn.slaves = slaves
conn.options = file.bonding_module_opts
Expand Down
Expand Up @@ -17,15 +17,15 @@
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "y2network/sysconfig/connection_config_readers/base"
require "y2network/wicked/connection_config_readers/base"

module Y2Network
module Sysconfig
module Wicked
module ConnectionConfigReaders
# This class is able to build a ConnectionConfig::Bridge object given a
# SysconfigInterfaceFile object.
class Bridge < Base
# @see Y2Network::Sysconfig::ConnectionConfigReaders::Base#update_connection_config
# @see Y2Network::Wicked::ConnectionConfigReaders::Base#update_connection_config
def update_connection_config(conn)
conn.ports = file.bridge_ports ? file.bridge_ports.split(" ") : []
conn.stp = file.bridge_stp == "on"
Expand Down
Expand Up @@ -17,13 +17,13 @@
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "y2network/sysconfig/connection_config_readers/base"
require "y2network/wicked/connection_config_readers/base"

module Y2Network
module Sysconfig
module Wicked
module ConnectionConfigReaders
# This class is able to build a ConnectionConfig::Ctc object given a
# Sysconfig::InterfaceFile object.
# Wicked::InterfaceFile object.
class Ctc < Base
LIST_CMD = "/sbin/lszdev".freeze

Expand Down
Expand Up @@ -17,13 +17,13 @@
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "y2network/sysconfig/connection_config_readers/base"
require "y2network/wicked/connection_config_readers/base"

module Y2Network
module Sysconfig
module Wicked
module ConnectionConfigReaders
# This class is able to build a ConnectionConfig::Dummy object given a
# Sysconfig::InterfaceFile object.
# Wicked::InterfaceFile object.
class Dummy < Base
end
end
Expand Down

0 comments on commit 67ad5d2

Please sign in to comment.