Class: VagrantPlugins::HP::Action::HaltServer

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-hp/action/halt_server.rb

Overview

This deletes the running server, if there is one.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ HaltServer

Returns a new instance of HaltServer.



13
14
15
16
# File 'lib/vagrant-hp/action/halt_server.rb', line 13

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new('vagrant_hp::action::delete_server')
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/vagrant-hp/action/halt_server.rb', line 18

def call(env)
  if env[:machine].id
    @logger.info(I18n.t('vagrant_hp.deleting_server'))
    server = env[:hp_compute].servers.get(env[:machine].id)
    server.stop # verify this
    env[:machine].id = nil
  end
  @app.call(env)
end