right_chimp 2.1.12 → 2.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc15b41e6fcc5ea1696d6255206015000f9a31ee
4
- data.tar.gz: 462e82c8dc41dfb152fa2218be76f8dbe04b1c1c
3
+ metadata.gz: 1a1bf8d5dec859eb24d0fad4003af83381f78339
4
+ data.tar.gz: fdabc1c04d9aa7593bf6ca56966c31958e593361
5
5
  SHA512:
6
- metadata.gz: f0a8baa2ba2a7b35585d4d6c73a339d03d59cd21b7d02cb576f2f25f0f1fd502ee9d059f619b19d88628611563566de1fad78eddcdf02d274c19aab14df76d82
7
- data.tar.gz: 7cc171141adc3b7c1204489c234e22e3e13ad6461591a47f68910ff31c5e87cbaa32c7d12b28d5e7cc7fbd669ed953a7fde5aedfd5d892ff73154d6a7520b70c
6
+ metadata.gz: 30a3fab9da5cac9f3a8401719cc1d04a9a266c262d0f7fd16fec33ce69b789ac9c4812f73bca4002da74156d7f9d0670f231a06a1a9d163b4f94bba3b14b1f5d
7
+ data.tar.gz: cba737a819c688bf0a68f7c6c7ba1d9c0a7c6b62e6496ab4d46d6b3ba933770bd7454c85b7c4d8859e02faf7e84a1ed75ada587071b055b41d0ff6b07eaf5f2e
data/CHANGES CHANGED
@@ -147,6 +147,12 @@ Version 2.1.3
147
147
  -------------
148
148
  * Feature: chimpd-wait-until now dsiplays the group name it is waiting on every 120secs
149
149
 
150
- Vearsion 2.1.4
150
+ Version 2.1.4
151
151
  -------------
152
152
  * Bugfix: Fixed UI issues casued by long job names
153
+
154
+ Version 2.1.13
155
+ --------------
156
+ * Feature: Changed error reporting format
157
+ * Feature: Web UI now shows job_uuid
158
+ * Feature: One can now associate a "note" to a job by using --job-notes="foo"
@@ -2,11 +2,10 @@
2
2
  #
3
3
  module Chimp
4
4
  class Chimp
5
-
6
5
  attr_accessor :concurrency, :delay, :retry_count, :hold, :progress, :prompt,
7
6
  :quiet, :use_chimpd, :chimpd_host, :chimpd_port, :tags, :array_names,
8
7
  :deployment_names, :script, :all_scripts, :servers, :ssh, :report, :interactive, :action,
9
- :limit_start, :limit_end, :dry_run, :group, :job_id, :job_uuid, :verify, :cli_args
8
+ :limit_start, :limit_end, :dry_run, :group, :job_id, :job_uuid, :job_note, :verify, :cli_args
10
9
  #
11
10
  # These class variables control verbosity
12
11
  #
@@ -259,7 +258,7 @@ module Chimp
259
258
  # If script is an uri/url no need to "detect it"
260
259
  # https://my.rightscale.com/acct/9202/right_scripts/205347
261
260
  if @script =~ /\A#{URI::regexp}\z/
262
- if not @use_chimpd
261
+ if not @use_chimpd || !@prompt
263
262
  puts "=================================================="
264
263
  puts "WARNING! You will be running this script on all "
265
264
  puts "server matches! (Press enter to continue)"
@@ -333,7 +332,8 @@ module Chimp
333
332
  [ '--timing-log', '-4', GetoptLong::REQUIRED_ARGUMENT ],
334
333
  [ '--timeout', '-5', GetoptLong::REQUIRED_ARGUMENT ],
335
334
  [ '--noverify', '-6', GetoptLong::NO_ARGUMENT ],
336
- [ '--exact-matching', '-8', GetoptLong::NO_ARGUMENT ]
335
+ [ '--exact-matching', '-8', GetoptLong::NO_ARGUMENT ],
336
+ [ '--job-notes', '-k', GetoptLong::OPTIONAL_ARGUMENT ]
337
337
  )
338
338
 
339
339
  opts.each do |opt, arg|
