vsphere/internal/helper/hostsystem/host_system_helper.go
func EnterMaintenanceMode(host *object.HostSystem, timeout int, evacuate bool) error {
	if err := viapi.VimValidateVirtualCenter(host.Client()); err != nil {
		evacuate = false
	}

	log.Printf("[DEBUG] Host %q is entering maintenance mode (evacuate: %t)", host.Name(), evacuate)

	ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(timeout))
	defer cancel()
	task, err := host.EnterMaintenanceMode(ctx, int32(timeout), evacuate, nil)
	if err != nil {
		return err
	}

	return task.Wait(ctx)
}
func EnterMaintenanceMode(host *object.HostSystem, timeout int, evacuate bool) error {
	if err := viapi.VimValidateVirtualCenter(host.Client()); err != nil {
		evacuate = false
	}

	log.Printf("[DEBUG] Host %q is entering maintenance mode (evacuate: %t)", host.Name(), evacuate)

	ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(timeout))
	defer cancel()
	task, err := host.EnterMaintenanceMode(ctx, int32(timeout), evacuate, nil)
	if err != nil {
		return err
	}

	return task.Wait(ctx)
}
// EnterMaintenanceMode puts a host into maintenance mode. If evacuate is set
// to true, all powered off VMs will be removed from the host, or the task will
// block until this is the case, depending on whether or not DRS is on or off
// for the host's cluster. This parameter is ignored on direct ESXi.