Add windows_install_type config and improve shutdown resilience#367
Open
andrew-sumner wants to merge 6 commits into
Open
Add windows_install_type config and improve shutdown resilience#367andrew-sumner wants to merge 6 commits into
andrew-sumner wants to merge 6 commits into
Conversation
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
d518a92 to
79a65a1
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #366. Split from #357 at the maintainer's request.
windows_install_typebuilder field (FRESHorPREPARED) to controlthe Sysprep InstallType sent to the V4 API during Windows guest customization
shutdown_command(e.g. syspreppowering off the VM before Packer reads exit status)