diff options
author | Chinthakayala, Sheshashailavas (sc2914) <sc2914@us.att.com> | 2017-08-28 05:25:46 -0900 |
---|---|---|
committer | Chinthakayala, Sheshashailavas (sc2914) <sc2914@att.com> | 2017-08-28 05:36:52 -0900 |
commit | d1569975bb18f4359fac18aa98f55b69c248a3ad (patch) | |
tree | c8681eeac12dca8673ccf841705daac88bf01ca6 /dgbuilder/red/sla.js | |
parent | a016ea661ff5767a3539734c4c07ef974a6e4614 (diff) |
[CCSDK-28] populated the seed code for dgbuilder
updated the code to point to the new package name for sli
Change-Id: I3b5a1d05dc5193664fd4a667afdcd0b2354010a4
Issue-ID:{CCSDK-28}
Signed-off-by: Chinthakayala, Sheshashailavas (sc2914) <sc2914@att.com>
Signed-off-by: Chinthakayala, Sheshashailavas (sc2914) <sc2914@att.com>
Diffstat (limited to 'dgbuilder/red/sla.js')
-rw-r--r-- | dgbuilder/red/sla.js | 249 |
1 files changed, 249 insertions, 0 deletions
diff --git a/dgbuilder/red/sla.js b/dgbuilder/red/sla.js new file mode 100644 index 00000000..1729ecbb --- /dev/null +++ b/dgbuilder/red/sla.js @@ -0,0 +1,249 @@ +exports.listSLA = function(settings,req,res) { +try{ + var mysql = require('mysql'); + + //console.dir(settings); + + var connection = mysql.createConnection( + { + host : settings.dbHost, + port : settings.dbPort, + user : settings.dbUser, + password : settings.dbPassword, + database : settings.dbName + }); + + var rows=[]; + + var sqlQuery = "SELECT module,rpc,version,mode,active FROM SVC_LOGIC"; + //console.log("sqlQuery:" + sqlQuery); + connection.query(sqlQuery, function(err, rows) { + if(!err) { + if ( rows.length > 0 ) + { + res.send({ 'rows': rows,'dbHost':settings.dbHost } ); + }else{ + res.send({'rows': [],'dbHost':settings.dbHost}); + } + } else { + console.log("error:" + err); + res.send({error: "Connection to DB failed.",'dbHost':settings.dbHost}); + } + //console.dir(rows); + connection.end(); + }); //end query +}catch(error){ + console.log(error); + res.send({'error': "Connection to DB failed.",'dbHost':settings.dbHost}); +} +} + +exports.listCurrentDGs = function(settings,req,res) { + var _module = req.query.module; + var rpc = req.query.rpc; + console.log("_module:" + _module); + console.log("rpc:" + rpc); +try{ + var mysql = require('mysql'); + + //console.dir(settings); + + var connection = mysql.createConnection( + { + host : settings.dbHost, + port : settings.dbPort, + user : settings.dbUser, + password : settings.dbPassword, + database : settings.dbName + }); + + var rows=[]; + + var sqlQuery = "SELECT module,rpc,version,mode,active FROM SVC_LOGIC where module ='" + _module + "' and rpc ='" + rpc + "'"; + console.log("sqlQuery:" + sqlQuery); + connection.query(sqlQuery, function(err, rows) { + if(!err) { + if ( rows.length > 0 ) + { + res.send({ 'rows': rows,'dbHost':settings.dbHost } ); + }else{ + res.send({'rows': [],'dbHost':settings.dbHost}); + } + } else { + console.log("error:" + err); + res.send({error: "Connection to DB failed.",'dbHost':settings.dbHost}); + } + //console.dir(rows); + connection.end(); + }); //end query +}catch(error){ + console.log(error); + res.send({'error': "Connection to DB failed.",'dbHost':settings.dbHost}); +} +} + +exports.activateDG = function(settings,req,res){ + var _module = req.query.module; + var rpc = req.query.rpc; + var version = req.query.version; + var mode = req.query.mode; + var displayOnlyCurrent = req.query.displayOnlyCurrent; + +try{ + var mysql = require('mysql'); + + var connection = mysql.createConnection( + { + host : settings.dbHost, + port : settings.dbPort, + user : settings.dbUser, + password : settings.dbPassword, + database : settings.dbName + }); + + var rows=[]; + + var updateStmt = "UPDATE SVC_LOGIC SET active=\'Y\' WHERE module=\'" + + _module + "' AND rpc=\'" + + rpc + "' AND version=\'" + + version + "' AND mode=\'" + + mode + "'"; + + connection.query(updateStmt, function(err, result) { + var nextUpdateStmt = "UPDATE SVC_LOGIC SET active=\'N\' WHERE module=\'" + + _module + "' AND rpc=\'" + + rpc + "' AND version !=\'" + + version + "'"; + connection.query(nextUpdateStmt, function(err, result) { + var query = "SELECT module,rpc,version,mode,active FROM SVC_LOGIC"; + if(displayOnlyCurrent == 'true'){ + query = "SELECT module,rpc,version,mode,active FROM SVC_LOGIC WHERE module=\'" + + _module + "' and rpc=\'" + rpc + "'"; + } + connection.query(query, function(err, rows) { + if(!err) { + if ( rows.length > 0 ) + { + res.send({ 'rows': rows,'dbHost':settings.dbHost } ); + }else{ + res.send({'rows': [],'dbHost':settings.dbHost}); + } + } else { + res.send({'error': "Connection to DB failed.",'dbHost':settings.dbHost}); + } + connection.end(); + }); //end query + }); //end query + }); //end query +}catch(error){ + res.send({'error': "Connection to DB failed.",'dbHost':settings.dbHost}); +} +} + + +exports.deActivateDG = function(settings,req,res){ + + var _module = req.query.module; + var rpc = req.query.rpc; + var version = req.query.version; + var mode = req.query.mode; + var displayOnlyCurrent = req.query.displayOnlyCurrent; + +try{ + var mysql = require('mysql'); + + var connection = mysql.createConnection( + { + host : settings.dbHost, + port : settings.dbPort, + user : settings.dbUser, + password : settings.dbPassword, + database : settings.dbName + }); + + var rows=[]; + + var updateStmt = "UPDATE SVC_LOGIC SET active=\'N\' WHERE module=\'" + + _module + "' AND rpc=\'" + + rpc + "' AND version=\'" + + version + "' AND mode=\'" + + mode + "'"; + + connection.query(updateStmt, function(err, result) { + var query = "SELECT module,rpc,version,mode,active FROM SVC_LOGIC"; + if(displayOnlyCurrent == 'true'){ + query = "SELECT module,rpc,version,mode,active FROM SVC_LOGIC WHERE module=\'" + + _module + "' and rpc=\'" + rpc + "'"; + } + connection.query(query, function(err, rows) { + if(!err) { + if ( rows.length > 0 ) + { + res.send({ 'rows': rows,'dbHost':settings.dbHost } ); + }else{ + res.send({'rows': [],'dbHost':settings.dbHost}); + } + } else { + res.send({'error': "Connection to DB failed.",'dbHost':settings.dbHost}); + } + connection.end(); + }); //end query + }); //end query +}catch(error){ + res.send({'error': "Connection to DB failed.",'dbHost':settings.dbHost}); +} +} + +exports.deleteDG = function(settings,req,res){ + + var _module = req.query.module; + var rpc = req.query.rpc; + var version = req.query.version; + var mode = req.query.mode; + var displayOnlyCurrent = req.query.displayOnlyCurrent; + +try{ + var mysql = require('mysql'); + + var connection = mysql.createConnection( + { + host : settings.dbHost, + port : settings.dbPort, + user : settings.dbUser, + password : settings.dbPassword, + database : settings.dbName + }); + + var rows=[]; + + var deleteStmt = "DELETE FROM SVC_LOGIC WHERE module=\'" + + _module + "' AND rpc=\'" + + rpc + "' AND version=\'" + + version + "' AND mode=\'" + + mode + "'"; + console.log(deleteStmt); + + connection.query(deleteStmt, function(err, result) { + var query = "SELECT module,rpc,version,mode,active FROM SVC_LOGIC"; + if(displayOnlyCurrent == 'true'){ + query = "SELECT module,rpc,version,mode,active FROM SVC_LOGIC WHERE module=\'" + + _module + "' and rpc=\'" + rpc + "'"; + } + connection.query(query, function(err, rows) { + if(!err) { + if ( rows.length > 0 ) + { + res.send({ 'rows': rows,'dbHost':settings.dbHost } ); + }else{ + res.send({'rows': [],'dbHost':settings.dbHost}); + } + } else { + res.send({'error': "Connection to DB failed.",'dbHost':settings.dbHost}); + } + connection.end(); + }); //end query + }); //end query +}catch(error){ + res.send({'error': "Connection to DB failed.",'dbHost':settings.dbHost}); +} +} |