Class: Y2Network::AutoinstProfile::DNSSection

Inherits:
SectionWithAttributes show all
Defined in:
src/lib/y2network/autoinst_profile/dns_section.rb

Overview

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

<dns>
  <dhcp_hostname config:type="boolean">true</dhcp_hostname>
  <hostname>linux.example.org</hostname>
  <nameservers config:type="list">
    <nameserver>192.168.122.1</nameserver>
    <nameserver>10.0.0.2</nameserver>
  </nameservers>
  <resolv_conf_policy>auto</resolv_conf_policy>
  <searchlist config:type="list">
    <search>example.net</search>
    <search>example.org</search>
  </searchlist>
</dns>

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) ⇒ DNSSection

Constructor


81
82
83
84
85
# File 'src/lib/y2network/autoinst_profile/dns_section.rb', line 81

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

Instance Attribute Details

#dhcp_hostnameBoolean

Returns:

  • (Boolean)

# File 'src/lib/y2network/autoinst_profile/dns_section.rb', line 52

#domainString

Returns:

  • (String)

# File 'src/lib/y2network/autoinst_profile/dns_section.rb', line 55

#hostnameString

Returns:

  • (String)

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

#nameserversArray<String>

Returns:

  • (Array<String>)

# File 'src/lib/y2network/autoinst_profile/dns_section.rb', line 61

#resolv_conf_policyArray<String>

Returns:

  • (Array<String>)

# File 'src/lib/y2network/autoinst_profile/dns_section.rb', line 64

#searchlistArray<String>

Returns:

  • (Array<String>)

# File 'src/lib/y2network/autoinst_profile/dns_section.rb', line 67

Class Method Details

.attributesObject


40
41
42
43
44
45
46
47
48
# File 'src/lib/y2network/autoinst_profile/dns_section.rb', line 40

def self.attributes
  [
    { name: :dhcp_hostname },
    { name: :hostname },
    { name: :nameservers },
    { name: :resolv_conf_policy },
    { name: :searchlist }
  ]
end

.new_from_network(dns) ⇒ DNSSection

Clones network dns settings into an AutoYaST dns section

Parameters:

Returns:


74
75
76
77
78
# File 'src/lib/y2network/autoinst_profile/dns_section.rb', line 74

def self.new_from_network(dns)
  result = new
  initialized = result.init_from_network(dns)
  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:


90
91
92
93
94
# File 'src/lib/y2network/autoinst_profile/dns_section.rb', line 90

def init_from_hashes(hash)
  super
  @nameservers = hash["nameservers"] || []
  @searchlist = hash["searchlist"] || []
end

#init_from_network(dns) ⇒ Boolean

Method used by new_from_network to populate the attributes when cloning DNS options

Parameters:

Returns:

  • (Boolean)

    Result true on success or false otherwise


100
101
102
103
104
105
106
107
# File 'src/lib/y2network/autoinst_profile/dns_section.rb', line 100

def init_from_network(dns)
  @dhcp_hostname = dns.dhcp_hostname
  @hostname = dns.hostname
  @nameservers = dns.nameservers.map(&:to_s)
  @resolv_conf_policy = dns.resolv_conf_policy
  @searchlist = dns.searchlist
  true
end