Sha256: 7fab1dc4a1aa7affdb8b927a4c849dbe5331cfac3e7e2d003f9e6724c452227e

Contents?: true

Size: 859 Bytes

Versions: 3

Compression:

Stored size: 859 Bytes

Contents

require 'vagrant-conoha/action/abstract_action'

module VagrantPlugins
  module ConoHa
    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

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-conoha-0.1.10 lib/vagrant-conoha/action/snapshot_delete.rb
vagrant-conoha-0.1.9 lib/vagrant-conoha/action/snapshot_delete.rb
vagrant-conoha-0.1.8 lib/vagrant-conoha/action/snapshot_delete.rb