Class: HashiCorp::VagrantVMwareworkstation::Action::SnapshotRollback

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-multiprovider-snap/providers/vmware_workstation/action/snapshot_rollback.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ SnapshotRollback

Returns a new instance of SnapshotRollback.



9
10
11
# File 'lib/vagrant-multiprovider-snap/providers/vmware_workstation/action/snapshot_rollback.rb', line 9

def initialize(app, env)
    @app = app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vagrant-multiprovider-snap/providers/vmware_workstation/action/snapshot_rollback.rb', line 13

def call(env)

    # Snapshot rollback involves powering off and on the VM, so we need to find the gui
    # state ... however, the start() method in VagrantVMwarefusion.Driver.Fusion takes a
    # bool, not a string, so setting this to "gui" or "nogui" will therefore always start
    # in gui mode. Setting this to a bool instead

    boot_mode = env[:machine].provider_config.gui

    if env[:snap_name].nil?
        env[:snap_name] = env[:machine].provider.driver.snapshot_list.last
        env[:ui].info I18n.t("vagrant_snap.actions.vm.snapshot_rollback.rolling_back")
    else
        env[:ui].info(I18n.t("vagrant_snap.actions.vm.snapshot_rollback.rolling_back_named",
            :snapshot => env[:snap_name]),
        )
    end

    env[:machine].provider.driver.snapshot_rollback(boot_mode,env[:snap_name])

    @app.call(env)

end