Class: VagrantPlugins::Openstack::Action::StopServer

Inherits:
AbstractAction show all
Defined in:
lib/vagrant-openstack-provider/action/stop_server.rb

Instance Method Summary collapse

Methods inherited from AbstractAction

#call

Constructor Details

#initialize(app, _env) ⇒ StopServer

Returns a new instance of StopServer.



9
10
11
12
# File 'lib/vagrant-openstack-provider/action/stop_server.rb', line 9

def initialize(app, _env)
  @app    = app
  @logger = Log4r::Logger.new('vagrant_openstack::action::stop_server')
end

Instance Method Details

#execute(env) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/vagrant-openstack-provider/action/stop_server.rb', line 14

def execute(env)
  if env[:machine].id
    @logger.info "Stopping server #{env[:machine].id}..."
    env[:ui].info(I18n.t('vagrant_openstack.stopping_server'))
    env[:openstack_client].nova.stop_server(env, env[:machine].id)
  end
  @app.call(env)
end