Class: Y2Network::AutoinstProfile::DNSSection

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

Overview

This class represents an AutoYaST section under

true linux.example.org 192.168.122.1 10.0.0.2 auto example.net example.org

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*_args) ⇒ DNSSection

Constructor



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

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, hostname, parent = nil) ⇒ DNSSection

Clones network dns settings into an AutoYaST dns section

NOTE: we need both DNS and Hostname settings because of historical reasons when both used to be handled in one class / module

Parameters:

  • dns (Y2Network::DNS)

    DNS settings

  • hostname (Y2Network::Hostname)

    Hostname settings

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

    Parent section

Returns:



78
79
80
81
82
# File 'src/lib/y2network/autoinst_profile/dns_section.rb', line 78

def self.new_from_network(dns, hostname, parent = nil)
  result = new(parent)
  initialized = result.init_from_network(dns, hostname)
  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 (Hash)

    see new_from_hashes



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

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

#init_from_network(dns, hostname) ⇒ 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



106
107
108
109
110
111
112
113
# File 'src/lib/y2network/autoinst_profile/dns_section.rb', line 106

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