Class: Capistrano::ASG::Rolling::Instances
- Inherits:
-
Object
- Object
- Capistrano::ASG::Rolling::Instances
- Includes:
- Enumerable
- Defined in:
- lib/capistrano/asg/rolling/instances.rb
Overview
Collection of Instances. Runs commands on instances in parallel.
Instance Method Summary collapse
- #<<(instance) ⇒ Object
- #auto_terminate ⇒ Object
- #create_ami(name: nil, description: nil, tags: nil) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(instances = []) ⇒ Instances
constructor
A new instance of Instances.
- #stop ⇒ Object
- #terminate ⇒ Object
- #wait_for_ssh ⇒ Object
- #with_image(image_id) ⇒ Object
Constructor Details
#initialize(instances = []) ⇒ Instances
Returns a new instance of Instances.
10 11 12 |
# File 'lib/capistrano/asg/rolling/instances.rb', line 10 def initialize(instances = []) @instances = instances end |
Instance Method Details
#<<(instance) ⇒ Object
14 15 16 |
# File 'lib/capistrano/asg/rolling/instances.rb', line 14 def <<(instance) @instances << instance end |
#auto_terminate ⇒ Object
26 27 28 |
# File 'lib/capistrano/asg/rolling/instances.rb', line 26 def auto_terminate self.class.new(select(&:auto_terminate?)) end |
#create_ami(name: nil, description: nil, tags: nil) ⇒ Object
46 47 48 49 50 |
# File 'lib/capistrano/asg/rolling/instances.rb', line 46 def create_ami(name: nil, description: nil, tags: nil) Parallel.run(instances) do |instance| instance.create_ami(name: name, description: description, tags: ) end end |
#each(&block) ⇒ Object
18 19 20 |
# File 'lib/capistrano/asg/rolling/instances.rb', line 18 def each(&block) instances.each(&block) end |
#empty? ⇒ Boolean
22 23 24 |
# File 'lib/capistrano/asg/rolling/instances.rb', line 22 def empty? instances.empty? end |
#stop ⇒ Object
38 39 40 |
# File 'lib/capistrano/asg/rolling/instances.rb', line 38 def stop Parallel.run(instances, &:stop) end |
#terminate ⇒ Object
42 43 44 |
# File 'lib/capistrano/asg/rolling/instances.rb', line 42 def terminate Parallel.run(instances, &:terminate) end |
#wait_for_ssh ⇒ Object
34 35 36 |
# File 'lib/capistrano/asg/rolling/instances.rb', line 34 def wait_for_ssh Parallel.run(instances, &:wait_for_ssh) end |
#with_image(image_id) ⇒ Object
30 31 32 |
# File 'lib/capistrano/asg/rolling/instances.rb', line 30 def with_image(image_id) self.class.new(select { |instance| instance.image_id == image_id }) end |