Class: Y2Network::InterfaceConfigBuilders::Bonding

Inherits:
Y2Network::InterfaceConfigBuilder show all
Extended by:
Forwardable
Includes:
Yast::Logger
Defined in:
src/lib/y2network/interface_config_builders/bonding.rb

Constant Summary

Constants inherited from Y2Network::InterfaceConfigBuilder

Y2Network::InterfaceConfigBuilder::NEW_DEVICES_COUNT

Instance Attribute Summary

Attributes inherited from Y2Network::InterfaceConfigBuilder

#connection_config, #firewall_zone, #interface, #name, #newly_added, #renaming_mechanism, #type

Instance Method Summary collapse

Methods inherited from Y2Network::InterfaceConfigBuilder

#alias_for, #aliases, #aliases=, #boot_protocol, #boot_protocol=, #configure_as_port, #driver, #driver=, #drivers, for, #hostname, #hostname=, #hwinfo, #hwinfo_from, #ifplugd_priority, #ifplugd_priority=, #ip_address, #ip_address=, #mtu, #mtu=, #name_exists?, #name_valid_characters, #newly_added?, #proposed_names, #remote_ip, #remote_ip=, #rename_interface, #renamed_interface?, #startmode=, #subnet_prefix, #subnet_prefix=, #valid_name?

Constructor Details

#initialize(config: nil) ⇒ Bonding

Returns a new instance of Bonding.



30
31
32
# File 'src/lib/y2network/interface_config_builders/bonding.rb', line 30

def initialize(config: nil)
  super(type: InterfaceType::BONDING, config: config)
end

Instance Method Details

#bond_optionsString

current options for bonding

Returns:

  • (String)


49
50
51
# File 'src/lib/y2network/interface_config_builders/bonding.rb', line 49

def bond_options
  connection_config.options
end

#bond_options=(value) ⇒ Object

Parameters:

  • value (String)

    options for bonding



43
44
45
# File 'src/lib/y2network/interface_config_builders/bonding.rb', line 43

def bond_options=(value)
  connection_config.options = value
end

#bondable_interfacesArray<Interface>

Returns list of interfaces usable for the bond device.

Returns:

  • (Array<Interface>)

    list of interfaces usable for the bond device



35
36
37
# File 'src/lib/y2network/interface_config_builders/bonding.rb', line 35

def bondable_interfaces
  interfaces.select { |i| bondable?(i) }
end

#require_adaptation?(devices) ⇒ Boolean

return [Boolean] true if there is a device config that needs to be adaptated; false otherwise

Parameters:

  • devices (Array<String>)

    devices to check

Returns:

  • (Boolean)


59
60
61
62
63
64
65
# File 'src/lib/y2network/interface_config_builders/bonding.rb', line 59

def require_adaptation?(devices)
  devices.any? do |device|
    next false unless yast_config.configured_interface?(device)

    !valid_port_config?(device)
  end
end

#saveObject

additionally it adapts configuration of devices to be included in a bonding if needed



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'src/lib/y2network/interface_config_builders/bonding.rb', line 68

def save
  ports.each do |port|
    interface = yast_config.interfaces.by_name(port)
    next if valid_port_config?(port)

    connection = yast_config.connections.by_name(port)
    builder = InterfaceConfigBuilder.for(interface.type, config: connection)
    builder.name = interface.name
    builder.configure_as_port
    builder.startmode = "hotplug"
    builder.save
  end

  super
end