class HashiCorp::VagrantVMwareDesktop::Action::DiscardSuspendedState

This discards the suspended state of the machine.

Public Class Methods

new(app, env) click to toggle source
# File lib/vagrant-vmware-desktop/action/discard_suspended_state.rb, line 10
def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new("hashicorp::provider::vmware::discard_suspended_state")
end

Public Instance Methods

call(env) click to toggle source
# File lib/vagrant-vmware-desktop/action/discard_suspended_state.rb, line 15
def call(env)
  machine_state = env[:machine].provider.state.id
  if machine_state == :suspended
    env[:ui].info(I18n.t("hashicorp.vagrant_vmware_desktop.discarding_suspended_state"))
  end

  if machine_state != :not_created
    # We don't care if the machine is suspended or not, just always
    # delete the suspended state if it is created, since that is our job
    env[:machine].provider.driver.discard_suspended_state
  end

  @app.call(env)
end