Sha256: 4906591c2c70de3cdfbba355355fadc64565c7b28a8c71e4e5ba944967d78e9a

Contents?: true

Size: 813 Bytes

Versions: 5

Compression:

Stored size: 813 Bytes

Contents

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

module VagrantPlugins
  module Openstack
    module Action
      class SnapshotCleanup < 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)

          snapshots_to_clean = machine_snapshots.select do |s|
            s.metadata.key?('vagrant_snapshot')
          end

          @app.call env

          unless snapshots_to_clean.empty?
            env[:ui].info("Deleting Vagrant snapshots: #{snapshots_to_clean.map(&:name)}")
          end

          snapshots_to_clean.each do |s|
            nova.delete_snapshot(env, s.id)
          end
        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_cleanup.rb
vagrant-openstack-provider-0.12.0 lib/vagrant-openstack-provider/action/snapshot_cleanup.rb
vagrant-openstack-provider-illuin-0.11.1 lib/vagrant-openstack-provider/action/snapshot_cleanup.rb
vagrant-openstack-provider-0.11.0 lib/vagrant-openstack-provider/action/snapshot_cleanup.rb
vagrant-openstack-provider-0.10.0 lib/vagrant-openstack-provider/action/snapshot_cleanup.rb