awsome 0.0.10 → 0.0.11

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 (2) hide show
  1. data/lib/awsome/executor.rb +22 -11
  2. metadata +1 -1
@@ -21,6 +21,18 @@ module Awsome
21
21
  terminate
22
22
  end
23
23
 
24
+ def instances_to_use(&block)
25
+ @i_pool.each_with_index do |instance, index|
26
+ yield(instance, @r_pool[index]) if index < @r_pool.length
27
+ end
28
+ end
29
+
30
+ def instances_to_terminate(&block)
31
+ @i_pool.each_with_index do |instance, index|
32
+ yield(instance) if index >= @r_pool.length
33
+ end
34
+ end
35
+
24
36
  def run
25
37
  @i_pool.each_with_index do |instance, i|
26
38
  @i_pool[i] = Awsome::Ec2.run_instance(@r_pool[i].properties) if instance.nil?
@@ -28,30 +40,29 @@ module Awsome
28
40
  end
29
41
 
30
42
  def wait_for_ssh
31
- @i_pool.each do |i|
32
- i.wait_until_running!
33
- i.wait_for_ssh!
43
+ instances_to_use do |instance, requirement|
44
+ instance.wait_until_running!
45
+ instance.wait_for_ssh!
34
46
  end
35
47
  end
36
48
 
37
49
  def reattach_volumes
38
- @i_pool.each_with_index do |instance, i|
39
- instance.reattach_volumes(*@r_pool[i].volumes_to_attach(instance))
50
+ instances_to_use do |instance, requirement|
51
+ instance.reattach_volumes(*requirement.volumes_to_attach(instance))
40
52
  end
41
53
  end
42
54
 
43
55
  def deploy
44
- @i_pool.each_with_index do |instance, i|
56
+ instances_to_use do |instance, requirement|
45
57
  instance.deregister_from_elbs
46
- instance.remove_packages(*@r_pool[i].packages_to_remove(instance))
47
- instance.install_packages(*@r_pool[i].packages_to_install(instance))
48
- instance.register_with_elbs(*@r_pool[i].elbs)
58
+ instance.remove_packages(*requirement.packages_to_remove(instance))
59
+ instance.install_packages(*requirement.packages_to_install(instance))
60
+ instance.register_with_elbs(*requirement.elbs)
49
61
  end
50
62
  end
51
63
 
52
64
  def terminate
53
- @i_pool.each_with_index do |instance, i|
54
- next if i < @r_pool.length
65
+ instances_to_terminate do |instance|
55
66
  instance.deregister_from_elbs
56
67
  instance.terminate
57
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awsome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: