Merge pull request #4208 from mwrock/file-path

providers/hyperv: accept vhd as well as vhdx file types on hyper-v
This commit is contained in:
Mitchell Hashimoto 2014-08-05 17:51:11 -07:00
commit 79fd20c8c7
2 changed files with 12 additions and 10 deletions

View File

@ -27,15 +27,17 @@ module VagrantPlugins
end end
end end
vhdx_path = nil image_path = nil
image_ext = nil
hd_dir.each_child do |f| hd_dir.each_child do |f|
if f.extname.downcase == ".vhdx" if %w{.vhd .vhdx}.include?(f.extname.downcase)
vhdx_path = f image_path = f
image_ext = f.extname.downcase
break break
end end
end end
if !config_path || !vhdx_path if !config_path || !image_path
raise Errors::BoxInvalid raise Errors::BoxInvalid
end end
@ -64,16 +66,16 @@ module VagrantPlugins
end end
env[:ui].detail("Cloning virtual hard drive...") env[:ui].detail("Cloning virtual hard drive...")
source_path = vhdx_path.to_s source_path = image_path.to_s
dest_path = env[:machine].data_dir.join("disk.vhdx").to_s dest_path = env[:machine].data_dir.join("disk.#{image_ext}").to_s
FileUtils.cp(source_path, dest_path) FileUtils.cp(source_path, dest_path)
vhdx_path = dest_path image_path = dest_path
# We have to normalize the paths to be Windows paths since # We have to normalize the paths to be Windows paths since
# we're executing PowerShell. # we're executing PowerShell.
options = { options = {
vm_xml_config: config_path.to_s.gsub("/", "\\"), vm_xml_config: config_path.to_s.gsub("/", "\\"),
vhdx_path: vhdx_path.to_s.gsub("/", "\\") image_path: image_path.to_s.gsub("/", "\\")
} }
options[:switchname] = switch if switch options[:switchname] = switch if switch

View File

@ -2,7 +2,7 @@ Param(
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$vm_xml_config, [string]$vm_xml_config,
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$vhdx_path, [string]$image_path,
[string]$switchname=$null [string]$switchname=$null
) )
@ -119,7 +119,7 @@ foreach ($controller in $controllers) {
$addDriveParam = @{ $addDriveParam = @{
ControllerNumber = $rx.Match($controller.node.name).value ControllerNumber = $rx.Match($controller.node.name).value
Path = $vhdx_path Path = $image_path
} }
if ($drive.pool_id."#text") { if ($drive.pool_id."#text") {