Class: VagrantPlugins::ArubaCloud::Action::DeleteServer
- Inherits:
-
Object
- Object
- VagrantPlugins::ArubaCloud::Action::DeleteServer
- Defined in:
- lib/vagrant-arubacloud/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.
9 10 11 12 |
# File 'lib/vagrant-arubacloud/action/delete_server.rb', line 9 def initialize(app, env) @app = app @logger = Log4r::Logger.new('vagrant_arubacloud::action::delete_server') end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vagrant-arubacloud/action/delete_server.rb', line 14 def call(env) if env[:machine].id config = env[:machine].provider_config arubacloud_dc = config.endpoint env[:ui].info(" [#{arubacloud_dc}] " + I18n.t('vagrant_arubacloud.deleting_server')) # On fog side, get will call get_service_details, I must be sure # that the returned object has the "id" parameters not nil server = env[:arubacloud_compute].servers.get(env[:machine].id) begin server.delete rescue Fog::ArubaCloud::Errors::VmStatus env[:ui].warn(I18n.t('vagrant_arubacloud.bad_state')) end env[:machine].id = nil end @app.call(env) end |