Sha256: 64ae3ec4bd53b30ecf394f07297a2d0319e49c3f3ed8b00ecfbdd2f263cebfb1
Contents?: true
Size: 1.71 KB
Versions: 8
Compression:
Stored size: 1.71 KB
Contents
require_relative '../model/cloudfile' require_relative '../model/event' module Convection module Control ## # Control tour Clouds ## class Cloud def configure(cloudfile) @cloudfile = Model::Cloudfile.new(cloudfile) end def stacks @cloudfile.stacks end def deck @cloudfile.deck end def converge(to_stack, &block) unless to_stack.nil? || stacks.include?(to_stack) block.call(Model::Event.new(:error, "Stack #{ to_stack } is not defined", :error)) if block return end deck.each do |stack| block.call(Model::Event.new(:converge, "Stack #{ stack.name }", :info)) if block stack.apply(&block) if stack.error? block.call(Model::Event.new(:error, "Error converging stack #{ stack.name }", :error), stack.errors) if block break end ## Stop on converge error break unless stack.success? ## Stop here break if !to_stack.nil? && stack.name == to_stack sleep rand @cloudfile.splay || 2 end end def diff(to_stack, &block) @cloudfile.deck.each do |stack| block.call(Model::Event.new(:compare, "Compare local state of stack #{ stack.name } (#{ stack.cloud_name }) with remote template", :info)) difference = stack.diff if difference.empty? difference << Model::Event.new(:unchanged, "Stack #{ stack.cloud_name } Has no changes", :info) end difference.each { |diff| block.call(diff) } break if !to_stack.nil? && stack.name == to_stack sleep rand @cloudfile.splay || 2 end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems