prometheus-splash 0.4.5 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +64 -2
- data/README.md +58 -60
- data/bin/splash +13 -5
- data/config/splash.yml +77 -7
- data/lib/splash/backends.rb +6 -0
- data/lib/splash/backends/file.rb +40 -0
- data/lib/splash/backends/redis.rb +47 -4
- data/lib/splash/cli.rb +31 -3
- data/lib/splash/cli/commands.rb +82 -33
- data/lib/splash/cli/config.rb +25 -4
- data/lib/splash/cli/daemon.rb +11 -14
- data/lib/splash/cli/documentation.rb +5 -2
- data/lib/splash/cli/logs.rb +27 -17
- data/lib/splash/cli/process.rb +103 -0
- data/lib/splash/cli/sequences.rb +112 -0
- data/lib/splash/cli/webadmin.rb +46 -0
- data/lib/splash/commands.rb +146 -120
- data/lib/splash/config.rb +170 -15
- data/lib/splash/config/flush.rb +30 -0
- data/lib/splash/config/sanitycheck.rb +7 -2
- data/lib/splash/config/service.rb +33 -0
- data/lib/splash/config/setup.rb +8 -3
- data/lib/splash/constants.rb +37 -8
- data/lib/splash/daemon.rb +6 -0
- data/lib/splash/daemon/controller.rb +136 -0
- data/lib/splash/daemon/metrics.rb +103 -0
- data/lib/splash/daemon/orchestrator.rb +182 -0
- data/lib/splash/daemon/orchestrator/grammar.rb +76 -0
- data/lib/splash/daemon/orchestrator/hooks.rb +28 -0
- data/lib/splash/dependencies.rb +17 -2
- data/lib/splash/exiter.rb +15 -0
- data/lib/splash/helpers.rb +91 -50
- data/lib/splash/loggers.rb +48 -17
- data/lib/splash/loggers/cli.rb +18 -3
- data/lib/splash/loggers/daemon.rb +23 -4
- data/lib/splash/loggers/dual.rb +35 -2
- data/lib/splash/loggers/web.rb +51 -0
- data/lib/splash/logs.rb +67 -53
- data/lib/splash/processes.rb +83 -0
- data/lib/splash/sequences.rb +105 -0
- data/lib/splash/templates.rb +10 -0
- data/lib/splash/transports.rb +9 -0
- data/lib/splash/transports/rabbitmq.rb +33 -4
- data/lib/splash/webadmin.rb +122 -0
- data/lib/splash/webadmin/api/routes/commands.rb +28 -0
- data/lib/splash/webadmin/api/routes/config.rb +10 -0
- data/lib/splash/webadmin/api/routes/init.rb +2 -0
- data/lib/splash/webadmin/api/routes/logs.rb +59 -0
- data/lib/splash/webadmin/api/routes/process.rb +60 -0
- data/lib/splash/webadmin/main.rb +26 -0
- data/lib/splash/webadmin/portal/controllers/commands.rb +7 -0
- data/lib/splash/webadmin/portal/controllers/documentation.rb +6 -0
- data/lib/splash/webadmin/portal/controllers/home.rb +12 -0
- data/lib/splash/webadmin/portal/controllers/logs.rb +14 -0
- data/lib/splash/webadmin/portal/controllers/notfound.rb +5 -0
- data/lib/splash/webadmin/portal/controllers/processes.rb +14 -0
- data/lib/splash/webadmin/portal/controllers/proxy.rb +28 -0
- data/lib/splash/webadmin/portal/controllers/restclient.rb +19 -0
- data/lib/splash/webadmin/portal/init.rb +11 -0
- data/lib/splash/webadmin/portal/public/css/ultragreen.css +8544 -0
- data/lib/splash/webadmin/portal/public/fonts/FontAwesome.otf +0 -0
- data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff +0 -0
- data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff2 +0 -0
- data/lib/splash/webadmin/portal/public/images/logo_splash.png +0 -0
- data/lib/splash/webadmin/portal/public/images/logo_splash_reduce.png +0 -0
- data/lib/splash/webadmin/portal/public/images/logo_splash_tiny.png +0 -0
- data/lib/splash/webadmin/portal/views/commands.slim +49 -0
- data/lib/splash/webadmin/portal/views/documentation.slim +3 -0
- data/lib/splash/webadmin/portal/views/home.slim +78 -0
- data/lib/splash/webadmin/portal/views/layout.slim +43 -0
- data/lib/splash/webadmin/portal/views/logs.slim +32 -0
- data/lib/splash/webadmin/portal/views/nav.slim +17 -0
- data/lib/splash/webadmin/portal/views/not_found.slim +3 -0
- data/lib/splash/webadmin/portal/views/processes.slim +29 -0
- data/lib/splash/webadmin/portal/views/proxy.slim +13 -0
- data/lib/splash/webadmin/portal/views/restclient.slim +41 -0
- data/lib/splash/webadmin/portal/views/restclient_result.slim +29 -0
- data/prometheus-splash.gemspec +8 -1
- data/spec/helpers_spec.rb +119 -0
- data/templates/ansible-splash/Vagrantfile +1 -1
- data/templates/ansible-splash/deploy.yml +28 -1
- data/templates/ansible-splash/group_vars/DEV.yml +2 -0
- data/templates/ansible-splash/roles/mq/handlers/main.yml +1 -1
- data/templates/ansible-splash/roles/mq/tasks/main.yml +17 -1
- data/templates/ansible-splash/roles/mq/templates/rabbitmq-env.conf.j2 +13 -0
- data/templates/ansible-splash/roles/splash/handlers/main.yml +4 -0
- data/templates/ansible-splash/roles/splash/tasks/main.yml +25 -1
- data/templates/ansible-splash/roles/splash/templates/logrotate.splash.j2 +11 -0
- data/templates/ansible-splash/roles/splash/templates/splash.yml.j2 +1 -1
- data/templates/splashd.service +1 -1
- data/test.sh +42 -0
- metadata +159 -11
- data/lib/splash/controller.rb +0 -90
- data/lib/splash/orchestrator.rb +0 -100
- data/lib/splash/orchestrator/grammar.rb +0 -53
- data/lib/splash/orchestrator/hooks.rb +0 -16
- data/templates/ansible-splash/inventory.prod +0 -26
@@ -1,57 +1,100 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
3
|
+
# base Splash Module
|
2
4
|
module Splash
|
5
|
+
|
6
|
+
# generic backends module
|
3
7
|
module Backends
|
8
|
+
|
9
|
+
# Redis backend definition
|
4
10
|
class Redis
|
5
11
|
include Splash::Config
|
12
|
+
|
13
|
+
# Constructor
|
14
|
+
# @param [Symbol] store name in [:execution_trace] actually (see config and constants )
|
15
|
+
# @return [Splash::Backends::Redis] a Redis backend
|
6
16
|
def initialize(store)
|
7
17
|
@hostname = Socket.gethostname
|
8
18
|
@config = get_config[:backends][:stores][store]
|
9
19
|
conf = { :host => @config[:host], :port => @config[:port], :db => @config[:base].to_i}
|
10
20
|
conf[:password] = @config[:auth] if @config[:auth]
|
11
21
|
@store = ::Redis.new conf
|
12
|
-
|
22
|
+
#@redis_cli_cmd = `which redis-cli`
|
13
23
|
@store.auth(@config[:auth]) if @config[:auth]
|
14
24
|
end
|
15
25
|
|
26
|
+
# return the list of find records in backend for a specific pattern
|
27
|
+
# @param [String] hostname optionnal (default : local hostname)
|
28
|
+
# @param [String] pattern shell regexp
|
29
|
+
# @return [Array] list of record (for all hostname if hostname is specified)
|
16
30
|
def list(pattern='*', hostname = @hostname)
|
17
31
|
return @store.keys("#{hostname}##{pattern}").map{|item| item = remove_hostname(item)}
|
18
32
|
end
|
19
33
|
|
34
|
+
# return the list of find records in backend for a specific pattern, without hostname Checking
|
35
|
+
# Redis Backend specific method
|
36
|
+
# @param [String] pattern shell regexp
|
37
|
+
# @return [Array] list of record (for all hostname if hostname is specified)
|
20
38
|
def listall(pattern='*')
|
21
39
|
return @store.keys(pattern)
|
22
40
|
end
|
23
41
|
|
42
|
+
# return value of queried record
|
43
|
+
# @param [Hash] options
|
44
|
+
# @option options [Symbol] :key the name of the record
|
45
|
+
# @return [String] content value of record
|
24
46
|
def get(options)
|
25
47
|
hostname = (options[:hostname])? options[:hostname] : @hostname
|
26
48
|
return @store.get(prefix_hostname(options[:key],hostname))
|
27
49
|
end
|
28
50
|
|
51
|
+
# defined and store value for specified key
|
52
|
+
# @param [Hash] options
|
53
|
+
# @option options [Symbol] :key the name of the record
|
54
|
+
# @option options [Symbol] :value the content value of the record
|
55
|
+
# @return [String] content value of record
|
29
56
|
def put(options)
|
30
57
|
hostname = (options[:hostname])? options[:hostname] : @hostname
|
31
58
|
@store.set prefix_hostname(options[:key],hostname), options[:value]
|
32
59
|
end
|
33
60
|
|
61
|
+
# delete a specific record
|
62
|
+
# @param [Hash] options
|
63
|
+
# @option options [Symbol] :key the name of the record
|
64
|
+
# @return [Boolean] status of the operation
|
34
65
|
def del(options)
|
35
66
|
hostname = (options[:hostname])? options[:hostname] : @hostname
|
36
67
|
@store.del prefix_hostname(options[:key],hostname)
|
37
68
|
end
|
38
69
|
|
70
|
+
# flush all records in backend
|
39
71
|
def flush
|
40
|
-
|
41
|
-
|
72
|
+
#`#{@redis_cli_cmd} -n #{@config[:base]} flushdb`
|
73
|
+
@store.flushdb
|
42
74
|
end
|
43
75
|
|
76
|
+
# verifiy a specific record existance
|
77
|
+
# @param [Hash] options
|
78
|
+
# @option options [Symbol] :key the name of the record
|
79
|
+
# @return [Boolean] presence of the record
|
44
80
|
def exist?(options)
|
45
81
|
hostname = (options[:hostname])? options[:hostname] : @hostname
|
46
82
|
return ( not @store.get(prefix_hostname(options[:key],hostname)).nil?)
|
47
83
|
end
|
48
84
|
|
49
85
|
private
|
86
|
+
|
87
|
+
# Redis backend specific method for prefix record name with hostname
|
88
|
+
# @param [String] key
|
89
|
+
# @param [String] hostname
|
90
|
+
# @return [String] prefixed string
|
50
91
|
def prefix_hostname(key,hostname)
|
51
92
|
return "#{hostname}##{key}"
|
52
93
|
end
|
53
94
|
|
54
|
-
|
95
|
+
# Redis backend specific method for removing hostname of record
|
96
|
+
# @param [String] astring
|
97
|
+
# @return [String] cleaned string
|
55
98
|
def remove_hostname(astring)
|
56
99
|
result = astring.split("#")
|
57
100
|
result.shift
|
data/lib/splash/cli.rb
CHANGED
@@ -1,20 +1,48 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
Dir[File.dirname(__FILE__) + '/cli/*.rb'].each {|file| require file }
|
3
3
|
|
4
|
+
# The CLI Command structure for Thor
|
4
5
|
class CLI < Thor
|
6
|
+
|
7
|
+
# callback for managing ARGV errors
|
5
8
|
def self.exit_on_failure?
|
6
9
|
true
|
7
10
|
end
|
8
11
|
|
12
|
+
# Constructor override to manage debug, colors and emoji options for logger
|
13
|
+
def initialize(*args)
|
14
|
+
super
|
15
|
+
log = get_logger
|
16
|
+
options[:colors.to_s]
|
17
|
+
log.level = :debug if options[:debug]
|
18
|
+
log.emoji = options[:emoji.to_s]
|
19
|
+
log.color = options[:colors.to_s]
|
20
|
+
log.debug "DEBUG activated" if options[:debug]
|
21
|
+
end
|
22
|
+
|
23
|
+
class_option :quiet, :desc => "Quiet mode, limit output to :fatal", :aliases => "-q", :type => :boolean
|
24
|
+
class_option :emoji, :desc => "Display Emoji", :type => :boolean, :default => true
|
25
|
+
class_option :colors, :desc => "Display colors", :type => :boolean, :default => true
|
26
|
+
class_option :debug, :desc => "Set log level to :debug", :aliases => "-d", :type => :boolean
|
27
|
+
|
28
|
+
|
9
29
|
include CLISplash
|
10
|
-
desc "commands SUBCOMMAND ...ARGS", "Managing commands/batchs supervision"
|
30
|
+
desc "commands SUBCOMMAND ...ARGS", "Managing commands/batchs supervision & orchestration"
|
11
31
|
subcommand "commands", Commands
|
32
|
+
desc "sequences SUBCOMMAND ...ARGS", "Managing Sequences of commands"
|
33
|
+
subcommand "sequences", Sequences
|
12
34
|
desc "logs SUBCOMMAND ...ARGS", "Managing Files/Logs supervision"
|
13
35
|
subcommand "logs", Logs
|
14
|
-
desc "
|
36
|
+
desc "processes SUBCOMMAND ...ARGS", "Managing processes supervision"
|
37
|
+
subcommand "processes", Processes
|
38
|
+
desc "daemon SUBCOMMAND ...ARGS", "Splash daemon controller"
|
15
39
|
subcommand "daemon", CLIController
|
16
|
-
desc "config SUBCOMMAND ...ARGS", "
|
40
|
+
desc "config SUBCOMMAND ...ARGS", "Config tools for Splash"
|
17
41
|
subcommand "config", Config
|
18
42
|
desc "documentation SUBCOMMAND ...ARGS", "Documentation for Splash"
|
19
43
|
subcommand "documentation", Documentation
|
44
|
+
desc "webadmin SUBCOMMAND ...ARGS", "Splash Webadmin daemon controller"
|
45
|
+
subcommand "webadmin", WebAdmin
|
46
|
+
|
47
|
+
|
20
48
|
end
|
data/lib/splash/cli/commands.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
module CLISplash
|
3
2
|
|
3
|
+
# module for all Thor subcommands
|
4
|
+
module CLISplash
|
4
5
|
|
6
|
+
# Thor inherited class for commands management
|
5
7
|
class Commands < Thor
|
6
8
|
include Splash::Config
|
7
9
|
include Splash::Backends
|
@@ -9,7 +11,10 @@ module CLISplash
|
|
9
11
|
include Splash::Transports
|
10
12
|
include Splash::Templates
|
11
13
|
include Splash::Loggers
|
14
|
+
include Splash::Commands
|
12
15
|
|
16
|
+
|
17
|
+
# Thor method : execution of command
|
13
18
|
desc "execute NAME", "run for command/sequence or ack result"
|
14
19
|
long_desc <<-LONGDESC
|
15
20
|
execute command or sequence or ack result\n
|
@@ -21,14 +26,16 @@ module CLISplash
|
|
21
26
|
with --hostname, execute on an other Splash daemon node
|
22
27
|
LONGDESC
|
23
28
|
option :trace, :type => :boolean, :default => true
|
24
|
-
option :ack, :type => :boolean, negate: false
|
29
|
+
option :ack, :type => :boolean, negate: false, :aliases => "-a"
|
25
30
|
option :notify, :type => :boolean, :default => true
|
26
31
|
option :callback, :type => :boolean, :default => true
|
27
|
-
option :hostname, :type => :string
|
32
|
+
option :hostname, :type => :string, :aliases => "-H"
|
28
33
|
def execute(name)
|
29
34
|
log = get_logger
|
35
|
+
log.level = :fatal if options[:quiet]
|
30
36
|
if is_root? then
|
31
37
|
if options[:hostname] then
|
38
|
+
options[:hostname] = Socket.gethostname if options[:hostname] == 'hostname'
|
32
39
|
splash_exit({ :case => :options_incompatibility, :more => '--hostname forbidden with delagate commands'}) if get_config.commands[name.to_sym][:delegate_to]
|
33
40
|
log.info "Remote Splash configured commands on #{options[:hostname]}:"
|
34
41
|
log.info "ctrl+c for interrupt"
|
@@ -49,15 +56,16 @@ module CLISplash
|
|
49
56
|
payload: {:name => name},
|
50
57
|
:return_to => "splash.#{Socket.gethostname}.returncli",
|
51
58
|
:queue => "splash.#{options[:hostname]}.input" })
|
52
|
-
res[:more] = "Remote command : :execute_command Scheduled"
|
53
|
-
splash_exit res
|
54
59
|
end
|
55
60
|
end
|
56
61
|
rescue Interrupt
|
57
62
|
splash_exit case: :interrupt, more: "Remote command exection"
|
58
63
|
end
|
64
|
+
log.receive "Command execute confirmation"
|
65
|
+
res[:more] = "Remote command : :execute_command Scheduled"
|
66
|
+
splash_exit res
|
59
67
|
else
|
60
|
-
command =
|
68
|
+
command = CommandWrapper::new(name)
|
61
69
|
if options[:ack] then
|
62
70
|
splash_exit command.ack
|
63
71
|
end
|
@@ -70,6 +78,7 @@ module CLISplash
|
|
70
78
|
end
|
71
79
|
|
72
80
|
|
81
|
+
# Thor method : scheduling commands
|
73
82
|
desc "schedule NAME", "Schedule excution of command on Splash daemon"
|
74
83
|
long_desc <<-LONGDESC
|
75
84
|
Schedule excution of command on Splash daemon\n
|
@@ -80,11 +89,12 @@ module CLISplash
|
|
80
89
|
WARNING : scheduling by CLI are not percisted, so use it only for specifics cases.\n
|
81
90
|
NOTES : Scheduling, force trace, notifying and callback.
|
82
91
|
LONGDESC
|
83
|
-
option :hostname, :type => :string
|
92
|
+
option :hostname, :type => :string, :default => Socket.gethostname, :aliases => "-H"
|
84
93
|
option :at, :type => :string
|
85
94
|
option :in, :type => :string
|
86
95
|
def schedule(name)
|
87
96
|
log = get_logger
|
97
|
+
log.level = :fatal if options[:quiet]
|
88
98
|
hostname = (options[:hostname])? options[:hostname] : Socket.gethostname
|
89
99
|
splash_exit({ :case => :options_incompatibility, :more => '--at or --in is required'}) unless options[:at] or options[:in]
|
90
100
|
splash_exit({ :case => :options_incompatibility, :more => '--at an --in'}) if options[:at] and options[:in]
|
@@ -101,47 +111,78 @@ module CLISplash
|
|
101
111
|
payload: {:name => name, :schedule => schedule},
|
102
112
|
:return_to => "splash.#{Socket.gethostname}.returncli",
|
103
113
|
:queue => "splash.#{hostname}.input" })
|
104
|
-
log.receive "Execute command sheduled confirmed"
|
105
|
-
res[:more] = "Remote command : :execute_command with schedule"
|
106
|
-
splash_exit res
|
107
114
|
end
|
108
115
|
rescue Interrupt
|
109
116
|
splash_exit case: :interrupt, more: "Remote command exection"
|
110
117
|
end
|
118
|
+
log.receive "Execute command sheduled confirmed"
|
119
|
+
res[:more] = "Remote command : :execute_command with schedule"
|
120
|
+
splash_exit res
|
111
121
|
|
112
122
|
end
|
113
123
|
|
114
|
-
|
124
|
+
# Thor method : getting a treeview of sequence of commands
|
115
125
|
desc "treeview", "Show commands sequence tree"
|
116
|
-
|
126
|
+
long_desc <<-LONGDESC
|
127
|
+
Show commands sequence tree\n
|
128
|
+
with --hostname, ask other Splash daemon via transport\n
|
129
|
+
LONGDESC
|
130
|
+
option :hostname, :type => :string, :aliases => "-H"
|
131
|
+
def treeview(command)
|
132
|
+
depht = 0
|
117
133
|
log = get_logger
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
134
|
+
if options[:hostname] then
|
135
|
+
options[:hostname] = Socket.gethostname if options[:hostname] == 'hostname'
|
136
|
+
log.info "Remote Splash treeview command on #{options[:hostname]}:"
|
137
|
+
log.info "ctrl+c for interrupt"
|
138
|
+
begin
|
139
|
+
transport = get_default_client
|
140
|
+
if transport.class == Hash and transport.include? :case then
|
141
|
+
splash_exit transport
|
142
|
+
else
|
143
|
+
commands = transport.execute({ :verb => :list_commands,
|
144
|
+
:return_to => "splash.#{Socket.gethostname}.returncli",
|
145
|
+
:queue => "splash.#{options[:hostname]}.input" })
|
146
|
+
end
|
147
|
+
rescue Interrupt
|
148
|
+
splash_exit case: :interrupt, more: "Remote command exection"
|
149
|
+
end
|
150
|
+
log.receive "Receving list of commands from #{options[:hostname]}"
|
151
|
+
else
|
152
|
+
commands = get_config.commands
|
124
153
|
end
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
154
|
+
log.info "Command : #{command.to_s}" if depht == 0
|
155
|
+
aproc = Proc::new do |command,depht|
|
156
|
+
cmd = commands[command.to_sym]
|
157
|
+
if cmd[:on_failure] then
|
158
|
+
spacer= " " * depht + " "
|
159
|
+
log.flat "#{spacer}* on failure => #{cmd[:on_failure]}"
|
160
|
+
aproc.call(cmd[:on_failure], depht+2)
|
161
|
+
end
|
162
|
+
if cmd[:on_success] then
|
163
|
+
spacer = " " * depht + " "
|
164
|
+
log.flat "#{spacer}* on success => #{cmd[:on_success]}"
|
165
|
+
aproc.call(cmd[:on_success],depht+2)
|
166
|
+
end
|
129
167
|
end
|
168
|
+
aproc.call(command,depht)
|
130
169
|
end
|
131
170
|
|
132
171
|
|
172
|
+
# Thor method : getting the list of available commands in splash config
|
133
173
|
desc "list", "Show configured commands"
|
134
174
|
long_desc <<-LONGDESC
|
135
175
|
Show configured commands\n
|
136
176
|
with --detail, show command details\n
|
137
177
|
with --hostname, ask other Splash daemon via transport\n
|
138
178
|
LONGDESC
|
139
|
-
option :detail, :type => :boolean
|
140
|
-
option :hostname, :type => :string
|
179
|
+
option :detail, :type => :boolean, :aliases => "-D"
|
180
|
+
option :hostname, :type => :string, :aliases => "-H"
|
141
181
|
def list
|
142
182
|
log = get_logger
|
143
183
|
list = {}
|
144
184
|
if options[:hostname] then
|
185
|
+
options[:hostname] = Socket.gethostname if options[:hostname] == 'hostname'
|
145
186
|
log.info "Remote Splash configured commands on #{options[:hostname]}:"
|
146
187
|
log.info "ctrl+c for interrupt"
|
147
188
|
begin
|
@@ -156,10 +197,11 @@ module CLISplash
|
|
156
197
|
rescue Interrupt
|
157
198
|
splash_exit case: :interrupt, more: "remote list Command"
|
158
199
|
end
|
200
|
+
log.receive "Receving list of commands from #{options[:hostname]}"
|
159
201
|
else
|
160
|
-
log.info "Splash configured commands :"
|
161
202
|
list = get_config.commands
|
162
203
|
end
|
204
|
+
log.info "Splash configured commands :"
|
163
205
|
log.ko 'No configured commands found' if list.keys.empty?
|
164
206
|
list.keys.each do |command|
|
165
207
|
log.item "#{command.to_s}"
|
@@ -177,17 +219,18 @@ module CLISplash
|
|
177
219
|
splash_exit case: :quiet_exit
|
178
220
|
end
|
179
221
|
|
180
|
-
|
222
|
+
# Thor method: getting informations about a specific splash configuration defined command
|
181
223
|
desc "show COMMAND", "Show specific configured command COMMAND"
|
182
224
|
long_desc <<-LONGDESC
|
183
225
|
Show specific configured command COMMAND\n
|
184
226
|
with --hostname <HOSTNAME>, an other Splash monitored server (only with Redis backend configured)
|
185
227
|
LONGDESC
|
186
|
-
option :hostname, :type => :string
|
228
|
+
option :hostname, :type => :string, :aliases => "-H"
|
187
229
|
def show(command)
|
188
230
|
log = get_logger
|
189
231
|
list = {}
|
190
232
|
if options[:hostname] then
|
233
|
+
options[:hostname] = Socket.gethostname if options[:hostname] == 'hostname'
|
191
234
|
log.info "Remote Splash configured commands on #{options[:hostname]}:"
|
192
235
|
log.info "ctrl+c for interrupt"
|
193
236
|
begin
|
@@ -202,6 +245,7 @@ module CLISplash
|
|
202
245
|
rescue Interrupt
|
203
246
|
splash_exit case: :interrupt, more: "remote list Command"
|
204
247
|
end
|
248
|
+
log.receive "Receving list of commands from #{options[:hostname]}"
|
205
249
|
else
|
206
250
|
list = get_config.commands
|
207
251
|
end
|
@@ -221,13 +265,13 @@ module CLISplash
|
|
221
265
|
end
|
222
266
|
end
|
223
267
|
|
224
|
-
|
268
|
+
# Thor method : getting information on the last execution of a command
|
225
269
|
desc "lastrun COMMAND", "Show last running result for specific configured command COMMAND"
|
226
270
|
long_desc <<-LONGDESC
|
227
271
|
Show last running result for specific configured command COMMAND\n
|
228
272
|
with --hostname <HOSTNAME>, an other Splash monitored server (only with Redis backend configured)
|
229
273
|
LONGDESC
|
230
|
-
option :hostname, :type => :string
|
274
|
+
option :hostname, :type => :string, :aliases => "-H"
|
231
275
|
def lastrun(command)
|
232
276
|
log = get_logger
|
233
277
|
backend = get_backend :execution_trace
|
@@ -235,8 +279,10 @@ module CLISplash
|
|
235
279
|
if not redis and options[:hostname] then
|
236
280
|
splash_exit case: :specific_config_required, :more => "Redis backend is requiered for Remote execution report request"
|
237
281
|
end
|
282
|
+
splash_exit case: :not_root if not is_root? and not redis
|
238
283
|
list = get_config.commands.keys
|
239
284
|
if options[:hostname] then
|
285
|
+
options[:hostname] = Socket.gethostname if options[:hostname] == 'hostname'
|
240
286
|
list = backend.list("*", options[:hostname]).map(&:to_sym)
|
241
287
|
end
|
242
288
|
if list.include? command.to_sym then
|
@@ -259,6 +305,7 @@ module CLISplash
|
|
259
305
|
end
|
260
306
|
end
|
261
307
|
|
308
|
+
# Thor method : getting the list of avaibles executions reports
|
262
309
|
desc "getreportlist", "list all executions report results "
|
263
310
|
long_desc <<-LONGDESC
|
264
311
|
list all executions report results\n
|
@@ -268,12 +315,13 @@ module CLISplash
|
|
268
315
|
with --detail, get major informations of each reports\n
|
269
316
|
--all and --hostname are exclusives
|
270
317
|
LONGDESC
|
271
|
-
option :pattern, :type => :string
|
272
|
-
option :hostname, :type => :string
|
273
|
-
option :all, :type => :boolean, :negate => false
|
274
|
-
option :detail, :type => :boolean
|
318
|
+
option :pattern, :type => :string, :aliases => "-p"
|
319
|
+
option :hostname, :type => :string, :aliases => "-H"
|
320
|
+
option :all, :type => :boolean, :negate => false, :aliases => "-A"
|
321
|
+
option :detail, :type => :boolean, :aliases => "-D"
|
275
322
|
def getreportlist
|
276
323
|
log = get_logger
|
324
|
+
options[:hostname] = Socket.gethostname if options[:hostname] == 'hostname'
|
277
325
|
if options[:hostname] and options[:all] then
|
278
326
|
splash_exit case: :options_incompatibility, more: "--all, --hostname"
|
279
327
|
end
|
@@ -282,6 +330,7 @@ module CLISplash
|
|
282
330
|
if not redis and (options[:hostname] or options[:all]) then
|
283
331
|
splash_exit case: :specific_config_required, more: "Redis Backend requiered for Remote execution report Request"
|
284
332
|
end
|
333
|
+
splash_exit case: :not_root if not is_root? and not redis
|
285
334
|
pattern = (options[:pattern])? options[:pattern] : '*'
|
286
335
|
if options[:all] then
|
287
336
|
res = backend.listall pattern
|
data/lib/splash/cli/config.rb
CHANGED
@@ -1,39 +1,60 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
3
|
+
# module for all Thor subcommands
|
2
4
|
module CLISplash
|
3
5
|
|
6
|
+
# Thor inherited class for configuration management
|
4
7
|
class Config < Thor
|
5
8
|
include Splash::ConfigUtilities
|
6
9
|
include Splash::Helpers
|
7
10
|
include Splash::Exiter
|
8
11
|
include Splash::Loggers
|
9
12
|
|
10
|
-
|
13
|
+
# Thor method : running of Splash setup
|
11
14
|
desc "setup", "Setup installation fo Splash"
|
12
15
|
long_desc <<-LONGDESC
|
13
16
|
Setup installation fo Splash\n
|
14
17
|
with --preserve, preserve from reinstallation of the config
|
15
18
|
LONGDESC
|
16
|
-
option :preserve, :type => :boolean
|
19
|
+
option :preserve, :type => :boolean, :aliases => "-P"
|
17
20
|
def setup
|
18
21
|
acase = run_as_root :setupsplash, options
|
19
22
|
splash_exit acase
|
20
23
|
end
|
21
24
|
|
25
|
+
# Thor method : running of Splash sanitycheck
|
22
26
|
desc "sanitycheck", "Verify installation fo Splash"
|
23
27
|
def sanitycheck
|
24
28
|
acase = run_as_root :checkconfig
|
25
29
|
splash_exit acase
|
26
30
|
end
|
27
31
|
|
28
|
-
|
32
|
+
# Thor method : Getting the current Splash version
|
33
|
+
desc "version", "Display current Splash version"
|
29
34
|
def version
|
30
35
|
log = get_logger
|
31
36
|
config = get_config
|
32
37
|
log.info "Splash version : #{config.version}, Author : #{config.author}"
|
33
|
-
|
38
|
+
log.info config.copyright
|
34
39
|
splash_exit case: :quiet_exit
|
35
40
|
end
|
36
41
|
|
42
|
+
# Thor method : Installing Splashd Systemd service file
|
43
|
+
desc "service", "Install Splashd Systemd service"
|
44
|
+
def service
|
45
|
+
acase = run_as_root :addservice
|
46
|
+
splash_exit acase
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
# Thor method : flushing configured backend
|
51
|
+
desc "flushbackend", "Flush configured backend"
|
52
|
+
def flushbackend
|
53
|
+
acase = run_as_root :flush_backend
|
54
|
+
splash_exit acase
|
55
|
+
end
|
56
|
+
|
57
|
+
|
37
58
|
end
|
38
59
|
|
39
60
|
end
|