Class: Y2Network::AutoinstProfile::DNSSection

Inherits:
SectionWithAttributes 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

Constant Summary

Constants inherited from SectionWithAttributes

SectionWithAttributes::VALUES_TO_SKIP

Instance Attribute Summary collapse

Attributes inherited from SectionWithAttributes

#parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SectionWithAttributes

#attribute_key, #attribute_name, #attribute_scalar, #attribute_skip?, #attribute_value, #attributes, define_attr_accessors, #init_scalars_from_hash, 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


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


#domainString


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


#hostnameString


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


#nameserversArray<String>


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


#resolv_conf_policyArray<String>


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


#searchlistArray<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


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


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


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