vagrant-vbox-snapshot 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/DEVNOTES.md +69 -33
- data/README.md +0 -1
- data/lib/vagrant-vbox-snapshot/commands/back.rb +16 -5
- data/lib/vagrant-vbox-snapshot/commands/delete.rb +7 -3
- data/lib/vagrant-vbox-snapshot/commands/go.rb +19 -15
- data/lib/vagrant-vbox-snapshot/commands/list.rb +5 -2
- data/lib/vagrant-vbox-snapshot/commands/take.rb +4 -2
- data/lib/vagrant-vbox-snapshot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33e9abe0b4d5521bffb2509f88c1aad9a2d6152f
|
4
|
+
data.tar.gz: 9a3ffca4dec1a13a32bcd420e5c26e4d55755cd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73151d2048746312481aff7ad37b2c4fb8f525e2ac8ce88a80984be697e569a9e0c1d9fec58ca11be31df150fac5fafb23d5a1fbac38193e94768a995bb09e9e
|
7
|
+
data.tar.gz: 91bc767c5c6813f4d2daf0169f6b7d2399f4e14e4f86cad5d236347d7306e9806fcb6b99b60f443e90e3cc095c83aae9a31daa0d8954fbba83eada4add3575cb
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## [0.0.4](https://github.com/dergachev/vagrant-vbox-snapshot/compare/v0.0.3...v0.0.4) (Sep 23, 2013)
|
2
|
+
|
3
|
+
BACKWARDS INCOMPATIBILITIES:
|
4
|
+
|
5
|
+
- none
|
6
|
+
|
7
|
+
FEATURES:
|
8
|
+
|
9
|
+
- Add Windows compatibility [#12](https://github.com/dergachev/vagrant-vbox-snapshot/issues/12)
|
10
|
+
|
11
|
+
IMPROVEMENTS:
|
12
|
+
|
13
|
+
- Clean up `vagrant snapshot go` output when target is already in poweroff state. [#14](https://github.com/dergachev/vagrant-vbox-snapshot/pull/14)
|
14
|
+
|
1
15
|
## [0.0.3](https://github.com/dergachev/vagrant-vbox-snapshot/compare/v0.0.2...v0.0.3) (Sep 3, 2013)
|
2
16
|
|
3
17
|
BACKWARDS INCOMPATIBILITIES:
|
data/DEVNOTES.md
CHANGED
@@ -1,31 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Resources:
|
1
|
+
# Developer notes for vagrant-vbox-snapshot
|
4
2
|
|
5
|
-
|
6
|
-
* http://railscasts.com/episodes/245-new-gem-with-bundler?view=asciicast (Gem tutorial)
|
3
|
+
## Forking and hacking on vagrant-vbox-snapshot
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
* https://github.com/RiotGames/berkshelf-vagrant
|
14
|
-
* https://github.com/mitchellh/vagrant-aws/blob/master/lib/vagrant-aws/plugin.rb
|
15
|
-
* sahara 1.1 update commit: https://github.com/ryuzee/sahara/commit/b80a621a9200bb4935c782bd4e538886c42b8643
|
16
|
-
* vagrant-snap: https://github.com/t9md/vagrant-snap/blob/master/lib/vagrant_snap.rb
|
17
|
-
* https://github.com/dotless-de/vagrant-plugins-env/blob/master/.gitmodules
|
18
|
-
|
19
|
-
Vagrant source code:
|
5
|
+
```
|
6
|
+
# fork vagrant-vbox-snapshot on github.com, and clone locally
|
7
|
+
cd ~/code # or wherever you like to put coding projects
|
8
|
+
git clone git@github.com/USERNAME/vagrant-vbox-snapshot.git
|
9
|
+
cd vagrant-vbox-snapshot
|
20
10
|
|
21
|
-
|
22
|
-
|
23
|
-
* https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/plugin/v2/provisioner.rb
|
24
|
-
* https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/plugin/v2/command.rb
|
11
|
+
# create a new branch for your work
|
12
|
+
git checkout -b FEATURE_NAME
|
25
13
|
|
26
|
-
|
14
|
+
bundle install # not 100% sure this is necessary
|
15
|
+
# hack away...
|
16
|
+
# then test, possibly modifying Vagrantfile to suit scenario
|
17
|
+
vagrant up
|
18
|
+
vagrant snapshot take TEST1 # and so on...
|
27
19
|
|
28
|
-
|
20
|
+
# then commit, push, and create pull request
|
21
|
+
```
|
29
22
|
|
30
23
|
## Reviewing a pull request
|
31
24
|
|
@@ -41,28 +34,71 @@ git push -u origin master
|
|
41
34
|
|
42
35
|
## Pushing out a new release of the gem
|
43
36
|
|
37
|
+
Do a local build:
|
38
|
+
|
44
39
|
```
|
45
|
-
# make commits
|
46
|
-
# consider creating/updating CHANGELOG.txt
|
47
40
|
vim lib/vagrant-vbox-snapshot/version.rb +/VERSION # increment version counter, eg to 0.0.3
|
48
|
-
gem build vagrant-vbox-snapshot.gemspec # creates vagrant-vbox-snapshot-0.0.3.gem
|
41
|
+
gem build vagrant-vbox-snapshot.gemspec # creates vagrant-vbox-snapshot-0.0.3.gem
|
42
|
+
```
|
49
43
|
|
44
|
+
Test the local build:
|
45
|
+
|
46
|
+
```
|
50
47
|
# test the gem locally, in a random vagrant project
|
51
48
|
cd ~/code/screengif
|
52
49
|
vagrant plugin uninstall vagrant-vbox-snapshot
|
53
|
-
vagrant plugin install ~/code/vagrant-vbox-snapshot/vagrant-vbox-snapshot-0.0.3
|
54
|
-
|
55
|
-
vagrant snapshot list -h
|
56
|
-
# cleanup
|
57
|
-
|
50
|
+
vagrant plugin install ~/code/vagrant-vbox-snapshot/vagrant-vbox-snapshot-VERSION.gem # replace VERSION with 0.0.3
|
51
|
+
vagrant plugin list | grep snapshot # ensure that correct version is installed
|
52
|
+
vagrant snapshot list -h # quick sanity check
|
53
|
+
vagrant plugin uninstall # cleanup
|
54
|
+
```
|
55
|
+
|
56
|
+
Now commit and tag:
|
57
|
+
|
58
|
+
|
59
|
+
```
|
60
|
+
cd ~/code/vagrant-vbox-snapshot
|
61
|
+
|
62
|
+
vim CHANGELOG.txt # update CHANGELOG
|
63
|
+
# git commit everything
|
58
64
|
|
59
|
-
cd ~/code/vagrant-vbox-snapshot/
|
60
65
|
gem push vagrant-vbox-snapshot-0.0.3.gem
|
61
|
-
git tag
|
66
|
+
git tag vN.N.N # eg v0.0.3
|
62
67
|
git push --tags
|
68
|
+
```
|
63
69
|
|
64
70
|
# test installing from rubygems
|
65
71
|
cd ~/code/screengif
|
66
72
|
vagrant plugin install vagrant-vbox-snapshot
|
67
73
|
vagrant plugin list
|
68
74
|
```
|
75
|
+
|
76
|
+
|
77
|
+
## Updating to vagrant 1.1 plugin API
|
78
|
+
|
79
|
+
Resources:
|
80
|
+
|
81
|
+
* http://docs.vagrantup.com/v2/plugins/development-basics.html
|
82
|
+
* http://railscasts.com/episodes/245-new-gem-with-bundler?view=asciicast (Gem tutorial)
|
83
|
+
|
84
|
+
Example code:
|
85
|
+
|
86
|
+
* https://gist.github.com/dergachev/5367385#vagrant-snapshot.rb
|
87
|
+
* https://github.com/mitchellh/vagrant/issues/143#add-vagrant-snapshot-option
|
88
|
+
* https://github.com/fgrehm/vagrant-notify
|
89
|
+
* https://github.com/RiotGames/berkshelf-vagrant
|
90
|
+
* https://github.com/mitchellh/vagrant-aws/blob/master/lib/vagrant-aws/plugin.rb
|
91
|
+
* sahara 1.1 update commit: https://github.com/ryuzee/sahara/commit/b80a621a9200bb4935c782bd4e538886c42b8643
|
92
|
+
* vagrant-snap: https://github.com/t9md/vagrant-snap/blob/master/lib/vagrant_snap.rb
|
93
|
+
* https://github.com/dotless-de/vagrant-plugins-env/blob/master/.gitmodules
|
94
|
+
|
95
|
+
Vagrant source code:
|
96
|
+
|
97
|
+
* https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/registry.rb
|
98
|
+
* https://github.com/mitchellh/vagrant/tree/master/plugins/provisioners/shell
|
99
|
+
* https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/plugin/v2/provisioner.rb
|
100
|
+
* https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/plugin/v2/command.rb
|
101
|
+
|
102
|
+
## other ideas related to snapshots
|
103
|
+
|
104
|
+
* http://code.chrisroberts.org/blog/2012/05/09/cooking-up-partial-run-lists-with-chef/
|
data/README.md
CHANGED
@@ -15,11 +15,22 @@ module VagrantPlugins
|
|
15
15
|
return if !argv
|
16
16
|
|
17
17
|
with_target_vms(argv, single_target: true) do |machine|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
|
19
|
+
if machine.state.id != :poweroff
|
20
|
+
machine.provider.driver.execute("controlvm", machine.id, "poweroff")
|
21
|
+
end
|
22
|
+
|
23
|
+
machine.provider.driver.execute("snapshot", machine.id, "restorecurrent") do |type, data|
|
24
|
+
machine.env.ui.info(data, :color => type == :stderr ? :red : :white, :new_line => false)
|
25
|
+
end
|
26
|
+
|
27
|
+
if options[:reload]
|
28
|
+
@env.ui.info("Reloading VM, since --reload passed")
|
29
|
+
machine.action(:reload, :provision_enabled => false)
|
30
|
+
else
|
31
|
+
@env.ui.info("Starting restored VM")
|
32
|
+
machine.action(:up, :provision_enabled => false)
|
33
|
+
end
|
23
34
|
end
|
24
35
|
end
|
25
36
|
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# this command is very slow
|
2
|
+
# consider removing it; or replacing with this idea: http://superuser.com/questions/590968/quickest-way-to-merge-snapshots-in-virtualbox
|
3
|
+
|
1
4
|
require_relative 'multi_vm_args'
|
2
5
|
|
3
6
|
module VagrantPlugins
|
@@ -10,7 +13,7 @@ module VagrantPlugins
|
|
10
13
|
options = {}
|
11
14
|
|
12
15
|
opts = OptionParser.new do |opts|
|
13
|
-
opts.banner = "Delete snapshot"
|
16
|
+
opts.banner = "Delete snapshot (warning: this is a very slow operation)"
|
14
17
|
opts.separator ""
|
15
18
|
opts.separator "Usage: vagrant snapshot delete [vm-name] <SNAPSHOT_NAME>"
|
16
19
|
end
|
@@ -22,8 +25,9 @@ module VagrantPlugins
|
|
22
25
|
return if !snapshot_name
|
23
26
|
|
24
27
|
with_target_vms(vm_name, single_target: true) do |machine|
|
25
|
-
|
26
|
-
|
28
|
+
machine.provider.driver.execute("snapshot", machine.id, "delete", snapshot_name) do |type, data|
|
29
|
+
machine.env.ui.info(data, :color => type == :stderr ? :red : :white)
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
@@ -6,9 +6,9 @@ module VagrantPlugins
|
|
6
6
|
class Go < Vagrant.plugin(2, :command)
|
7
7
|
include MultiVmArgs
|
8
8
|
|
9
|
-
def get_shared_folders(
|
9
|
+
def get_shared_folders(machine)
|
10
10
|
shared_folders = []
|
11
|
-
info =
|
11
|
+
info = machine.provider.driver.execute("showvminfo", machine.id, "--machinereadable")
|
12
12
|
info.split("\n").each do |line|
|
13
13
|
if line =~ /^SharedFolderNameMachineMapping\d+="(.+?)"$/
|
14
14
|
shared_folders << $1.to_s
|
@@ -17,14 +17,13 @@ module VagrantPlugins
|
|
17
17
|
return shared_folders
|
18
18
|
end
|
19
19
|
|
20
|
-
def before_restore(
|
21
|
-
@shared_folders_before = get_shared_folders(
|
20
|
+
def before_restore(machine)
|
21
|
+
@shared_folders_before = get_shared_folders(machine)
|
22
22
|
end
|
23
23
|
|
24
|
-
def after_restore(
|
25
|
-
@shared_folders_after = get_shared_folders(
|
24
|
+
def after_restore(machine)
|
25
|
+
@shared_folders_after = get_shared_folders(machine)
|
26
26
|
if @shared_folders_before != @shared_folders_after
|
27
|
-
missing_folders = @shared_folders_before - @shared_folders_after
|
28
27
|
@env.ui.warn("Synced folders have changed after restoring snapshot. Consider running 'vagrant reload'.")
|
29
28
|
@env.ui.warn(" Before restore: #{@shared_folders_before}")
|
30
29
|
@env.ui.warn(" After restore: #{@shared_folders_after}")
|
@@ -55,21 +54,26 @@ module VagrantPlugins
|
|
55
54
|
with_target_vms(vm_name, single_target: true) do |machine|
|
56
55
|
vm_id = machine.id
|
57
56
|
|
58
|
-
before_restore(
|
57
|
+
before_restore(machine)
|
59
58
|
|
60
|
-
|
61
|
-
|
59
|
+
if machine.state.id != :poweroff
|
60
|
+
@env.ui.info("Powering off machine #{vm_id}")
|
61
|
+
machine.provider.driver.execute("controlvm", machine.id, "poweroff")
|
62
|
+
end
|
63
|
+
|
64
|
+
machine.provider.driver.execute("snapshot", machine.id, "restore", snapshot_name) do |type, data|
|
65
|
+
machine.env.ui.info(data, :color => type == :stderr ? :red : :white, :new_line => false)
|
66
|
+
end
|
62
67
|
|
63
68
|
if options[:reload]
|
64
|
-
@env.ui.info("Reloading VM")
|
69
|
+
@env.ui.info("Reloading VM, since --reload passed")
|
65
70
|
machine.action(:reload, :provision_enabled => false)
|
66
71
|
else
|
67
|
-
@env.ui.info("Starting
|
68
|
-
|
69
|
-
system "VBoxManage startvm #{vm_id} --type headless"
|
72
|
+
@env.ui.info("Starting restored VM")
|
73
|
+
machine.action(:up, :provision_enabled => false)
|
70
74
|
end
|
71
75
|
|
72
|
-
after_restore(
|
76
|
+
after_restore(machine)
|
73
77
|
end
|
74
78
|
end
|
75
79
|
end
|
@@ -15,8 +15,11 @@ module VagrantPlugins
|
|
15
15
|
return if !argv
|
16
16
|
|
17
17
|
with_target_vms(argv, single_target: true) do |machine|
|
18
|
-
|
19
|
-
|
18
|
+
puts "Listing snapshots for '#{machine.name}':"
|
19
|
+
|
20
|
+
res = machine.provider.driver.execute("snapshot", machine.id, "list", "--details") do |type, data|
|
21
|
+
machine.env.ui.info(data, :color => :green) if (type == :stdout)
|
22
|
+
end
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
@@ -22,8 +22,10 @@ module VagrantPlugins
|
|
22
22
|
return if !snapshot_name
|
23
23
|
|
24
24
|
with_target_vms(vm_name, single_target: true) do |machine|
|
25
|
-
|
26
|
-
|
25
|
+
machine.env.ui.info("Taking snapshot #{snapshot_name}")
|
26
|
+
machine.provider.driver.execute("snapshot", machine.id, "take", snapshot_name, "--pause") do |type, data|
|
27
|
+
machine.env.ui.info(data, :color => type == :stderr ? :red : :white, :new_line => false)
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-vbox-snapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Dergachev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|