class Lono::Sets::Status
Attributes
operation_id[R]
Public Class Methods
new(options={})
click to toggle source
# File lib/lono/sets/status.rb, line 9 def initialize(options={}) @options = options @stack, @operation_id = options[:stack], options[:operation_id] @shown = [] @output = "" # for say method and specs end
Public Instance Methods
completed?(status)
click to toggle source
describe_stack_set_operation stack_set_operation.status is one of RUNNING, SUCCEEDED, FAILED, STOPPING, STOPPED
# File lib/lono/sets/status.rb, line 92 def completed?(status) completed_statuses = %w[SUCCEEDED FAILED STOPPED] completed_statuses.include?(status) end
display_one()
click to toggle source
# File lib/lono/sets/status.rb, line 36 def display_one resp = cfn.describe_stack_set_operation( stack_set_name: @stack, operation_id: operation_id, ) stack_set_operation = resp.stack_set_operation show_stack_set_operation(stack_set_operation) @shown << stack_set_operation resp end
latest_operation_id()
click to toggle source
# File lib/lono/sets/status.rb, line 111 def latest_operation_id summaries.first.operation_id end
say(text)
click to toggle source
# File lib/lono/sets/status.rb, line 86 def say(text) ENV["LONO_TEST"] ? @output << "#{text}\n" : puts(text) end
show()
click to toggle source
# File lib/lono/sets/status.rb, line 47 def show if summaries.empty? puts "No stack operations have been done with this stack set. So there is no status to report." return end display_one o = @options.merge(show_time_spent: false) instances_status = Lono::SetInstances::Status.new(o) instances_status.run summarize(operation_id) end
show_stack_set_operation(stack_set_operation)
click to toggle source
# File lib/lono/sets/status.rb, line 77 def show_stack_set_operation(stack_set_operation) already_shown = @shown.detect do |o| o[:status] == stack_set_operation[:status] end return if already_shown say "Stack Set Operation Status: #{stack_set_operation.status}" end
stack_instances()
click to toggle source
# File lib/lono/sets/status.rb, line 123 def stack_instances Lono::Sets::Status::Instances.new(@options).stack_instances end
stack_set_status()
click to toggle source
# File lib/lono/sets/status.rb, line 97 def stack_set_status resp = cfn.describe_stack_set_operation( stack_set_name: @stack, operation_id: operation_id, ) # describe_stack_set_operation stack_set_operation.status is # status one of RUNNING, SUCCEEDED, FAILED, STOPPING, STOPPED resp.stack_set_operation.status end
start_instances_status_waiter()
click to toggle source
# File lib/lono/sets/status.rb, line 61 def start_instances_status_waiter return if @@instances_status_waiter_started if stack_instances.empty? @@instances_status_waiter_started = true return end Thread.new do # show_time_spent because we already show it in this status class. Dont want it to show twice. o = @options.merge(start_on_outdated: true, show_time_spent: false) instances_status = Lono::SetInstances::Status.new(o) instances_status.run end @@instances_status_waiter_started = true end
summaries()
click to toggle source
# File lib/lono/sets/status.rb, line 115 def summaries resp = cfn.list_stack_set_operations( stack_set_name: @stack, max_results: 1, ) resp.summaries end
wait()
click to toggle source
# File lib/lono/sets/status.rb, line 16 def wait Lono::Sets::Status::Instance::Base.show_time_progress = true Lono::Sets::Status::Instance::Base.delay_factor = stack_instances.size status = nil until completed?(status) resp = display_one stack_set_operation = resp.stack_set_operation status = stack_set_operation.status # always sleep delay even if completed to provide start_instances_status_waiter some extra time to complete sleep 5 if completed?(status) show_time_spent(stack_set_operation) else start_instances_status_waiter end end status == "SUCCEEDED" end