CleanMachineFolder action works with VBoxManage

This commit is contained in:
Mitchell Hashimoto 2011-12-21 14:45:14 -08:00
parent 4c7059eaf6
commit d2e33768f3
2 changed files with 14 additions and 3 deletions

View File

@ -13,12 +13,12 @@ module Vagrant
end
def call(env)
clean_machine_folder
clean_machine_folder(env[:vm].driver.read_machine_folder)
@app.call(env)
end
def clean_machine_folder
folder = File.join(VirtualBox::Global.global.system_properties.default_machine_folder, "*")
def clean_machine_folder(machine_folder)
folder = File.join(machine_folder, "*")
# Small safeguard against potentially unwanted rm-rf, since the default
# machine folder will typically always be greater than 10 characters long.

View File

@ -146,6 +146,17 @@ module Vagrant
return nil
end
# This reads the folder where VirtualBox places it's VMs.
def read_machine_folder
execute("list", "systemproperties").split("\n").each do |line|
if line =~ /^Default machine folder:\s+(.+?)$/
return $1.to_s
end
end
nil
end
# This reads the state for the given UUID. The state of the VM
# will be returned as a symbol.
def read_state