vsphere/resource_vsphere_compute_cluster.go
func resourceVSphereComputeClusterDeleteProcessForceRemoveHosts(
	d *schema.ResourceData,
	meta interface{},
	cluster *object.ClusterComputeResource,
) error {
	if !d.Get("force_evacuate_on_destroy").(bool) {
		return nil
	}

	client, err := resourceVSphereComputeClusterClient(meta)
	if err != nil {
		return err
	}

	log.Printf("[DEBUG] %s: Force-evacuating hosts in cluster before removal", resourceVSphereComputeClusterIDString(d))
	hosts, err := resourceVSphereComputeClusterGetHostSystemObjects(
		client,
		structure.SliceInterfacesToStrings(d.Get("host_system_ids").(*schema.Set).List()),
	)
	if err != nil {
		return err
	}

	if err := clustercomputeresource.MoveHostsOutOf(cluster, hosts, d.Get("host_cluster_exit_timeout").(int)); err != nil {
		return fmt.Errorf("error force-removing old hosts out of cluster: %s", err)
	}

	return nil
}
func resourceVSphereComputeClusterDeleteProcessForceRemoveHosts(
	d *schema.ResourceData,
	meta interface{},
	cluster *object.ClusterComputeResource,
) error {
	if !d.Get("force_evacuate_on_destroy").(bool) {
		return nil
	}

	client, err := resourceVSphereComputeClusterClient(meta)
	if err != nil {
		return err
	}

	log.Printf("[DEBUG] %s: Force-evacuating hosts in cluster before removal", resourceVSphereComputeClusterIDString(d))
	hosts, err := resourceVSphereComputeClusterGetHostSystemObjects(
		client,
		structure.SliceInterfacesToStrings(d.Get("host_system_ids").(*schema.Set).List()),
	)
	if err != nil {
		return err
	}

	if err := clustercomputeresource.MoveHostsOutOf(cluster, hosts, d.Get("host_cluster_exit_timeout").(int)); err != nil {
		return fmt.Errorf("error force-removing old hosts out of cluster: %s", err)
	}

	return nil
}
func resourceVSphereComputeClusterDeleteProcessForceRemoveHosts ( d * schema . ResourceData , meta interface { } , cluster * object . ClusterComputeResource , ) error { if ! d . Get ( " " ) . ( bool ) { return nil } client , err := resourceVSphereComputeClusterClient ( meta ) if err != nil { return err } log . Printf ( " " , resourceVSphereComputeClusterIDString ( d ) ) hosts , err := resourceVSphereComputeClusterGetHostSystemObjects ( client , structure . SliceInterfacesToStrings ( d . Get ( " " ) . ( * schema . Set ) . List ( ) ) , ) if err != nil { return err } if err := clustercomputeresource . MoveHostsOutOf ( cluster , hosts , d . Get ( " " ) . ( int ) ) ; err != nil { return fmt . Errorf ( " " , err ) } return nil }
// resourceVSphereComputeClusterDeleteProcessForceRemoveHosts process
// force-evacuation if the resource has been configured to do so.
//
// NOTE: As documented, this should only be used in testing. Improper use
// of this option can lead to service disruptions and/or may fail to
// actually succeed depending on the resources actually in use in the
// cluster, and specific constraints that exist in the cluster.
resourceVSphereComputeClusterDeleteProcessForceRemoveHosts process force - evacuation if the resource has been configured to do so . NOTE : As documented this should only be used in testing . Improper use of this option can lead to service disruptions and / or may fail to actually succeed depending on the resources actually in use in the cluster and specific constraints that exist in the cluster .