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
|
end
|
||||||
|
|
||||||
config_path = nil
|
config_path = nil
|
||||||
|
config_type = nil
|
||||||
vm_dir.each_child do |f|
|
vm_dir.each_child do |f|
|
||||||
if f.extname.downcase == ".xml"
|
|
||||||
|
if f.extname.downcase == '.xml'
|
||||||
config_path = f
|
config_path = f
|
||||||
|
config_type = 'xml'
|
||||||
|
break
|
||||||
|
end
|
||||||
|
if f.extname.downcase == '.vmcx'
|
||||||
|
config_path = f
|
||||||
|
config_type = 'vmcx'
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -111,7 +119,8 @@ module VagrantPlugins
|
||||||
# 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_config: config_path.to_s.gsub("/", "\\"),
|
||||||
|
vm_config_type: config_type,
|
||||||
image_path: image_path.to_s.gsub("/", "\\")
|
image_path: image_path.to_s.gsub("/", "\\")
|
||||||
}
|
}
|
||||||
options[:switchname] = switch if switch
|
options[:switchname] = switch if switch
|
||||||
|
|
|
@ -74,7 +74,12 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def import(options)
|
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
|
end
|
||||||
|
|
||||||
def net_set_vlan(vlan_id)
|
def net_set_vlan(vlan_id)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Param(
|
Param(
|
||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string]$vm_xml_config,
|
[string]$vm_config,
|
||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string]$image_path,
|
[string]$image_path,
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ Param(
|
||||||
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
|
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
|
||||||
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
|
. ([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
|
$generation = [int]($vmconfig.configuration.properties.subtype.'#text')+1
|
||||||
|
|
Loading…
Reference in New Issue