Class: VagrantPlugins::Scaleway::Action::StopServer

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-scaleway/action/stop_server.rb

Overview

This stops the running server.

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ StopServer

Returns a new instance of StopServer.



6
7
8
# File 'lib/vagrant-scaleway/action/stop_server.rb', line 6

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

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/vagrant-scaleway/action/stop_server.rb', line 10

def call(env)
  server = env[:scaleway_compute].servers.get(env[:machine].id)

  if env[:machine].state.id == :stopped
    env[:ui].info(I18n.t('vagrant_scaleway.already_status', status: env[:machine].state.id))
  else
    env[:ui].info(I18n.t('vagrant_scaleway.stopping'))
    server.poweroff(false)
  end

  @app.call(env)
end