2015-10-08 02:52:27 +00:00
|
|
|
require 'json'
|
|
|
|
require 'optparse'
|
|
|
|
|
2016-01-16 16:07:57 +00:00
|
|
|
require 'vagrant'
|
|
|
|
|
|
|
|
require Vagrant.source_root.join("plugins/commands/up/start_mixins")
|
|
|
|
|
2015-10-08 02:52:27 +00:00
|
|
|
require_relative "push_shared"
|
|
|
|
|
|
|
|
module VagrantPlugins
|
|
|
|
module CommandSnapshot
|
|
|
|
module Command
|
|
|
|
class Pop < Vagrant.plugin("2", :command)
|
|
|
|
include PushShared
|
2016-01-16 16:07:57 +00:00
|
|
|
include VagrantPlugins::CommandUp::StartMixins
|
2015-10-08 02:52:27 +00:00
|
|
|
|
|
|
|
def execute
|
2016-01-15 18:21:47 +00:00
|
|
|
options = {}
|
2016-01-16 16:07:57 +00:00
|
|
|
options[:snapshot_delete] = true
|
2015-10-08 02:52:27 +00:00
|
|
|
opts = OptionParser.new do |o|
|
|
|
|
o.banner = "Usage: vagrant snapshot pop [options] [vm-name]"
|
|
|
|
o.separator ""
|
2016-01-16 16:07:57 +00:00
|
|
|
build_start_options(o, options)
|
2015-10-08 02:52:27 +00:00
|
|
|
o.separator "Restore state that was pushed with `vagrant snapshot push`."
|
2016-01-15 18:21:47 +00:00
|
|
|
|
|
|
|
o.on("--no-delete", "Don't delete the snapshot after the restore") do
|
2016-01-16 16:07:57 +00:00
|
|
|
options[:snapshot_delete] = false
|
2016-01-15 18:21:47 +00:00
|
|
|
end
|
2015-10-08 02:52:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Parse the options
|
|
|
|
argv = parse_options(opts)
|
|
|
|
return if !argv
|
|
|
|
|
2016-01-16 16:07:57 +00:00
|
|
|
# Validate the provisioners
|
|
|
|
validate_provisioner_flags!(options, argv)
|
|
|
|
|
2016-01-15 18:21:47 +00:00
|
|
|
return shared_exec(argv, method(:pop), options)
|
2015-10-08 02:52:27 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|