private void toSlime(Node node, boolean allFields, Cursor object) {
        NodeResources realResources = nodeRepository.resourcesCalculator().realResourcesOf(node, nodeRepository);

        object.setString("url", nodeParentUrl + node.hostname());
        if ( ! allFields) return;
        object.setString("id", node.id());
        object.setString("state", NodeSerializer.toString(node.state()));
        object.setString("type", NodeSerializer.toString(node.type()));
        object.setString("hostname", node.hostname());
        if (node.parentHostname().isPresent()) {
            object.setString("parentHostname", node.parentHostname().get());
        }
        object.setString("flavor", node.flavor().name());
        node.reservedTo().ifPresent(reservedTo -> object.setString("reservedTo", reservedTo.value()));
        node.exclusiveToApplicationId().ifPresent(applicationId -> object.setString("exclusiveTo", applicationId.serializedForm()));
        node.provisionedForApplicationId().ifPresent(applicationId -> object.setString("provisionedFor", applicationId.serializedForm()));
        node.hostTTL().ifPresent(ttl -> object.setLong("hostTTL", ttl.toMillis()));
        node.hostEmptyAt().ifPresent(emptyAt -> object.setLong("hostEmptyAt", emptyAt.toEpochMilli()));
        node.exclusiveToClusterType().ifPresent(clusterType -> object.setString("exclusiveToClusterType", clusterType.name()));
        if (node.flavor().isConfigured())
            object.setDouble("cpuCores", node.flavor().resources().vcpu());
        NodeResourcesSerializer.toSlime(node.flavor().resources(), object.setObject("resources"));
        NodeResourcesSerializer.toSlime(realResources, object.setObject("realResources"));
        if (node.flavor().cost() > 0)
            object.setLong("cost", node.flavor().cost());
        object.setString("environment", node.flavor().getType().name());
        node.allocation().ifPresent(allocation -> {
            toSlime(allocation.owner(), object.setObject("owner"));
            toSlime(allocation.membership(), object.setObject("membership"));
            object.setLong("restartGeneration", allocation.restartGeneration().wanted());
            object.setLong("currentRestartGeneration", allocation.restartGeneration().current());
            object.setString("wantedDockerImage", nodeRepository.containerImages().get(node).withTag(resolveVersionFlag(wantedDockerTagFlag, node, allocation)).asString());
            object.setString("wantedVespaVersion", allocation.membership().cluster().vespaVersion().toFullString());
            NodeResourcesSerializer.toSlime(allocation.requestedResources(), object.setObject("requestedResources"));
            allocation.networkPorts().ifPresent(ports -> NetworkPortsSerializer.toSlime(ports, object.setArray("networkPorts")));
            orchestrator.apply(new com.yahoo.vespa.applicationmodel.HostName(node.hostname()))
                        .ifPresent(info -> {
                            if (info.status() != HostStatus.NO_REMARKS) {
                                object.setString("orchestratorStatus", info.status().asString());
                            }
                            info.suspendedSince().ifPresent(since -> object.setLong("suspendedSinceMillis", since.toEpochMilli()));
                        });
        });
        object.setLong("rebootGeneration", node.status().reboot().wanted());
        object.setLong("currentRebootGeneration", node.status().reboot().current());
        node.status().osVersion().current().ifPresent(version -> object.setString("currentOsVersion", version.toFullString()));
        node.status().osVersion().wanted().ifPresent(version -> object.setString("wantedOsVersion", version.toFullString()));
        if (node.type().isHost()) {
            object.setBool("deferOsUpgrade", nodeRepository.osVersions().deferringUpgrade(node));
        }
        node.status().firmwareVerifiedAt().ifPresent(instant -> object.setLong("currentFirmwareCheck", instant.toEpochMilli()));
        if (node.type().isHost())
            nodeRepository.firmwareChecks().requiredAfter().ifPresent(after -> object.setLong("wantedFirmwareCheck", after.toEpochMilli()));
        node.status().vespaVersion().ifPresent(version -> object.setString("vespaVersion", version.toFullString()));
        currentContainerImage(node).ifPresent(image -> object.setString("currentDockerImage", image.asString()));
        object.setLong("failCount", node.status().failCount());
        object.setBool("wantToRetire", node.status().wantToRetire());
        object.setBool("preferToRetire", node.status().preferToRetire());
        object.setBool("wantToDeprovision", node.status().wantToDeprovision());
        object.setBool("wantToRebuild", node.status().wantToRebuild());
        object.setBool("bootingAfterRebuild", node.status().bootingAfterRebuild());
        object.setBool("wantToUpgradeFlavor", node.status().wantToUpgradeFlavor());
        object.setBool("down", node.history().isDown());
        toSlime(node.history().events(), object.setArray("history"));
        toSlime(node.history().log(), object.setArray("log"));
        ipAddressesToSlime(node.ipConfig().primary(), object.setArray("ipAddresses"));
        ipAddressesToSlime(node.ipConfig().pool().ips(), object.setArray("additionalIpAddresses"));
        hostnamesToSlime(node.ipConfig().pool().hostnames(), object);
        node.reports().toSlime(object, "reports");
        node.modelName().ifPresent(modelName -> object.setString("modelName", modelName));
        node.switchHostname().ifPresent(switchHostname -> object.setString("switchHostname", switchHostname));
        nodeRepository.archiveUriManager().archiveUriFor(node).ifPresent(uri -> object.setString("archiveUri", uri));
        trustedCertsToSlime(node.trustedCertificates(), object);
        if (!node.cloudAccount().isUnspecified()) {
            object.setString("cloudAccount", node.cloudAccount().value());
        }
        node.wireguardPubKey().ifPresent(key -> toSlime(key, object.setObject("wireguard")));
        node.status().snapshot().ifPresent(snapshot -> toSlime(snapshot, object.setObject("snapshot")));
    }
Outputs the nodes in the given states to a node array
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodesResponse.java