Sha256: 8d914c44b662a59fbe2f7bbf951fd51a077126154c78f58ff6f42e6b3146ced6
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module Capistrano module ASG module Rolling # Collection of Instances. Runs commands on instances in parallel. class Instances include Enumerable def initialize(instances = []) @instances = instances end def <<(instance) @instances << instance end def each(&block) instances.each(&block) end def empty? instances.empty? end def auto_terminate self.class.new(select(&:auto_terminate?)) end def with_image(image_id) self.class.new(select { |instance| instance.image_id == image_id }) end def wait_for_ssh Parallel.run(instances, &:wait_for_ssh) end def stop Parallel.run(instances, &:stop) end def terminate Parallel.run(instances, &:terminate) end def create_ami(name: nil, description: nil) Parallel.run(instances) do |instance| instance.create_ami(name: name, description: description) end end private def instances @instances.reject(&:terminated?) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
capistrano-asg-rolling-0.1.0 | lib/capistrano/asg/rolling/instances.rb |