Class: Y2Network::NtpServer

Inherits:
Object
  • Object
show all
Includes:
Yast2::Equatable, Yast::Logger
Defined in:
src/lib/y2network/ntp_server.rb

Overview

Represents an NTP server

It includes basic information about NTP servers. It could be extended in the future as needed.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname, country: nil, location: nil) ⇒ NtpServer

Constructor

Parameters:

  • hostname (String)

    Server's hostname

  • country (String) (defaults to: nil)

    Country code (e.g., "DE")

  • location (String) (defaults to: nil)

    Server's location



103
104
105
106
107
# File 'src/lib/y2network/ntp_server.rb', line 103

def initialize(hostname, country: nil, location: nil)
  @hostname = hostname
  @country = country
  @location = location
end

Instance Attribute Details

#countryString? (readonly)

Returns Country code where the server is located.

Returns:

  • (String, nil)

    Country code where the server is located



39
40
41
# File 'src/lib/y2network/ntp_server.rb', line 39

def country
  @country
end

#hostnameString (readonly)

Returns Server's hostname.

Returns:

  • (String)

    Server's hostname



37
38
39
# File 'src/lib/y2network/ntp_server.rb', line 37

def hostname
  @hostname
end

#locationString? (readonly)

Returns Server's location.

Returns:

  • (String, nil)

    Server's location



41
42
43
# File 'src/lib/y2network/ntp_server.rb', line 41

def location
  @location
end

Class Method Details

.default_servers(products = nil) ⇒ Array<NtpServer>

Determines the default servers

It reads the default NTP servers from the control file, in case of not defined the content of this list will depend on the base product.

Parameters:

  • products (Array<Hash>) (defaults to: nil)

    List of base products

Returns:



58
59
60
61
62
63
64
65
66
67
68
69
# File 'src/lib/y2network/ntp_server.rb', line 58

def default_servers(products = nil)
  servers = control_servers

  if servers
    log.info "Using the servers defined in the control file: #{servers.inspect}"
  else
    servers = product_servers(products)
    log.info "Using the NTP product servers: #{servers.inspect}"
  end

  servers.map { |s| new(s) }
end