Class: VagrantPlugins::Linode::Actions::PowerOff

Inherits:
Object
  • Object
show all
Includes:
Helpers::Waiter
Defined in:
lib/vagrant-linode/actions/power_off.rb

Instance Method Summary collapse

Methods included from Helpers::Waiter

#wait_for_event

Constructor Details

#initialize(app, env) ⇒ PowerOff

Returns a new instance of PowerOff.



10
11
12
13
14
# File 'lib/vagrant-linode/actions/power_off.rb', line 10

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

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vagrant-linode/actions/power_off.rb', line 16

def call(env)
  @client = env[:linode_api]
  # submit power off linode request
  result = @client.linode.shutdown(linodeid: @machine.id)

  # wait for request to complete
  env[:ui].info I18n.t('vagrant_linode.info.powering_off')
  wait_for_event(env, result['jobid'])

  # refresh linode state with provider
  Provider.linode(@machine, refresh: true)

  @app.call(env)
end