Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Secure boot VMs when doing updates #496

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions nutanix/resource_nutanix_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,12 @@ func resourceNutanixVirtualMachineUpdate(ctx context.Context, d *schema.Resource
metadata.SpecVersion = specVersion
}

// Check if we are dealing with SECURE_BOOT machine, MachineType is needed then set to Q35
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need this check at two places. we can always preFill the machineType using the response.
here:

preFillResUpdateRequest(res, response)

if *res.BootConfig.BootType == "SECURE_BOOT" {
log.Printf("[DEBUG] UpdateVM: Machine Boot is set to Secure Boot, set MachineType to Q35")
res.MachineType = response.Spec.Resources.MachineType
}

spec.Resources = res
request.Metadata = metadata
request.Spec = spec
Expand Down Expand Up @@ -1337,6 +1343,12 @@ func changePowerState(ctx context.Context, conn *v3.Client, id string, powerStat
spec.AvailabilityZoneReference = response.Status.AvailabilityZoneReference
spec.ClusterReference = response.Status.ClusterReference

// check if SECURE_BOOT is set, we need to set MachineType to Q35 if that's the case.
if *res.BootConfig.BootType == "SECURE_BOOT" {
log.Printf("[DEBUG] Machine Boot is set to Secure Boot, set MachineType to Q35")
res.MachineType = response.Spec.Resources.MachineType
}

res.PowerStateMechanism = pw
spec.Resources = res
request.Metadata = metadata
Expand Down