awful 0.0.128 → 0.0.129
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awful/elb.rb +25 -18
- data/lib/awful/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b42c1307ba85f1ac5d4d7b891a89b31e2eb81db
|
4
|
+
data.tar.gz: e41231a0ce6fe31bdd0053b913f70da625284b82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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).
|
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.
|
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.
|
64
|
+
end.output { |list| print_table list }
|
58
65
|
else
|
59
|
-
instances_by_id.keys.
|
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).
|
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.
|
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.
|
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).
|
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.
|
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.
|
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, *
|
134
|
-
elb.register_instances_with_load_balancer(load_balancer_name: name, instances: instance_ids
|
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, *
|
139
|
-
elb.deregister_instances_from_load_balancer(load_balancer_name: name, instances: instance_ids
|
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, *
|
145
|
-
elb.describe_instance_health(load_balancer_name: name, instances: instance_ids
|
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
|
154
|
+
print_table list.map { |i| [ i.instance_id, i.state, i.reason_code, i.description ] }
|
148
155
|
else
|
149
|
-
puts
|
156
|
+
puts list.map(&:state)
|
150
157
|
end
|
151
158
|
end
|
152
159
|
end
|
data/lib/awful/version.rb
CHANGED