awful 0.0.46 → 0.0.47

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d157d01948ca24e5720e4bb99092ac61f59f94d
4
- data.tar.gz: 883ecf5a96b431922f6a49277e251a8ecdc35945
3
+ metadata.gz: a9ba35ecdd70ca8fee5d800ba790c62c1f408155
4
+ data.tar.gz: 6b50ea11a998dadc5373a87178c26bde4304b789
5
5
  SHA512:
6
- metadata.gz: cabb8bd5d87cd0107884fb47fbb4ef3ea7c911c99c6d73bd06b004a24fe90434cfdedd0beb2c567e332564995689e14127c428a6d651cf1af0ffb389bdad0366
7
- data.tar.gz: 2331c69b58f074f94e779385c9c4b17af4112e8040059e8215834c73025b1aa3ca33c7eb07b00886dc36dca454f8b24290cbc4b39827e6728a781fa15cab86e5
6
+ metadata.gz: 876875b8a02dfc3fd79987da6bf1941911106fba7167b0a0b363222df69f4adbec0cb8e742b46a390af49437ea7711c549e2784a7b373ac912648b4987ae7d9c
7
+ data.tar.gz: 46ba584635090d505144bfd5d2791d2dcbe8e95f738919a31cd0b5fc8a0f521fc5dacc0d5ce8be2a42b11fb73883c015dcc9bf4a4ae1113c07fed8fc23d47435
@@ -2,6 +2,20 @@ module Awful
2
2
 
3
3
  class AutoScaling < Cli
4
4
 
5
+ COLORS = {
6
+ Pending: :yellow,
7
+ InService: :green,
8
+ Terminating: :red,
9
+ HEALTHY: :green,
10
+ UNHEALTHY: :red,
11
+ }
12
+
13
+ no_commands do
14
+ def color(string)
15
+ set_color(string, COLORS.fetch(string.to_sym, :yellow))
16
+ end
17
+ end
18
+
5
19
  desc 'ls [PATTERN]', 'list autoscaling groups with name matching PATTERN'
6
20
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
7
21
  def ls(name = /./)
@@ -38,20 +52,19 @@ module Awful
38
52
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
39
53
  method_option :launch_configuration, aliases: '-L', default: false, desc: 'Get instance launch_configs'
40
54
  def instances(name)
41
- fields = if options[:long]
42
- %i[ instance_id auto_scaling_group_name availability_zone lifecycle_state health_status launch_configuration_name ]
43
- elsif options[:launch_configuration]
44
- %i[ instance_id launch_configuration_name ]
45
- else
46
- %i[ instance_id ]
47
- end
48
-
49
55
  autoscaling.describe_auto_scaling_instances.map(&:auto_scaling_instances).flatten.select do |instance|
50
56
  instance.auto_scaling_group_name.match(name)
51
57
  end.tap do |instances|
52
- instances.map do |instance|
53
- fields.map { |field| instance.send(field) }
54
- end.tap { |list| print_table list }
58
+ if options[:long]
59
+ print_table instances.map { |i|
60
+ [i.instance_id, i.auto_scaling_group_name, i.availability_zone, color(i.lifecycle_state),
61
+ color(i.health_status), i.launch_configuration_name]
62
+ }
63
+ elsif options[:launch_configuration]
64
+ print_table instances.map { |i| [i.instance_id, i.launch_configuration_name] }
65
+ else
66
+ puts instances.map(&:instance_id)
67
+ end
55
68
  end
56
69
  end
57
70
 
@@ -2,10 +2,30 @@ module Awful
2
2
 
3
3
  class CloudFormation < Cli
4
4
 
5
+ COLORS = {
6
+ create_in_progress: :yellow,
7
+ delete_in_progress: :yellow,
8
+ update_in_progress: :yellow,
9
+ update_complete_cleanup_in_progress: :yellow,
10
+ create_failed: :red,
11
+ delete_failed: :red,
12
+ update_failed: :red,
13
+ create_complete: :green,
14
+ delete_complete: :green,
15
+ update_complete: :green,
16
+ delete_skipped: :yellow,
17
+ rollback_in_progress: :red,
18
+ rollback_complete: :red,
19
+ }
20
+
5
21
  no_commands do
