Fix gen 1 creation of dvd
This commit is contained in:
parent
07764c631e
commit
93a2615f7a
|
@ -61,7 +61,7 @@ func CreateDvdDrive(vmName string, generation uint) (uint, uint, error) {
|
||||||
// generation 1 requires dvd to be added to ide controller, generation 2 uses scsi for dvd drives
|
// generation 1 requires dvd to be added to ide controller, generation 2 uses scsi for dvd drives
|
||||||
script = `
|
script = `
|
||||||
param([string]$vmName)
|
param([string]$vmName)
|
||||||
$dvdDrives = (Get-VMDvdDrive -VMName $vmName)
|
$dvdDrives = @(Get-VMDvdDrive -VMName $vmName)
|
||||||
$lastControllerNumber = $dvdDrives | Sort-Object ControllerNumber | Select-Object -Last 1 | %{$_.ControllerNumber}
|
$lastControllerNumber = $dvdDrives | Sort-Object ControllerNumber | Select-Object -Last 1 | %{$_.ControllerNumber}
|
||||||
if (!$lastControllerNumber) {
|
if (!$lastControllerNumber) {
|
||||||
$lastControllerNumber = 0
|
$lastControllerNumber = 0
|
||||||
|
@ -90,21 +90,11 @@ $lastControllerNumber
|
||||||
|
|
||||||
script = `
|
script = `
|
||||||
param([string]$vmName,[int]$controllerNumber)
|
param([string]$vmName,[int]$controllerNumber)
|
||||||
Add-VMDvdDrive -VMName $vmName -ControllerNumber $controllerNumber
|
$dvdController = Add-VMDvdDrive -VMName $vmName -ControllerNumber $controllerNumber -Passthru
|
||||||
`
|
$dvdController.ControllerLocation
|
||||||
cmdOut, err := ps.Output(script, vmName)
|
|
||||||
if err != nil {
|
|
||||||
return controllerNumber, 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// we could try to get the controller location and number in one call, but this way we do not
|
|
||||||
// need to parse the output
|
|
||||||
script = `
|
|
||||||
param([string]$vmName)
|
|
||||||
(Get-VMDvdDrive -VMName $vmName | Where-Object {$_.Path -eq $null}).ControllerLocation
|
|
||||||
`
|
`
|
||||||
|
|
||||||
cmdOut, err = ps.Output(script, vmName)
|
cmdOut, err := ps.Output(script, vmName, strconv.FormatInt(int64(controllerNumber), 10))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return controllerNumber, 0, err
|
return controllerNumber, 0, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue