Merge pull request #7041 from interdev/7040-Preserve_Disk_Name

Fix for #7040 to Preserve disk name
This commit is contained in:
Seth Vargo 2016-02-16 12:59:52 -05:00
commit ce5bcc14ec
1 changed files with 6 additions and 4 deletions

View File

@ -19,7 +19,7 @@ module VagrantPlugins
cpus = env[:machine].provider_config.cpus cpus = env[:machine].provider_config.cpus
vmname = env[:machine].provider_config.vmname vmname = env[:machine].provider_config.vmname
env[:ui].output("Configured Dynamical memory allocation, maxmemory is #{maxmemory}") if maxmemory env[:ui].output("Configured Dynamic memory allocation, maxmemory is #{maxmemory}") if maxmemory
env[:ui].output("Configured startup memory is #{memory}") if memory env[:ui].output("Configured startup memory is #{memory}") if memory
env[:ui].output("Configured cpus number is #{cpus}") if cpus env[:ui].output("Configured cpus number is #{cpus}") if cpus
env[:ui].output("Configured vmname is #{vmname}") if vmname env[:ui].output("Configured vmname is #{vmname}") if vmname
@ -38,10 +38,12 @@ module VagrantPlugins
image_path = nil image_path = nil
image_ext = nil image_ext = nil
image_filename = nil
hd_dir.each_child do |f| hd_dir.each_child do |f|
if %w{.vhd .vhdx}.include?(f.extname.downcase) if %w{.vhd .vhdx}.include?(f.extname.downcase)
image_path = f image_path = f
image_ext = f.extname.downcase image_ext = f.extname.downcase
image_filename = File.basename(f,image_ext)
break break
end end
end end
@ -92,7 +94,7 @@ module VagrantPlugins
env[:ui].detail("Cloning virtual hard drive...") env[:ui].detail("Cloning virtual hard drive...")
source_path = image_path.to_s source_path = image_path.to_s
dest_path = env[:machine].data_dir.join("disk#{image_ext}").to_s dest_path = env[:machine].data_dir.join("#{image_filename}#{image_ext}").to_s
FileUtils.cp(source_path, dest_path) FileUtils.cp(source_path, dest_path)
image_path = dest_path image_path = dest_path
@ -103,10 +105,10 @@ module VagrantPlugins
image_path: image_path.to_s.gsub("/", "\\") image_path: image_path.to_s.gsub("/", "\\")
} }
options[:switchname] = switch if switch options[:switchname] = switch if switch
options[:memory] = memory if memory options[:memory] = memory if memory
options[:maxmemory] = maxmemory if maxmemory options[:maxmemory] = maxmemory if maxmemory
options[:cpus] = cpus if cpus options[:cpus] = cpus if cpus
options[:vmname] = vmname if vmname options[:vmname] = vmname if vmname
env[:ui].detail("Creating and registering the VM...") env[:ui].detail("Creating and registering the VM...")
server = env[:machine].provider.driver.import(options) server = env[:machine].provider.driver.import(options)