Class: CLISplash::Sequences

Inherits:
Thor
  • Object
show all
Includes:
Splash::Exiter, Splash::Loggers, Splash::Sequences, Splash::Transports
Defined in:
lib/splash/cli/sequences.rb

Overview

Thor inherited class for sequences management

Constant Summary

Constants included from Splash::Loggers

Splash::Loggers::ALIAS, Splash::Loggers::LEVELS

Constants included from Splash::Constants

Splash::Constants::AUTHOR, Splash::Constants::BACKENDS_STRUCT, Splash::Constants::CONFIG_FILE, Splash::Constants::COPYRIGHT, Splash::Constants::DAEMON_LOGMON_SCHEDULING, Splash::Constants::DAEMON_METRICS_SCHEDULING, Splash::Constants::DAEMON_PID_FILE, Splash::Constants::DAEMON_PROCESS_NAME, Splash::Constants::DAEMON_PROCMON_SCHEDULING, Splash::Constants::DAEMON_STDERR_TRACE, Splash::Constants::DAEMON_STDOUT_TRACE, Splash::Constants::DEFAULT_RETENTION, Splash::Constants::EMAIL, Splash::Constants::EXECUTION_TEMPLATE, Splash::Constants::EXECUTION_TEMPLATE_TOKENS_LIST, Splash::Constants::LICENSE, Splash::Constants::LOGGERS_STRUCT, Splash::Constants::PID_PATH, Splash::Constants::PROMETHEUS_ALERTMANAGER_URL, Splash::Constants::PROMETHEUS_PUSHGATEWAY_URL, Splash::Constants::PROMETHEUS_URL, Splash::Constants::TRACE_PATH, Splash::Constants::TRANSPORTS_STRUCT, Splash::Constants::VERSION, Splash::Constants::WEBADMIN_IP, Splash::Constants::WEBADMIN_PID_FILE, Splash::Constants::WEBADMIN_PID_PATH, Splash::Constants::WEBADMIN_PORT, Splash::Constants::WEBADMIN_PROCESS_NAME, Splash::Constants::WEBADMIN_PROXY, Splash::Constants::WEBADMIN_STDERR_TRACE, Splash::Constants::WEBADMIN_STDOUT_TRACE

Constants included from Splash::Exiter

Splash::Exiter::EXIT_MAP

Instance Method Summary collapse

Methods included from Splash::Loggers

#change_logger, #get_logger, #get_session

Methods included from Splash::Config

#get_config, #rehash_config

Methods included from Splash::ConfigUtilities

#addservice, #checkconfig, #flush_backend, #setupsplash

Methods included from Splash::Helpers

#check_unicode_term, #daemonize, #format_by_extensions, #format_response, #get_processes, #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

Methods included from Splash::Exiter

#splash_exit, #splash_return

Methods included from Splash::Transports

#get_default_client, #get_default_subscriber

Methods included from Splash::Sequences

#list_seq, #run_seq, #schedule_seq, #show_seq

Instance Method Details

#execute(sequence) ⇒ Object



21
22
23
24
25
# File 'lib/splash/cli/sequences.rb', line 21

def execute(sequence)
  options[:name] = sequence
  acase = run_as_root :run_seq, options
  splash_exit acase
end

#listObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/splash/cli/sequences.rb', line 65

def list
  acase = run_as_root :list_seq, options
  log = get_logger
  unless acase[:data].nil?
    log.info "Splash configured sequences"
    acase[:data].keys.each do |seq|
      log.item seq
      if options[:detail] then
        dseq = acase[:data][seq]
        unless dseq[:options].nil? then
          log.arrow "Options : "
          log.flat  "    * continue on failure : #{dseq[:options][:continue]}" unless dseq[:options][:continue].nil?
        end
        log.arrow "Definition :"
        dseq[:definition].each do |step|
          log.flat "    * Step name : #{step[:step]}"
          log.flat "      => Splash Command to execute : #{step[:command]}"
          log.flat "      => Execute remote on host : #{step[:on_host]}" unless step[:on_host].nil?
          log.flat "      => Follow Callback : #{step[:callback]}" unless step[:callback].nil?
          log.flat "      => Prometheus notification : #{step[:notification]}" unless step[:notification].nil?
        end
      end
    end
  end
  splash_exit acase
end

#schedule(sequence) ⇒ Object



104
105
106
107
108
109
110
# File 'lib/splash/cli/sequences.rb', line 104

def schedule(sequence)
  options[:sequence] = sequence
  acase = run_as_root :schedule_seq, options
  log = get_logger
  log.info "Feature in development"
  splash_exit acase
end

#show(sequence) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/splash/cli/sequences.rb', line 33

def show(sequence)
  options = {}
  log = get_logger
  options[:name] = sequence
  acase = run_as_root :show_seq, options
  unless acase[:data].nil? then
    dseq = acase[:data]
    log.item sequence
    unless dseq[:options].nil? then
      log.arrow "Options : "
      log.flat  "    * continue on failure : #{dseq[:options][:continue]}" unless dseq[:options][:continue].nil?
    end
    log.arrow "Definition :"
    dseq[:definition].each do |step|
      log.flat "    * Step name : #{step[:step]}"
      log.flat "      => Splash Command to execute : #{step[:command]}"
      log.flat "      => Execute remote on host : #{step[:on_host]}" unless step[:on_host].nil?
      log.flat "      => Follow Callback : #{step[:callback]}" unless step[:callback].nil?
      log.flat "      => Prometheus notification : #{step[:notification]}" unless step[:notification].nil?
    end
  end
  splash_exit acase
end