Sha256: 5952d8c2d391a93e0fad96a993fd130f7f6d2cf9025f02973595f730fa41eeac

Contents?: true

Size: 982 Bytes

Versions: 7

Compression:

Stored size: 982 Bytes

Contents

require 'log4r'

module VagrantPlugins
  module OVirtProvider
    module Action
      class DestroyVM
        def initialize(app, env)
          @logger = Log4r::Logger.new("vagrant_ovirt4::action::destroy_vm")
          @app = app
        end

        def call(env)
          # Destroy the server, remove the tracking ID
          env[:ui].info(I18n.t("vagrant_ovirt4.destroy_vm"))

          vm_service = env[:vms_service].vm_service(env[:machine].id)
          begin
            vm_service.remove
          rescue OvirtSDK4::Error => e
            fault_message = /Fault detail is \"\[?(.+?)\]?\".*/.match(e.message)[1] rescue e.message
            retry if e.message =~ /Please try again/

            if config.debug
              raise e
            else
              raise Errors::RemoveVMError,
                :error_message => fault_message
            end
          end

          env[:machine].id = nil

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vagrant-ovirt4-2.2.0 lib/vagrant-ovirt4/action/destroy_vm.rb
vagrant-ovirt4-2.1.3 lib/vagrant-ovirt4/action/destroy_vm.rb
vagrant-ovirt4-2.1.0 lib/vagrant-ovirt4/action/destroy_vm.rb
vagrant-ovirt4-2.0.0 lib/vagrant-ovirt4/action/destroy_vm.rb
vagrant-ovirt4-1.2.3 lib/vagrant-ovirt4/action/destroy_vm.rb
vagrant-ovirt4-1.2.2 lib/vagrant-ovirt4/action/destroy_vm.rb
vagrant-ovirt4-1.2.1 lib/vagrant-ovirt4/action/destroy_vm.rb