lib/sfn/provider.rb in sfn-3.0.30 vs lib/sfn/provider.rb in sfn-3.0.32

- old
+ new

@@ -1,7 +1,7 @@ -require 'logger' -require 'sfn' +require "logger" +require "sfn" module Sfn # Remote provider interface class Provider include Bogo::AnimalStrings @@ -39,34 +39,34 @@ # @option args [Numeric] :stack_list_interval interval to wait between stack list refresh def initialize(args = {}) args = args.to_smash unless args.get(:miasma, :provider) best_guess = (args[:miasma] || {}).keys.group_by do |key| - key.to_s.split('_').first + key.to_s.split("_").first end.sort do |x, y| y.size <=> x.size end.first if best_guess provider = best_guess.first.to_sym else - raise ArgumentError.new 'Cannot auto determine :provider value for credentials' + raise ArgumentError.new "Cannot auto determine :provider value for credentials" end else provider = args[:miasma].delete(:provider).to_sym end if provider == :aws if args[:miasma][:region] args[:miasma][:aws_region] = args[:miasma].delete(:region) end end - if ENV['DEBUG'].to_s.downcase == 'true' + if ENV["DEBUG"].to_s.downcase == "true" log_to = STDOUT else if Gem.win_platform? - log_to = 'NUL' + log_to = "NUL" else - log_to = '/dev/null' + log_to = "/dev/null" end end @logger = args.fetch(:logger, Logger.new(log_to)) @stack_expansion_interval = args.fetch(:stack_expansion_interval, STACK_EXPAND_INTERVAL) @stack_list_interval = args.fetch(:stack_list_interval, STACK_LIST_INTERVAL) @@ -99,11 +99,11 @@ recache = !!stacks.get(stack_id) end fetch_stacks(stack_id) if recache end value = cache[:stacks].value - value ? MultiJson.dump(MultiJson.load(value).values) : '[]' + value ? MultiJson.dump(MultiJson.load(value).values) : "[]" end # @return [Miasma::Orchestration::Stack, NilClass] def stack(stack_id) stacks(stack_id).get(stack_id) @@ -116,11 +116,11 @@ # @return [TrueClass] def save_expanded_stack(stack_id, stack_attributes) current_stacks = MultiJson.load(cached_stacks) cache.locked_action(:stacks_lock) do logger.info "Saving expanded stack attributes in cache (#{stack_id})" - current_stacks[stack_id] = stack_attributes.merge('Cached' => Time.now.to_i) + current_stacks[stack_id] = stack_attributes.merge("Cached" => Time.now.to_i) cache[:stacks].value = MultiJson.dump(current_stacks) end true end @@ -142,18 +142,18 @@ # Expand all lazy loaded attributes within stack # # @param stack [Miasma::Models::Orchestration::Stack] def expand_stack(stack) logger.info "Stack expansion requested (#{stack.id})" - if ((stack.in_progress? && Time.now.to_i - stack.attributes['Cached'].to_i > stack_expansion_interval) || - !stack.attributes['Cached']) + if ((stack.in_progress? && Time.now.to_i - stack.attributes["Cached"].to_i > stack_expansion_interval) || + !stack.attributes["Cached"]) begin expanded = false cache.locked_action(:stack_expansion_lock) do expanded = true stack.reload - stack.data['Cached'] = Time.now.to_i + stack.data["Cached"] = Time.now.to_i end if expanded save_expanded_stack(stack.id, stack.to_json) end rescue => e @@ -194,10 +194,10 @@ stacks.delete(stale_id) end end end cache[:stacks].value = stacks.to_json - logger.info 'Stack list has been updated from upstream and cached locally' + logger.info "Stack list has been updated from upstream and cached locally" end @initial_fetch_complete = true end # Start async stack list update. Creates thread that loops every