Class: Y2Network::AutoinstProfile::InterfacesSection

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

Overview

This class represents an AutoYaST section under

dhcp eth0 auto static 127.255.255.255 lo no 127.0.0.1 02:02:02:02:02:02 255.0.0.0 127.0.0.0 8 nfsroot no

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*_args) ⇒ InterfacesSection

Constructor



76
77
78
79
# File 'src/lib/y2network/autoinst_profile/interfaces_section.rb', line 76

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

Instance Attribute Details

#interfacesArray<InterfaceSection>

Returns:



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

Class Method Details

.attributesObject



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

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

.new_from_network(config, parent = nil) ⇒ InterfacesSection

Clones network interfaces settings into an AutoYaST interfaces section

Parameters:

  • config (Y2Network::Config)

    whole config as it need both interfaces and connection configs

  • parent (SectionWithAttributes, nil) (defaults to: nil)

    Parent section

Returns:



69
70
71
72
73
# File 'src/lib/y2network/autoinst_profile/interfaces_section.rb', line 69

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

Instance Method Details

#init_from_hashes(hash) ⇒ Object

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

Parameters:

  • hash (Array)

    see new_from_hashes. In this case it is array of interfaces



84
85
86
87
88
# File 'src/lib/y2network/autoinst_profile/interfaces_section.rb', line 84

def init_from_hashes(hash)
  # we expect list of hashes here, remove everything else
  h = hash.delete_if { |v| !v.is_a?(Hash) }
  @interfaces = interfaces_from_hash(h)
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



94
95
96
97
# File 'src/lib/y2network/autoinst_profile/interfaces_section.rb', line 94

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