Class: Y2Network::DNS

Inherits:
Object
  • Object
show all
Defined in:
src/lib/y2network/dns.rb

Overview

DNS configuration (hostname, nameservers, etc.).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ DNS

TODO:

receive an array instead all these arguments

Returns a new instance of DNS.

Parameters:

  • opts (Hash) (defaults to: {})

    DNS configuration options

Options Hash (opts):

  • :hostname (String)
  • :nameservers (Array<String>)
  • :searchlist (Array<String>)
  • :resolv_conf_policy (ResolvConfPolicy)
  • :dhcp_hostname (Boolean)

50
51
52
53
54
55
56
# File 'src/lib/y2network/dns.rb', line 50

def initialize(opts = {})
  @hostname = opts[:hostname]
  @nameservers = opts[:nameservers] || []
  @searchlist = opts[:searchlist] || []
  @resolv_conf_policy = opts[:resolv_conf_policy]
  @dhcp_hostname = opts[:dhcp_hostname]
end

Instance Attribute Details

#dhcp_hostnameString, Symbol

Returns Whether to take the hostname from DHCP. It can be an interface name (String), :any for any interface or :none from no taking the hostname from DHCP.

Returns:

  • (String, Symbol)

    Whether to take the hostname from DHCP. It can be an interface name (String), :any for any interface or :none from no taking the hostname from DHCP.


40
41
42
# File 'src/lib/y2network/dns.rb', line 40

def dhcp_hostname
  @dhcp_hostname
end

#hostnameString

Returns Hostname (local part).

Returns:

  • (String)

    Hostname (local part)


26
27
28
# File 'src/lib/y2network/dns.rb', line 26

def hostname
  @hostname
end

#nameserversArray<IPAddr>

Returns List of nameservers.

Returns:

  • (Array<IPAddr>)

    List of nameservers


29
30
31
# File 'src/lib/y2network/dns.rb', line 29

def nameservers
  @nameservers
end

#resolv_conf_policyString

Returns resolv.conf update policy.

Returns:

  • (String)

    resolv.conf update policy


35
36
37
# File 'src/lib/y2network/dns.rb', line 35

def resolv_conf_policy
  @resolv_conf_policy
end

#searchlistArray<String>

Returns List of search domains.

Returns:

  • (Array<String>)

    List of search domains


32
33
34
# File 'src/lib/y2network/dns.rb', line 32

def searchlist
  @searchlist
end

Instance Method Details

#==(other) ⇒ Boolean

Determines whether two set of DNS settings are equal

Parameters:

  • other (DNS)

    DNS settings to compare with

Returns:

  • (Boolean)

68
69
70
# File 'src/lib/y2network/dns.rb', line 68

def ==(other)
  ATTRS.all? { |a| public_send(a) == other.public_send(a) }
end