Sha256: 1a869a004313ba37c20a63271c5bd5cc1457c3cbff8f8c18cab52d380d448aa7

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

module VagrantPlugins

    module ProviderVirtualBox

        module Driver

            class Base

                def snapshot_take
                    execute("snapshot", @uuid, "take", "vagrant-snap-#{Time.now.to_i}", "--pause")
                end

                def snapshot_rollback(bootmode)
                    if read_state != :poweroff # don't try to power off if we're already off
                        halt
                        sleep 2 # race condition on locked VMs otherwise?
                    end
                    execute("snapshot",  @uuid, "restore", snapshot_list.first)
                    start(bootmode)
                end

                def snapshot_list
                    info = execute("showvminfo", @uuid, "--machinereadable")
                    snapshots = []
                    info.split("\n").each do |line|
                        if line =~ /^SnapshotName="(vagrant-snap-.+?)"$/
                            snapshots << $1.to_s
                        end
                    end
                    snapshots
                end

                def has_snapshot?
                    snapshot_list.length > 0
                end

            end

        end

    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-multiprovider-snap-0.0.6 lib/vagrant-multiprovider-snap/providers/virtualbox/driver/base.rb