6
22
  def cf
7
23
  @cf ||= Aws::CloudFormation::Client.new
8
24
  end
25
+
26
+ def color(string)
27
+ set_color(string, COLORS.fetch(string.downcase.to_sym, :blue))
28
+ end
9
29
  end
10
30
 
11
31
  desc 'ls [PATTERN]', 'list cloudformation stacks matching PATTERN'
@@ -23,7 +43,7 @@ module Awful
23
43
 
24
44
  stacks.tap do |stacks|
25
45
  if options[:long]
26
- print_table stacks.map { |s| [s.stack_name, s.creation_time, s.stack_status, s.template_description] }
46
+ print_table stacks.map { |s| [s.stack_name, s.creation_time, color(s.stack_status), s.template_description] }
27
47
  else
28
48
  puts stacks.map(&:stack_name)
29
49
  end
@@ -85,7 +105,7 @@ module Awful
85
105
  desc 'events NAME', 'show events for stack with name NAME'
86
106
  def events(name)
87
107
  cf.describe_stack_events(stack_name: name).stack_events.tap do |events|
88
- print_table events.map { |e| [e.timestamp, e.resource_status, e.resource_type, e.logical_resource_id, e.resource_status_reason] }
108
+ print_table events.map { |e| [e.timestamp, color(e.resource_status), e.resource_type, e.logical_resource_id, e.resource_status_reason] }
89
109
  end
90
110
  end
91
111
 
data/lib/awful/ec2.rb CHANGED
@@ -4,11 +4,23 @@ module Awful
4
4
 
5
5
  class Ec2 < Cli
6
6
 
7
+ COLORS = {
8
+ running: :green,
9
+ stopped: :yellow,
10
+ terminated: :red,
11
+ }
12
+
13
+ no_commands do
14
+ def color(string)
15
+ set_color(string, COLORS.fetch(string.to_sym, :yellow))
16
+ end
17
+ end
18
+
7
19
  desc 'ls [PATTERN]', 'list EC2 instances [with id or tags matching PATTERN]'
8
20
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
9
21
  def ls(name = /./)
10
22
  fields = options[:long] ?
11
- ->(i) { [ (tag_name(i) || '-').slice(0..40), i.instance_id, i.instance_type, i.virtualization_type, i.placement.availability_zone, i.state.name,
23
+ ->(i) { [ (tag_name(i) || '-').slice(0..40), i.instance_id, i.instance_type, i.virtualization_type, i.placement.availability_zone, color(i.state.name),
12
24
  i.security_groups.map(&:group_name).join(',').slice(0..30), i.private_ip_address, i.public_ip_address ] } :
13
25
  ->(i) { [ tag_name(i) || i.instance_id ] }
14
26
 
data/lib/awful/elb.rb CHANGED
@@ -2,6 +2,17 @@ module Awful
2
2
 
3
3
  class Elb < Cli
4
4
 
5
+ COLORS = {
6
+ InService: :green,
7
+ OutOfService: :red,
8
+ }
9
+
10
+ no_commands do
11
+ def color(string)
12
+ set_color(string, COLORS.fetch(string.to_sym, :yellow))
13
+ end
14
+ end
15
+
5
16
  desc 'ls [PATTERN]', 'list vpcs [with any tags matching PATTERN]'
6
17
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
7
18
  def ls(name = /./)
@@ -30,7 +41,7 @@ module Awful
30
41
  ec2.describe_instances(instance_ids: instances_by_id.keys).map(&:reservations).flatten.map(&:instances).flatten.map do |instance|
31
42
  health = instances_by_id[instance.instance_id]
32
43
  instance_name = tag_name(instance) || '-'
33
- [ instance.instance_id, instance_name, instance.public_ip_address, health.state, health.reason_code, health.description ]
44
+ [ instance.instance_id, instance_name, instance.public_ip_address, color(health.state), health.reason_code, health.description ]
34
45
  end.tap { |list| print_table list }
35
46
  else
36
47
  instances_by_id.keys.tap { |list| puts list }
data/lib/awful/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.46"
2
+ VERSION = "0.0.47"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.46
4
+ version: 0.0.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-13 00:00:00.000000000 Z
11
+ date: 2015-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler