Class: Y2Network::AutoinstProfile::InterfacesSection

Inherits:
SectionWithAttributes show all
Includes:
Yast::Logger
Defined in:
src/lib/y2network/autoinst_profile/interfaces_section.rb

Overview

This class represents an AutoYaST <interfaces> section under <networking>

<interfaces config:type="list">
  <interface>
    <bootproto>dhcp</bootproto>
    <device>eth0</device>
    <startmode>auto</startmode>
  </interface>
  <interface>
    <bootproto>static</bootproto>
    <broadcast>127.255.255.255</broadcast>
    <device>lo</device>
    <firewall>no</firewall>
    <ipaddr>127.0.0.1</ipaddr>
    <netmask>255.0.0.0</netmask>
    <network>127.0.0.0</network>
    <prefixlen>8</prefixlen>
    <startmode>nfsroot</startmode>
    <usercontrol>no</usercontrol>
  </interface>
</interfaces>

See Also:

Instance Attribute Summary collapse

Attributes inherited from SectionWithAttributes

#parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SectionWithAttributes

new_from_hashes, #section_name, #to_hashes

Constructor Details

#initialize(*_args) ⇒ InterfacesSection

Constructor


73
74
75
76
# File 'src/lib/y2network/autoinst_profile/interfaces_section.rb', line 73

def initialize(*_args)
  super
  @interfaces = []
end

Instance Attribute Details

#interfacesArray<InterfaceSection>

Returns:


# File 'src/lib/y2network/autoinst_profile/interfaces_section.rb', line 59

Class Method Details

.attributesObject


51
52
53
54
55
# File 'src/lib/y2network/autoinst_profile/interfaces_section.rb', line 51

def self.attributes
  [
    { name: :interfaces }
  ]
end

.new_from_network(config) ⇒ InterfacesSection

Clones network interfaces settings into an AutoYaST interfaces section

Parameters:

  • config (Y2Network::Config)

    whole config as it need both interfaces and connection configs

Returns:


66
67
68
69
70
# File 'src/lib/y2network/autoinst_profile/interfaces_section.rb', line 66

def self.new_from_network(config)
  result = new
  initialized = result.init_from_network(config)
  initialized ? result : nil
end

Instance Method Details

#init_from_hashes(hash) ⇒ Object

Method used by SectionWithAttributes.new_from_hashes to populate the attributes when importing a profile

Parameters:


81
82
83
# File 'src/lib/y2network/autoinst_profile/interfaces_section.rb', line 81

def init_from_hashes(hash)
  @interfaces = interfaces_from_hash(hash)
end

#init_from_network(connection_configs) ⇒ Boolean

Method used by new_from_network to populate the attributes when cloning routing settings

Parameters:

Returns:

  • (Boolean)

    Result true on success or false otherwise


89
90
91
92
# File 'src/lib/y2network/autoinst_profile/interfaces_section.rb', line 89

def init_from_network(connection_configs)
  @interfaces = interfaces_section(connection_configs)
  true
end