Support provisioning flags on snapshot rollback
This commit is contained in:
parent
7ba398ead8
commit
eff2b2d7b4
|
@ -1,6 +1,10 @@
|
|||
require 'json'
|
||||
require 'optparse'
|
||||
|
||||
require 'vagrant'
|
||||
|
||||
require Vagrant.source_root.join("plugins/commands/up/start_mixins")
|
||||
|
||||
require_relative "push_shared"
|
||||
|
||||
module VagrantPlugins
|
||||
|
@ -8,16 +12,19 @@ module VagrantPlugins
|
|||
module Command
|
||||
class Pop < Vagrant.plugin("2", :command)
|
||||
include PushShared
|
||||
include VagrantPlugins::CommandUp::StartMixins
|
||||
|
||||
def execute
|
||||
options = {}
|
||||
options[:snapshot_delete] = true
|
||||
opts = OptionParser.new do |o|
|
||||
o.banner = "Usage: vagrant snapshot pop [options] [vm-name]"
|
||||
o.separator ""
|
||||
build_start_options(o, options)
|
||||
o.separator "Restore state that was pushed with `vagrant snapshot push`."
|
||||
|
||||
o.on("--no-delete", "Don't delete the snapshot after the restore") do
|
||||
options[:no_delete] = true
|
||||
options[:snapshot_delete] = false
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,6 +32,9 @@ module VagrantPlugins
|
|||
argv = parse_options(opts)
|
||||
return if !argv
|
||||
|
||||
# Validate the provisioners
|
||||
validate_provisioner_flags!(options, argv)
|
||||
|
||||
return shared_exec(argv, method(:pop), options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,16 +45,9 @@ module VagrantPlugins
|
|||
return
|
||||
end
|
||||
|
||||
snapshot_delete = true
|
||||
if opts.key?(:no_delete)
|
||||
snapshot_delete = false
|
||||
end
|
||||
|
||||
# Restore the snapshot and tell the provider to delete it, if required
|
||||
machine.action(
|
||||
:snapshot_restore,
|
||||
snapshot_name: name,
|
||||
snapshot_delete: snapshot_delete)
|
||||
opts[:snapshot_name] = name
|
||||
machine.action(:snapshot_restore, opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,15 +1,23 @@
|
|||
require 'optparse'
|
||||
|
||||
require 'vagrant'
|
||||
|
||||
require Vagrant.source_root.join("plugins/commands/up/start_mixins")
|
||||
|
||||
module VagrantPlugins
|
||||
module CommandSnapshot
|
||||
module Command
|
||||
class Restore < Vagrant.plugin("2", :command)
|
||||
|
||||
include VagrantPlugins::CommandUp::StartMixins
|
||||
|
||||
def execute
|
||||
options = {}
|
||||
|
||||
opts = OptionParser.new do |o|
|
||||
o.banner = "Usage: vagrant snapshot restore [options] [vm-name] <name>"
|
||||
o.separator ""
|
||||
build_start_options(o, options)
|
||||
o.separator "Restore a snapshot taken previously with snapshot save."
|
||||
end
|
||||
|
||||
|
@ -21,9 +29,14 @@ module VagrantPlugins
|
|||
help: opts.help.chomp
|
||||
end
|
||||
|
||||
# Validate the provisioners
|
||||
validate_provisioner_flags!(options, argv)
|
||||
|
||||
name = argv.pop
|
||||
options[:snapshot_name] = name
|
||||
|
||||
with_target_vms(argv) do |vm|
|
||||
vm.action(:snapshot_restore, snapshot_name: name)
|
||||
vm.action(:snapshot_restore, options)
|
||||
end
|
||||
|
||||
# Success, exit status 0
|
||||
|
|
Loading…
Reference in New Issue