Class: VagrantPlugins::Openstack::Action::SnapshotCleanup
- Inherits:
-
AbstractAction
- Object
- AbstractAction
- VagrantPlugins::Openstack::Action::SnapshotCleanup
- Defined in:
- lib/vagrant-openstack-provider/action/snapshot_cleanup.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, _env) ⇒ SnapshotCleanup
constructor
A new instance of SnapshotCleanup.
Constructor Details
#initialize(app, _env) ⇒ SnapshotCleanup
Returns a new instance of SnapshotCleanup.
7 8 9 |
# File 'lib/vagrant-openstack-provider/action/snapshot_cleanup.rb', line 7 def initialize(app, _env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vagrant-openstack-provider/action/snapshot_cleanup.rb', line 11 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..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 |