Class: VagrantPlugins::HP::Action::DeleteServer
- Inherits:
-
Object
- Object
- VagrantPlugins::HP::Action::DeleteServer
- Defined in:
- lib/vagrant-hp/action/delete_server.rb
Overview
This deletes the running server, if there is one.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ DeleteServer
constructor
A new instance of DeleteServer.
Constructor Details
#initialize(app, env) ⇒ DeleteServer
Returns a new instance of DeleteServer.
13 14 15 16 |
# File 'lib/vagrant-hp/action/delete_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 27 28 29 |
# File 'lib/vagrant-hp/action/delete_server.rb', line 18 def call(env) if env[:machine].id @logger.info(I18n.t('vagrant_hp.deleting_floating_ip')) ip = env[:hp_compute].addresses.find { |ip| ip.instance_id==env[:machine].id } ip.destroy @logger.info(I18n.t('vagrant_hp.deleting_server')) server = env[:hp_compute].servers.get(env[:machine].id) server.destroy env[:machine].id = nil end @app.call(env) end |