Class: VagrantPlugins::OneCloud::Actions::Destroy

Inherits:
Object
  • Object
show all
Includes:
Helpers::Client
Defined in:
lib/vagrant-1cloud/actions/destroy.rb

Instance Method Summary collapse

Methods included from Helpers::Client

#client

Constructor Details

#initialize(app, env) ⇒ Destroy

Returns a new instance of Destroy.



9
10
11
12
13
14
# File 'lib/vagrant-1cloud/actions/destroy.rb', line 9

def initialize(app, env)
  @app = app
  @machine = env[:machine]
  @client = client
  @logger = Log4r::Logger.new('vagrant::onecloud::destroy')
end

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vagrant-1cloud/actions/destroy.rb', line 16

def call(env)
  # submit destroy droplet request
  @client.delete("/server/#{@machine.id}")

  env[:ui].info I18n.t('vagrant_1cloud.info.destroying')
  @client.wait_for_destroy(env, @machine.id)

  # set the machine id to nil to cleanup local vagrant state
  @machine.id = nil

  @app.call(env)
end