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

Do not set the datastoreID in RelocateSpec when datastore_cluster is set #933

Merged
merged 1 commit into from
Jan 21, 2020
Merged
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
14 changes: 8 additions & 6 deletions vsphere/resource_vsphere_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1436,13 +1436,15 @@ func resourceVSphereVirtualMachineUpdateLocation(d *schema.ResourceData, meta in
Pool: types.NewReference(pool.Reference()),
}

// Fetch the datastore
if dsID, ok := d.GetOk("datastore_id"); ok {
ds, err := datastore.FromID(client, dsID.(string))
if err != nil {
return fmt.Errorf("error locating datastore for VM: %s", err)
// Fetch the datastore only if a datastore_cluster is not set
if _, ok := d.GetOk("datastore_cluster_id"); !ok {
if dsID, ok := d.GetOk("datastore_id"); ok {
ds, err := datastore.FromID(client, dsID.(string))
if err != nil {
return fmt.Errorf("error locating datastore for VM: %s", err)
}
spec.Datastore = types.NewReference(ds.Reference())
}
spec.Datastore = types.NewReference(ds.Reference())
}

if hs != nil {
Expand Down