Sha256: 8cb9281bef783c10f1c57fb318cc29cfdcc396136d26fa345595e5a9d5737c93

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module Roark
  class AmiCreateWorkflow

    def initialize(args)
      @ami        = args[:ami]
      @parameters = args[:parameters]
      @template   = args[:template]
      @logger     = Roark.logger
    end

    def execute
      %w(create_instance wait_for_instance stop_instance wait_for_instance_to_stop
         create_ami wait_for_ami destroy_instance).each do |m|
        response = self.send m.to_sym
        return response unless response.success?
      end
      Response.new :code => 0, :message => "AMI create workflow completed succesfully."
    end

    def create_instance
      @ami.create_instance :parameters => @parameters,
                             :template   => @template
    end

    def wait_for_instance
      @ami.wait_for_instance
    end

    def stop_instance
      @ami.stop_instance
    end

    def wait_for_instance_to_stop
      @ami.wait_for_instance_to_stop
    end

    def create_ami
      @ami.create_ami
    end

    def wait_for_ami
      @ami.wait_for_ami
    end

    def destroy_instance
      @ami.destroy_instance
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roark-0.0.1 lib/roark/ami_create_workflow.rb