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, #renaming_mechanism, #type

Instance Method Summary collapse

Methods inherited from Y2Network::InterfaceConfigBuilder

#aliases, #aliases=, #boot_protocol, #boot_protocol=, #configure_as_slave, #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

#already_configured?(devices) ⇒ Boolean

Checks if any of given device is already configured and need adaptation for bridge

Parameters:

  • devices (Array<String>)

    devices to check

Returns:

  • (Boolean)

    true if there is device that needs adaptation


56
57
58
59
60
61
# File 'src/lib/y2network/interface_config_builders/bonding.rb', line 56

def already_configured?(devices)
  devices.any? do |device|
    next false unless yast_config.configured_interface?(device)
    yast_config.connections.by_name(device).startmode.name != "none"
  end
end

#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

#saveObject

additionally it adapt slaves if needed


64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'src/lib/y2network/interface_config_builders/bonding.rb', line 64

def save
  slaves.each do |slave|
    interface = yast_config.interfaces.by_name(slave)
    connection = yast_config.connections.by_name(slave)
    next if connection && connection.startmode.name == "none"
    builder = InterfaceConfigBuilder.for(interface.type, config: connection)
    builder.name = interface.name
    builder.configure_as_slave
    builder.save
  end

  super
end