Skip to content

Commit 601de16

Browse files
committed
chore: fix vm test
1 parent 79b8b5b commit 601de16

1 file changed

Lines changed: 57 additions & 2 deletions

File tree

nutanix/resource_nutanix_virtual_machine_test.go

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,31 @@ func TestAccNutanixVirtualMachine_CdromGuestCustomisationReboot(t *testing.T) {
282282
ResourceName: resourceName,
283283
ImportState: true,
284284
ImportStateVerify: true,
285-
ImportStateVerifyIgnore: []string{"disk_list"},
285+
ImportStateVerifyIgnore: []string{"disk_list", "cloud_init_cdrom_uuid"},
286+
},
287+
},
288+
})
289+
}
290+
291+
func TestAccNutanixVirtualMachine_CdromGuestCustomisationRebootWithManualCDROM(t *testing.T) {
292+
r := acctest.RandInt()
293+
resourceName := "nutanix_virtual_machine.vm7"
294+
resource.Test(t, resource.TestCase{
295+
PreCheck: func() { testAccPreCheck(t) },
296+
Providers: testAccProviders,
297+
CheckDestroy: testAccCheckNutanixVirtualMachineDestroy,
298+
Steps: []resource.TestStep{
299+
{
300+
Config: testAccNutanixVMConfigCdromGuestCustomisationRebootWithManualCDROM(r),
301+
Check: resource.ComposeTestCheckFunc(
302+
testAccCheckNutanixVirtualMachineExists(resourceName),
303+
),
304+
},
305+
{
306+
ResourceName: resourceName,
307+
ImportState: true,
308+
ImportStateVerify: true,
309+
ImportStateVerifyIgnore: []string{"disk_list", "cloud_init_cdrom_uuid"},
286310
},
287311
},
288312
})
@@ -311,7 +335,7 @@ func TestAccNutanixVirtualMachine_CloudInitCustomKeyValues(t *testing.T) {
311335
ResourceName: resourceName,
312336
ImportState: true,
313337
ImportStateVerify: true,
314-
ImportStateVerifyIgnore: []string{"disk_list"},
338+
ImportStateVerifyIgnore: []string{"disk_list", "cloud_init_cdrom_uuid"},
315339
},
316340
},
317341
})
@@ -824,6 +848,37 @@ func testAccNutanixVMConfigCdromGuestCustomisationReboot(r int) string {
824848
`, r)
825849
}
826850

851+
func testAccNutanixVMConfigCdromGuestCustomisationRebootWithManualCDROM(r int) string {
852+
return fmt.Sprintf(`
853+
data "nutanix_clusters" "clusters" {}
854+
855+
locals {
856+
cluster1 = "${data.nutanix_clusters.clusters.entities.0.service_list.0 == "PRISM_CENTRAL"
857+
? data.nutanix_clusters.clusters.entities.1.metadata.uuid : data.nutanix_clusters.clusters.entities.0.metadata.uuid}"
858+
}
859+
860+
resource "nutanix_virtual_machine" "vm7" {
861+
name = "test-dou-%d"
862+
cluster_uuid = "${local.cluster1}"
863+
864+
num_vcpus_per_socket = 1
865+
num_sockets = 1
866+
memory_size_mib = 186
867+
guest_customization_cloud_init_user_data = base64encode("#cloud-config\nfqdn: test.domain.local")
868+
869+
disk_list {
870+
device_properties {
871+
device_type = "CDROM"
872+
disk_address = {
873+
device_index = 0
874+
adapter_type = "IDE"
875+
}
876+
}
877+
}
878+
}
879+
`, r)
880+
}
881+
827882
func testAccNutanixVMConfigCloudInitCustomKeyValues(r int) string {
828883
return fmt.Sprintf(`
829884
data "nutanix_clusters" "clusters" {}

0 commit comments

Comments
 (0)