Class: HashiCorp::VagrantVMwareDesktop::Action::Destroy
- Inherits:
-
Object
- Object
- HashiCorp::VagrantVMwareDesktop::Action::Destroy
- Includes:
- Common
- Defined in:
- lib/vagrant-vmware-desktop/action/destroy.rb
Overview
This deletes the machine from the system.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Destroy
constructor
A new instance of Destroy.
Methods included from Common
Constructor Details
#initialize(app, env) ⇒ Destroy
Returns a new instance of Destroy.
13 14 15 16 |
# File 'lib/vagrant-vmware-desktop/action/destroy.rb', line 13 def initialize(app, env) @app = app @logger = Log4r::Logger.new("hashicorp::provider::vmware::destroy") end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vagrant-vmware-desktop/action/destroy.rb', line 18 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 |