Class: Y2Network::AutoinstProfile::InterfaceSection
- Inherits:
-
Installation::AutoinstProfile::SectionWithAttributes
- Object
- Installation::AutoinstProfile::SectionWithAttributes
- Y2Network::AutoinstProfile::InterfaceSection
- Defined in:
- src/lib/y2network/autoinst_profile/interface_section.rb
Overview
This class represents an AutoYaST
Instance Attribute Summary collapse
-
#aliases ⇒ Array<AliasSection>
List of IP aliases.
-
#bonding_master ⇒ String
???.
-
#bonding_module_opts ⇒ String
Bonding options.
-
#bonding_slaveX ⇒ String
Bonding port on position X.
-
#bootproto ⇒ String
Boot protocol.
-
#bridge ⇒ String
"yes" if device is bridge.
-
#bridge_forward_delay ⇒ String
Time of delay.
-
#bridge_ports ⇒ String
Bridge ports separated by space.
-
#bridge_stp ⇒ String
"on" if stp is enabled.
-
#broadcast ⇒ String
Broadcast ip address.
-
#device ⇒ String
Device name.
-
#dhclient_set_default_route ⇒ String
???.
-
#dhclient_set_down_link ⇒ String
???.
-
#dhclient_set_hostname ⇒ String
If dhcp sets hostname.
-
#etherdevice ⇒ String
Parent device of vlan.
-
#ethtool_options ⇒ String
Options for ethtool.
-
#firewall ⇒ String
???.
-
#ifplugd_priority ⇒ String
Priority for ifplugd startmode.
-
#ipaddr ⇒ String
Ip address.
-
#lladdr ⇒ String
Ip address.
-
#mtu ⇒ String
MTU for interface.
-
#name ⇒ String
Device name.
-
#netmask ⇒ String
Network mask.
-
#network ⇒ String
Network ip after prefix applied.
-
#prefixlen ⇒ String
Size of network prefix.
-
#remote_ipaddr ⇒ String
Remote ip address for ptp connections.
-
#startmode ⇒ String
When to start network.
-
#usercontrol ⇒ String
No clue what it means, but it is ignored now.
-
#vlan_id ⇒ String
Id of vlan.
-
#wireless ⇒ String
???.
- #wireless_ap ⇒ Object
- #wireless_auth_mode ⇒ Object
- #wireless_bitrate ⇒ Object
- #wireless_ca_cert ⇒ Object
- #wireless_channel ⇒ Object
- #wireless_client_cert ⇒ Object
- #wireless_client_key ⇒ Object
- #wireless_client_key_password ⇒ Object
- #wireless_default_key ⇒ Object
- #wireless_eap_auth ⇒ Object
- #wireless_eap_mode ⇒ Object
- #wireless_essid ⇒ Object
- #wireless_frequency ⇒ Object
- #wireless_key ⇒ Object
- #wireless_key_length ⇒ Object
-
#wireless_keyX ⇒ String
Key on position X.
- #wireless_mode ⇒ Object
- #wireless_nick ⇒ Object
- #wireless_nwid ⇒ Object
- #wireless_peap_version ⇒ Object
- #wireless_power ⇒ Object
- #wireless_wpa_anonid ⇒ Object
- #wireless_wpa_identity ⇒ Object
- #wireless_wpa_password ⇒ Object
- #wireless_wpa_psk ⇒ Object
-
#zone ⇒ String
Firewall zone to which interface belongs.
Class Method Summary collapse
- .attributes ⇒ Object
-
.new_from_network(connection_config, parent = nil) ⇒ InterfacesSection
Clones a network interface into an AutoYaST interface section.
Instance Method Summary collapse
-
#bonding_slaves ⇒ Array<String>
Helper to get devices in the bonding as array.
-
#collection_name ⇒ String
Returns the collection name.
-
#init_from_config(config) ⇒ Boolean
Method used by InterfaceSection.new_from_network to populate the attributes when cloning a network interface.
-
#init_from_hashes(hash) ⇒ Object
Overwrite base method to load also nested aliases.
-
#initialize(*_args) ⇒ InterfaceSection
constructor
A new instance of InterfaceSection.
-
#section_path ⇒ Installation::AutoinstProfile::ElementPath?
Returns the section path.
- #to_hashes ⇒ Object
-
#wireless_keys ⇒ Array<String>
Helper to get wireless keys as array.
Constructor Details
#initialize(*_args) ⇒ InterfaceSection
Returns a new instance of InterfaceSection.
251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 251 def initialize(*_args) super # TODO: Initializing all the attributes to an empty string makes # hard to know whether the value was defined or not at all. We probably # should ommit this initialization self.class.attributes.each do |attr| # init everything to empty string public_send(:"#{attr[:name]}=", "") end self.aliases = [] end |
Instance Attribute Details
#aliases ⇒ Array<AliasSection>
Returns list of IP aliases.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 171
|
#bonding_master ⇒ String
Returns ???.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 162
|
#bonding_module_opts ⇒ String
Returns bonding options.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 168
|
#bonding_slaveX ⇒ String
Returns bonding port on position X.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 165
|
#bootproto ⇒ String
Returns boot protocol.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 119
|
#bridge ⇒ String
Returns "yes" if device is bridge.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 201
|
#bridge_forward_delay ⇒ String
Returns time of delay.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 210
|
#bridge_ports ⇒ String
Returns bridge ports separated by space.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 204
|
#bridge_stp ⇒ String
Returns "on" if stp is enabled.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 207
|
#broadcast ⇒ String
Returns broadcast ip address.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 122
|
#device ⇒ String
Returns device name. Deprecated. name
should be used instead.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 125
|
#dhclient_set_default_route ⇒ String
Returns ???.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 192
|
#dhclient_set_down_link ⇒ String
Returns ???.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 189
|
#dhclient_set_hostname ⇒ String
Returns if dhcp sets hostname. "yes" if sets, "no" not set and nil not specified.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 159
|
#etherdevice ⇒ String
Returns parent device of vlan.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 198
|
#ethtool_options ⇒ String
Returns options for ethtool.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 177
|
#firewall ⇒ String
Returns ???.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 183
|
#ifplugd_priority ⇒ String
Returns priority for ifplugd startmode.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 153
|
#ipaddr ⇒ String
Returns ip address.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 134
|
#lladdr ⇒ String
Returns ip address.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 131
|
#mtu ⇒ String
Returns MTU for interface.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 174
|
#name ⇒ String
Returns device name.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 128
|
#netmask ⇒ String
Returns network mask. Deprecated prefix
should be used instead.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 140
|
#network ⇒ String
Returns network ip after prefix applied. Deprecated as it can be computed from ipaddr and prefixlen.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 143
|
#prefixlen ⇒ String
Returns size of network prefix.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 147
|
#remote_ipaddr ⇒ String
Returns remote ip address for ptp connections.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 137
|
#startmode ⇒ String
Returns when to start network.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 150
|
#usercontrol ⇒ String
Returns no clue what it means, but it is ignored now.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 156
|
#vlan_id ⇒ String
Returns id of vlan.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 195
|
#wireless ⇒ String
Returns ???.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 180
|
#wireless_ap ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_auth_mode ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_bitrate ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_ca_cert ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_channel ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_client_cert ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_client_key ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_client_key_password ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_default_key ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_eap_auth ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_eap_mode ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_essid ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_frequency ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_key ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_key_length ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_keyX ⇒ String
Returns key on position X.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_mode ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_nick ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_nwid ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_peap_version ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_power ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_wpa_anonid ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_wpa_identity ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_wpa_password ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#wireless_wpa_psk ⇒ Object
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 213
|
#zone ⇒ String
Returns firewall zone to which interface belongs.
|
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 186
|
Class Method Details
.attributes ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 43 def self.attributes [ { name: :bootproto }, { name: :broadcast }, { name: :device }, { name: :name }, # has precedence over device { name: :lladdr }, { name: :description }, { name: :ipaddr }, { name: :remote_ipaddr }, { name: :netmask }, { name: :network }, # TODO: what it is? looks like ipaddr with applied prefix { name: :prefixlen }, # has precedence over netmask { name: :startmode }, { name: :ifplugd_priority }, { name: :usercontrol }, # no longer used, ignored { name: :dhclient_set_hostname }, { name: :bonding_master }, { name: :bonding_slave0 }, { name: :bonding_slave1 }, { name: :bonding_slave2 }, { name: :bonding_slave3 }, { name: :bonding_slave4 }, { name: :bonding_slave5 }, { name: :bonding_slave6 }, { name: :bonding_slave7 }, { name: :bonding_slave8 }, { name: :bonding_slave9 }, { name: :bonding_module_opts }, { name: :aliases }, { name: :mtu }, { name: :ethtool_options }, { name: :wireless }, # TODO: what it is? { name: :firewall }, # yes/no { name: :zone }, # firewall zone { name: :dhclient_set_down_link }, # TODO: what it do? { name: :dhclient_set_default_route }, # TODO: what it do? { name: :vlan_id }, { name: :etherdevice }, { name: :bridge }, # yes/no # why? bridge always have to be yes { name: :bridge_ports }, { name: :bridge_stp }, # on/off { name: :bridge_forward_delay }, { name: :wireless_ap }, { name: :wireless_auth_mode }, { name: :wireless_bitrate }, { name: :wireless_ca_cert }, { name: :wireless_channel }, { name: :wireless_client_cert }, { name: :wireless_client_key }, { name: :wireless_client_key_password }, { name: :wireless_default_key }, { name: :wireless_eap_auth }, { name: :wireless_eap_mode }, { name: :wireless_essid }, { name: :wireless_frequency }, { name: :wireless_key }, # default wep key { name: :wireless_key0 }, { name: :wireless_key1 }, { name: :wireless_key2 }, { name: :wireless_key3 }, { name: :wireless_key_length }, { name: :wireless_mode }, { name: :wireless_nick }, { name: :wireless_nwid }, { name: :wireless_peap_version }, { name: :wireless_power }, { name: :wireless_wpa_anonid }, { name: :wireless_wpa_identity }, { name: :wireless_wpa_password }, { name: :wireless_wpa_psk } ] end |
.new_from_network(connection_config, parent = nil) ⇒ InterfacesSection
Clones a network interface into an AutoYaST interface section
245 246 247 248 249 |
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 245 def self.new_from_network(connection_config, parent = nil) result = new(parent) result.init_from_config(connection_config) result end |
Instance Method Details
#bonding_slaves ⇒ Array<String>
Helper to get devices in the bonding as array
360 361 362 363 364 365 366 367 368 369 |
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 360 def bonding_slaves ports = [] (0..9).each do |i| port = public_send(:"bonding_slave#{i}") ports << port unless port.empty? end ports end |
#collection_name ⇒ String
Returns the collection name
374 375 376 |
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 374 def collection_name "interfaces" end |
#init_from_config(config) ⇒ Boolean
Method used by new_from_network to populate the attributes when cloning a network interface
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 287 def init_from_config(config) # nil bootproto is valid use case (missing explicit setup) - wicked defaults to static then @bootproto = config.bootproto&.name @name = config.name @lladdr = config.lladdress if config.bootproto == BootProtocol::STATIC && config.ip # missing ip is valid scenario for wicked - so use empty string here @ipaddr = config.ip.address&.address.to_s @prefixlen = config.ip.address&.prefix.to_s @remote_ipaddr = config.ip.remote_address.address.to_s if config.ip.remote_address @broadcast = config.ip.broadcast.address.to_s if config.ip.broadcast end @dhclient_set_hostname = case config.dhclient_set_hostname when true then "yes" when false then "no" when nil then "" end @startmode = config.startmode.name @ifplugd_priority = config.startmode.priority.to_s if config.startmode.name == "ifplugd" @mtu = config.mtu.to_s if config.mtu @ethtool_options = config. if config. @zone = config.firewall_zone.to_s # see aliases for example output @aliases = config.ip_aliases.map { |ip| AliasSection.new_from_network(ip) } case config when ConnectionConfig::Vlan @vlan_id = config.vlan_id.to_s @etherdevice = config.parent_device when ConnectionConfig::Bridge @bridge = "yes" @bridge_ports = config.ports.join(" ") @bridge_stp = config.stp ? "on" : "off" @bridge_forward_delay = config.forward_delay.to_s when ConnectionConfig::Bonding @bonding_module_opts = config. config.ports.each_with_index do |port, index| public_send(:"bonding_slave#{index}=", port) end when ConnectionConfig::Wireless init_from_wireless(config) end true end |
#init_from_hashes(hash) ⇒ Object
Overwrite base method to load also nested aliases
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 266 def init_from_hashes(hash) hash = rename_key(hash, "bridge_forwarddelay", "bridge_forward_delay") super(hash) # When the name and the device attributes are given then the pre network-ng behavior will be # adopted using the name as the description and the device as the name (bsc#1192270). unless hash.fetch("name", "").empty? || hash.fetch("device", "").empty? self.name = hash["device"] self.description = hash["name"] end return unless hash["aliases"].is_a?(Hash) self.aliases = hash["aliases"].values.map { |h| AliasSection.new_from_hashes(h) } end |
#section_path ⇒ Installation::AutoinstProfile::ElementPath?
Returns the section path
382 383 384 385 386 |
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 382 def section_path return nil unless parent parent.section_path.join(index) end |
#to_hashes ⇒ Object
335 336 337 338 339 340 341 342 343 344 |
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 335 def to_hashes hash = super alias_sections = hash.delete("aliases") if alias_sections && !alias_sections.empty? hash["aliases"] = alias_sections.each_with_object({}).each_with_index do |(a, all), idx| all["alias#{idx}"] = a end end hash end |
#wireless_keys ⇒ Array<String>
Helper to get wireless keys as array
348 349 350 351 352 353 354 355 356 |
# File 'src/lib/y2network/autoinst_profile/interface_section.rb', line 348 def wireless_keys keys = [] (0..3).each do |i| key = public_send(:"wireless_key#{i}") keys << key unless key.empty? end keys end |