Setting boot drive is generation specific
This commit is contained in:
parent
93a2615f7a
commit
18241e5215
@ -90,7 +90,7 @@ type Driver interface {
|
|||||||
|
|
||||||
MountDvdDrive(string, string, uint, uint) error
|
MountDvdDrive(string, string, uint, uint) error
|
||||||
|
|
||||||
SetBootDvdDrive(string, uint, uint) error
|
SetBootDvdDrive(string, uint, uint, uint) error
|
||||||
|
|
||||||
UnmountDvdDrive(string, uint, uint) error
|
UnmountDvdDrive(string, uint, uint) error
|
||||||
|
|
||||||
|
@ -213,8 +213,8 @@ func (d *HypervPS4Driver) MountDvdDrive(vmName string, path string, controllerNu
|
|||||||
return hyperv.MountDvdDrive(vmName, path, controllerNumber, controllerLocation)
|
return hyperv.MountDvdDrive(vmName, path, controllerNumber, controllerLocation)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *HypervPS4Driver) SetBootDvdDrive(vmName string, controllerNumber uint, controllerLocation uint) error {
|
func (d *HypervPS4Driver) SetBootDvdDrive(vmName string, controllerNumber uint, controllerLocation uint, generation uint) error {
|
||||||
return hyperv.SetBootDvdDrive(vmName, controllerNumber, controllerLocation)
|
return hyperv.SetBootDvdDrive(vmName, controllerNumber, controllerLocation, generation)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *HypervPS4Driver) UnmountDvdDrive(vmName string, controllerNumber uint, controllerLocation uint) error {
|
func (d *HypervPS4Driver) UnmountDvdDrive(vmName string, controllerNumber uint, controllerLocation uint) error {
|
||||||
|
@ -44,7 +44,7 @@ func (s *StepMountDvdDrive) Run(state multistep.StateBag) multistep.StepAction {
|
|||||||
state.Put("os.dvd.properties", dvdControllerProperties)
|
state.Put("os.dvd.properties", dvdControllerProperties)
|
||||||
|
|
||||||
ui.Say(fmt.Sprintf("Setting boot drive to os dvd drive %s ...", isoPath))
|
ui.Say(fmt.Sprintf("Setting boot drive to os dvd drive %s ...", isoPath))
|
||||||
err = driver.SetBootDvdDrive(vmName, controllerNumber, controllerLocation)
|
err = driver.SetBootDvdDrive(vmName, controllerNumber, controllerLocation, s.Generation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf(errorMsg, err)
|
err := fmt.Errorf(errorMsg, err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
@ -135,18 +135,28 @@ Set-VMDvdDrive -VMName $vmName -ControllerNumber $controllerNumber -ControllerLo
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetBootDvdDrive(vmName string, controllerNumber uint, controllerLocation uint) error {
|
func SetBootDvdDrive(vmName string, controllerNumber uint, controllerLocation uint, generation uint) error {
|
||||||
var script = `
|
|
||||||
|
if generation < 2 {
|
||||||
|
script := `
|
||||||
|
param([string]$vmName)
|
||||||
|
Set-VMBios -VMName $vmName -StartupOrder @("CD", "IDE","LegacyNetworkAdapter","Floppy")
|
||||||
|
`
|
||||||
|
var ps powershell.PowerShellCmd
|
||||||
|
err := ps.Run(script, vmName)
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
script := `
|
||||||
param([string]$vmName,[int]$controllerNumber,[int]$controllerLocation)
|
param([string]$vmName,[int]$controllerNumber,[int]$controllerLocation)
|
||||||
$vmDvdDrive = Get-VMDvdDrive -VMName $vmName -ControllerNumber $controllerNumber -ControllerLocation $controllerLocation
|
$vmDvdDrive = Get-VMDvdDrive -VMName $vmName -ControllerNumber $controllerNumber -ControllerLocation $controllerLocation
|
||||||
if (!$vmDvdDrive) {throw 'unable to find dvd drive'}
|
if (!$vmDvdDrive) {throw 'unable to find dvd drive'}
|
||||||
Set-VMFirmware -VMName $vmName -FirstBootDevice $vmDvdDrive
|
Set-VMFirmware -VMName $vmName -FirstBootDevice $vmDvdDrive
|
||||||
`
|
`
|
||||||
|
|
||||||
var ps powershell.PowerShellCmd
|
var ps powershell.PowerShellCmd
|
||||||
err := ps.Run(script, vmName, strconv.FormatInt(int64(controllerNumber), 10), strconv.FormatInt(int64(controllerLocation), 10))
|
err := ps.Run(script, vmName, strconv.FormatInt(int64(controllerNumber), 10), strconv.FormatInt(int64(controllerLocation), 10))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func DeleteDvdDrive(vmName string, controllerNumber uint, controllerLocation uint) error {
|
func DeleteDvdDrive(vmName string, controllerNumber uint, controllerLocation uint) error {
|
||||||
var script = `
|
var script = `
|
||||||
|
Loading…
x
Reference in New Issue
Block a user