vsphere/resource_vsphere_datastore_cluster.go
func resourceVSphereDatastoreClusterApplyCreate(d *schema.ResourceData, meta interface{}) (*object.StoragePod, error) {
	log.Printf("[DEBUG] %s: Processing datastore cluster creation", resourceVSphereDatastoreClusterIDString(d))
	client := meta.(*VSphereClient).vimClient
	if err := viapi.ValidateVirtualCenter(client); err != nil {
		return nil, err
	}

	dc, err := datacenterFromID(client, d.Get("datacenter_id").(string))
	if err != nil {
		return nil, fmt.Errorf("cannot locate datacenter: %s", err)
	}

	// Find the folder based off the path to the datacenter. This is where we
	// create the datastore cluster.
	f, err := folder.FromPath(client, d.Get("folder").(string), folder.VSphereFolderTypeDatastore, dc)
	if err != nil {
		return nil, fmt.Errorf("cannot locate folder: %s", err)
	}

	// Create the storage pod (datastore cluster).
	pod, err := storagepod.Create(f, d.Get("name").(string))
	if err != nil {
		return nil, fmt.Errorf("error creating datastore cluster: %s", err)
	}

	// Set the ID now before proceeding with tags, custom attributes, and DRS.
	// This ensures that we can recover from a problem with any of these
	// operations.
	d.SetId(pod.Reference().Value)

	return pod, nil
}
func resourceVSphereDatastoreClusterApplyCreate(d *schema.ResourceData, meta interface{}) (*object.StoragePod, error) {
	log.Printf("[DEBUG] %s: Processing datastore cluster creation", resourceVSphereDatastoreClusterIDString(d))
	client := meta.(*VSphereClient).vimClient
	if err := viapi.ValidateVirtualCenter(client); err != nil {
		return nil, err
	}

	dc, err := datacenterFromID(client, d.Get("datacenter_id").(string))
	if err != nil {
		return nil, fmt.Errorf("cannot locate datacenter: %s", err)
	}

	// Find the folder based off the path to the datacenter. This is where we
	// create the datastore cluster.
	f, err := folder.FromPath(client, d.Get("folder").(string), folder.VSphereFolderTypeDatastore, dc)
	if err != nil {
		return nil, fmt.Errorf("cannot locate folder: %s", err)
	}

	// Create the storage pod (datastore cluster).
	pod, err := storagepod.Create(f, d.Get("name").(string))
	if err != nil {
		return nil, fmt.Errorf("error creating datastore cluster: %s", err)
	}

	// Set the ID now before proceeding with tags, custom attributes, and DRS.
	// This ensures that we can recover from a problem with any of these
	// operations.
	d.SetId(pod.Reference().Value)

	return pod, nil
}
// resourceVSphereDatastoreClusterApplyCreate processes the creation part of
// resourceVSphereDatastoreClusterCreate.