From 1e0b66427955ac52998b1f1f0751e79f96688f47 Mon Sep 17 00:00:00 2001 From: Pekka Panula Date: Thu, 22 Sep 2022 13:00:58 +0300 Subject: [PATCH 1/2] Fix for changePowerState to handle SECURE_BOOT VMs --- nutanix/resource_nutanix_virtual_machine.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nutanix/resource_nutanix_virtual_machine.go b/nutanix/resource_nutanix_virtual_machine.go index 29bb93aa7..70d7c2886 100644 --- a/nutanix/resource_nutanix_virtual_machine.go +++ b/nutanix/resource_nutanix_virtual_machine.go @@ -1337,6 +1337,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 From 96bfe660eaf4ff0a1299ee76b393a379301e2ca9 Mon Sep 17 00:00:00 2001 From: Pekka Panula Date: Thu, 22 Sep 2022 13:19:15 +0300 Subject: [PATCH 2/2] fix VM update to handle SECURE_BOOT VMs --- nutanix/resource_nutanix_virtual_machine.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nutanix/resource_nutanix_virtual_machine.go b/nutanix/resource_nutanix_virtual_machine.go index 70d7c2886..2b6355555 100644 --- a/nutanix/resource_nutanix_virtual_machine.go +++ b/nutanix/resource_nutanix_virtual_machine.go @@ -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 + 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