<commit_before>// Copyright 2015, EMC, Inc.

'use strict';

var di = require('di'),
    util = require('util');

module.exports = ipmiObmServiceFactory;

di.annotate(ipmiObmServiceFactory, new di.Provide('ipmi-obm-service'));
di.annotate(ipmiObmServiceFactory, new di.Inject('OBM.base', 'Promise'));

function ipmiObmServiceFactory(BaseObmService, Promise) {
    function IpmiObmService(options) {
        BaseObmService.call(this, options);
        this.requiredKeys = ['password', 'host', 'user'];
    }
    util.inherits(IpmiObmService, BaseObmService);

    IpmiObmService.prototype.mcResetCold = function() {
        return this._runInternal(['mc', 'reset', 'cold']);
    };

    IpmiObmService.prototype.mcInfo = function() {
        return this._runInternal(['mc', 'info']);
    };

    IpmiObmService.prototype.identifyOn = function() {
        return this._runInternal(['chassis', 'identify', 'force']);
    };

    IpmiObmService.prototype.identifyOff = function() {
        return this._runInternal(['chassis', 'identify', '0']);
    };

    IpmiObmService.prototype.reboot = function() {
        return this._runInternal(['chassis', 'power', 'cycle']);
    };

    IpmiObmService.prototype.powerOn = function() {
        return this._runInternal(['chassis', 'power', 'on']);
    };

    IpmiObmService.prototype.powerOff = function() {
        return this._runInternal(['chassis', 'power', 'off']);
    };

    IpmiObmService.prototype.powerStatus = function() {
        return this._runInternal(['chassis', 'power', 'status']).then(function (result) {
            if (result && result.stdout) {
                return Promise.resolve(result.stdout.indexOf('Chassis Power is on') >= 0);
            } else {
                return Promise.reject(
                    new Error('Unable to determine power state (' + result.stdout + ').')
                );
            }
        });
    };

    IpmiObmService.prototype.setBootPxe = function() {
        return this._runInternal(['chassis', 'bootdev', 'pxe']);
    };
    
    /*
    * Force system to boot PXE without clearing PXE bootflag by 60s timeout and PEF resets.
    */
    IpmiObmService.prototype.forceBootPxe = function() {
        return this._runInternal(
            ['chassis', 'bootparam', 'set', 'bootflag', 'force_pxe', 'options=no-timeout,no-PEF']
        );
    };
<commit_msg>Disable timer prior to setting pxe boot dev - Some HW takes longer then one minute to come up<commit_after>// Copyright 2015, EMC, Inc.

'use strict';

var di = require('di'),
    util = require('util');

module.exports = ipmiObmServiceFactory;

di.annotate(ipmiObmServiceFactory, new di.Provide('ipmi-obm-service'));
di.annotate(ipmiObmServiceFactory, new di.Inject('OBM.base', 'Promise'));

function ipmiObmServiceFactory(BaseObmService, Promise) {
    function IpmiObmService(options) {
        BaseObmService.call(this, options);
        this.requiredKeys = ['password', 'host', 'user'];
    }
    util.inherits(IpmiObmService, BaseObmService);

    IpmiObmService.prototype.mcResetCold = function() {
        return this._runInternal(['mc', 'reset', 'cold']);
    };

    IpmiObmService.prototype.mcInfo = function() {
        return this._runInternal(['mc', 'info']);
    };

    IpmiObmService.prototype.identifyOn = function() {
        return this._runInternal(['chassis', 'identify', 'force']);
    };

    IpmiObmService.prototype.identifyOff = function() {
        return this._runInternal(['chassis', 'identify', '0']);
    };

    IpmiObmService.prototype.reboot = function() {
        return this._runInternal(['chassis', 'power', 'cycle']);
    };

    IpmiObmService.prototype.powerOn = function() {
        return this._runInternal(['chassis', 'power', 'on']);
    };

    IpmiObmService.prototype.powerOff = function() {
        return this._runInternal(['chassis', 'power', 'off']);
    };

    IpmiObmService.prototype.powerStatus = function() {
        return this._runInternal(['chassis', 'power', 'status']).then(function (result) {
            if (result && result.stdout) {
                return Promise.resolve(result.stdout.indexOf('Chassis Power is on') >= 0);
            } else {
                return Promise.reject(
                    new Error('Unable to determine power state (' + result.stdout + ').')
                );
            }
        });
    };

    IpmiObmService.prototype.setBootPxe = function() {
        // Disable timer (60s) raw 0x00 0x08 0x03 0x08
        var self = this;
        return self._runInternal(['raw', '0x00', '0x08', '0x03', '0x08'])
        .then(function(){
              return self._runInternal(['chassis', 'bootdev', 'pxe']);
        });
    };
    
    /*
    * Force system to boot PXE without clearing PXE bootflag by 60s timeout and PEF resets.
    */
    IpmiObmService.prototype.forceBootPxe = function() {
        return this._runInternal(
            ['chassis', 'bootparam', 'set', 'bootflag', 'force_pxe', 'options=no-timeout,no-PEF']
        );
    };

{'fraction_non_alphanumeric': 0.1521216973578863, 'fraction_numerical': 0.008406725380304243, 'mean_word_length': 2.8826728826728827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3375823', 'n_tokens_mistral': 1588, 'n_tokens_neox': 1513, 'n_words': 299}