Class: VagrantPlugins::DigitalOcean::Actions::ShutDown
- Inherits:
-
Object
- Object
- VagrantPlugins::DigitalOcean::Actions::ShutDown
- Includes:
- Helpers::Client
- Defined in:
- lib/vagrant-digitalocean/actions/shut_down.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ShutDown
constructor
A new instance of ShutDown.
Methods included from Helpers::Client
Constructor Details
#initialize(app, env) ⇒ ShutDown
Returns a new instance of ShutDown.
9 10 11 12 13 14 |
# File 'lib/vagrant-digitalocean/actions/shut_down.rb', line 9 def initialize(app, env) @app = app @machine = env[:machine] @client = client @logger = Log4r::Logger.new('vagrant::digitalocean::shut_down') end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vagrant-digitalocean/actions/shut_down.rb', line 16 def call(env) # submit shutdown droplet request result = @client.post("/v2/droplets/#{@machine.id}/actions", { :type => 'shutdown' }) # wait for request to complete env[:ui].info I18n.t('vagrant_digital_ocean.info.shutting_down') @client.wait_for_event(env, result['action']['id']) # refresh droplet state with provider Provider.droplet(@machine, :refresh => true) @app.call(env) end |