Skip to content

Commit

Permalink
r/virtual_machine: Add device connectivity check to CDROM tests
Browse files Browse the repository at this point in the history
To facilitate #278.
  • Loading branch information
vancluever committed Dec 6, 2017
1 parent efa7cfc commit c192c1c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vsphere/resource_vsphere_virtual_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,8 @@ func testAccResourceVSphereVirtualMachineCheckMultiDevice(expectedD, expectedN [
}
}

// testAccResourceVSphereVirtualMachineCheckCdrom checks to make sure that the
// subject VM has a CDROM device configured and connected.
func testAccResourceVSphereVirtualMachineCheckCdrom() resource.TestCheckFunc {
return func(s *terraform.State) error {
props, err := testGetVirtualMachineProperties(s, "vm")
Expand All @@ -1587,6 +1589,9 @@ func testAccResourceVSphereVirtualMachineCheckCdrom() resource.TestCheckFunc {

for _, dev := range props.Config.Hardware.Device {
if cdrom, ok := dev.(*types.VirtualCdrom); ok {
if !cdrom.Connectable.Connected {
return fmt.Errorf("expected CDROM device to be connected")
}
if backing, ok := cdrom.Backing.(*types.VirtualCdromIsoBackingInfo); ok {
expected := &object.DatastorePath{
Datastore: os.Getenv("VSPHERE_ISO_DATASTORE"),
Expand Down

0 comments on commit c192c1c

Please sign in to comment.