Sha256: c46965a8fbfe38229851a1980b9439906cd958bbd272cbd274b344d1654bcd4e

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 KB

Contents

require 'log4r'

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

        def call(env)
          env[:ui].info(I18n.t("vagrant_ovirt4.snapshot_delete"))
          
          snapshots_service = env[:vms_service].vm_service(env[:machine].id).snapshots_service
          
          snapshot = snapshots_service.snapshot_service(env[:snapshot_name])

          begin
            raise RemoveActiveSnapshotError, :id => env[:snapshot_name] if snapshot.get.snapshot_type == 'active' 
            snapshot.remove
          rescue OvirtSDK4::Error => e
            fault_detail = /Fault detail is \"\[(.*)\]\".*/.match(e.message)
            error_message = e.message
            error_message = fault_detail[1] unless fault_detail.nil?
            raise Errors::RemoveSnapshotError,
              :id => env[:snapshot_name],
              :error_message => error_message
          end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
vagrant-ovirt4-2.2.0 lib/vagrant-ovirt4/action/snapshot_delete.rb
vagrant-ovirt4-2.1.3 lib/vagrant-ovirt4/action/snapshot_delete.rb
vagrant-ovirt4-2.1.0 lib/vagrant-ovirt4/action/snapshot_delete.rb
vagrant-ovirt4-2.0.0 lib/vagrant-ovirt4/action/snapshot_delete.rb
vagrant-ovirt4-1.2.3 lib/vagrant-ovirt4/action/snapshot_delete.rb
vagrant-ovirt4-1.2.2 lib/vagrant-ovirt4/action/snapshot_delete.rb
vagrant-ovirt4-1.2.1 lib/vagrant-ovirt4/action/snapshot_delete.rb
vagrant-ovirt4-1.2.0 lib/vagrant-ovirt4/action/snapshot_delete.rb
vagrant-ovirt4-1.1.0 lib/vagrant-ovirt4/action/snapshot_delete.rb
vagrant-ovirt4-1.0.2 lib/vagrant-ovirt4/action/snapshot_delete.rb