Skip to content

Commit

Permalink
Iotronic 2.3.5: bug fixed in Service Manager (port generation).
Browse files Browse the repository at this point in the history
  • Loading branch information
npeditto committed Jun 19, 2019
1 parent fe6b7af commit 5a59ccd
Show file tree
Hide file tree
Showing 7 changed files with 1,065 additions and 233 deletions.
5 changes: 4 additions & 1 deletion lib/management/mng_db.js
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,10 @@ db_utils.prototype.changeBoardWampStatus = function (board_id, session, status,
message: '',
result: ''
};
connection.query("UPDATE boards SET board_id=" + mysql.escape(board_id) + ", session_id=" + mysql.escape(session) + ", status=" + mysql.escape(status) + " WHERE board_id=" + mysql.escape(board_id), function (err, result) {

var conn_time = new Date().toISOString().replace(/\..+/, '');

connection.query("UPDATE boards SET conn_time=" + mysql.escape(conn_time) + ", board_id=" + mysql.escape(board_id) + ", session_id=" + mysql.escape(session) + ", status=" + mysql.escape(status) + " WHERE board_id=" + mysql.escape(board_id), function (err, result) {
if (err != null) {
response.result = "ERROR";
response.message = err;
Expand Down
196 changes: 8 additions & 188 deletions lib/modules/plugin_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,18 @@ plugin_utils = function (session, rest) {
* plugin_id:
* type: integer
* description: "The IoTronic plugin ID"
* latest_change:
* plugin_name:
* type: string
* description: "Timestamp of the latest plugin state update."
* description: "Plugin name"
* state:
* type: string
* description: "Plugin status: 'injected', 'executed', 'running', 'killed'"
* latest_change:
* type: string
* description: "Timestamp of the latest plugin state update."
* parameters:
* type: object
* description: "latest JSON parameters injected"
* 403:
* description: "Wrong, expired or not specified token in request header."
* 500:
Expand Down Expand Up @@ -2634,49 +2640,6 @@ plugin_utils.prototype.managePlugins = function (board, request_id, args) {

}

/*
computeParameters(board, plugin, parameters, parameters_set, plugin_defaults,
function (cparams) {
console.log("FFFFFFFFFFFFFFFFFFFFF\nPARAMS COMPUTED: " + cparams.message + "\nFFFFFFFFFFFFFFFFFFFFF");
}
);
computeParameters(board, plugin, parameters, parameters_set, plugin_defaults,
function (cparams) {
if(cparams.result == "ERROR"){
if(res != false){
logger.warn("[PLUGIN] --> " + cparams.message);
res.status(500).send(cparams);
}else{
request_utils.updateResult(request_id, board, cparams.result, cparams.message);
}
}
else{
console.log("FFFFFFFFFFFFFFFFFFFFF\nPARAMS COMPUTED: " + cparams.message + "\nFFFFFFFFFFFFFFFFFFFFF");
}
}
);
*/



switch (plugin_operation) {

case 'run':
Expand Down Expand Up @@ -2833,149 +2796,6 @@ plugin_utils.prototype.managePlugins = function (board, request_id, args) {
}
);


/*
if (parameters == "" || parameters == undefined) {
response.message = "WARNING - ASYNC PLUGIN '" + plugin_name + "' has not parameters!";
response.result = "ERROR";
if(res != false){
logger.warn("[PLUGIN] --> " + response.message);
res.status(500).send(response);
}else{
request_utils.updateResult(request_id, board, response.result, response.message);
}
}
else {
if(res != false)
logger.debug("[PLUGIN] --> Plugin '" + plugin_name + "' parameters:\n " + parameters);
//I need to read the category of the plugin from the DB
db.getPluginCategory(plugin_name, function (data) {
if (data.result == "ERROR") {
response.message = data.message;
response.result = "ERROR";
if(res != false){
logger.warn("[PLUGIN] --> " + response.message);
res.status(500).send(response);
}else{
request_utils.updateResult(request_id, board, response.result, response.message);
}
} else {
var plugincategory = data.message[0].category;
if(res != false)
logger.debug("[PLUGIN] --> Plugin category: " + plugincategory);
if (plugincategory === "async") {
session_wamp.call('s4t.'+ board + '.plugin.run', [plugin_name, parameters, plugin_checksum]).then(
function (rpc_response) {
if (rpc_response.result == "ERROR") {
response.message = rpc_response.message;
response.result = "ERROR";
db.updatePluginStatus(board, plugin, "failed", function (out) {
if(res != false){
logger.debug("[PLUGIN] ----> " + out.message);
logger.warn("[PLUGIN] --> Start plugin error for '" + plugin_name + "': " + JSON.stringify(response.message, null, "\t"));
res.status(500).send(response);
}else{
request_utils.updateResult(request_id, board, response.result, response.message);
}
});
}
else if (rpc_response.result == "SUCCESS"){
response.message = rpc_response.message;
response.result = "SUCCESS";
db.updatePluginStatus(board, plugin, "running", function (out) {
if(res != false){
logger.debug("[PLUGIN] ----> " + out.message);
logger.info("[PLUGIN] --> Start plugin result for '" + plugin_name + "': " + response.message);
res.status(200).send(response);
}else{
request_utils.updateResult(request_id, board, response.result, response.message);
}
});
}else {
response.message = rpc_response.message;
response.result = rpc_response.result;
if(res != false){
logger.warn("[PLUGIN] --> Running warning result for '" + plugin_name + "' plugin: " + response.message);
res.status(500).send(response);
}else{
request_utils.updateResult(request_id, board, response.result, response.message);
}
}
},
function (error) {
response.message = error.args[0].message;
response.result = "ERROR";
if(res != false)
logger.error("[PLUGIN] --> Plugin error '" + plugin_name + "': " + JSON.stringify(response.message));
db.updatePluginStatus(board, plugin, "failed", function (out) {
if(res != false){
logger.debug("[PLUGIN] ----> " + out.message);
logger.info("[PLUGIN] --> Error starting plugin '" + plugin_name + "': " + response.message);
res.status(500).send(response);
}else{
request_utils.updateResult(request_id, board, response.result, response.message);
}
});
}
);
} else {
response.message = "Operation 'run' not supported for this plugin category!";
response.result = "ERROR";
if(res != false){
logger.warn("[PLUGIN] ----> " + response.message);
res.status(500).send(response);
}else{
request_utils.updateResult(request_id, board, response.result, response.message);
}
}
}
});
}
*/

break;


Expand Down
Loading

0 comments on commit 5a59ccd

Please sign in to comment.