Class: Vagrant::Commit::Action::FullDestroyVolumes
- Inherits:
-
Object
- Object
- Vagrant::Commit::Action::FullDestroyVolumes
- Defined in:
- lib/vagrant-commit/action/full_destroy.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ FullDestroyVolumes
constructor
A new instance of FullDestroyVolumes.
Constructor Details
#initialize(app, env) ⇒ FullDestroyVolumes
Returns a new instance of FullDestroyVolumes.
6 7 8 |
# File 'lib/vagrant-commit/action/full_destroy.rb', line 6 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 |
# File 'lib/vagrant-commit/action/full_destroy.rb', line 11 def call(env) server = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s) files = [] server.volumes.each do |vol| backing = `sudo -E qemu-img info #{vol.path} --force | grep 'backing file:' | cut -d ':' -f2`.chomp files << backing end `vagrant destroy -f` files.each do |backing| `sudo -E rm -rf #{backing}` end # ? maybe with a config flag # `sudo -E systemctl restart libvirtd` @app.call env end |