Update Hyper-V import command and the driver to check for configuration type and call the correct import script.
This commit is contained in:
parent
b041c1955c
commit
1ec1cf8177
|
@ -35,9 +35,17 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
config_path = nil
|
||||
config_type = nil
|
||||
vm_dir.each_child do |f|
|
||||
if f.extname.downcase == ".xml"
|
||||
|
||||
if f.extname.downcase == '.xml'
|
||||
config_path = f
|
||||
config_type = 'xml'
|
||||
break
|
||||
end
|
||||
if f.extname.downcase == '.vmcx'
|
||||
config_path = f
|
||||
config_type = 'vmcx'
|
||||
break
|
||||
end
|
||||
end
|
||||
|
@ -111,7 +119,8 @@ module VagrantPlugins
|
|||
# We have to normalize the paths to be Windows paths since
|
||||
# we're executing PowerShell.
|
||||
options = {
|
||||
vm_xml_config: config_path.to_s.gsub("/", "\\"),
|
||||
vm_config: config_path.to_s.gsub("/", "\\"),
|
||||
vm_config_type: config_type,
|
||||
image_path: image_path.to_s.gsub("/", "\\")
|
||||
}
|
||||
options[:switchname] = switch if switch
|
||||
|
|
|
@ -74,7 +74,12 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def import(options)
|
||||
execute('import_vm.ps1', options)
|
||||
config_type = options.delete(:vm_config_type)
|
||||
if config_type === "vmcx"
|
||||
execute('import_vm_vmcx.ps1', options)
|
||||
else
|
||||
execute('import_vm_xml.ps1', options)
|
||||
end
|
||||
end
|
||||
|
||||
def net_set_vlan(vlan_id)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$vm_xml_config,
|
||||
[string]$vm_config,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$image_path,
|
||||
|
||||
|
@ -17,7 +17,7 @@ Param(
|
|||
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
|
||||
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
|
||||
|
||||
[xml]$vmconfig = Get-Content -Path $vm_xml_config
|
||||
[xml]$vmconfig = Get-Content -Path $vm_config
|
||||
|
||||
$generation = [int]($vmconfig.configuration.properties.subtype.'#text')+1
|
||||
|
Loading…
Reference in New Issue