@@ -428,6 +428,8 @@ module Chimp
428
428
  @group_type = arg.to_sym
429
429
  when '--group-concurrency'
430
430
  @group_concurrency = arg.to_i
431
+ when '--job-notes'
432
+ @job_notes = arg
431
433
  when '--timing-log'
432
434
  @timing_log = arg
433
435
  when '--timeout'
@@ -904,6 +906,7 @@ module Chimp
904
906
  :server => s,
905
907
  :exec => queue_executable,
906
908
  :job_uuid => @job_uuid,
909
+ :job_notes => @job_notes,
907
910
  :inputs => @inputs,
908
911
  :timeout => @timeout,
909
912
  :verbose => @@verbose,
@@ -1027,7 +1030,7 @@ module Chimp
1027
1030
  message = result[:error].to_s || "unknown"
1028
1031
  message.sub!("\n", "")
1029
1032
  failed_workers << result[:worker]
1030
- results_display << "#{name.ljust(40)} #{message}"
1033
+ results_display << "#{name[0..40]} >> #{message}"
1031
1034
  end
1032
1035
  end
1033
1036
 
@@ -1253,7 +1256,7 @@ module Chimp
1253
1256
  i = 0
1254
1257
  items.sort.each do |item|
1255
1258
  i += 1
1256
- puts " %03d. #{item}" % i
1259
+ puts "%03d.#{item}" % i
1257
1260
  end
1258
1261
 
1259
1262
  puts "=================================================="
@@ -5,7 +5,7 @@
5
5
  module Chimp
6
6
  class Executor
7
7
  attr_accessor :server, :array, :exec, :inputs, :template, :owner, :group,
8
- :job_id, :job_uuid, :status, :dry_run, :verbose, :quiet, :timeout,
8
+ :job_id, :job_uuid, :job_notes, :status, :dry_run, :verbose, :quiet, :timeout,
9
9
  :retry_count, :retry_sleep, :time_start, :time_end, :error
10
10
 
11
11
  attr_reader :results
@@ -24,6 +24,8 @@ module Chimp
24
24
 
25
25
  @job_id = h[:job_id] || nil
26
26
  @job_uuid = h[:job_uuid] || nil
27
+ @job_notes = h[:job_notes] || nil
28
+
27
29
  @group = h[:group] || nil
28
30
  @exec = h[:exec] || nil
29
31
  @inputs = h[:inputs] || nil
@@ -155,9 +157,18 @@ module Chimp
155
157
  end
156
158
 
157
159
  rescue RuntimeError => ex
158
- Log.error "[#{@job_uuid}] Caught RuntimeError: #{ex}. Aborting job."
159
- Log.error ex.inspect
160
- Log.error ex.backtrace
160
+ if @server.params["ip_address"]
161
+ err = ex.message + "IP: #{@server.params["ip_address"]}\n"
162
+ end
163
+ if @group.group_id
164
+ err += " Group: #{@group.group_id}\n"
165
+ end
166
+ if @job_notes
167
+ err += " Notes: #{@job_notes}\n"
168
+ end
169
+ Log.error "[#{@job_uuid}] Caught RuntimeError: #{err} Aborting job.\n"
170
+ #Log.error ex.inspect
171
+ #Log.error ex.backtrace
161
172
  @status = STATUS_ERROR
162
173
  @error = ex
163
174
  end
@@ -276,152 +276,4 @@ module Chimp
276
276
  end
277
277
 
278
278
  end
