<commit_before>// Copyright © 2017 Dell Inc. or its subsidiaries. All Rights Reserved.

'use strict';

var di = require('di');
var urlParse = require('url-parse');

module.exports = wsmanServiceFactory;
di.annotate(wsmanServiceFactory, new di.Provide('Http.Services.Wsman'));
di.annotate(wsmanServiceFactory,
    new di.Inject(
        'Services.Waterline',
        'Services.Encryption',
        'Services.Configuration',
        'JobUtils.WsmanTool',
        'Errors'
    )
);
function wsmanServiceFactory(
    waterline,
    encryption,
    configuration,
    WsmanTool,
    errors
) {

    //var logger = Logger.initialize(wsmanServiceFactory);

    function WsmanService() {
        this.dellConfigs = null;
    }

    WsmanService.prototype.init = function (node) {
    	var self = this;
        return waterline.obms.findByNode(node.id, 'dell-wsman-obm-service', true)
        .then(function(obm) {
            if (!obm) { throw new errors.NotFoundError('Failed to find Wsman obm settings'); }
            self.dellConfigs = configuration.get('dell');
            if (!self.dellConfigs) {
            	throw new errors.NotFoundError(
                    'Configuration for WSMan web services is not defined in wsmanConfig.json.');
            }
            var parse = urlParse(self.dellConfigs.gateway);
            
            var protocol = parse.protocol.replace(':','').trim();
            self.settings = {
                uri: parse.href,
                host: parse.host.split(':')[0],
                root: parse.pathname,
                port: parse.port,
                protocol: protocol,
                verifySSL: false,
                recvTimeoutMs: 30000
            };
            self.wsman = new WsmanTool();
            self.wsman.settings = self.settings;
            
            self.target = {
                address: obm.config.host,
                userName: obm.config.user,
                password: encryption.decrypt(obm.config.password)
            };
        });<commit_msg>refactor WsmanTool<commit_after>// Copyright © 2017 Dell Inc. or its subsidiaries. All Rights Reserved.

'use strict';

var di = require('di');

module.exports = wsmanServiceFactory;
di.annotate(wsmanServiceFactory, new di.Provide('Http.Services.Wsman'));
di.annotate(wsmanServiceFactory,
    new di.Inject(
        'Services.Waterline',
        'Services.Encryption',
        'Services.Configuration',
        'JobUtils.WsmanTool',
        'Errors'
    )
);
function wsmanServiceFactory(
    waterline,
    encryption,
    configuration,
    WsmanTool,
    errors
) {

    //var logger = Logger.initialize(wsmanServiceFactory);

    function WsmanService() {
        this.dellConfigs = null;
    }

    WsmanService.prototype.init = function (node) {
    	var self = this;
        return waterline.obms.findByNode(node.id, 'dell-wsman-obm-service', true)
        .then(function(obm) {
            if (!obm) { throw new errors.NotFoundError('Failed to find Wsman obm settings'); }
            self.dellConfigs = configuration.get('dell');
            if (!self.dellConfigs) {
            	throw new errors.NotFoundError(
                    'Configuration for WSMan web services is not defined in wsmanConfig.json.');
            }
            
            self.wsman = new WsmanTool(self.dellConfigs.gateway, {
                verifySSL: false,
                recvTimeoutMs: 30000
            });
            
            self.target = {
                address: obm.config.host,
                userName: obm.config.user,
                password: <PASSWORD>(obm.config.password)
            };
        });
{'fraction_non_alphanumeric': 0.11086596800882516, 'fraction_numerical': 0.005239933811362383, 'mean_word_length': 1.951179820992677, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2203560', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1021, 'n_words': 215}