Class: VagrantPlugins::MCS::Action::StopInstance

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-mcs/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-mcs/action/stop_instance.rb', line 8

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

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  #server = env[:mcs_compute].servers.get(env[:machine].id)
  #server = (env[:mcs_compute].describe_instances([env[:machine].id]))["Instance"]
  if env[:machine].state.id == "ready"
    env[:ui].info(I18n.t("vagrant_mcs.already stopped"))
  else
    env[:ui].info(I18n.t("vagrant_mcs.stopping"))
    #server.stop(!!env[:force_halt])
    env[:mcs_compute].stop_instance(env[:machine].id)
  end

  @app.call(env)
end