Class: Y2Network::AutoinstProfile::NetworkingSection

Inherits:
Installation::AutoinstProfile::SectionWithAttributes
  • Object
show all
Defined in:
src/lib/y2network/autoinst_profile/networking_section.rb

Overview

This class represents an AutoYaST <networking> section

<!-- the routing configuration -->

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#backendString

Returns:

  • (String)


# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 58

#dnsDNSSection

Returns:



# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 58

#interfacesInterfacesSection

Returns:



# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 58

#keep_install_networkBoolean

Returns:

  • (Boolean)


# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 58

#managedBoolean

Returns:

  • (Boolean)


# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 58

#routingRoutingSection

Returns:



# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 58

#s390_devicesS390DevicesSection

Returns:



# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 58

#setup_before_proposalBoolean

Returns:

  • (Boolean)


# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 58

#start_immediatelyBoolean

Returns:

  • (Boolean)


# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 58

#strict_ip_check_timeoutBoolean

Returns:

  • (Boolean)


# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 58

#udev_rulesUdevRulesSection

Returns:



# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 58

#virt_bridge_proposalBoolean

Returns:

  • (Boolean)


# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 58

Class Method Details

.attributesObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 39

def self.attributes
  [
    { name: :setup_before_proposal },
    { name: :start_immediately },
    { name: :keep_install_network },
    { name: :virt_bridge_proposal },
    { name: :strict_ip_check_timeout },
    { name: :routing },
    { name: :dns },
    { name: :interfaces },
    { name: :udev_rules },
    { name: :s390_devices },
    { name: :managed },
    { name: :backend }
  ]
end

.new_from_hashes(hash) ⇒ NetworkingSection

Creates an instance based on the profile representation used by the AutoYaST modules (hash with nested hashes and arrays).

Parameters:

  • hash (Hash)

    Networking section from an AutoYaST profile

Returns:



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 88

def self.new_from_hashes(hash)
  result = new
  result.backend = hash["backend"]
  result.managed = hash["managed"]
  result.setup_before_proposal = hash["setup_before_proposal"]
  result.start_immediately = hash["start_immediately"]
  result.keep_install_network = hash["keep_install_network"]
  result.virt_bridge_proposal = hash["virt_bridge_proposal"]
  result.strict_ip_check_timeout = hash["strict_ip_check_timeout"]
  result.routing = RoutingSection.new_from_hashes(hash["routing"], result) if hash["routing"]
  result.dns = DNSSection.new_from_hashes(hash["dns"], result) if hash["dns"]
  if hash["interfaces"]
    result.interfaces = InterfacesSection.new_from_hashes(hash["interfaces"], result)
  end
  if hash["net-udev"]
    result.udev_rules = UdevRulesSection.new_from_hashes(hash["net-udev"], result)
  end
  if hash["s390-devices"]
    result.s390_devices = S390DevicesSection.new_from_hashes(hash["s390-devices"], result)
  end
  result
end

.new_from_network(config) ⇒ NetworkingSection

Creates an instance based on the network configuration representation

Parameters:

Returns:



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 115

def self.new_from_network(config)
  result = new
  return result unless config

  result.managed = config.backend?(:network_manager)
  result.backend = config.backend&.id.to_s if config.backend
  build_dns = config.dns || config.hostname

  result.routing = RoutingSection.new_from_network(config.routing) if config.routing
  result.dns = DNSSection.new_from_network(config.dns, config.hostname) if build_dns
  result.interfaces = InterfacesSection.new_from_network(config.connections, result)
  result.udev_rules = UdevRulesSection.new_from_network(config.interfaces)
  result.s390_devices = S390DevicesSection.new_from_network(config.connections)
  result
end

Instance Method Details

#to_hashesHash

Export the section to a hash so it might be used when cloning the system

Returns:

  • (Hash)


134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'src/lib/y2network/autoinst_profile/networking_section.rb', line 134

def to_hashes
  result = {}
  result["dns"] = dns&.to_hashes || {}
  unless managed
    result["routing"] = routing&.to_hashes || {}
    result["net-udev"] = udev_rules&.udev_rules&.map(&:to_hashes) || []
    result["interfaces"] = interfaces&.interfaces&.map(&:to_hashes) || []
    result["s390-devices"] = s390_devices&.to_hashes&.fetch("devices", []) || []
  end

  result.each_key { |k| result.delete(k) if result[k].empty? }
  result["managed"] = true if managed
  result["backend"] = backend if backend
  result
end