class Lono::Sets::Status::Instance::Base
Public Class Methods
new(stack_instance)
click to toggle source
# File lib/lono/sets/status/instance/base.rb, line 51 def initialize(stack_instance) @stack_instance = stack_instance @shown = [] @output = "" # for say method and specs end
Public Instance Methods
delay()
click to toggle source
# File lib/lono/sets/status/instance/base.rb, line 110 def delay # delay factor based on number of stack instances factor = self.class.delay_factor || 1 base = 4.5 delay = factor * base delay = [delay, 30].min # limit the delay to a max puts "Sleeping for #{delay}s..." if ENV['LONO_DEBUG_THROTTLE'] sleep delay end
describe_stack_instance()
click to toggle source
# File lib/lono/sets/status/instance/base.rb, line 91 def describe_stack_instance retries = 0 begin cfn.describe_stack_instance( stack_instance_account: @stack_instance.account, stack_instance_region: @stack_instance.region, stack_set_name: @stack_instance.stack_set_id) rescue Aws::CloudFormation::Errors::Throttling => e retries += 1 delay = 2 ** retries if ENV['LONO_DEBUG_THROTTLE'] puts "#{e.class}: #{e.message}" puts "Backing off for #{delay}s and will retry" end sleep delay retry end end
say(text)
click to toggle source
# File lib/lono/sets/status/instance/base.rb, line 87 def say(text) ENV["LONO_TEST"] ? @output << "#{text}\n" : puts(text) end
show_instance(stack_instance)
click to toggle source
# File lib/lono/sets/status/instance/base.rb, line 57 def show_instance(stack_instance) already_shown = @shown.detect do |o| o[:account] == stack_instance[:account] && o[:region] == stack_instance[:region] && o[:status] == stack_instance[:status] && o[:status_reason] == stack_instance[:status_reason] end return if already_shown s = stack_instance say status_line(s.account, s.region, s.status, s.status_reason) end
show_time_progress()
click to toggle source
# File lib/lono/sets/status/instance/base.rb, line 70 def show_time_progress self.class.show_time_progress end
status_line(account, region, status, reason=nil)
click to toggle source
# File lib/lono/sets/status/instance/base.rb, line 74 def status_line(account, region, status, reason=nil) time = Time.now.strftime("%F %I:%M:%S%p") if show_time_progress items = [ time, "Stack Instance:", "account".color(:purple), account, "region".color(:purple), region, "status".color(:purple), status, ] items += ["reason".color(:purple), reason] if reason items.compact.join(" ") end