<commit_before>var ssh2 = require('ssh2');
var fs = require('fs');

var sshDockerManager = function (overrideResources, overrideHostConfig, overrideGuestInstance) {

    var resources = {
        cpus: 1,
        memory: 128
    };

    var hostConfig = {
        minContainerAge: 10,
        maxContainerNumber: 1,
        containerType: 'm2container',
        sshdCmd: "/usr/sbin/sshd -D",
        dockerRunCmd: '',
        host: '192.168.2.42',
        username: 'vagrant',
        port: '22',
        sshKey: "/home/vagrant/InteractiveShell/separate_machines/host_key"
    };

    var currentContainers = [];

    var guestInstance = {
        host: '192.168.2.42',
        username: 'm2user',
        port: '5000',
        sshKey: '/home/vagrant/InteractiveShell/separate_machines/docker_key',
        containerName: '',
        lastActiveTime: 0
    };

    var overrideDefaultOptions = function (overrideOptions, defaultOptions) {
        for (var opt in overrideOptions) {
            if (defaultOptions.hasOwnProperty(opt)) {
                defaultOoptions[opt] = overrideOptions[opt];
                logExceptOnTest("server option: " + opt + " set to " + defaultOptions[opt]);
            }
        }
    };

    overrideDefaultOptions(overrideResources, resources);
    overrideDefaultOptions(overrideHostConfig, hostConfig);
    overrideDefaultOptions(overrideGuestInstance, guestInstance);

    function init() {
        hostConfig.dockerRunCmd = 'sudo docker run -d';
        hostConfig.dockerRunCmd += ' -c ' + resources.cpus;
        hostConfig.dockerRunCmd += ' -m ' + resources.memory + 'm';
        hostConfig.dockerRunCmd += ' --name';
    }

    init();

    var getDockerStartCmd = function (instance) {
        var result = hostConfig.dockerRunCmd;
        result += ' ' + instance.containerName;
        result += ' -p ' + instance.port + ":22";
        result += ' ' + hostConfig.containerType + " " + hostConfig.sshdCmd;
        return result;
    };

    var removeInstance = function (instance, next) {
        console.log("Removing container: " + instance.containerName);
        if (instance.killNotify) {
            instance.killNotify();
        }
        var removalCommand = "sudo docker rm -f " + instance.containerName;
        connectToHostAndExecCmd(removalCommand, function (stream) {
            stream.on('data', function (dataObject) {
            });
            stream.stderr.on('data', function (dataObject) {
            });
            removeInstanceFromArray(instance);
            if (next) {
                next();
            }
        });
    };<commit_msg>cpuShares instead of cpus, to indicate that this does not mean the number of cpus.<commit_after>var ssh2 = require('ssh2');
var fs = require('fs');

var sshDockerManager = function (overrideResources, overrideHostConfig, overrideGuestInstance) {

    var resources = {
        cpuShares: 10, // minimum number is 2
        memory: 128
    };

    var hostConfig = {
        minContainerAge: 10,
        maxContainerNumber: 1,
        containerType: 'm2container',
        sshdCmd: "/usr/sbin/sshd -D",
        dockerRunCmd: '',
        host: '192.168.2.42',
        username: 'vagrant',
        port: '22',
        sshKey: "/home/vagrant/InteractiveShell/separate_machines/host_key"
    };

    var currentContainers = [];

    var guestInstance = {
        host: '192.168.2.42',
        username: 'm2user',
        port: '5000',
        sshKey: '/home/vagrant/InteractiveShell/separate_machines/docker_key',
        containerName: '',
        lastActiveTime: 0
    };

    var overrideDefaultOptions = function (overrideOptions, defaultOptions) {
        for (var opt in overrideOptions) {
            if (defaultOptions.hasOwnProperty(opt)) {
                defaultOoptions[opt] = overrideOptions[opt];
                logExceptOnTest("server option: " + opt + " set to " + defaultOptions[opt]);
            }
        }
    };

    overrideDefaultOptions(overrideResources, resources);
    overrideDefaultOptions(overrideHostConfig, hostConfig);
    overrideDefaultOptions(overrideGuestInstance, guestInstance);

    function init() {
        hostConfig.dockerRunCmd = 'sudo docker run -d';
        hostConfig.dockerRunCmd += ' -c ' + resources.cpuShares;
        hostConfig.dockerRunCmd += ' -m ' + resources.memory + 'm';
        hostConfig.dockerRunCmd += ' --name';
    }

    init();

    var getDockerStartCmd = function (instance) {
        var result = hostConfig.dockerRunCmd;
        result += ' ' + instance.containerName;
        result += ' -p ' + instance.port + ":22";
        result += ' ' + hostConfig.containerType + " " + hostConfig.sshdCmd;
        return result;
    };

    var removeInstance = function (instance, next) {
        console.log("Removing container: " + instance.containerName);
        if (instance.killNotify) {
            instance.killNotify();
        }
        var removalCommand = "sudo docker rm -f " + instance.containerName;
        connectToHostAndExecCmd(removalCommand, function (stream) {
            stream.on('data', function (dataObject) {
            });
            stream.stderr.on('data', function (dataObject) {
            });
            removeInstanceFromArray(instance);
            if (next) {
                next();
            }
        });
    };
{'fraction_non_alphanumeric': 0.11972227434790768, 'fraction_numerical': 0.014636892475136049, 'mean_word_length': 2.2759680393362016, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '1759654', 'n_tokens_mistral': 1575, 'n_tokens_neox': 1452, 'n_words': 308}