Module: Splash::ConfigUtilities

Includes:
Constants, Helpers
Included in:
CLISplash::Config, Config
Defined in:
lib/splash/config/setup.rb,
lib/splash/config/sanitycheck.rb

Constant Summary

Constants included from Constants

Splash::Constants::AUTHOR, Splash::Constants::BACKENDS_STRUCT, Splash::Constants::CONFIG_FILE, Splash::Constants::COPYRIGHT, Splash::Constants::DAEMON_LOGMON_SCHEDULING, Splash::Constants::DAEMON_PID_FILE, Splash::Constants::DAEMON_PID_PATH, Splash::Constants::DAEMON_PROCESS_NAME, Splash::Constants::DAEMON_STDERR_TRACE, Splash::Constants::DAEMON_STDOUT_TRACE, Splash::Constants::EMAIL, Splash::Constants::EXECUTION_TEMPLATE, Splash::Constants::EXECUTION_TEMPLATE_TOKENS_LIST, Splash::Constants::LICENSE, Splash::Constants::LOGGERS_STRUCT, Splash::Constants::PROMETHEUS_PUSHGATEWAY_HOST, Splash::Constants::PROMETHEUS_PUSHGATEWAY_PORT, Splash::Constants::TRACE_PATH, Splash::Constants::TRANSPORTS_STRUCT, Splash::Constants::VERSION

Instance Method Summary collapse

Methods included from Helpers

#daemonize, #get_process, #group_root, #install_file, #is_root?, #make_folder, #make_link, #run_as_root, #search_file_in_gem, #user_root, #verify_file, #verify_folder, #verify_link, #verify_service

Instance Method Details

#checkconfig(options = {}) ⇒ Integer

Sanitycheck action method for testing installation of Splash

Returns:

  • (Integer)

    an errorcode value



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/splash/config/sanitycheck.rb', line 10

def checkconfig(options ={})
  self.extend Splash::Loggers
  log = get_logger
  log.info "Splash -> sanitycheck : "
  config = get_config
  full_res = 0
  res = verify_file(name: CONFIG_FILE, mode: "644", owner: config.user_root, group: config.group_root)
  target = "Config file : #{CONFIG_FILE}"
  if res.empty? then
    log.ok target
  else
    log.ko target
    full_res =+ 1
    log.flat "    pbm => #{res.map {|p| p.to_s}.join(',')}"
  end

  target = "PID Path : #{config[:pid_path]}"
  res = verify_folder(name: config[:pid_path], mode: "755", owner: config.user_root, group: config.group_root)
  if res.empty? then
    log.ok target
  else
    log.ko target
    full_res =+ 1
    log.flat "    pbm => #{res.map {|p| p.to_s}.join(',')}"

  end

  target =  "Trace Path : #{config[:trace_path]}"
  res = verify_folder(name: config[:trace_path], mode: "755", owner: config.user_root, group: config.group_root)
  if res.empty? then
    log.ok target
  else
    log.ko target
    full_res =+ 1
    log.flat "    pbm => #{res.map {|p| p.to_s}.join(',')}"
  end

  target = "Prometheus PushGateway Service running"
  if verify_service host: config.prometheus_pushgateway_host ,port: config.prometheus_pushgateway_port then
    log.ok target
  else
    log.ko target
    full_res =+ 1
  end

  if full_res > 0 then
    log.error "#{full_res} errors occured"
    return { :case => :splash_sanitycheck_error }
  else
    return { :case => :splash_sanitycheck_success}
  end
end

#setupsplash(options = {}) ⇒ Integer

Setup action method for installing Splash

Returns:

  • (Integer)

    an errorcode value



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/splash/config/setup.rb', line 11

def setupsplash(options = {})
  conf_in_path = search_file_in_gem "prometheus-splash", "config/splash.yml"
  full_res = 0
  puts "Splash -> setup : "
  unless options[:preserve] then
    print "* Installing Configuration file : #{CONFIG_FILE} : "
    # TODO TTY plateform
    if install_file source: conf_in_path, target: CONFIG_FILE, mode: "644", owner: user_root, group:  group_root then
      puts "[OK]"
    else
      full_res =+ 1
      puts "[KO]"
    end
  else
    puts "Config file preservation, verify your homemade templates."
  end
  config = get_config
  self.extend Splash::Loggers
  log = get_logger
  log.ok "Splash Initialisation"
  report_in_path = search_file_in_gem "prometheus-splash", "templates/report.txt"
  target =  "Installing template file : #{config.execution_template_path}"
  if install_file source: report_in_path, target: config.execution_template_path, mode: "644", owner: config.user_root, group: config.group_root then
    log.ok target
  else
    full_res =+ 1
    log.ko target
  end

  target = "Creating/Checking pid file path : #{config[:pid_path]}"
  if make_folder path: config[:pid_path], mode: "755", owner: config.user_root, group: config.group_root then
    log.ok target
  else
    full_res =+ 1
    log.ko target
  end

  target = "Creating/Checking trace file path : #{config[:trace_path]} : "
  if make_folder path: config[:trace_path], mode: "755", owner: config.user_root, group: config.group_root then
    log.ok target
  else
    full_res =+ 1
    log.ko target
  end


  if full_res > 0 then
    log.error "#{full_res} errors occured"
    return { :case => :splash_setup_error}
  else
    return { :case => :splash_setup_success }
  end

end