Class: VagrantZFS::Action::VM::Destroy
- Inherits:
-
Object
- Object
- VagrantZFS::Action::VM::Destroy
- Defined in:
- lib/vagrant_zfs/action/vm/destroy.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Destroy
constructor
A new instance of Destroy.
- #zpool ⇒ Object
Constructor Details
#initialize(app, env) ⇒ Destroy
Returns a new instance of Destroy.
5 6 7 8 |
# File 'lib/vagrant_zfs/action/vm/destroy.rb', line 5 def initialize(app, env) @logger = Log4r::Logger.new("vagrant_zfs::action::vm::destroy") @app = app end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/vagrant_zfs/action/vm/destroy.rb', line 25 def call(env) @env = env env[:ui].info I18n.t("vagrant.actions.vm.destroy.destroying") cmd = "VBoxManage showvminfo #{env[:vm].uuid}" stdout, stderr, status = Open3.capture3(*cmd) if status.success? and stderr.empty? instance_name = stdout.lines.grep(/^Name:\s*(.+)/){$1}.first else raise Exception, "Could not find instance name for VM #{env[:vm].uuid}" end puts "ZPOOL: #{zpool}" fs = "#{zpool}/vagrant_#{env[:vm].config.vm.box}" clonename = "#{fs}/#{instance_name}" snapname = "#{fs}@#{instance_name}" env[:vm].driver.delete env[:vm].uuid = nil VagrantZFS::ZFS.destroy clonename VagrantZFS::ZFS.destroy snapname @app.call(env) end |
#zpool ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/vagrant_zfs/action/vm/destroy.rb', line 10 def zpool # Is the zpool specified in the Vagrantfile? if @env['global_config'].zfs.zpool @env['global_config'].zfs.zpool else # If we have only one zpool available, go with that. zpools = VagrantZFS::ZFS.zpool_list if zpools.length == 1 zpools.first else raise Exception, "zpool not specified and more than one available." end end end |