Skip to content

Commit

Permalink
Merge pull request #609 from terraform-providers/b-only-relocate-when…
Browse files Browse the repository at this point in the history
…-hostid-is-set

r/virtual_machine: Only relocate if host_system_id is set
  • Loading branch information
bill-rich authored Sep 4, 2018
2 parents 3bccdeb + e91423a commit a5d9118
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions vsphere/resource_vsphere_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,14 @@ func resourceVSphereVirtualMachineCreate(d *schema.ResourceData, meta interface{
if err != nil {
return err
}
if d.Get("host_system_id").(string) != vprops.Runtime.Host.Reference().Value {
hid := d.Get("host_system_id").(string)
if hid, ok := d.GetOk("host_system_id"); hid.(string) != vprops.Runtime.Host.Reference().Value && ok {
err = resourceVSphereVirtualMachineRead(d, meta)
if err != nil {
return err
}
// Restore the old host_system_id so we can still tell if a relocation is
// necessary.
err = d.Set("host_system_id", hid)
err = d.Set("host_system_id", hid.(string))
if err != nil {
return err
}
Expand Down

0 comments on commit a5d9118

Please # to comment.