awful 0.0.15 → 0.0.16

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: f08603e28f31d8ffcca5784bd8a3322f34b9518c
4
- data.tar.gz: 8fadd7303be34019c6c362391086877fe27fbea3
3
+ metadata.gz: d86db7d836b9f87cbdef6d7d0fcb557d98a8c774
4
+ data.tar.gz: 0720786aa239a62ad628f17f77b30e85b7415c6d
5
5
  SHA512:
6
- metadata.gz: ab2b585419b4153e55d4d953e49c43c8e7dabaae357ebea1e16d72e1e0e6b020f53132963925ed286f0ee326b381ffa1325fb00d4e089f40eace9e08ed6b1fbf
7
- data.tar.gz: 452c315e6b9a805cec044fdcf538af00389ccbb0364836001222ddb82aecd2d11c897d70812c9ca1f7ac91c28351fedf2183605a9997b4eae42b94332edbaf84
6
+ metadata.gz: 4e5579d26928c00946f87b2d07cc014c174e62d6fb51aa656bd6ed9617893bb2342904ab169e02acee17e65809cbd92b0ad11c3f34ee154f29ec127492b764c7
7
+ data.tar.gz: da0c1adfac59ce33d2d4e1499fba5cc2ae51115a71cc910dc8da892842334304096b8e5b8cf11da6ed4d2490c9c34924e2fa54e9916f244c2e5d4aaba497377b
@@ -123,6 +123,12 @@ module Awful
123
123
  ## update the group
124
124
  autoscaling.update_auto_scaling_group(only_keys_matching(opt, whitelist))
125
125
 
126
+ # ## update load_balancers if given
127
+ # ## TODO: maybe delete instead if empty?
128
+ # if opt[:load_balancer_names]
129
+ # autoscaling.attach_load_balancers(auto_scaling_group_name: name, load_balancer_names: opt[:load_balancer_names])
130
+ # end
131
+
126
132
  ## update any tags
127
133
  if opt[:tags]
128
134
  tags = opt[:tags].map { |tag| tag.merge(resource_id: name, resource_type: 'auto-scaling-group') }
@@ -182,6 +188,36 @@ module Awful
182
188
  end
183
189
  end
184
190
 
191
+ desc 'processes', 'describe scaling process types for use with suspend/resume'
192
+ def processes
193
+ autoscaling.describe_scaling_process_types.processes.map(&:process_name).sort.tap do |procs|
194
+ puts procs
195
+ end
196
+ end
197
+
198
+ desc 'suspend NAME [PROCS]', 'suspend all [or listed] processes for auto-scaling group NAME'
199
+ method_option :list, aliases: '-l', default: false, type: :boolean, desc: 'list currently suspended processes'
200
+ def suspend(name, *procs)
201
+ if options[:list]
202
+ autoscaling.describe_auto_scaling_groups(auto_scaling_group_names: Array(name)).map(&:auto_scaling_groups).flatten.first.suspended_processes.tap do |list|
203
+ print_table list.map{ |proc| [ proc.process_name, proc.suspension_reason] }
204
+ end
205
+ elsif procs.empty?
206
+ autoscaling.suspend_processes(auto_scaling_group_name: name)
207
+ else
208
+ autoscaling.suspend_processes(auto_scaling_group_name: name, scaling_processes: procs)
209
+ end
210
+ end
211
+
212
+ desc 'resume NAME [PROCS]', 'resume all [or listed] processes for auto-scaling group NAME'
213
+ def resume(name, *procs)
214
+ if procs.empty?
215
+ autoscaling.resume_processes(auto_scaling_group_name: name)
216
+ else
217
+ autoscaling.resume_processes(auto_scaling_group_name: name, scaling_processes: procs)
218
+ end
219
+ end
220
+
185
221
  end
186
222
 
187
223
  end
data/lib/awful/elb.rb CHANGED
@@ -21,13 +21,16 @@ module Awful
21
21
  desc 'instances NAME', 'list instances and states for elb NAME'
22
22
  def instances(name)
23
23
  instances = elb.describe_instance_health(load_balancer_name: name).map(&:instance_states).flatten
24
- instances_by_id = instances.inject({}) { |hash,instance| hash[instance.instance_id] = instance; hash }
25
-
26
- ec2.describe_instances(instance_ids: instances_by_id.keys).map(&:reservations).flatten.map(&:instances).flatten.map do |instance|
27
- health = instances_by_id[instance.instance_id]
28
- [ instance.tags.map(&:value).sort.join(','), instance.public_ip_address, health.state, health.reason_code, health.description ]
29
- end.tap do |list|
30
- print_table list
24
+ if instances.empty?
25
+ puts 'no instances'
26
+ else
27
+ instances_by_id = instances.inject({}) { |hash,instance| hash[instance.instance_id] = instance; hash }
28
+ ec2.describe_instances(instance_ids: instances_by_id.keys).map(&:reservations).flatten.map(&:instances).flatten.map do |instance|
29
+ health = instances_by_id[instance.instance_id]
30
+ [ instance.tags.map(&:value).sort.join(','), instance.public_ip_address, health.state, health.reason_code, health.description ]
31
+ end.tap do |list|
32
+ print_table list
33
+ end
31
34
  end
32
35
  end
33
36
 
@@ -80,6 +83,16 @@ module Awful
80
83
  end
81
84
  end
82
85
 
86
+ desc 'register INSTANCES', 'register listed instance IDs with ELB'
87
+ def register(name, *instance_ids)
88
+ elb.register_instances_with_load_balancer(load_balancer_name: name, instances: instance_ids.map{ |id| {instance_id: id} })
89
+ end
90
+
91
+ desc 'deregister INSTANCES', 'deregister listed instance IDs from ELB'
92
+ def deregister(name, *instance_ids)
93
+ elb.deregister_instances_from_load_balancer(load_balancer_name: name, instances: instance_ids.map{ |id| {instance_id: id} })
94
+ end
95
+
83
96
  end
84
97
 
85
98
  end
data/lib/awful/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
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.15
4
+ version: 0.0.16
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-06-05 00:00:00.000000000 Z
11
+ date: 2015-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler