vagrant-multiprovider-snap 0.0.4

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.
Files changed (26) hide show
  1. data/CHANGELOG.md +19 -0
  2. data/LICENSE +21 -0
  3. data/README.md +78 -0
  4. data/lib/vagrant-multiprovider-snap.rb +8 -0
  5. data/lib/vagrant-multiprovider-snap/command/list.rb +54 -0
  6. data/lib/vagrant-multiprovider-snap/command/rollback.rb +36 -0
  7. data/lib/vagrant-multiprovider-snap/command/root.rb +73 -0
  8. data/lib/vagrant-multiprovider-snap/command/take.rb +36 -0
  9. data/lib/vagrant-multiprovider-snap/plugin.rb +51 -0
  10. data/lib/vagrant-multiprovider-snap/providers/virtualbox/action.rb +54 -0
  11. data/lib/vagrant-multiprovider-snap/providers/virtualbox/action/has_snapshot.rb +27 -0
  12. data/lib/vagrant-multiprovider-snap/providers/virtualbox/action/message_snapshot_not_created.rb +27 -0
  13. data/lib/vagrant-multiprovider-snap/providers/virtualbox/action/snapshot_rollback.rb +33 -0
  14. data/lib/vagrant-multiprovider-snap/providers/virtualbox/action/snapshot_take.rb +28 -0
  15. data/lib/vagrant-multiprovider-snap/providers/virtualbox/driver/base.rb +41 -0
  16. data/lib/vagrant-multiprovider-snap/providers/virtualbox/driver/meta.rb +20 -0
  17. data/lib/vagrant-multiprovider-snap/providers/vmware_fusion/action.rb +51 -0
  18. data/lib/vagrant-multiprovider-snap/providers/vmware_fusion/action/has_snapshot.rb +27 -0
  19. data/lib/vagrant-multiprovider-snap/providers/vmware_fusion/action/message_snapshot_not_created.rb +27 -0
  20. data/lib/vagrant-multiprovider-snap/providers/vmware_fusion/action/snapshot_rollback.rb +33 -0
  21. data/lib/vagrant-multiprovider-snap/providers/vmware_fusion/action/snapshot_take.rb +28 -0
  22. data/lib/vagrant-multiprovider-snap/providers/vmware_fusion/driver/base.rb +38 -0
  23. data/lib/vagrant-multiprovider-snap/version.rb +5 -0
  24. data/locales/en.yml +21 -0
  25. data/vagrant-multiprovider-snap.gemspec +33 -0
  26. metadata +70 -0
@@ -0,0 +1,19 @@
1
+ ## 0.0.4 (July 26, 2013)
2
+
3
+ - Handle ordering of plugin dependencies better - deprecate the 'zz' name component.
4
+ - Tested working with latest vagrant (1.2.5) and vmware fusion plugin (0.8.3)
5
+
6
+ ## 0.0.3 (July 1, 2013)
7
+
8
+ - Adds snapshot methods to VirtualBox::Driver::Meta for use outside of
9
+ the plugin
10
+
11
+ ## 0.0.2 (June 27, 2013)
12
+
13
+ - Adds has_snapshot? method to drivers
14
+ - Uses proper error messages when attempting to rollback on VMs with no snapshots
15
+ - Makes sure VirtualBox driver only deals with its own snapshots.
16
+
17
+ ## 0.0.1 (June 12, 2013)
18
+
19
+ Initial release - supports Virtualbox and VMWare Fusion
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010-2013 The Scale Factory Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,78 @@
1
+ Vagrant Multi-Provider Snap
2
+ ==========================
3
+
4
+ Description
5
+ -----------
6
+
7
+ This Vagrant plugin provides a consistent interface to taking snapshots of
8
+ running Vagrant boxes. It currently supports the following providers:
9
+
10
+ * VirtualBox
11
+ * VMWare Fusion (via the commercial VMWare plugin)
12
+
13
+
14
+ Installation
15
+ ------------
16
+
17
+ The easiest way to install this plugin is via the published gem.
18
+
19
+ ```
20
+ vagrant plugin install vagrant-multiprovider-snap
21
+ ```
22
+
23
+
24
+ Usage
25
+ -----
26
+
27
+ Typical usage:
28
+
29
+ * Take a new snapshot
30
+ ```vagrant snap take [vm]```
31
+
32
+ * Roll back to the last snapshot
33
+ ```vagrant snap rollback [vm]```
34
+
35
+ * List snapshots
36
+ ```vagrant snap list [vm]```
37
+
38
+ Limitations
39
+ -----------
40
+
41
+ It's currently not possible to do any of the following:
42
+
43
+ * Give a custom snapshot name
44
+ * Roll back to a specific named snapshot
45
+ * Disable snapshotting
46
+
47
+ My own requirements don't include these features, but I could be tempted to
48
+ add them if anyone would find them useful.
49
+
50
+
51
+ Hacking
52
+ -------
53
+
54
+ Working on this module is a little tricky because of the obfuscation used by
55
+ the commercial VMWare module. The following approach should get you up and
56
+ running - although it's a bundler environment, you'll also need a packaged
57
+ Vagrant install in order to get access to the rgloader libraries.
58
+
59
+ ```
60
+ git clone git@github.com:scalefactory/vagrant-multiprovider-snap.git
61
+ cd vagrant-multiprovider-snap
62
+ cp ~/.vagrant.d/license-vagrant-vmware-fusion.lic .
63
+ bundle install
64
+ bundle install --deployment
65
+ ```
66
+
67
+ You should now find that ```bundle exec vagrant status``` returns correctly,
68
+ and you can hack on the code from there.
69
+
70
+ Once you've made changes that you're happy with, I'd recommend using
71
+ ```rake build``` to create a gem, then installing that into your packaged
72
+ Vagrant install since some things which work in the bundler environment might
73
+ not work as expected in the packaged copy due to differences in how the plugins
74
+ are handled.
75
+
76
+ License
77
+ -------
78
+ vagrant-multiprovider-snap is licensed under the MIT license.
@@ -0,0 +1,8 @@
1
+ require "vagrant-multiprovider-snap/version"
2
+ require "vagrant-multiprovider-snap/plugin"
3
+
4
+ module VagrantSnap
5
+ def self.source_root
6
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
7
+ end
8
+ end
@@ -0,0 +1,54 @@
1
+ require 'optparse'
2
+ require 'vagrant'
3
+
4
+ module VagrantSnap
5
+
6
+ module Command
7
+
8
+ class List < Vagrant.plugin("2", :command)
9
+
10
+ def execute
11
+
12
+ options = {}
13
+
14
+ opts = OptionParser.new do |o|
15
+ o.banner = "Usage: vagrant snap list [vm-name]"
16
+ o.separator ""
17
+ end
18
+
19
+ argv = parse_options(opts)
20
+ return if !argv
21
+
22
+ results = []
23
+
24
+ with_target_vms(argv) do |machine|
25
+
26
+ results << "#{machine.name.to_s}"
27
+
28
+ snaps = machine.provider.driver.snapshot_list
29
+
30
+ if snaps.length == 0
31
+ results << " (none)"
32
+ else
33
+ snaps.each do |snap|
34
+ results << " + #{snap}"
35
+ end
36
+ end
37
+
38
+ results << "\n"
39
+
40
+ end
41
+
42
+ @env.ui.info(I18n.t("vagrant_snap.commands.list.output",
43
+ :snapshots => results.join("\n")),
44
+ :prefix => false)
45
+
46
+ 0
47
+
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+
54
+ end
@@ -0,0 +1,36 @@
1
+ require 'optparse'
2
+ require 'vagrant'
3
+
4
+ module VagrantSnap
5
+
6
+ module Command
7
+
8
+ class Rollback < Vagrant.plugin("2", :command)
9
+
10
+ def execute
11
+
12
+ options = {}
13
+
14
+ opts = OptionParser.new do |o|
15
+ o.banner = "Usage: vagrant snap rollback [vm-name]"
16
+ o.separator ""
17
+ end
18
+
19
+ argv = parse_options(opts)
20
+ return if !argv
21
+
22
+ with_target_vms(argv) do |vm|
23
+
24
+ vm.action(:snapshot_rollback)
25
+
26
+ end
27
+
28
+ 0
29
+
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,73 @@
1
+ require 'optparse'
2
+
3
+ module VagrantSnap
4
+
5
+ module Command
6
+
7
+ class Root < Vagrant.plugin("2", :command)
8
+
9
+ def initialize(argv, env)
10
+
11
+ super
12
+
13
+ @main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
14
+
15
+ @subcommands = Vagrant::Registry.new
16
+
17
+ @subcommands.register(:take) do
18
+ require_relative "take"
19
+ Take
20
+ end
21
+
22
+ @subcommands.register(:rollback) do
23
+ require_relative "rollback"
24
+ Rollback
25
+ end
26
+
27
+ @subcommands.register(:list) do
28
+ require_relative "list"
29
+ List
30
+ end
31
+
32
+
33
+ end
34
+
35
+ def execute
36
+
37
+ if @main_args.include?("-h") || @main_args.include?("--help")
38
+ return help
39
+ end
40
+
41
+ command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
42
+ return help if !command_class || !@sub_command
43
+
44
+ # Initialize and execute the command class
45
+ command_class.new(@sub_args, @env).execute
46
+
47
+ end
48
+
49
+ def help
50
+ opts = OptionParser.new do |opts|
51
+ opts.banner = 'Usage: vagrant snap <command> [<args>]'
52
+ opts.separator ""
53
+ opts.separator "Available subcommands:"
54
+
55
+ keys = []
56
+ @subcommands.each { |key, value| keys << key.to_s }
57
+
58
+ keys.sort.each do |key|
59
+ opts.separator " #{key}"
60
+ end
61
+
62
+ opts.separator ""
63
+ opts.separator "For help on any individual command run 'vagrant snap COMMAND -h'"
64
+ end
65
+
66
+ @env.ui.info(opts.help, :prefix => false)
67
+ end
68
+
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -0,0 +1,36 @@
1
+ require 'optparse'
2
+ require 'vagrant'
3
+
4
+ module VagrantSnap
5
+
6
+ module Command
7
+
8
+ class Take < Vagrant.plugin("2", :command)
9
+
10
+ def execute
11
+
12
+ options = {}
13
+
14
+ opts = OptionParser.new do |o|
15
+ o.banner = "Usage: vagrant snap take [vm-name]"
16
+ o.separator ""
17
+ end
18
+
19
+ argv = parse_options(opts)
20
+ return if !argv
21
+
22
+ with_target_vms(argv) do |vm|
23
+
24
+ vm.action(:snapshot_take)
25
+
26
+ end
27
+
28
+ 0
29
+
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,51 @@
1
+ require 'vagrant'
2
+
3
+ module VagrantSnap
4
+ class Plugin < Vagrant.plugin("2")
5
+
6
+
7
+ require_relative "command/root"
8
+ require_relative "providers/virtualbox/action"
9
+ require_relative "providers/virtualbox/driver/base"
10
+ require_relative "providers/virtualbox/driver/meta"
11
+
12
+ begin
13
+
14
+ # Make sure the fusion plugin is installed, then
15
+ # include the fusion providers.
16
+
17
+ puts "require fusion"
18
+
19
+ Vagrant.require_plugin("vagrant-vmware-fusion")
20
+ require_relative "providers/vmware_fusion/action"
21
+ require_relative "providers/vmware_fusion/driver/base"
22
+
23
+ rescue Vagrant::Errors::PluginLoadError => e
24
+
25
+ puts "oh noes"
26
+
27
+ # If we can't load the fusion plugin, quietly ignore it
28
+ # I'd like to log an info level message here, but I don't
29
+ # think I can get at a ui object in this scope.
30
+
31
+ end
32
+
33
+ name "snap command"
34
+
35
+ description <<-DESC
36
+ This command provides snapshot features across multiple
37
+ Vagrant providers
38
+ DESC
39
+
40
+ command("snap") do
41
+ setup_i18n
42
+ Command::Root
43
+ end
44
+
45
+ def self.setup_i18n
46
+ I18n.load_path << File.expand_path("locales/en.yml", VagrantSnap.source_root)
47
+ I18n.reload!
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,54 @@
1
+ require "vagrant/action/builder"
2
+
3
+ module VagrantPlugins
4
+
5
+ module ProviderVirtualBox
6
+
7
+ module Action
8
+
9
+ autoload :SnapshotTake, File.expand_path("../action/snapshot_take.rb", __FILE__)
10
+ autoload :SnapshotRollback, File.expand_path("../action/snapshot_rollback.rb", __FILE__)
11
+ autoload :HasSnapshot, File.expand_path("../action/has_snapshot.rb", __FILE__)
12
+ autoload :MessageSnapshotNotCreated, File.expand_path("../action/message_snapshot_not_created.rb", __FILE__)
13
+
14
+ def self.action_snapshot_take
15
+ Vagrant::Action::Builder.new.tap do |b|
16
+ b.use CheckVirtualbox
17
+ b.use Call, Created do |env, b2|
18
+ if env[:result]
19
+ b2.use CheckAccessible
20
+ b2.use SnapshotTake
21
+ else
22
+ b2.use MessageNotCreated
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ def self.action_snapshot_rollback
29
+ Vagrant::Action::Builder.new.tap do |b|
30
+ b.use CheckVirtualbox
31
+ b.use Call, Created do |env, b2|
32
+ if env[:result]
33
+ b2.use Call, HasSnapshot do |env2, b3|
34
+ if env2[:result]
35
+ b3.use CheckAccessible
36
+ b3.use SnapshotRollback
37
+ else
38
+ b3.use MessageSnapshotNotCreated
39
+ end
40
+ end
41
+ else
42
+ b2.use MessageNotCreated
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+
54
+
@@ -0,0 +1,27 @@
1
+ module VagrantPlugins
2
+
3
+ module ProviderVirtualBox
4
+
5
+ module Action
6
+
7
+ class HasSnapshot
8
+
9
+ def initialize(app, env)
10
+ @app = app
11
+ end
12
+
13
+ def call(env)
14
+
15
+ env[:result] = env[:machine].provider.driver.has_snapshot?
16
+
17
+ @app.call(env)
18
+
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ module VagrantPlugins
2
+
3
+ module ProviderVirtualBox
4
+
5
+ module Action
6
+
7
+ class MessageSnapshotNotCreated
8
+
9
+ def initialize(app, env)
10
+ @app = app
11
+ end
12
+
13
+ def call(env)
14
+
15
+ env[:ui].info I18n.t("vagrant_snap.actions.vm.snapshot_not_created")
16
+
17
+ @app.call(env)
18
+
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,33 @@
1
+ module VagrantPlugins
2
+
3
+ module ProviderVirtualBox
4
+
5
+ module Action
6
+
7
+ class SnapshotRollback
8
+
9
+ def initialize(app, env)
10
+ @app = app
11
+ end
12
+
13
+ def call(env)
14
+
15
+ env[:ui].info I18n.t("vagrant_snap.actions.vm.snapshot_rollback.rolling_back")
16
+
17
+ # Snapshot rollback involves powering off and on the VM
18
+ # so we need to find the gui state
19
+ boot_mode = env[:machine].provider_config.gui ? "gui" : "headless"
20
+
21
+ env[:machine].provider.driver.snapshot_rollback(boot_mode)
22
+
23
+ @app.call(env)
24
+
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,28 @@
1
+ module VagrantPlugins
2
+
3
+ module ProviderVirtualBox
4
+
5
+ module Action
6
+
7
+ class SnapshotTake
8
+
9
+ def initialize(app, env)
10
+ @app = app
11
+ end
12
+
13
+ def call(env)
14
+
15
+ env[:ui].info I18n.t("vagrant_snap.actions.vm.snapshot_take.taking")
16
+ env[:machine].provider.driver.snapshot_take
17
+
18
+ @app.call(env)
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,41 @@
1
+ module VagrantPlugins
2
+
3
+ module ProviderVirtualBox
4
+
5
+ module Driver
6
+
7
+ class Base
8
+
9
+ def snapshot_take
10
+ execute("snapshot", @uuid, "take", "vagrant-snap-#{Time.now.to_i}", "--pause")
11
+ end
12
+
13
+ def snapshot_rollback(bootmode)
14
+ halt
15
+ sleep 2 # race condition on locked VMs otherwise?
16
+ execute("snapshot", @uuid, "restore", snapshot_list.first)
17
+ start(bootmode)
18
+ end
19
+
20
+ def snapshot_list
21
+ info = execute("showvminfo", @uuid, "--machinereadable")
22
+ snapshots = []
23
+ info.split("\n").each do |line|
24
+ if line =~ /^SnapshotName="(vagrant-snap-.+?)"$/
25
+ snapshots << $1.to_s
26
+ end
27
+ end
28
+ snapshots
29
+ end
30
+
31
+ def has_snapshot?
32
+ snapshot_list.length > 0
33
+ end
34
+
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,20 @@
1
+ module VagrantPlugins
2
+
3
+ module ProviderVirtualBox
4
+
5
+ module Driver
6
+
7
+ class Meta
8
+
9
+ def_delegators :@driver, :snapshot_take,
10
+ :snapshot_rollback,
11
+ :snapshot_list,
12
+ :has_snapshot?
13
+
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,51 @@
1
+ require "vagrant/action/builder"
2
+
3
+ module HashiCorp
4
+
5
+ module VagrantVMwarefusion
6
+
7
+ module Action
8
+
9
+ autoload :SnapshotTake, File.expand_path("../action/snapshot_take.rb", __FILE__)
10
+ autoload :SnapshotRollback, File.expand_path("../action/snapshot_rollback.rb", __FILE__)
11
+ autoload :HasSnapshot, File.expand_path("../action/has_snapshot.rb", __FILE__)
12
+ autoload :MessageSnapshotNotCreated, File.expand_path("../action/message_snapshot_not_created.rb", __FILE__)
13
+
14
+ def self.action_snapshot_take
15
+ Vagrant::Action::Builder.new.tap do |b|
16
+ b.use CheckVMware
17
+ b.use Call, Created do |env, b2|
18
+ if env[:result]
19
+ b2.use SnapshotTake
20
+ else
21
+ b2.use MessageNotCreated
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ def self.action_snapshot_rollback
28
+ Vagrant::Action::Builder.new.tap do |b|
29
+ b.use CheckVMware
30
+ b.use Call, Created do |env, b2|
31
+ if env[:result]
32
+ b2.use Call, HasSnapshot do |env2, b3|
33
+ if env2[:result]
34
+ b3.use SnapshotRollback
35
+ else
36
+ b3.use MessageSnapshotNotCreated
37
+ end
38
+ end
39
+ else
40
+ b2.use MessageNotCreated
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+
51
+
@@ -0,0 +1,27 @@
1
+ module HashiCorp
2
+
3
+ module VagrantVMwarefusion
4
+
5
+ module Action
6
+
7
+ class HasSnapshot
8
+
9
+ def initialize(app, env)
10
+ @app = app
11
+ end
12
+
13
+ def call(env)
14
+
15
+ env[:result] = env[:machine].provider.driver.has_snapshot?
16
+
17
+ @app.call(env)
18
+
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ module HashiCorp
2
+
3
+ module VagrantVMwarefusion
4
+
5
+ module Action
6
+
7
+ class MessageSnapshotNotCreated
8
+
9
+ def initialize(app, env)
10
+ @app = app
11
+ end
12
+
13
+ def call(env)
14
+
15
+ env[:ui].info I18n.t("vagrant_snap.actions.vm.snapshot_not_created")
16
+
17
+ @app.call(env)
18
+
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,33 @@
1
+ module HashiCorp
2
+
3
+ module VagrantVMwarefusion
4
+
5
+ module Action
6
+
7
+ class SnapshotRollback
8
+
9
+ def initialize(app, env)
10
+ @app = app
11
+ end
12
+
13
+ def call(env)
14
+
15
+ env[:ui].info I18n.t("vagrant_snap.actions.vm.snapshot_rollback.rolling_back")
16
+
17
+ # Snapshot rollback involves powering off and on the VM
18
+ # so we need to find the gui state
19
+ boot_mode = env[:machine].provider_config.gui ? "gui" : "headless"
20
+
21
+ env[:machine].provider.driver.snapshot_rollback(boot_mode)
22
+
23
+ @app.call(env)
24
+
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,28 @@
1
+ module HashiCorp
2
+
3
+ module VagrantVMwarefusion
4
+
5
+ module Action
6
+
7
+ class SnapshotTake
8
+
9
+ def initialize(app, env)
10
+ @app = app
11
+ end
12
+
13
+ def call(env)
14
+
15
+ env[:ui].info I18n.t("vagrant_snap.actions.vm.snapshot_take.taking")
16
+ env[:machine].provider.driver.snapshot_take
17
+
18
+ @app.call(env)
19
+
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,38 @@
1
+ module HashiCorp
2
+
3
+ module VagrantVMwarefusion
4
+
5
+ module Driver
6
+
7
+ class Fusion
8
+
9
+ def snapshot_take
10
+ vmrun("snapshot", "#{vmx_path}", "vagrant-snap-#{Time.now.to_i}")
11
+ end
12
+
13
+ def snapshot_rollback(bootmode)
14
+ vmrun("revertToSnapshot", "#{vmx_path}", snapshot_list.first)
15
+ start
16
+ end
17
+
18
+ def snapshot_list
19
+ snapshots = []
20
+ vmrun("listSnapshots", "#{vmx_path}").stdout.split("\n").each do |line|
21
+ if line =~ /^vagrant-snap-/
22
+ snapshots << line
23
+ end
24
+ end
25
+ snapshots.sort
26
+ end
27
+
28
+ def has_snapshot?
29
+ snapshot_list.length > 0
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,5 @@
1
+ module Vagrant
2
+ module Snap
3
+ VERSION = "0.0.4"
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ en:
2
+ vagrant_snap:
3
+ commands:
4
+ list:
5
+ output: |-
6
+ Current available snapshots by VM:
7
+
8
+ %{snapshots}
9
+
10
+ actions:
11
+ vm:
12
+ snapshot_take:
13
+ taking: |-
14
+ Taking snapshot.
15
+ snapshot_rollback:
16
+ rolling_back: |-
17
+ Rolling back to previous snapshot
18
+ snapshot_not_created: |-
19
+ Snapshot not created for this VM
20
+
21
+
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "vagrant-multiprovider-snap/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "vagrant-multiprovider-snap"
7
+ s.version = Vagrant::Snap::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Jon Topper"]
10
+ s.email = ["jon@scalefactory.com"]
11
+ s.homepage = "http://github.com/scalefactory/vagrant-multiprovider-snap"
12
+
13
+ s.summary = %q{Multi-provider snapshots for Vagrant}
14
+ s.description = %q{Multi-provider snapshots for Vagrant}
15
+
16
+ s.rubyforge_project = "vagrant-multiprovider-snap"
17
+
18
+ files = `git ls-files`.split("\n")
19
+ ignore = %w{rgloader/* Gemfile Rakefile Vagrantfile .gitignore}
20
+
21
+ files.delete_if do |f|
22
+ ignore.any? do |i|
23
+ File.fnmatch(i, f, File::FNM_PATHNAME) ||
24
+ File.fnmatch(i, File.basename(f), File::FNM_PATHNAME)
25
+ end
26
+ end
27
+
28
+ s.files = files
29
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
30
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
31
+ s.require_paths = ["lib"]
32
+
33
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-multiprovider-snap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jon Topper
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-26 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Multi-provider snapshots for Vagrant
15
+ email:
16
+ - jon@scalefactory.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CHANGELOG.md
22
+ - LICENSE
23
+ - README.md
24
+ - lib/vagrant-multiprovider-snap.rb
25
+ - lib/vagrant-multiprovider-snap/command/list.rb
26
+ - lib/vagrant-multiprovider-snap/command/rollback.rb
27
+ - lib/vagrant-multiprovider-snap/command/root.rb
28
+ - lib/vagrant-multiprovider-snap/command/take.rb
29
+ - lib/vagrant-multiprovider-snap/plugin.rb
30
+ - lib/vagrant-multiprovider-snap/providers/virtualbox/action.rb
31
+ - lib/vagrant-multiprovider-snap/providers/virtualbox/action/has_snapshot.rb
32
+ - lib/vagrant-multiprovider-snap/providers/virtualbox/action/message_snapshot_not_created.rb
33
+ - lib/vagrant-multiprovider-snap/providers/virtualbox/action/snapshot_rollback.rb
34
+ - lib/vagrant-multiprovider-snap/providers/virtualbox/action/snapshot_take.rb
35
+ - lib/vagrant-multiprovider-snap/providers/virtualbox/driver/base.rb
36
+ - lib/vagrant-multiprovider-snap/providers/virtualbox/driver/meta.rb
37
+ - lib/vagrant-multiprovider-snap/providers/vmware_fusion/action.rb
38
+ - lib/vagrant-multiprovider-snap/providers/vmware_fusion/action/has_snapshot.rb
39
+ - lib/vagrant-multiprovider-snap/providers/vmware_fusion/action/message_snapshot_not_created.rb
40
+ - lib/vagrant-multiprovider-snap/providers/vmware_fusion/action/snapshot_rollback.rb
41
+ - lib/vagrant-multiprovider-snap/providers/vmware_fusion/action/snapshot_take.rb
42
+ - lib/vagrant-multiprovider-snap/providers/vmware_fusion/driver/base.rb
43
+ - lib/vagrant-multiprovider-snap/version.rb
44
+ - locales/en.yml
45
+ - vagrant-multiprovider-snap.gemspec
46
+ homepage: http://github.com/scalefactory/vagrant-multiprovider-snap
47
+ licenses: []
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project: vagrant-multiprovider-snap
66
+ rubygems_version: 1.8.11
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Multi-provider snapshots for Vagrant
70
+ test_files: []