Skip to content

Add windows_install_type config and improve shutdown resilience#367

Open
andrew-sumner wants to merge 6 commits into
nutanix-cloud-native:mainfrom
andrew-sumner:issue/windows-guest-customization
Open

Add windows_install_type config and improve shutdown resilience#367
andrew-sumner wants to merge 6 commits into
nutanix-cloud-native:mainfrom
andrew-sumner:issue/windows-guest-customization

Conversation

@andrew-sumner

@andrew-sumner andrew-sumner commented May 11, 2026

Copy link
Copy Markdown

Summary

Closes #366. Split from #357 at the maintainer's request.

  • Add windows_install_type builder field (FRESH or PREPARED) to control
    the Sysprep InstallType sent to the V4 API during Windows guest customization
  • Tolerate communicator disconnect during shutdown_command (e.g. sysprep
    powering off the VM before Packer reads exit status)
  • Tolerate PowerOff errors when the VM has already shut down

When the shutdown command triggers a VM power-off (e.g. sysprep
/generalize /oobe /shutdown), the communicator drops before it can
read the exit status. Previously this was treated as a fatal error,
halting the build. Now log a warning and fall through to the power-
state polling loop, which detects the VM is off and proceeds to
image capture.
Without this, the Sysprep guest customization defaults to PREPARED,
which tells Nutanix to auto-restart the VM after shutdown to apply
the customization on first boot. For Packer ISO builds, the unattend
is for a fresh install — the VM should stay off after sysprep so
Packer can capture the disk.
When sysprep runs as a provisioner with /shutdown, the VM may be off
before StepShutdown calls PowerOff(). Log a warning and fall through
to the polling loop instead of halting.
Exposes the Nutanix V4 API InstallType field as a Packer config option
(windows_install_type). Defaults to PREPARED (existing behaviour for
template/clone deployments). Set to FRESH for ISO-based builds where
the unattend is for a fresh install — prevents Nutanix from auto-
restarting the VM after sysprep shutdown.
- Validate windows_install_type in Prepare(), reject values other than
  FRESH or PREPARED
- Use strings.EqualFold for case-insensitive comparison in sysprep logic
- Add TestPrepareRejectsInvalidWindowsInstallType test
@tuxtof tuxtof force-pushed the issue/windows-guest-customization branch from d518a92 to 79a65a1 Compare May 19, 2026 14:51
andrew-sumner added a commit to andrew-sumner/packer-plugin-nutanix that referenced this pull request Jun 8, 2026
…to combined/api-key-and-windows

# Conflicts:
#	builder/nutanix/config_test.go
TestPrepareRejectsInvalidWindowsInstallType previously relied on the
default nutanix_username/nutanix_password set by minimalValidConfig.
Pass them explicitly so the test is self-contained and does not depend
on helper defaults — also avoids a behavioural conflict when this PR is
rebased against the API-key PR (nutanix-cloud-native#358), whose minimalValidConfig omits
default credentials so its auth-combination tests can work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add windows_install_type config and improve shutdown resilience

1 participant