Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions server/app/engine/bots/scriptExecutor.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ function executeScriptOnLocal(botsScriptDetails,auditTrail,userName,botHostDetai
});
request.post(options, function (err, res, body) {
if (err) {
logger.error("Logging body"+JSON.stringify(body))
logger.error("Error: ",err)
logger.error(err);
var timestampEnded = new Date().getTime();
logsDao.insertLog({
referenceId: logsReferenceIds,
Expand Down
44 changes: 12 additions & 32 deletions server/app/services/botService.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,6 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
var botId = null;
var botRemoteServerDetails = {};
var bots = [];
var taskId = null;
var cryptoConfig = appConfig.cryptoSettings;
var cryptography = new Cryptography(cryptoConfig.algorithm, cryptoConfig.password);
logger.info("Entering WF");
async.waterfall([
function (next) {
Expand All @@ -375,30 +372,13 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
function (botList, next) {
bots = botList;
logger.info("Got Bots " + JSON.stringify(bots));
if(bots.length > 0) {
if(bots[0].params){
if(bot[0].params.data){
if(bot[0].params.data.sysid){
sysId = bot[0].params.data.sysid
logger.info("Task ID",sysId)
var decryptedTaskId = cryptography.decryptText(sysId, cryptoConfig.decryptionEncoding,
cryptoConfig.encryptionEncoding);
logger.info("Decrypted Task ID",decryptedTaskId)
taskId = decryptedTaskId
logger.info(taskId)
}else{
logger.info("Task ID does not exist")
}
}
}
}
if (schedulerCallCheck)
scheduledBots.getScheduledBotsByBotId(botsId, next);
else next(null, []);
},
function (scheduledBots, next) {
if (bots.length > 0) {
logger.info("task_id"+taskId+" Got Bots " + JSON.stringify(scheduledBots));
logger.info("Got Bots " + JSON.stringify(scheduledBots));
botId = bots[0]._id;
if (scheduledBots.length > 0) {
//included check for params if empty.
Expand All @@ -413,31 +393,31 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
//logger.info("Executing BOTs Deatails", bots[0].execution[0].os, bots[0].execution[0].type);
masterUtil.getBotRemoteServerDetailByOrgId(bots[0].orgId, function (err, botServerDetails) {
if (err) {
logger.error("task_id"+taskId+" Error while fetching BOTs Server Details");
logger.error("Error while fetching BOTs Server Details");
callback(err, null);
return;

} else if (botServerDetails !== null && botServerDetails.length > 0) {
logger.info("task_id"+taskId+" Checking flag status--->", appConfig.enableBotExecuterOsCheck)
logger.info("Checking flag status--->", appConfig.enableBotExecuterOsCheck)
if (bots[0].type === 'blueprints') {
botRemoteServerDetails.hostIP = botServerDetails[0].hostIP;
botRemoteServerDetails.hostPort = botServerDetails[0].hostPort;
} else {
//As env variable will always be in string changed the check value to string
if (appConfig.enableBotExecuterOsCheck === true || process.env.enableBotExecuterOsCheck === 'true') {
logger.info("task_id"+taskId+" Inn OS check condition");
logger.info("Inn OS check condition");
executorOsTypeConditionCheck(botServerDetails, botRemoteServerDetails, bots);
} else {

botRemoteServerDetails.hostIP = botServerDetails[0].hostIP;
botRemoteServerDetails.hostPort = botServerDetails[0].hostPort;
logger.info("task_id"+taskId+" Default Details as working without Multiple executor feature", botRemoteServerDetails.hostIP, botRemoteServerDetails.hostPort);
logger.info("Default Details as working without Multiple executor feature", botRemoteServerDetails.hostIP, botRemoteServerDetails.hostPort);
}
}
encryptedParam(reqBody, next);
} else {
var error = new Error();
error.message = 'task_id'+taskId+' BOTs Remote Engine is not configured or not in running mode';
error.message = 'BOTs Remote Engine is not configured or not in running mode';
error.status = 403;
//next(error, null);
encryptedParam(reqBody, next);
Expand All @@ -448,7 +428,7 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi

} else {
var error = new Error();
error.message = 'task_id'+taskId+' There is no record available in DB against BOT : ' + botsId;
error.message = 'There is no record available in DB against BOT : ' + botsId;
error.status = 403;
next(error, null);
}
Expand All @@ -460,15 +440,15 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
if (reqBody.nodeIds) {
botObj.params.nodeIds = reqBody.nodeIds;
}
logger.info("task_id"+taskId+" Updating bot details" + JSON.stringify(botObj));
logger.info("Updating bot details" + JSON.stringify(botObj));
botDao.updateBotsDetail(botId, botObj, next);
},
function (updateStatus, next) {
botDao.getBotsById(botId, next);
},
function (botDetails, next) {
if (botDetails.length > 0) {
logger.info("task_id"+taskId+" Executor in parallel " + JSON.stringify(botDetails));
logger.info("Executor in parallel " + JSON.stringify(botDetails));
async.parallel({
executor: function (callback) {
async.waterfall([
Expand Down Expand Up @@ -569,17 +549,17 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
}
});
} else {
logger.info("task_id"+taskId+" No Botdetails found ");
logger.info("No Botdetails found ");
next(null, botDetails);
}
}
], function (err, results) {
if (err) {
logger.error("task_id"+taskId+" "+ err);
logger.error(err);
callback(err, null);
return;
} else {
logger.info("task_id"+taskId+" Completed Bot execution " + JSON.stringify(results));
logger.info("Completed Bot execution " + JSON.stringify(results));
callback(null, results);
return;
}
Expand Down