require 'stackster/stack/stack_creater' require 'stackster/stack/stack_updater' require 'stackster/stack/stack_destroyer' require 'stackster/stack/stack_reader' require 'stackster/stack/stack_formater' require 'stackster/stack/stack_lister' require 'stackster/stack/status' module Stackster class Stack def initialize(args) @name = args[:name] @config = Config.new :config => args[:config], :logger => args[:logger] ||= StacksterLogger.new @entry = Entry.new :name => @name, :config => @config end # ToDo - maybe in stack creater # Rescure stack creation errors and verify entry is not saved def create(args) @template_file = args[:template] @entry.set_attributes args[:attributes] stack_creater.create @entry.save end # To Do - maybe in stack udpater # Rescure stack creation errors and verify entry is not saved def update(args) @template_body = template @entry.set_attributes args[:attributes] stack_updater.update_stack_if_parameters_changed args[:attributes] @entry.save end # To do - maybe in stack destroyer # Rescue stack creation exception and only delete on success def destroy stack_destroyer.destroy @entry.delete_attributes end def display stack_formater.display end def attributes stack_reader.attributes end def outputs stack_reader.outputs end def status stack_reader.status end def events(limit=3) stack_reader.events limit end def instances stack_reader.instances end def resources stack_reader.resources end def template stack_reader.template end def parameters stack_reader.parameters end private def stack_creater @stack_creater ||= StackCreater.new :name => @name, :entry => @entry, :template_file => @template_file, :config => @config end def stack_updater @stack_updater ||= StackUpdater.new :name => @name, :entry => @entry, :template_body => @template_body, :config => @config end def stack_destroyer @stack_destroyer ||= StackDestroyer.new :name => @name, :config => @config end def stack_reader @stack_reader ||= StackReader.new :name => @name, :config => @config end def stack_formater @stack_formater ||= StackFormater.new :name => @name, :config => @config end def stack_status @status ||= Status.new :name => @name, :config => @config end end end