Sha256: 1d87ba0ea3cb0f5826328fe77bdeba34de1cf93b4bf6e8b20e3bc0a746f01315

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

module Heirloom

  class Destroyer

    attr_accessor :config, :id, :logger, :name

    def initialize(args)
      self.config = args[:config]
      self.name = args[:name]
      self.id = args[:id]
      self.logger = config.logger
    end

    def destroy
      logger.info "Destroying #{@name} - #{@id}"

      config.regions.each do |region|
        bucket = reader.get_bucket :region => region

        key = "#{id}.tar.gz"

        if bucket
          logger.info "Destroying 's3://#{bucket}/#{name}/#{key}'."

          s3_destroyer = Destroyer::S3.new :config => config,
                                           :region => region

          s3_destroyer.destroy_file :key_name => key,
                                    :key_folder => name,
                                    :bucket => bucket
        end
      end
      sdb.delete name, id
      logger.info "Destroy complete."
    end

    private

    def sdb
      @sdb ||= AWS::SimpleDB.new :config => @config
    end

    def reader
      @reader ||= Reader.new :config => config,
                             :name   => name,
                             :id     => id
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heirloom-0.2.0 lib/heirloom/archive/destroyer.rb