Sha256: b765dddb13bd49f04acde50011640d549579bf8e8be39f65b7087070fecc5351

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

require 'asetus'

module Ring
  class SQA
    Directory = '/etc/ring-sqa'
    class InvalidConfig < StandardError; end
    class NoConfig < StandardError; end

    Config = Asetus.new name: 'sqa', load: false, usrdir: Directory, cfgfile: 'main.conf'
    Config.default.directory          = Directory
    Config.default.debug              = false
    Config.default.hosts.load         = %w( ring.nlnog.net )
    Config.default.hosts.ignore       = %w( infra.ring.nlnog.net )
    Config.default.port               = 'ring'.to_i(36)/100
    Config.default.analyzer.tolerance = 1.2
    Config.default.nodes_json         = '/etc/ring/nodes.json'
    Config.default.mtr.args           = '-i0.5 -c5 -r -w -n'
    Config.default.mtr.timeout        = 15
    Config.default.ram_database       = false
    Config.default.paste.url          = 'https://ring.nlnog.net/paste/'

    begin
      Config.load
    rescue => error
      raise InvalidConfig, "Error loading configuration: #{error.message}"
    end

    CFG = Config.cfg

    CFG.host.name = Socket.gethostname
    CFG.host.ipv4 = Socket::getaddrinfo(CFG.host.name,"echo",Socket::AF_INET)[0][3]
    CFG.host.ipv6 = Socket::getaddrinfo(CFG.host.name,"echo",Socket::AF_INET6)[0][3]

    raise NoConfig, 'edit /etc/ring-sqa/main.conf' if Config.create
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ring-sqa-0.0.23 lib/ring/sqa/cfg.rb
ring-sqa-0.0.22 lib/ring/sqa/cfg.rb
ring-sqa-0.0.21 lib/ring/sqa/cfg.rb
ring-sqa-0.0.20 lib/ring/sqa/cfg.rb