Skip to content

Commit

Permalink
Convert folder path to MOID (#1207)
Browse files Browse the repository at this point in the history
  • Loading branch information
bill-rich authored Sep 23, 2020
1 parent 8ff64f9 commit 3b1d5a3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion vsphere/resource_vsphere_virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1447,17 +1447,29 @@ func resourceVsphereMachineDeployOvfAndOva(d *schema.ResourceData, meta interfac

func createVCenterDeploy(d *schema.ResourceData, meta interface{}) (*virtualmachine.VCenterDeploy, error) {
restClient := meta.(*VSphereClient).restClient
vimClient := meta.(*VSphereClient).vimClient
vCenterManager := vcenter.NewManager(restClient)

item, err := contentlibrary.ItemFromID(restClient, d.Get("clone.0.template_uuid").(string))
if err != nil {
return nil, err
}

poolID := d.Get("resource_pool_id").(string)
poolObj, err := resourcepool.FromID(vimClient, poolID)
if err != nil {
return nil, fmt.Errorf("could not find resource pool ID %q: %s", poolID, err)
}

folderObj, err := folder.VirtualMachineFolderFromObject(vimClient, poolObj, d.Get("folder").(string))
if err != nil {
return nil, err
}

return &virtualmachine.VCenterDeploy{
VMName: d.Get("name").(string),
Annotation: d.Get("annotation").(string),
FolderID: d.Get("folder_id").(string),
FolderID: folderObj.Reference().Value,
DatastoreID: d.Get("datastore_id").(string),
NetworkMap: contentlibrary.MapNetworkDevices(d),
ResourcePoolID: d.Get("resource_pool_id").(string),
Expand Down

0 comments on commit 3b1d5a3

Please sign in to comment.