awful 0.0.55 → 0.0.56

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/awful/elb.rb +33 -18
  3. data/lib/awful/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56376495dec02b800fed9491623c01bbbdf421c1
4
- data.tar.gz: 75d49a923b5d25064346e65f063938384192c75b
3
+ metadata.gz: 26f0326b74820ced71a71f07aaf0f4fee963d1b4
4
+ data.tar.gz: 658234154ad0d798cfd05cd657207cca1b9a95a2
5
5
  SHA512:
6
- metadata.gz: a13c33a1eac8b19dcab30d6498ce53f5a98ca1cfd6c1896ed658923c11f0297ee09b6d23070053b71072fe4dc61757c4006b65e061e54723f12ceb00ca77ae8e
7
- data.tar.gz: 2d3c8916d7028a62a076a8d57255fa7ba672bff1789b1a1c1bb3688d8266ae692afaf1774131ebe8147fd8cd6337391f9796e75d23f91b2d4edbe31ddef3b793
6
+ metadata.gz: 15aa87695dff68a363302b9c31f0233b02da4d081a19e6b3cd1452a508eb16eee02df29af49b07f31b861211e5b5da6ff6805c29f751beed6f48c61fcbb16c22
7
+ data.tar.gz: 0e9b09cb86c5650c3a245eb3c11bdeed010b34b744038b2138b4d3b55a272a4f491b867aea8621baac95e948a9b43bbe9d1f3c42dfeb0be68a98a107564f92df
@@ -11,21 +11,26 @@ module Awful
11
11
  def color(string)
12
12
  set_color(string, COLORS.fetch(string.to_sym, :yellow))
13
13
  end
14
+
15
+ ## cannot search ELBs by tag, so just name here
16
+ def all_matching_elbs(name)
17
+ elb.describe_load_balancers.map(&:load_balancer_descriptions).flatten.select do |elb|
18
+ elb.load_balancer_name.match(name)
19
+ end
20
+ end
14
21
  end
15
22
 
16
- desc 'ls [PATTERN]', 'list vpcs [with any tags matching PATTERN]'
23
+ desc 'ls [NAME]', 'list load-balancers matching NAME'
17
24
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
18
25
  def ls(name = /./)
19
- fields = options[:long] ?
20
- ->(e) { [e.load_balancer_name, e.instances.length, e.availability_zones.join(','), e.dns_name] } :
21
- ->(e) { [e.load_balancer_name] }
22
-
23
- elb.describe_load_balancers.map(&:load_balancer_descriptions).flatten.select do |elb|
24
- elb.load_balancer_name.match(name)
25
- end.map do |elb|
26
- fields.call(elb)
27
- end.tap do |list|
28
- print_table list
26
+ all_matching_elbs(name).tap do |elbs|
27
+ if options[:long]
28
+ print_table elbs.map { |e|
29
+ [e.load_balancer_name, e.instances.length, e.availability_zones.join(','), e.dns_name]
30
+ }
31
+ else
32
+ puts elbs.map(&:load_balancer_name)
33
+ end
29
34
  end
30
35
  end
31
36
 
@@ -51,16 +56,26 @@ module Awful
51
56
 
52
57
  desc 'dump NAME', 'dump VPC with id or tag NAME as yaml'
53
58
  def dump(name)
54
- lb = elb.describe_load_balancers(load_balancer_names: Array(name)).map(&:load_balancer_descriptions).flatten.first.to_hash
55
- puts YAML.dump(stringify_keys(lb))
59
+ all_matching_elbs(name).map(&:to_hash).tap do |elbs|
60
+ elbs.each do |elb|
61
+ puts YAML.dump(stringify_keys(elb))
62
+ end
63
+ end
64
+ end
65
+
66
+ desc 'tags NAME', 'dump tags on all ELBs matching NAME (up to 20)'
67
+ def tags(name)
68
+ elb.describe_tags(load_balancer_names: all_matching_elbs(name).map(&:load_balancer_name)).tag_descriptions.tap do |tags|
69
+ tags.each do |tag|
70
+ puts YAML.dump(stringify_keys(tag.to_hash))
71
+ end
72
+ end
56
73
  end
57
74
 
58
- desc 'dns NAME', 'get DNS name for load-balancers matching NAME'
75
+ desc 'dns NAME', 'get DNS names for load-balancers matching NAME'
59
76
  def dns(name)
60
- elb.describe_load_balancers.map(&:load_balancer_descriptions).flatten.select do |elb|
61
- elb.load_balancer_name.match(name)
62
- end.map(&:dns_name).tap do |dns|
63
- puts dns
77
+ all_matching_elbs(name).map(&:dns_name).tap do |dns_names|
78
+ puts dns_names
64
79
  end
65
80
  end
66
81
 
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.55"
2
+ VERSION = "0.0.56"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.55
4
+ version: 0.0.56
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister