class HashiCorp::VagrantVMwareDesktop::Action::Destroy

This deletes the machine from the system.

Public Class Methods

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

Public Instance Methods

call(env) click to toggle source
# File lib/vagrant-vmware-desktop/action/destroy.rb, line 15
def call(env)
  if env[:machine].provider.state.id == :running
    raise Errors::DestroyInvalidState
  end

  # As long as the VM exists, we destroy it.
  if env[:machine].provider.state.id != :not_created
    env[:ui].info(I18n.t("hashicorp.vagrant_vmware_desktop.destroying"))
    env[:machine].provider.driver.delete
    env[:machine].id = nil
  end

  @app.call(env)
end