Class: VagrantPlugins::Dustcloud::Action::StopInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-dustcloud/action/stop_instance.rb

Overview

This stops the running instance.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ StopInstance

Returns a new instance of StopInstance.



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

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new("vagrant_dustcloud::action::stop_instance")
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/vagrant-dustcloud/action/stop_instance.rb', line 13

def call(env)
  if env[:machine].state.id == :shutoff
    env[:ui].info(I18n.t("vagrant_dustcloud.already_status", :status => env[:machine].state.id))
  else
    env[:ui].info(I18n.t("vagrant_dustcloud.stopping"))
    env[:dustcloud].stop_vm(env[:machine].id)
  end

  @app.call(env)
end