Class: VagrantPlugins::Google::Action::StopInstance
- Inherits:
-
Object
- Object
- VagrantPlugins::Google::Action::StopInstance
- Includes:
- Vagrant::Util::Retryable
- Defined in:
- lib/vagrant-google/action/stop_instance.rb
Overview
This stops the running instance.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ StopInstance
constructor
A new instance of StopInstance.
Constructor Details
#initialize(app, env) ⇒ StopInstance
Returns a new instance of StopInstance.
25 26 27 28 |
# File 'lib/vagrant-google/action/stop_instance.rb', line 25 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_google::action::stop_instance") end |
Instance Method Details
#call(env) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vagrant-google/action/stop_instance.rb', line 30 def call(env) server = env[:google_compute].servers.get(env[:machine].id, env[:machine].provider_config.zone) if env[:machine].state.id == :TERMINATED env[:ui].info(I18n.t("vagrant_google.already_status", :status => env[:machine].state.id)) else env[:ui].info(I18n.t("vagrant_google.stopping")) operation = server.stop operation.wait_for { ready? } end @app.call(env) end |