Skip to content

Instantly share code, notes, and snippets.

@dfranciosi
Created October 5, 2017 09:13
Show Gist options
  • Save dfranciosi/3bba0fbc87e4007cf49268055ad9f97f to your computer and use it in GitHub Desktop.
Save dfranciosi/3bba0fbc87e4007cf49268055ad9f97f to your computer and use it in GitHub Desktop.
const pipelineState = require('state').pipeline;
const fs = require('fs');
const log = require('log');
const moment = require('moment');
const config = require('config');
module.exports = (done) => {
log.info('[STEP][NMS] Dumping backup infos');
const activeNEs = pipelineState.get('activeNEs');
const errorStack = pipelineState.get('errorStack');
if (!activeNEs) return done();
if (!errorStack) return done();
fs.writeFile(`${config.baseProjectFolder}/opt/sarah2/active_nes_${moment().format('DDMMYYYYHHmm')}.txt`, activeNEs.join('\n'), (err) => {
if(err) {
return log.error(`[STEP][NMS] Error dumping active NEs ${err.message}`);
}
log.info('[STEP][NMS] Active NEs dumped.');
const content = errorStack.map((e) => [e.networkElement, e.error.message].join(','));
fs.writeFile(`${config.baseProjectFolder}/opt/sarah2/nms_error_stack_${moment().format('DDMMYYYYHHmm')}.txt`, content.join('\n'), (err) => {
if(err) {
return log.error(`[STEP][NMS] Error dumping Error Stack ${err.message}`);
}
log.info('[STEP][NMS] Error Stack dumped dumped.');
return done();
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment