Class: VagrantPlugins::Azure::Action::TerminateInstance
- Inherits:
-
Object
- Object
- VagrantPlugins::Azure::Action::TerminateInstance
- Includes:
- Util::MachineIdHelper
- Defined in:
- lib/vagrant-azure/action/terminate_instance.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, _) ⇒ TerminateInstance
constructor
A new instance of TerminateInstance.
Methods included from Util::MachineIdHelper
#parse_machine_id, #serialize_machine_id
Constructor Details
#initialize(app, _) ⇒ TerminateInstance
Returns a new instance of TerminateInstance.
13 14 15 16 |
# File 'lib/vagrant-azure/action/terminate_instance.rb', line 13 def initialize(app, _) @app = app @logger = Log4r::Logger.new('vagrant_azure::action::terminate_instance') end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vagrant-azure/action/terminate_instance.rb', line 18 def call(env) parsed = parse_machine_id(env[:machine].id) begin env[:ui].info(I18n.t('vagrant_azure.terminating', parsed)) env[:ui].info('Deleting resource group') # Call the begin_xxx_async version to kick off the delete, but don't wait for the resource group to be cleaned up if env[:machine].provider_config.wait_for_destroy env[:azure_arm_service].resources.resource_groups.delete(parsed[:group]) else env[:azure_arm_service].resources.resource_groups.begin_delete_async(parsed[:group]).value! end env[:ui].info('Resource group is deleting... Moving on.') rescue MsRestAzure::AzureOperationError => ex unless ex.response.status == 404 raise ex end end env[:ui].info(I18n.t('vagrant_azure.terminated', parsed)) env[:machine].id = nil @app.call(env) end |