awful 0.0.128 → 0.0.129

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/awful/elb.rb +25 -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: a0da7e8c9d19b6ce0b6188f1e1c32c81c9c75eaa
4
- data.tar.gz: 97a8e87f2f1e5e83e1e1d5ec3e1c8fae26a83727
3
+ metadata.gz: 0b42c1307ba85f1ac5d4d7b891a89b31e2eb81db
4
+ data.tar.gz: e41231a0ce6fe31bdd0053b913f70da625284b82
5
5
  SHA512:
6
- metadata.gz: 135c8ae7944cdd637c553000d5997e282b682c8b65db6d45f940d12a9c1c7b582868f789126e1cd704113ea8f7ed5c9d890ef081ed0fb4a46935a4b209bd1ff6
7
- data.tar.gz: 8360d46cd3a3ab4caac731d72a289b4811063727ed689bd474f7bef4e78b52fada39af9b80d0bac6efa675a5061231540f47d16cacb9249f918b24fb3eb49083
6
+ metadata.gz: 05d39485efefac9c059141353c8559ad7da30ef07e3855e281f1e45131c044d7d1d01c614bd3cd1a47787af2d27a9e1f1d2c5032df1981c608bf45d70582c47a
7
+ data.tar.gz: 9a175c7d3fab01a0768d50536803f2e1cef69f46c9b429f4b2ce484dbc984aadf48b1aea3eef96ed64a07132449caa70e8a32ab0ae805ce6fbae493124fdb99c
data/lib/awful/elb.rb CHANGED
@@ -22,12 +22,19 @@ module Awful
22
22
  elb.load_balancer_name.match(name)
23
23
  end
24
24
  end
25
+
26
+ ## get array of instance_id hashes in form expected by get methods
27
+ def instance_ids(*ids)
28
+ ids.map do |id|
29
+ {instance_id: id}
30
+ end
31
+ end
25
32
  end
26
33
 
27
34
  desc 'ls [NAME]', 'list load-balancers matching NAME'
28
35
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
29
36
  def ls(name = /./)
30
- all_matching_elbs(name).tap do |elbs|
37
+ all_matching_elbs(name).output do |elbs|
31
38
  if options[:long]
