Class: Y2Network::InterfaceConfigBuilders::Vlan

Inherits:
Y2Network::InterfaceConfigBuilder show all
Defined in:
src/lib/y2network/interface_config_builders/vlan.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?, #save, #startmode=, #subnet_prefix, #subnet_prefix=, #valid_name?

Constructor Details

#initialize(config: nil) ⇒ Vlan

Returns a new instance of Vlan.



26
27
28
# File 'src/lib/y2network/interface_config_builders/vlan.rb', line 26

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

Instance Method Details

#etherdeviceString

Returns:

  • (String)


41
42
43
# File 'src/lib/y2network/interface_config_builders/vlan.rb', line 41

def etherdevice
  connection_config.parent_device
end

#etherdevice=(value) ⇒ Object

Parameters:

  • value (String)


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

def etherdevice=(value)
  connection_config.parent_device = value
end

#possible_vlansHash<String, String>

Keys are ids for #etherdevice and value are label

Returns:

  • (Hash<String, String>)

    returns ordered list of devices that can be used for vlan



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

def possible_vlans
  yast_config.interfaces.to_a.each_with_object({}) do |interface, result|
    next if interface.type.vlan? # does not make sense to have vlan of vlan

    result[interface.name] = if interface.hardware && interface.hardware.present?
      "#{interface.name} - #{interface.hardware.description}"
    else
      interface.name
    end
  end
end

#vlan_idInteger

Returns:

  • (Integer)


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

def vlan_id
  connection_config.vlan_id || 0
end

#vlan_id=(value) ⇒ Object

Parameters:

  • value (Integer)


36
37
38
# File 'src/lib/y2network/interface_config_builders/vlan.rb', line 36

def vlan_id=(value)
  connection_config.vlan_id = value
end