10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/vagrant-vbox-snapshot/commands/back.rb', line 10
def execute
options = {}
opts = OptionParser.new do |opts|
opts.banner = "Back to current snapshot"
opts.separator ""
opts.separator "Usage: vagrant snapshot back [vm-name]"
end
argv = parse_options(opts)
return if !argv
with_target_vms(argv, single_target: true) do |machine|
check_runnable_on(machine)
if machine.state.id != :poweroff and machine.state.id != :saved and machine.state.id != :aborted
machine.provider.driver.execute("controlvm", machine.id, "poweroff")
end
machine.provider.driver.execute("snapshot", machine.id, "restorecurrent") do |type, data|
machine.env.ui.info(data, :color => type == :stderr ? :red : :white, :new_line => false)
end
if options[:reload]
@env.ui.info("Reloading VM, since --reload passed")
machine.action(:reload, :provision_enabled => false)
else
@env.ui.info("Starting restored VM")
machine.action(:up, :provision_enabled => false)
end
end
end
|