No need to remove floppy controller for 2nd generation vms

Don't want to be prompted for confirmation from powershell commandlets
This commit is contained in:
Taliesin Sisson 2015-07-14 07:51:03 +01:00
parent 837f9addd0
commit 5f2c12324c
3 changed files with 12 additions and 6 deletions

View File

@ -11,14 +11,18 @@ import (
"github.com/mitchellh/packer/powershell/hyperv" "github.com/mitchellh/packer/powershell/hyperv"
) )
type StepUnmountFloppyDrive struct { type StepUnmountFloppyDrive struct {
Generation uint
} }
func (s *StepUnmountFloppyDrive) Run(state multistep.StateBag) multistep.StepAction { func (s *StepUnmountFloppyDrive) Run(state multistep.StateBag) multistep.StepAction {
//driver := state.Get("driver").(Driver) //driver := state.Get("driver").(Driver)
ui := state.Get("ui").(packer.Ui) ui := state.Get("ui").(packer.Ui)
if s.Generation > 1 {
return multistep.ActionContinue
}
errorMsg := "Error Unmounting floppy drive: %s" errorMsg := "Error Unmounting floppy drive: %s"
vmName := state.Get("vmName").(string) vmName := state.Get("vmName").(string)

View File

@ -345,7 +345,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
// remove the integration services dvd drive // remove the integration services dvd drive
// after we power down // after we power down
&hypervcommon.StepUnmountSecondaryDvdImages{}, &hypervcommon.StepUnmountSecondaryDvdImages{},
&hypervcommon.StepUnmountFloppyDrive{}, &hypervcommon.StepUnmountFloppyDrive{
Generation: b.config.Generation,
},
&hypervcommon.StepUnmountDvdDrive{}, &hypervcommon.StepUnmountDvdDrive{},
&hypervcommon.StepExportVm{ &hypervcommon.StepExportVm{

View File

@ -160,7 +160,7 @@ if (($vm.State -ne [Microsoft.HyperV.PowerShell.VMState]::Off) -and ($vm.State -
Stop-VM -VM $vm -TurnOff -Force -Confirm:$false Stop-VM -VM $vm -TurnOff -Force -Confirm:$false
} }
Remove-VM -Name $vmName -Force Remove-VM -Name $vmName -Force -Confirm:$false
` `
var ps powershell.PowerShellCmd var ps powershell.PowerShellCmd
@ -231,7 +231,7 @@ func DeleteVirtualSwitch(switchName string) error {
param([string]$switchName) param([string]$switchName)
$switch = Get-VMSwitch -Name $switchName -ErrorAction SilentlyContinue $switch = Get-VMSwitch -Name $switchName -ErrorAction SilentlyContinue
if ($switch -ne $null) { if ($switch -ne $null) {
$switch | Remove-VMSwitch -Force $switch | Remove-VMSwitch -Force -Confirm:$false
} }
` `
@ -246,7 +246,7 @@ func StartVirtualMachine(vmName string) error {
param([string]$vmName) param([string]$vmName)
$vm = Get-VM -Name $vmName -ErrorAction SilentlyContinue $vm = Get-VM -Name $vmName -ErrorAction SilentlyContinue
if ($vm.State -eq [Microsoft.HyperV.PowerShell.VMState]::Off) { if ($vm.State -eq [Microsoft.HyperV.PowerShell.VMState]::Off) {
Start-VM -Name $vmName Start-VM -Name $vmName -Confirm:$false
} }
` `
@ -259,7 +259,7 @@ func RestartVirtualMachine(vmName string) error {
var script = ` var script = `
param([string]$vmName) param([string]$vmName)
Restart-VM $vmName -Force Restart-VM $vmName -Force -Confirm:$false
` `
var ps powershell.PowerShellCmd var ps powershell.PowerShellCmd