Class: Y2Network::InterfaceConfigBuilders::Bridge

Inherits:
Y2Network::InterfaceConfigBuilder show all
Extended by:
Forwardable
Includes:
Yast::Logger
Defined in:
src/lib/y2network/interface_config_builders/bridge.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) ⇒ Bridge


31
32
33
# File 'src/lib/y2network/interface_config_builders/bridge.rb', line 31

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

Instance Method Details

#already_configured?(devices) ⇒ Boolean

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


38
39
40
41
42
43
# File 'src/lib/y2network/interface_config_builders/bridge.rb', line 38

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

#bridgeable_interfacesArray<Interface>


46
47
48
# File 'src/lib/y2network/interface_config_builders/bridge.rb', line 46

def bridgeable_interfaces
  interfaces.select { |i| bridgeable?(i) }
end

#saveObject

additionally it adapt slaves if needed


51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'src/lib/y2network/interface_config_builders/bridge.rb', line 51

def save
  ports.each do |port|
    interface = yast_config.interfaces.by_name(port)
    connection = yast_config.connections.by_name(port)
    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