Sha256: 81c3e63e1b905868d2b46bb4ef0efb6df3b63b76504c0bf10f7f96b57161e4df

Contents?: true

Size: 589 Bytes

Versions: 2

Compression:

Stored size: 589 Bytes

Contents

require 'fog'

module EbsSnapshotter

  class Snapshotter

    def initialize(config_path, volume_id)
      @volume_id = volume_id
      @aws_config = YAML::load(File.open(config_path))
    end

    def snapshot
      new_snapshot = connection.snapshots.new
      new_snapshot.description = "#{@volume_id} - #{Time.now}"
      new_snapshot.volume_id = @volume_id
      saved = new_snapshot.save
      raise "Failed to save snapshot for #{@volume_id}" unless saved 
    end

    private

      def connection
        @connection ||= Fog::Compute.new(@aws_config[:fog])
      end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ebs_snapshotter-0.0.2 lib/ebs_snapshotter/snapshotter.rb
ebs_snapshotter-0.0.1 lib/ebs_snapshotter/snapshotter.rb