func resourceVSphereVirtualMachineCreateCloneWithSDRS(
	d *schema.ResourceData,
	meta interface{},
	srcVM *object.VirtualMachine,
	fo *object.Folder,
	name string,
	spec types.VirtualMachineCloneSpec,
	timeout int,
) (*object.VirtualMachine, error) {
	client := meta.(*VSphereClient).vimClient
	if err := viapi.ValidateVirtualCenter(client); err != nil {
		return nil, fmt.Errorf("connection ineligible to use datastore_cluster_id: %s", err)
	}

	log.Printf("[DEBUG] %s: Cloning virtual machine through Storage DRS API", resourceVSphereVirtualMachineIDString(d))
	pod, err := storagepod.FromID(client, d.Get("datastore_cluster_id").(string))
	if err != nil {
		return nil, fmt.Errorf("error getting datastore cluster: %s", err)
	}

	vm, err := storagepod.CloneVM(client, srcVM, fo, name, spec, timeout, pod)
	if err != nil {
		return nil, fmt.Errorf("error cloning on datastore cluster %q: %s", pod.Name(), err)
	}

	return vm, nil
}
func resourceVSphereVirtualMachineCreateCloneWithSDRS(
	d *schema.ResourceData,
	meta interface{},
	srcVM *object.VirtualMachine,
	fo *object.Folder,
	name string,
	spec types.VirtualMachineCloneSpec,
	timeout int,
) (*object.VirtualMachine, error) {
	client := meta.(*VSphereClient).vimClient
	if err := viapi.ValidateVirtualCenter(client); err != nil {
		return nil, fmt.Errorf("connection ineligible to use datastore_cluster_id: %s", err)
	}

	log.Printf("[DEBUG] %s: Cloning virtual machine through Storage DRS API", resourceVSphereVirtualMachineIDString(d))
	pod, err := storagepod.FromID(client, d.Get("datastore_cluster_id").(string))
	if err != nil {
		return nil, fmt.Errorf("error getting datastore cluster: %s", err)
	}

	vm, err := storagepod.CloneVM(client, srcVM, fo, name, spec, timeout, pod)
	if err != nil {
		return nil, fmt.Errorf("error cloning on datastore cluster %q: %s", pod.Name(), err)
	}

	return vm, nil
}
func resourceVSphereVirtualMachineCreateCloneWithSDRS ( d * schema . ResourceData , meta interface { } , srcVM * object . VirtualMachine , fo * object . Folder , name string , spec types . VirtualMachineCloneSpec , timeout int , ) ( * object . VirtualMachine , error ) { client := meta . ( * VSphereClient ) . vimClient if err := viapi . ValidateVirtualCenter ( client ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } log . Printf ( " " , resourceVSphereVirtualMachineIDString ( d ) ) pod , err := storagepod . FromID ( client , d . Get ( " " ) . ( string ) ) if err != nil { return nil , fmt . Errorf ( " " , err ) } vm , err := storagepod . CloneVM ( client , srcVM , fo , name , spec , timeout , pod ) if err != nil { return nil , fmt . Errorf ( " " , pod . Name ( ) , err ) } return vm , nil }
// resourceVSphereVirtualMachineCreateCloneWithSDRS runs the clone part of
// resourceVSphereVirtualMachineCreateClone through storage DRS. It's designed
// to be run when a storage cluster is specified, versus simply specifying
// datastores.
resourceVSphereVirtualMachineCreateCloneWithSDRS runs the clone part of resourceVSphereVirtualMachineCreateClone through storage DRS . It s designed to be run when a storage cluster is specified versus simply specifying datastores .