Sha256: fdcce811469714358d707d6d50ab86ce11375b628e6002345d3f5d552454f4c6

Contents?: true

Size: 874 Bytes

Versions: 5

Compression:

Stored size: 874 Bytes

Contents

require 'vagrant-openstack-provider/action/abstract_action'

module VagrantPlugins
  module Openstack
    module Action
      class SnapshotDelete < AbstractAction
        def initialize(app, _env)
          @app = app
        end

        def call(env)
          nova = env[:openstack_client].nova
          machine_snapshots = nova.list_snapshots(env, env[:machine].id)

          snapshot = machine_snapshots.find { |s| s.name == env[:snapshot_name] }

          unless snapshot.nil?
            env[:ui].info(I18n.t('vagrant.actions.vm.snapshot.deleting',
                                 name: snapshot.name))

            nova.delete_snapshot(env, snapshot.id)

            env[:ui].info(I18n.t('vagrant.actions.vm.snapshot.deleted',
                                 name: snapshot.name))
          end

          @app.call env
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
vagrant-openstack-provider-0.13.0 lib/vagrant-openstack-provider/action/snapshot_delete.rb
vagrant-openstack-provider-0.12.0 lib/vagrant-openstack-provider/action/snapshot_delete.rb
vagrant-openstack-provider-illuin-0.11.1 lib/vagrant-openstack-provider/action/snapshot_delete.rb
vagrant-openstack-provider-0.11.0 lib/vagrant-openstack-provider/action/snapshot_delete.rb
vagrant-openstack-provider-0.10.0 lib/vagrant-openstack-provider/action/snapshot_delete.rb