Class: VagrantPlugins::Libvirt::Action::DestroyDomain

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-libvirt/action/destroy_domain.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ DestroyDomain

Returns a new instance of DestroyDomain.



7
8
9
10
# File 'lib/vagrant-libvirt/action/destroy_domain.rb', line 7

def initialize(app, env)
  @logger = Log4r::Logger.new("vagrant_libvirt::action::destroy_domain")
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/vagrant-libvirt/action/destroy_domain.rb', line 12

def call(env)
  # Destroy the server, remove the tracking ID
  env[:ui].info(I18n.t("vagrant_libvirt.destroy_domain"))

  domain = env[:libvirt_compute].servers.get(env[:machine].id.to_s)
  domain.destroy(:destroy_volumes => true)
  env[:machine].id = nil

  @app.call(env)
end