<commit_before>'use strict';

// given k8s information, generates teraslice cluster state

/**
 * Given the k8s Pods API output generates the appropriate Teraslice cluster
 * state
 * @param  {Object} k8sPods      k8s pods API object (k8s v1.10)
 * @param  {Object} clusterState Teraslice Cluster State
 */
function gen(k8sPods, clusterState) {
    // Loop over the nodes in clusterState and set active = [] so we can append
    // later
    Object.keys(clusterState).forEach((nodeId) => {
        clusterState[nodeId].active = [];
    });

    // add a worker for each pod
    k8sPods.items.forEach((element) => {
        if (!Object.prototype.hasOwnProperty.call(clusterState, element.status.hostIP)) {
            // If the node isn't in clusterState, add it
            clusterState[element.status.hostIP] = {
                node_id: element.status.hostIP,
                hostname: element.status.hostIP,
                pid: 'N/A',
                node_version: 'N/A',
                teraslice_version: 'N/A',
                total: 'N/A',
                state: 'connected',
                available: 'N/A',
                active: []<commit_msg>Adding teraslice and node versions to nodes.<commit_after>'use strict';

const _ = require('lodash');

const terasliceVersion = require('../../../../../../package.json').version;

// given k8s information, generates teraslice cluster state

/**
 * Given the k8s Pods API output generates the appropriate Teraslice cluster
 * state
 * @param  {Object} k8sPods      k8s pods API object (k8s v1.10)
 * @param  {Object} clusterState Teraslice Cluster State
 */
function gen(k8sPods, clusterState) {
    // Loop over the nodes in clusterState and set active = [] so we can append
    // later
    Object.keys(clusterState).forEach((nodeId) => {
        clusterState[nodeId].active = [];
    });

    // add a worker for each pod
    k8sPods.items.forEach((element) => {
        if (!_.has(clusterState, element.status.hostIP)) {
            // If the node isn't in clusterState, add it
            clusterState[element.status.hostIP] = {
                node_id: element.status.hostIP,
                hostname: element.status.hostIP,
                pid: 'N/A',
                node_version: process.version,
                teraslice_version: terasliceVersion,
                total: 'N/A',
                state: 'connected',
                available: 'N/A',
                active: []
{'fraction_non_alphanumeric': 0.11721311475409836, 'fraction_numerical': 0.00819672131147541, 'mean_word_length': 2.1335044929396663, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4497984', 'n_tokens_mistral': 730, 'n_tokens_neox': 698, 'n_words': 193}