Class: VagrantPlugins::SoftLayer::Action::StopInstance

Inherits:
Object
  • Object
show all
Includes:
Util::Warden
Defined in:
lib/vagrant-softlayer/action/stop_instance.rb

Overview

This stops the running instance.

Instance Method Summary collapse

Methods included from Util::Warden

#sl_warden

Constructor Details

#initialize(app, env) ⇒ StopInstance

Returns a new instance of StopInstance.



8
9
10
# File 'lib/vagrant-softlayer/action/stop_instance.rb', line 8

def initialize(app, env)
  @app    = app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant-softlayer/action/stop_instance.rb', line 12

def call(env)
  if env[:machine].state.id == :halted
    env[:ui].info I18n.t("vagrant_softlayer.vm.already_stopped")
  else
    if env[:force_halt]
      env[:ui].info I18n.t("vagrant_softlayer.vm.stopping_force")
      sl_warden { env[:sl_machine].powerOff }
    else
      env[:ui].info I18n.t("vagrant_softlayer.vm.stopping")
      sl_warden { env[:sl_machine].powerOffSoft }
    end
  end

  @app.call(env)
end