lib/aerosol/instance.rb in aerosol-1.1.0 vs lib/aerosol/instance.rb in aerosol-1.2.0

- old
+ new

@@ -1,5 +1,7 @@ +require 'active_support/core_ext/object/blank' + class Aerosol::Instance include Aerosol::AWSModel aws_attribute :availability_zone, :health_status, :instance_id, :lifecycle_state aws_class_attribute :launch_configuration, Aerosol::LaunchConfiguration @@ -36,13 +38,25 @@ def description @description ||= describe! end + def self.request_all_for_token(next_token) + options = next_token.nil? ? {} : { next_token: next_token } + Aerosol::AWS.auto_scaling.describe_auto_scaling_instances(options) + end + def self.request_all - Aerosol::AWS.auto_scaling - .describe_auto_scaling_instances - .auto_scaling_instances + next_token = nil + instances = [] + + begin + new_instances = request_all_for_token(next_token) + instances.concat(new_instances.auto_scaling_instances) + next_token = new_instances.next_token + end until next_token.nil? + + instances end private def describe! ensure_present! :instance_id