Class: VagrantZFS::Middleware::DestroyZFS

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant_zfs/middleware/destroy_zfs.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ DestroyZFS

Returns a new instance of DestroyZFS.



4
5
6
7
# File 'lib/vagrant_zfs/middleware/destroy_zfs.rb', line 4

def initialize(app, env)
  @app = app
  @env = env
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/vagrant_zfs/middleware/destroy_zfs.rb', line 9

def call(env)
  uuid = @env[:vm].uuid

  env[:vm].config.zfs.cloned_folders.each do |name, data|
    new_fs = ZFS("#{data[:filesystem]}-#{uuid}")
    snapshot = new_fs.origin

    new_fs.destroy!
    snapshot.destroy!
  end

  @app.call(env)
end