Class: VagrantPlugins::DigitalOcean::Actions::Destroy
- Inherits:
-
Object
- Object
- VagrantPlugins::DigitalOcean::Actions::Destroy
- Includes:
- Helpers::Client
- Defined in:
- lib/vagrant-digitalocean/actions/destroy.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Destroy
constructor
A new instance of Destroy.
Methods included from Helpers::Client
Constructor Details
#initialize(app, env) ⇒ Destroy
Returns a new instance of Destroy.
9 10 11 12 13 14 |
# File 'lib/vagrant-digitalocean/actions/destroy.rb', line 9 def initialize(app, env) @app = app @machine = env[:machine] @client = client @logger = Log4r::Logger.new('vagrant::digitalocean::destroy') end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vagrant-digitalocean/actions/destroy.rb', line 16 def call(env) # submit destroy droplet request result = @client.request("/droplets/#{@machine.id}/destroy") env[:ui].info I18n.t('vagrant_digital_ocean.info.destroying') # wait for the destroy progress to start @client.wait_for_event(env, result['event_id']) do |response| break if response['event']['percentage'] != nil end # set the machine id to nil to cleanup local vagrant state @machine.id = nil @app.call(env) end |