vagrant-vbox-snapshot 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/DEVNOTES.md +27 -0
- data/Gemfile +4 -0
- data/README.md +37 -0
- data/lib/vagrant-vbox-snapshot/commands/back.rb +28 -0
- data/lib/vagrant-vbox-snapshot/commands/delete.rb +31 -0
- data/lib/vagrant-vbox-snapshot/commands/go.rb +33 -0
- data/lib/vagrant-vbox-snapshot/commands/list.rb +25 -0
- data/lib/vagrant-vbox-snapshot/commands/root.rb +75 -0
- data/lib/vagrant-vbox-snapshot/commands/take.rb +31 -0
- data/lib/vagrant-vbox-snapshot/plugin.rb +20 -0
- data/lib/vagrant-vbox-snapshot/version.rb +5 -0
- data/lib/vagrant-vbox-snapshot.rb +2 -0
- data/vagrant-vbox-snapshot.gemspec +21 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OWYyMDIzMDlmMTUwZDlhZGJlOTEwMmU2NTU3YzgzMTFmNmExMDc1OA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzQ3NDZhOTg5NjBhODk0Mzk0YTFiZTIxZTU3YzAwNzljOWYwOWQxMA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZTFkOGQxY2E0YzU0MWM4YTZiMTQ5OTVhNThjMWI5NzM2ZjgyNzMwYTYzN2Ri
|
10
|
+
YjA4MTIyN2IxNWI1ZWU4MzI1M2UxNWRiZDE2ODk5MWYwMDFmOWU5YTlmODIy
|
11
|
+
MTAxN2I3OGMxMDNiYjUzNWFiYzUzMTBlMmQzOTllMmRmYzVmYTU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YWU2MjhkMTM4MWNkZmNlYTNhMmUwODU1MjAyMjA1YzM0YzhkZDVlZTRkM2Qy
|
14
|
+
YmJkNDhmMzQ3M2ZiOGVlNmVhYjljODVmODVjN2NkMzFkNzRhZGY5ODRmYjM3
|
15
|
+
ZWJhNGE5NzI5NDA0NTZlZmM1YjY5YjdmNGIwYzM3NjM3OTU4Mzg=
|
data/.gitignore
ADDED
data/DEVNOTES.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
## Updating to vagrant 1.1 plugin API
|
2
|
+
|
3
|
+
Resources:
|
4
|
+
|
5
|
+
* http://docs.vagrantup.com/v2/plugins/development-basics.html
|
6
|
+
|
7
|
+
Example code:
|
8
|
+
|
9
|
+
* https://gist.github.com/dergachev/5367385#vagrant-snapshot.rb
|
10
|
+
* https://github.com/mitchellh/vagrant/issues/143#add-vagrant-snapshot-option
|
11
|
+
* https://github.com/fgrehm/vagrant-notify
|
12
|
+
* https://github.com/RiotGames/berkshelf-vagrant
|
13
|
+
* https://github.com/mitchellh/vagrant-aws/blob/master/lib/vagrant-aws/plugin.rb
|
14
|
+
* sahara 1.1 update commit: https://github.com/ryuzee/sahara/commit/b80a621a9200bb4935c782bd4e538886c42b8643
|
15
|
+
* vagrant-snap: https://github.com/t9md/vagrant-snap/blob/master/lib/vagrant_snap.rb
|
16
|
+
* https://github.com/dotless-de/vagrant-plugins-env/blob/master/.gitmodules
|
17
|
+
|
18
|
+
Vagrant source code:
|
19
|
+
|
20
|
+
* https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/registry.rb
|
21
|
+
* https://github.com/mitchellh/vagrant/tree/master/plugins/provisioners/shell
|
22
|
+
* https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/plugin/v2/provisioner.rb
|
23
|
+
* https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/plugin/v2/command.rb
|
24
|
+
|
25
|
+
## other ideas related to snapshots
|
26
|
+
|
27
|
+
* http://code.chrisroberts.org/blog/2012/05/09/cooking-up-partial-run-lists-with-chef/
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
vagrant-vbox-snapshot
|
2
|
+
==================================
|
3
|
+
Vagrant plugin that exposes the `VBoxManage snapshot` command.
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
Ensure you have Vagrant 1.1+ installed, then run:
|
8
|
+
|
9
|
+
vagrant plugin install vagrant-vbox-snapshot
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
The following commands are added by this plugin:
|
14
|
+
|
15
|
+
vagrant snap back # back to current snapshot
|
16
|
+
vagrant snap delete SNAP_NAME # delete snapshot
|
17
|
+
vagrant snap go SNAP_NAME # go to specified snapshot
|
18
|
+
vagrant snap help [COMMAND] # Describe subcommands or one specific subcommand
|
19
|
+
vagrant snap list # list snapshot
|
20
|
+
vagrant snap take [NAME] # take snapshot
|
21
|
+
|
22
|
+
## Other solutions
|
23
|
+
|
24
|
+
There have been a number of similar plugins, but none worked for Vagrant 1.1:
|
25
|
+
|
26
|
+
* [vagrant-snap](https://github.com/t9md/vagrant-snap)
|
27
|
+
- originally published as a gist: https://gist.github.com/t9md/1008031
|
28
|
+
- fork of above gist, with Vagrant 1.0.6 compatibility: https://gist.github.com/tombh/5142237
|
29
|
+
- [source](https://github.com/mitchellh/vagrant/issues/143#issuecomment-14781762)
|
30
|
+
- primary inspiration for vagrant-vbox-snapshot
|
31
|
+
* [sahara](https://github.com/jedi4ever/sahara)
|
32
|
+
- fork exists with 1.1 functionality: https://github.com/ryuzee/sahara
|
33
|
+
|
34
|
+
## Development
|
35
|
+
|
36
|
+
See [DEVNOTES.md](https://github.com/dergachev/vagrant-vbox-snapshot/blob/master/DEVNOTES.md)
|
37
|
+
for the notes I compiled while developing this plugin.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VBoxSnapshot
|
3
|
+
module Command
|
4
|
+
class Back < Vagrant.plugin(2, :command)
|
5
|
+
def execute
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
opts = OptionParser.new do |opts|
|
9
|
+
opts.banner = "Back to current snapshot"
|
10
|
+
opts.separator ""
|
11
|
+
opts.separator "Usage: vagrant snapshot back"
|
12
|
+
end
|
13
|
+
# Parse the options
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
with_target_vms do |machine|
|
18
|
+
vm_id = machine.id
|
19
|
+
system "VBoxManage snapshot #{vm_id} list --details"
|
20
|
+
system "VBoxManage controlvm #{vm_id} poweroff"
|
21
|
+
system "VBoxManage snapshot #{vm_id} restorecurrent"
|
22
|
+
system "VBoxManage startvm #{vm_id} --type headless"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VBoxSnapshot
|
3
|
+
module Command
|
4
|
+
class Delete < Vagrant.plugin(2, :command)
|
5
|
+
def execute
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
opts = OptionParser.new do |opts|
|
9
|
+
opts.banner = "Delete snapshot"
|
10
|
+
opts.separator ""
|
11
|
+
opts.separator "Usage: vagrant snapshot delete <SNAPSHOT_NAME>"
|
12
|
+
end
|
13
|
+
# Parse the options
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
if !argv[0]
|
18
|
+
@env.ui.info(opts.help, :prefix => false)
|
19
|
+
return
|
20
|
+
end
|
21
|
+
|
22
|
+
with_target_vms do |machine|
|
23
|
+
vm_id = machine.id
|
24
|
+
snapshot_name = argv[0]
|
25
|
+
system "VBoxManage snapshot #{vm_id} delete #{snapshot_name}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VBoxSnapshot
|
3
|
+
module Command
|
4
|
+
class Go < Vagrant.plugin(2, :command)
|
5
|
+
def execute
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
opts = OptionParser.new do |opts|
|
9
|
+
opts.banner = "Go to specified snapshot"
|
10
|
+
opts.separator ""
|
11
|
+
opts.separator "Usage: vagrant snapshot go <SNAPSHOT_NAME>"
|
12
|
+
end
|
13
|
+
# Parse the options
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
if !argv[0]
|
18
|
+
@env.ui.info(opts.help, :prefix => false)
|
19
|
+
return
|
20
|
+
end
|
21
|
+
|
22
|
+
with_target_vms do |machine|
|
23
|
+
vm_id = machine.id
|
24
|
+
snapshot_name = argv[0]
|
25
|
+
system "VBoxManage controlvm #{vm_id} poweroff"
|
26
|
+
system "VBoxManage snapshot #{vm_id} restore #{snapshot_name}"
|
27
|
+
system "VBoxManage startvm #{vm_id} --type headless"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VBoxSnapshot
|
3
|
+
module Command
|
4
|
+
class List < Vagrant.plugin(2, :command)
|
5
|
+
def execute
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
opts = OptionParser.new do |opts|
|
9
|
+
opts.banner = "List snapshots"
|
10
|
+
opts.separator ""
|
11
|
+
opts.separator "Usage: vagrant snapshot list"
|
12
|
+
end
|
13
|
+
# Parse the options
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
with_target_vms do |machine|
|
18
|
+
vm_id = machine.id
|
19
|
+
system "VBoxManage snapshot #{vm_id} list --details"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VBoxSnapshot
|
3
|
+
module Command
|
4
|
+
class Root < Vagrant.plugin(2, :command)
|
5
|
+
def initialize(argv, env)
|
6
|
+
super
|
7
|
+
|
8
|
+
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
|
9
|
+
|
10
|
+
@subcommands = Vagrant::Registry.new
|
11
|
+
@subcommands.register(:take) do
|
12
|
+
require_relative('take')
|
13
|
+
Take
|
14
|
+
end
|
15
|
+
@subcommands.register(:list) do
|
16
|
+
require_relative('list')
|
17
|
+
List
|
18
|
+
end
|
19
|
+
@subcommands.register(:go) do
|
20
|
+
require_relative('go')
|
21
|
+
Go
|
22
|
+
end
|
23
|
+
@subcommands.register(:back) do
|
24
|
+
require_relative('back')
|
25
|
+
Back
|
26
|
+
end
|
27
|
+
@subcommands.register(:delete) do
|
28
|
+
require_relative('delete')
|
29
|
+
Delete
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def execute
|
34
|
+
if @main_args.include?("-h") || @main_args.include?("--help")
|
35
|
+
# Print the help for all the box commands.
|
36
|
+
return help
|
37
|
+
end
|
38
|
+
|
39
|
+
# If we reached this far then we must have a subcommand. If not,
|
40
|
+
# then we also just print the help and exit.
|
41
|
+
command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
|
42
|
+
return help if !command_class || !@sub_command
|
43
|
+
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
|
44
|
+
|
45
|
+
# Initialize and execute the command class
|
46
|
+
command_class.new(@sub_args, @env).execute
|
47
|
+
end
|
48
|
+
|
49
|
+
# Prints the help out for this command
|
50
|
+
def help
|
51
|
+
opts = OptionParser.new do |opts|
|
52
|
+
opts.banner = "Usage: vagrant snapshot <command> [<args>]"
|
53
|
+
opts.separator ""
|
54
|
+
opts.separator "Available subcommands:"
|
55
|
+
|
56
|
+
# Add the available subcommands as separators in order to print them
|
57
|
+
# out as well.
|
58
|
+
keys = []
|
59
|
+
@subcommands.each { |key, value| keys << key.to_s }
|
60
|
+
|
61
|
+
keys.sort.each do |key|
|
62
|
+
opts.separator " #{key}"
|
63
|
+
end
|
64
|
+
|
65
|
+
opts.separator ""
|
66
|
+
opts.separator "For help on any individual command run `vagrant snapshot <command> -h`"
|
67
|
+
end
|
68
|
+
|
69
|
+
@env.ui.info(opts.help, :prefix => false)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VBoxSnapshot
|
3
|
+
module Command
|
4
|
+
class Take < Vagrant.plugin(2, :command)
|
5
|
+
def execute
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
opts = OptionParser.new do |opts|
|
9
|
+
opts.banner = "Take snapshot"
|
10
|
+
opts.separator ""
|
11
|
+
opts.separator "Usage: vagrant snapshot take <SNAPSHOT_NAME>"
|
12
|
+
end
|
13
|
+
# Parse the options
|
14
|
+
argv = parse_options(opts)
|
15
|
+
return if !argv
|
16
|
+
|
17
|
+
if !argv[0]
|
18
|
+
@env.ui.info(opts.help, :prefix => false)
|
19
|
+
return
|
20
|
+
end
|
21
|
+
|
22
|
+
with_target_vms do |machine|
|
23
|
+
vm_id = machine.id
|
24
|
+
snapshot_name = argv[0]
|
25
|
+
system "VBoxManage snapshot #{vm_id} take #{snapshot_name} --pause"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The Vagrant VBox Snapshot plugin must be run within Vagrant."
|
5
|
+
end
|
6
|
+
|
7
|
+
module VagrantPlugins
|
8
|
+
module VBoxSnapshot
|
9
|
+
class Plugin < Vagrant.plugin("2")
|
10
|
+
name "Vagrant VBox Snapshot"
|
11
|
+
description "Wrapper on the `VBoxManage snapshot` command."
|
12
|
+
|
13
|
+
command "snapshot" do
|
14
|
+
require_relative 'commands/root.rb'
|
15
|
+
Command::Root
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
2
|
+
require 'vagrant-vbox-snapshot/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "vagrant-vbox-snapshot"
|
6
|
+
spec.version = VagrantPlugins::VBoxSnapshot::VERSION
|
7
|
+
spec.authors = "Alex Dergachev"
|
8
|
+
spec.email = "alex@evolvingweb.ca"
|
9
|
+
spec.summary = 'Vagrant plugin that exposes the `VBoxManage snapshot` command.'
|
10
|
+
spec.description = 'Vagrant plugin that exposes the `VBoxManage snapshot` command.'
|
11
|
+
spec.homepage = 'https://github.com/dergachev/vagrant-vbox-snapshot'
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_path = 'lib'
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-vbox-snapshot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Dergachev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
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: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Vagrant plugin that exposes the `VBoxManage snapshot` command.
|
42
|
+
email: alex@evolvingweb.ca
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- .gitignore
|
48
|
+
- DEVNOTES.md
|
49
|
+
- Gemfile
|
50
|
+
- README.md
|
51
|
+
- lib/vagrant-vbox-snapshot.rb
|
52
|
+
- lib/vagrant-vbox-snapshot/commands/back.rb
|
53
|
+
- lib/vagrant-vbox-snapshot/commands/delete.rb
|
54
|
+
- lib/vagrant-vbox-snapshot/commands/go.rb
|
55
|
+
- lib/vagrant-vbox-snapshot/commands/list.rb
|
56
|
+
- lib/vagrant-vbox-snapshot/commands/root.rb
|
57
|
+
- lib/vagrant-vbox-snapshot/commands/take.rb
|
58
|
+
- lib/vagrant-vbox-snapshot/plugin.rb
|
59
|
+
- lib/vagrant-vbox-snapshot/version.rb
|
60
|
+
- vagrant-vbox-snapshot.gemspec
|
61
|
+
homepage: https://github.com/dergachev/vagrant-vbox-snapshot
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.0.3
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Vagrant plugin that exposes the `VBoxManage snapshot` command.
|
85
|
+
test_files: []
|