2014-02-16 19:42:20 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module HyperV
|
|
|
|
module Action
|
|
|
|
class DeleteVM
|
|
|
|
def initialize(app, env)
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
2014-02-26 19:57:17 +00:00
|
|
|
env[:ui].info("Deleting the machine...")
|
2014-03-06 16:51:07 +00:00
|
|
|
env[:machine].provider.driver.delete_vm
|
2018-06-18 16:09:27 +00:00
|
|
|
# NOTE: We remove the data directory and recreate it
|
|
|
|
# to overcome an issue seen when running within
|
|
|
|
# the WSL. Hyper-V will successfully remove the
|
|
|
|
# VM and the files will appear to be gone, but
|
|
|
|
# on a subsequent up, they will cause collisions.
|
|
|
|
# This forces them to be gone for real.
|
|
|
|
FileUtils.rm_rf(env[:machine].data_dir)
|
|
|
|
FileUtils.mkdir_p(env[:machine].data_dir)
|
2014-02-16 19:42:20 +00:00
|
|
|
@app.call(env)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|