From 4c810a879a68bef07fa30dead076a4129d2a627f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 26 Feb 2014 11:56:37 -0800 Subject: [PATCH] providers/hyperv: clone the disk --- plugins/providers/hyperv/action/import.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/providers/hyperv/action/import.rb b/plugins/providers/hyperv/action/import.rb index 2cf7240c7..0808e679b 100644 --- a/plugins/providers/hyperv/action/import.rb +++ b/plugins/providers/hyperv/action/import.rb @@ -1,3 +1,5 @@ +require "fileutils" + require "log4r" module VagrantPlugins @@ -37,6 +39,13 @@ module VagrantPlugins raise Errors::BoxInvalid end + env[:ui].output("Importing a Hyper-V instance") + env[:ui].detail("Cloning virtual hard drive...") + source_path = vhdx_path.to_s + dest_path = env[:machine].data_dir.join("disk.vhdx").to_s + FileUtils.cp(source_path, dest_path) + vhdx_path = dest_path + # We have to normalize the paths to be Windows paths since # we're executing PowerShell. options = { @@ -44,7 +53,7 @@ module VagrantPlugins vhdx_path: vhdx_path.to_s.gsub("/", "\\") } - env[:ui].output("Importing a Hyper-V instance") + env[:ui].detail("Creating and registering the VM...") server = env[:machine].provider.driver.execute( 'import_vm.ps1', options) env[:ui].detail("Successfully imported a VM with name: #{server['name']}")