32
39
  print_table elbs.map { |e|
33
40
  [e.load_balancer_name, e.instances.length, e.availability_zones.join(','), e.dns_name]
@@ -46,7 +53,7 @@ module Awful
46
53
  end.flatten
47
54
 
48
55
  if instances.empty?
49
- instances.tap { puts 'no instances' }
56
+ instances.output { puts 'no instances' }
50
57
  else
51
58
  instances_by_id = instances.inject({}) { |hash,instance| hash[instance.instance_id] = instance; hash }
52
59
  if options[:long]
@@ -54,16 +61,16 @@ module Awful
54
61
  health = instances_by_id[instance.instance_id]
55
62
  instance_name = tag_name(instance) || '-'
56
63
  [ instance.instance_id, instance_name, instance.public_ip_address, color(health.state), health.reason_code, health.description ]
57
- end.tap { |list| print_table list }
64
+ end.output { |list| print_table list }
58
65
  else
59
- instances_by_id.keys.tap { |list| puts list }
66
+ instances_by_id.keys.output { |list| puts list }
60
67
  end
61
68
  end
62
69
  end
63
70
 
64
71
  desc 'dump NAME', 'dump VPC with id or tag NAME as yaml'
65
72
  def dump(name)
66
- all_matching_elbs(name).map(&:to_hash).tap do |elbs|
73
+ all_matching_elbs(name).map(&:to_hash).output do |elbs|
67
74
  elbs.each do |elb|
68
75
  puts YAML.dump(stringify_keys(elb))
69
76
  end
@@ -72,7 +79,7 @@ module Awful
72
79
 
73
80
  desc 'tags NAME', 'dump tags on all ELBs matching NAME (up to 20)'
74
81
  def tags(name)
75
- elb.describe_tags(load_balancer_names: all_matching_elbs(name).map(&:load_balancer_name)).tag_descriptions.tap do |tags|
82
+ elb.describe_tags(load_balancer_names: all_matching_elbs(name).map(&:load_balancer_name)).tag_descriptions.output do |tags|
76
83
  tags.each do |tag|
77
84
  puts YAML.dump(stringify_keys(tag.to_hash))
78
85
  end
@@ -83,14 +90,14 @@ module Awful
83
90
  def tag(name, key)
84
91
  elb.describe_tags(load_balancer_names: [name]).tag_descriptions.first.tags.find do |tag|
85
92
  tag.key == key
86
- end.tap do |tag|
93
+ end.output do |tag|
87
94
  puts tag.value
88
95
  end
89
96
  end
90
97
 
91
98
  desc 'dns NAME', 'get DNS names for load-balancers matching NAME'
92
99
  def dns(name)
93
- all_matching_elbs(name).map(&:dns_name).tap do |dns_names|
100
+ all_matching_elbs(name).map(&:dns_name).output do |dns_names|
94
101
  puts dns_names
95
102
  end
96
103
  end
@@ -104,7 +111,7 @@ module Awful
104
111
  opt.delete(:availability_zones) unless opt.fetch(:subnets, []).empty?
105
112
  opt = remove_empty_strings(opt)
106
113
  opt = only_keys_matching(opt, whitelist)
107
- elb.create_load_balancer(opt).map(&:dns_name).flatten.tap { |dns| puts dns }
114
+ elb.create_load_balancer(opt).map(&:dns_name).flatten.output { |dns| puts dns }
108
115
  health_check(name) if opt[:health_check]
109
116
  end
110
117
 
@@ -117,7 +124,7 @@ module Awful
117
124
  def health_check(name)
118
125
  opt = load_cfg.merge(options.reject(&:nil?))
119
126
  hc = elb.configure_health_check(load_balancer_name: name, health_check: opt[:health_check])
120
- hc.map(&:health_check).flatten.first.tap do |h|
127
+ hc.map(&:health_check).flatten.first.output do |h|
121
128
  print_table h.to_hash
122
129
  end
123
130
  end
@@ -130,23 +137,23 @@ module Awful
130
137
  end
131
138
 
132
139
  desc 'register INSTANCES', 'register listed instance IDs with ELB'
133
- def register(name, *instance_ids)
134
- elb.register_instances_with_load_balancer(load_balancer_name: name, instances: instance_ids.map{ |id| {instance_id: id} })
140
+ def register(name, *instances)
141
+ elb.register_instances_with_load_balancer(load_balancer_name: name, instances: instance_ids(*instances))
135
142
  end
136
143
 
137
144
  desc 'deregister INSTANCES', 'deregister listed instance IDs from ELB'
138
- def deregister(name, *instance_ids)
139
- elb.deregister_instances_from_load_balancer(load_balancer_name: name, instances: instance_ids.map{ |id| {instance_id: id} })
145
+ def deregister(name, *instances)
146
+ elb.deregister_instances_from_load_balancer(load_balancer_name: name, instances: instance_ids(*instances))
140
147
  end
141
148
 
142
149
  desc 'state [INSTANCE_IDS]', 'show health state for all instances, or listed instance ids'
143
150
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
144
- def state(name, *instance_ids)
145
- elb.describe_instance_health(load_balancer_name: name, instances: instance_ids.map { |id| {instance_id: id} }).instance_states.tap do |instances|
151
+ def state(name, *instances)
152
+ elb.describe_instance_health(load_balancer_name: name, instances: instance_ids(*instances)).instance_states.output do |list|
146
153
  if options[:long]
147
- print_table instances.map { |i| [ i.instance_id, i.state, i.reason_code, i.description ] }
154
+ print_table list.map { |i| [ i.instance_id, i.state, i.reason_code, i.description ] }
148
155
  else
149
- puts instances.map { |i| i.state }
156
+ puts list.map(&:state)
150
157
  end
151
158
  end
152
159
  end
data/lib/awful/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = '0.0.128'
2
+ VERSION = '0.0.129'
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.128
4
+ version: 0.0.129
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister