func MoveHostsInto(cluster *object.ClusterComputeResource, hosts []*object.HostSystem) error {
	var hsNames []string
	var hsRefs []types.ManagedObjectReference
	for _, hs := range hosts {
		hsNames = append(hsNames, hs.Name())
		hsRefs = append(hsRefs, hs.Reference())
	}
	log.Printf("[DEBUG] Adding hosts into cluster %q: %s", cluster.Name(), strings.Join(hsNames, ", "))

	req := types.MoveInto_Task{
		This: cluster.Reference(),
		Host: hsRefs,
	}

	ctx, cancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
	defer cancel()
	resp, err := methods.MoveInto_Task(ctx, cluster.Client(), &req)
	if err != nil {
		return err
	}

	task := object.NewTask(cluster.Client(), resp.Returnval)
	return task.Wait(ctx)
}
func MoveHostsInto(cluster *object.ClusterComputeResource, hosts []*object.HostSystem) error {
	var hsNames []string
	var hsRefs []types.ManagedObjectReference
	for _, hs := range hosts {
		hsNames = append(hsNames, hs.Name())
		hsRefs = append(hsRefs, hs.Reference())
	}
	log.Printf("[DEBUG] Adding hosts into cluster %q: %s", cluster.Name(), strings.Join(hsNames, ", "))

	req := types.MoveInto_Task{
		This: cluster.Reference(),
		Host: hsRefs,
	}

	ctx, cancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
	defer cancel()
	resp, err := methods.MoveInto_Task(ctx, cluster.Client(), &req)
	if err != nil {
		return err
	}

	task := object.NewTask(cluster.Client(), resp.Returnval)
	return task.Wait(ctx)
}
func MoveHostsInto ( cluster * object . ClusterComputeResource , hosts [ ] * object . HostSystem ) error { var hsNames [ ] string var hsRefs [ ] types . ManagedObjectReference for _ , hs := range hosts { hsNames = append ( hsNames , hs . Name ( ) ) hsRefs = append ( hsRefs , hs . Reference ( ) ) } log . Printf ( " " , cluster . Name ( ) , strings . Join ( hsNames , " " ) ) req := types . MoveInto_Task { This : cluster . Reference ( ) , Host : hsRefs , } ctx , cancel := context . WithTimeout ( context . Background ( ) , provider . DefaultAPITimeout ) defer cancel ( ) resp , err := methods . MoveInto_Task ( ctx , cluster . Client ( ) , & req ) if err != nil { return err } task := object . NewTask ( cluster . Client ( ) , resp . Returnval ) return task . Wait ( ctx ) }
// MoveHostsInto moves all of the supplied hosts into the cluster. All virtual
// machines are moved to the cluster's root resource pool and any resource
// pools on the host itself are deleted.
MoveHostsInto moves all of the supplied hosts into the cluster . All virtual machines are moved to the cluster s root resource pool and any resource pools on the host itself are deleted .