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
47 changes: 32 additions & 15 deletions server/app/routes/v1.0/routes_serviceStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,55 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// The file contains all the end points for Tracks

var logger = require('_pr/logger')(module);
var request = require("request");
var https = require("https");
var errorResponses = require('./error_responses');
var appConfig = require('_pr/config');


module.exports.setRoutes = function(app, sessionVerificationFunc) {
app.all('/serviceAction/*', sessionVerificationFunc);

// Check for Service stop
app.post('/serviceAction', function(req, res) {

console.log(req.body);
var post_data = {
"cmd": req.body.cmd,
"type": req.body.type,
"hosts": req.body.hosts
};

request({
url: 'https://52.8.208.191/api/v1/webhooks/remotecmd?st2-api-key=YTU0M2RlNmMwMjdhMzFlNzVmMTExZDA4YWExMWY5MmFjOTUyYzc2Nzk5YjMzYmM4ZjAwNWJiYjc2NjFmZjY1MA',
body: post_data,
method: 'post',
json: true,
}, function(err, httpResponse, body) {
if (err) {
res.status(500).send(err);
return;
post_data = JSON.stringify(post_data);


var post_options = {
host: appConfig.serverControllerUrl,
port: 443,
path: '/api/v1/webhooks/remotecmd?st2-api-key='+appConfig.serviceControllerKey,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(post_data)
}
res.status(200).send(body);
};


var post_req = https.request(post_options, function(httpsRes) {
httpsRes.setEncoding('utf8');
var data = '';
httpsRes.on('data', function(chunk) {
data = data + chunk
console.log('Response: ' + chunk);
});
httpsRes.on('end', function(chunk) {
res.status(200).send(data);
});
httpsRes.on('error', function(err) {
res.status(500).send(err);
});
});

post_req.write(post_data);
post_req.end();

});
};
2 changes: 2 additions & 0 deletions server/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ function getDefaultsConfig() {
return config.catalystHome + this.cookbooksDirName + "/";
}
},
serviceControllerKey:'ZDQ2YWM3ZTUyZDhhZjhhOWRkMWQ2ZTc3NDhhNjk1OWEyYzgxZGJkMWVjYjA3ZThiZjY0NTBjYjBjMTM5YzA0Yg',
serverControllerUrl:'stackstorm.rlcatalyst.com',
constantData: {
common_field: ['envId', 'providerId', 'orgId', 'bgId','organizationId','businessGroupId', 'projectId','templateType','blueprintConfig.cloudProviderType','cloudProviderType'],
sort_field: ['name', 'description'],
Expand Down