279
-
280
- #
281
- # This class allows to check on the status of any of the tasks created.
282
- #
283
- class Task
284
-
285
- attr_writer :tasker
286
- attr_reader :tasker
287
-
288
- def wait_for_state(desired_state, timeout=900)
289
- while(timeout > 0)
290
- state=self.tasker.show.summary
291
- return true if self.state.match(desired_state)
292
- friendly_url = Connection.audit_url+"/audit_entries/"
293
- friendly_url += self.href.split(/\//).last
294
- friendly_url = friendly_url.gsub("ae-","")
295
- raise "FATAL error, #{self.tasker.show.summary}\n See Audit: #{friendly_url}'\n " if self.state.match("failed")
296
- sleep 30
297
- timeout -= 30
298
- end
299
- raise "FATAL: Timeout waiting for Executable to complete. State was #{self.state}" if timeout <= 0
300
- end
301
-
302
- def wait_for_completed(timeout=900)
303
- wait_for_state("completed", timeout)
304
- end
305
-
306
- def state
307
- self.tasker.show.summary
308
- end
309
-
310
- def href
311
- self.tasker.href
312
- end
313
-
314
- def details
315
- self.tasker.show(:view => "extended").detail
316
- end
317
- end
318
-
319
- #
320
- # This task contains parameters that describe a script/task to be executed
321
- #
322
- class Executable
323
-
324
- attr_writer :params
325
- attr_reader :params
326
-
327
- def initialize
328
- @params = {
329
- "position"=>5,
330
- "right_script"=>{
331
- "created_at"=>"",
332
- "href"=>"dummy_href",
333
- "updated_at"=>"",
334
- "version"=>4,
335
- "is_head_version"=>false,
336
- "script"=>"",
337
- "name"=>"dummy_name",
338
- "description"=>"dummy_description"
339
- },
340
- "recipe"=>nil,
341
- "apply"=>"operational"
342
- }
343
- end
344
-
345
- def href
346
- @params['right_script']['href']
347
- end
348
- def name
349
- @params['right_script']['name']
350
- end
351
- end
352
-
353
- #
354
- # This class holds all necessary information regarding an instance
355
- # and provides a way of executing a script on it via the run_executable method.
356
- #
357
- class Server
358
-
359
- attr_writer :params, :object
360
- attr_reader :params, :object
361
-
362
- attr_accessor :run_executable
363
-
364
- def initialize
365
- @params = {
366
- "href" => "dummy href",
367
- "current_instance_href" => nil,
368
- "current-instance-href " => nil,
369
- "name" => "dummy name",
370
- "nickname" => "dummy nickname",
371
- "ip_address" => nil,
372
- "ip-address" => nil,
373
- "private-ip-address" => nil,
374
- "aws-id" => "",
375
- "ec2-instance-type" => "",
376
- "dns-name" => "",
377
- "locked" => "",
378
- "state" => "",
379
- "datacenter" => nil
380
- }
381
- @object = nil
382
- end
383
-
384
- def href
385
- @params['href']
386
- end
387
-
388
- def name
389
- @params['name']
390
- end
391
-
392
- def nickname
393
- @params['nickname']
394
- end
395
-
396
- def ip_address
397
- @params['ip_address']
398
- end
399
-
400
- def encode_with(coder)
401
- vars = instance_variables.map{|x| x.to_s}
402
- vars = vars - ['@object']
403
-
404
- vars.each do |var|
405
- var_val = eval(var)
406
- coder[var.gsub('@', '')] = var_val
407
- end
408
- end
409
-
410
- #In order to run the task, we need to call run_executable on ourselves
411
- def run_executable(exec, options)
412
- script_href = "right_script_href="+exec.href
413
- # Construct the parameters to pass for the inputs
414
- params=options.collect { |k, v|
415
- "&inputs[][name]=#{k}&inputs[][value]=#{v}" unless k == :ignore_lock
416
- }.join('&')
417
-
418
- if options[:ignore_lock]
419
- params+="&ignore_lock=true"
420
- end
421
- # self is the actual Server object
422
- Log.debug "[#{Chimp.get_job_uuid}] Running executable"
423
- task = self.object.run_executable(script_href + params)
424
- return task
425
- end
426
- end
427
279
  end
@@ -0,0 +1,38 @@
1
+ #
2
+ # Extra classes needed to operate with Chimp
3
+ #
4
+ module Chimp
5
+ #
6
+ # This task contains parameters that describe a script/task to be executed
7
+ #
8
+ class Executable
9
+
10
+ attr_writer :params
11
+ attr_reader :params
12
+
13
+ def initialize
14
+ @params = {
15
+ "position"=>5,
16
+ "right_script"=>{
17
+ "created_at"=>"",
18
+ "href"=>"dummy_href",
19
+ "updated_at"=>"",
20
+ "version"=>4,
21
+ "is_head_version"=>false,
22
+ "script"=>"",
23
+ "name"=>"dummy_name",
24
+ "description"=>"dummy_description"
25
+ },
26
+ "recipe"=>nil,
27
+ "apply"=>"operational"
28
+ }
29
+ end
30
+
31
+ def href
32
+ @params['right_script']['href']
33
+ end
34
+ def name
35
+ @params['right_script']['name']
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,79 @@
1
+ #
2
+ # Extra classes needed to operate with Chimp
3
+ #
4
+ module Chimp
5
+ #
6
+ # This class holds all necessary information regarding an instance
7
+ # and provides a way of executing a script on it via the run_executable method.
8
+ #
9
+ class Server
10
+
11
+ attr_writer :params, :object
12
+ attr_reader :params, :object
13
+
14
+ attr_accessor :run_executable
15
+
16
+ def initialize
17
+ @params = {
18
+ "href" => "dummy href",
19
+ "current_instance_href" => nil,
20
+ "current-instance-href " => nil,
21
+ "name" => "dummy name",
22
+ "nickname" => "dummy nickname",
23
+ "ip_address" => nil,
24
+ "ip-address" => nil,
25
+ "private-ip-address" => nil,
26
+ "aws-id" => "",
27
+ "ec2-instance-type" => "",
28
+ "dns-name" => "",
29
+ "locked" => "",
30
+ "state" => "",
31
+ "datacenter" => nil
32
+ }
33
+ @object = nil
34
+ end
35
+
36
+ def href
37
+ @params['href']
38
+ end
39
+
40
+ def name
41
+ @params['name']
42
+ end
43
+
44
+ def nickname
45
+ @params['nickname']
46
+ end
47
+
48
+ def ip_address
49
+ @params['ip_address']
50
+ end
51
+
52
+ def encode_with(coder)
53
+ vars = instance_variables.map{|x| x.to_s}
54
+ vars = vars - ['@object']
55
+
56
+ vars.each do |var|
57
+ var_val = eval(var)
58
+ coder[var.gsub('@', '')] = var_val
59
+ end
60
+ end
61
+
62
+ #In order to run the task, we need to call run_executable on ourselves
63
+ def run_executable(exec, options)
64
+ script_href = "right_script_href="+exec.href
65
+ # Construct the parameters to pass for the inputs
66
+ params=options.collect { |k, v|
67
+ "&inputs[][name]=#{k}&inputs[][value]=#{v}" unless k == :ignore_lock
68
+ }.join('&')
69
+
70
+ if options[:ignore_lock]
71
+ params+="&ignore_lock=true"
72
+ end
73
+ # self is the actual Server object
74
+ Log.debug "[#{Chimp.get_job_uuid}] Running executable"
75
+ task = self.object.run_executable(script_href + params)
76
+ return task
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,43 @@
1
+ #
2
+ # Extra classes needed to operate with Chimp
3
+ #
4
+ module Chimp
5
+ #
6
+ # This class allows to check on the status of any of the tasks created.
7
+ #
8
+ class Task
9
+
10
+ attr_writer :tasker
11
+ attr_reader :tasker
12
+
13
+ def wait_for_state(desired_state, timeout=900)
14
+ while(timeout > 0)
15
+ state=self.tasker.show.summary
16
+ return true if self.state.match(desired_state)
17
+ friendly_url = Connection.audit_url+"/audit_entries/"
18
+ friendly_url += self.href.split(/\//).last
19
+ friendly_url = friendly_url.gsub("ae-","")
20
+ raise "FATAL error, #{self.tasker.show.summary}\n\n Audit: #{friendly_url}'\n " if self.state.match("failed")
21
+ sleep 30
22
+ timeout -= 30
23
+ end
24
+ raise "FATAL: Timeout waiting for Executable to complete. State was #{self.state}" if timeout <= 0
25
+ end
26
+
27
+ def wait_for_completed(timeout=900)
28
+ wait_for_state("completed", timeout)
29
+ end
30
+
31
+ def state
32
+ self.tasker.show.summary
33
+ end
34
+
35
+ def href
36
+ self.tasker.href
37
+ end
38
+
39
+ def details
40
+ self.tasker.show(:view => "extended").detail
41
+ end
42
+ end
43
+ end
@@ -167,18 +167,27 @@ jobs.each do |j|
167
167
  color = "red" if status == Executor::STATUS_ERROR
168
168
  %>
169
169
  <ul style="color: <%= color %>">
170
+ Uuid: [<%= j.job_uuid %>]
171
+
170
172
  <li>Server: <b><%= server_name %></b></li>
171
173
  <li>Group: <b><%= j.group.group_id %></b></li>
174
+ <% if j.job_notes %>
175
+ <li>Notes: <b><%= j.job_notes %></b></li>
176
+ <% end %>
172
177
  <li>Action: <%= action %></li>
173
178
  <li>Status: <%= status %></li>
174
179
  <li>Time: <%= time %></li>
175
180
  <% if status != Executor::STATUS_RUNNING %>
176
181
  <li>Results: <span style="color:#777"><%= j.results %></span></li>
182
+ <% end %>
183
+
184
+ <% if status == Executor::STATUS_DONE %>
177
185
  <!-- HACK HERE THE LOOP CODE TO INJECT CSS TO HIDE/EXPAND-->
178
186
  <li><label for="<%= id%>">Details (click to expand):</label> <input type="checkbox" id="<%= id%>"><span style="color:#777"><div id="d<%= id%>" class="job_details"><%= j.audit_entry_data %></div></span></li>
179
187
  <!-- HACK HERE THE LOOP CODE TO INJECT CSS TO HIDE/EXPAND-->
180
188
  <% end %>
181
189
 
190
+
182
191
  <li> <span class="action">
183
192
  <% case status
184
193
  when Executor::STATUS_ERROR %>
@@ -1,3 +1,3 @@
1
1
  module Chimp
2
- VERSION = "2.1.12"
2
+ VERSION = "2.1.13"
3
3
  end
data/lib/right_chimp.rb CHANGED
@@ -23,16 +23,23 @@ module Chimp
23
23
  require 'right_chimp/Chimp'
24
24
  require 'right_chimp/Log'
25
25
  require 'right_chimp/IDManager'
26
+
26
27
  require 'right_chimp/daemon/ChimpDaemon'
27
28
  require 'right_chimp/daemon/ChimpDaemonClient'
29
+
28
30
  require 'right_chimp/queue/ChimpQueue'
29
31
  require 'right_chimp/queue/QueueWorker'
30
32
  require 'right_chimp/queue/ExecutionGroup'
33
+
31
34
  require 'right_chimp/exec/Executor'
32
35
  require 'right_chimp/exec/ExecArray'
33
36
  require 'right_chimp/exec/ExecRightScript'
34
37
  require 'right_chimp/exec/ExecSSH'
35
38
  require 'right_chimp/exec/ExecReport'
36
39
  require 'right_chimp/exec/ExecNoop'
37
- require 'right_chimp/objects/ChimpObjects'
40
+
41
+ require 'right_chimp/resources/Connection'
42
+ require 'right_chimp/resources/Executable'
43
+ require 'right_chimp/resources/Server'
44
+ require 'right_chimp/resources/Task'
38
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_chimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.12
4
+ version: 2.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - RightScale Operations
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-14 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -155,10 +155,13 @@ files:
155
155
  - lib/right_chimp/exec/ExecRightScript.rb
156
156
  - lib/right_chimp/exec/ExecSSH.rb
157
157
  - lib/right_chimp/exec/Executor.rb
158
- - lib/right_chimp/objects/ChimpObjects.rb
159
158
  - lib/right_chimp/queue/ChimpQueue.rb
160
159
  - lib/right_chimp/queue/ExecutionGroup.rb
161
160
  - lib/right_chimp/queue/QueueWorker.rb
161
+ - lib/right_chimp/resources/Connection.rb
162
+ - lib/right_chimp/resources/Executable.rb
163
+ - lib/right_chimp/resources/Server.rb
164
+ - lib/right_chimp/resources/Task.rb
162
165
  - lib/right_chimp/templates/all_jobs.erb
163
166
  - lib/right_chimp/templates/default.css
164
167
  - lib/right_chimp/templates/greenscreen.css