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