ebs_snapshotter 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjY0YTRhZmM3Nzk0MzQxNmU5NzI2YjVhMDI4NTg2YWE3MDFlYTM1NQ==
5
+ data.tar.gz: !binary |-
6
+ YmJhZTkwZjc0ZDI3YWYxNmE1NDczMzZiODkzNjBhMzlhN2UwYzVjZQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZDU5NzUwNWQxYjk1NmM4NmI0Yzg5NjhjYjE5ZTcxODFkYzQwM2JkZDc5MzVi
10
+ MzEwMmMyOGM2MWVlNThjZDg5NmZiMTI0NDcyMjIyMDExZDlhODhiYTUxYzVl
11
+ MTA0NzM2MDAyMThjN2ZkMTMyNTEzODIzMTFkYzI4YTY0NWQ1OGY=
12
+ data.tar.gz: !binary |-
13
+ MDkzNDMxYzRhZjZlNjkxNDMzZWE4OTNiMGY0YTQ3ZmQ3YThjYzk2ZWZjZGE0
14
+ OTU0MTFhN2UxMzhhYzA3ZDQ2YjJhNjNkYjAzMjc3NTQxZDRlOWVlZjY1ZDYx
15
+ M2MyOThlMWNiZjdlYzA5MTczNmRiNmMwMjY4NjJiZjcyNjJkYmE=
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ config
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "thor"
4
+ gem "fog"
5
+
6
+ group :development do
7
+ gem "rspec"
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ builder (3.2.2)
5
+ diff-lcs (1.2.4)
6
+ excon (0.25.3)
7
+ fog (1.15.0)
8
+ builder
9
+ excon (~> 0.25.0)
10
+ formatador (~> 0.2.0)
11
+ mime-types
12
+ multi_json (~> 1.0)
13
+ net-scp (~> 1.1)
14
+ net-ssh (>= 2.1.3)
15
+ nokogiri (~> 1.5)
16
+ ruby-hmac
17
+ formatador (0.2.4)
18
+ mime-types (1.25)
19
+ mini_portile (0.5.1)
20
+ multi_json (1.7.9)
21
+ net-scp (1.1.2)
22
+ net-ssh (>= 2.6.5)
23
+ net-ssh (2.6.8)
24
+ nokogiri (1.6.0)
25
+ mini_portile (~> 0.5.0)
26
+ rspec (2.14.1)
27
+ rspec-core (~> 2.14.0)
28
+ rspec-expectations (~> 2.14.0)
29
+ rspec-mocks (~> 2.14.0)
30
+ rspec-core (2.14.5)
31
+ rspec-expectations (2.14.2)
32
+ diff-lcs (>= 1.1.3, < 2.0)
33
+ rspec-mocks (2.14.3)
34
+ ruby-hmac (0.4.0)
35
+ thor (0.18.1)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ fog
42
+ rspec
43
+ thor
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Erling Wegger Linde
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = EBS Snapshotter
2
+
3
+ Work in progress..
4
+
5
+ == Contributing to EBS Snapshotter
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 Erling Wegger Linde. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/Readme.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = EBS Snapshotter
2
+
3
+ Work in progress..
4
+
5
+ == Contributing to EBS Snapshotter
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 Erling Wegger Linde. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require File.expand_path("../../lib/ebs_snapshotter", __FILE__)
5
+ EbsSnapshotter::CLI.start
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ebs_snapshotter/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "ebs_snapshotter"
8
+ s.version = EbsSnapshotter::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ["Erling Wegger Linde"]
11
+ s.email = ["erlingwl@gmail.com"]
12
+ s.homepage =
13
+ s.summary = "Snapshot EBS volumes"
14
+ s.description = "Snapshot EBS volumes on AWS"
15
+
16
+ s.executables = ["ebs_snapshotter"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.homepage = "http://github.com/erlingwl/ebs_snapshotter"
25
+ s.licenses = ["MIT"]
26
+ s.require_paths = ["lib"]
27
+
28
+ s.add_dependency "thor"
29
+ s.add_dependency "fog"
30
+
31
+ s.add_development_dependency "rspec"
32
+
33
+ end
@@ -0,0 +1,16 @@
1
+ require 'logger'
2
+
3
+ LIBRARY_PATH = File.join(File.dirname(__FILE__), 'ebs_snapshotter')
4
+
5
+ require File.join(LIBRARY_PATH, 'version')
6
+ require File.join(LIBRARY_PATH, 'snapshotter')
7
+ require File.join(LIBRARY_PATH, 'cli')
8
+
9
+ module EbsSnapshotter
10
+
11
+ $stdout.sync = true
12
+
13
+ $log = Logger.new($stdout)
14
+ $log.level = Logger::INFO
15
+
16
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ require 'thor'
4
+
5
+ module EbsSnapshotter
6
+ class CLI < Thor
7
+ include Thor::Actions
8
+
9
+
10
+ method_option :config_path, :type => :string, :required => true, :desc => "Path to fog config i.e. ~/aws.yml"
11
+ method_option :volume_id, :type => :string, :required => true, :desc => "ID of the EBS volume to snapshot"
12
+
13
+ desc 'snapshot', "Snapshots an EBS volume."
14
+ def snapshot
15
+ snapshotter = EbsSnapshotter::Snapshotter.new(options[:config_path], options[:volume_id])
16
+ snapshotter.snapshot
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,28 @@
1
+ require 'fog'
2
+
3
+ module EbsSnapshotter
4
+
5
+ class Snapshotter
6
+
7
+ def initialize(config_path, volume_id)
8
+ @volume_id = volume_id
9
+ @aws_config = YAML::load(File.open(config_path))
10
+ end
11
+
12
+ def snapshot
13
+ new_snapshot = connection.snapshots.new
14
+ new_snapshot.description = "#{@volume_id} - #{Time.now}"
15
+ new_snapshot.volume_id = @volume_id
16
+ saved = new_snapshot.save
17
+ raise "Failed to save snapshot for #{@volume_id}" unless saved
18
+ end
19
+
20
+ private
21
+
22
+ def connection
23
+ @connection ||= Fog::Compute.new(@aws_config[:fog])
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,3 @@
1
+ module EbsSnapshotter
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ebs_snapshotter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Erling Wegger Linde
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fog
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Snapshot EBS volumes on AWS
56
+ email:
57
+ - erlingwl@gmail.com
58
+ executables:
59
+ - ebs_snapshotter
60
+ extensions: []
61
+ extra_rdoc_files:
62
+ - LICENSE.txt
63
+ - README.rdoc
64
+ files:
65
+ - .gitignore
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - LICENSE.txt
69
+ - Rakefile
70
+ - Readme.rdoc
71
+ - bin/ebs_snapshotter
72
+ - ebs_snapshotter.gemspec
73
+ - lib/ebs_snapshotter.rb
74
+ - lib/ebs_snapshotter/cli.rb
75
+ - lib/ebs_snapshotter/snapshotter.rb
76
+ - lib/ebs_snapshotter/version.rb
77
+ - README.rdoc
78
+ homepage: http://github.com/erlingwl/ebs_snapshotter
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.0.6
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Snapshot EBS volumes
102
+ test_files: []
103
+ has_rdoc: