From b86a8dc0f2f6dc82147ef8c410eeaf536b693048 Mon Sep 17 00:00:00 2001 From: Vinod Nair Date: Wed, 18 Jul 2018 11:11:39 +0530 Subject: [PATCH 1/2] Included Ohio region and runlist changes for CFT --- .../cloud-formation-blueprint.js | 19 +++- server/app/services/blueprintService.js | 89 ++++++++++--------- server/install.js | 8 +- 3 files changed, 71 insertions(+), 45 deletions(-) diff --git a/server/app/model/blueprint/blueprint-types/cloud-formation-blueprint/cloud-formation-blueprint.js b/server/app/model/blueprint/blueprint-types/cloud-formation-blueprint/cloud-formation-blueprint.js index 33bb2c330..393929b8b 100755 --- a/server/app/model/blueprint/blueprint-types/cloud-formation-blueprint/cloud-formation-blueprint.js +++ b/server/app/model/blueprint/blueprint-types/cloud-formation-blueprint/cloud-formation-blueprint.js @@ -785,12 +785,29 @@ CloudFormationBlueprintSchema.methods.launch = function (launchParams, callback) } if(launchParams.orgName) { - launchParams.monitor.parameters.orgName = launchParams.orgName; + var orgNameString = launchParams.orgName; + if(Array.isArray(orgNameString)) + orgNameString = orgNameString[0]; + launchParams.monitor.parameters.orgName = orgNameString; + //Adding to sensu-client cookbook attribute. + jsonAttributes['sensu-client'] = { + "check-tenant-id": orgNameString + } } //jsonAttributes['sensu-client'] = masterUtil.getSensuCookbookAttributes(launchParams.monitor, instance.id); //Changed based on new sensu and consul server configurations. jsonAttributes['consul-client-demo'] = masterUtil.getSensuCookbookAttributes(launchParams.monitor, instance.id); } + //Adding ipAddress to Attributes of all instances. Required only for the demo cookbook + var ipAddresses = []; + for (var x = 0; x < instances.length; x++) { + ipAddresses.push(instances[x].PrivateIpAddress); + } + ipAddresses = ipAddresses.join(','); + jsonAttributes['cft-rlc-demo'] = { + "ipAddresses":ipAddresses + } + logger.debug('Attributes: ', JSON.stringify(jsonAttributes)); logger.debug("runlist: ", JSON.stringify(runlist)); launchParams.infraManager.bootstrapInstance({ diff --git a/server/app/services/blueprintService.js b/server/app/services/blueprintService.js index b76679200..ea75096f2 100644 --- a/server/app/services/blueprintService.js +++ b/server/app/services/blueprintService.js @@ -407,49 +407,52 @@ blueprintService.launch = function launch(blueprintId,reqBody, callback) { Array.isArray(instId) ? instanceXId = instId[0] : instanceXId=results.id var instancePollObject = setInterval(()=> { instancesDao.getInstanceById(instanceXId, (err, resultx)=> { - if(err) cbx(err) - else{ - var result = resultx[0] - if(result.instanceState === 'running' && !jobDone) - { - logger.info('Blueprint succesfully launched and bootstrapped') - jobDone = true - clearInterval(instancePollObject) - async.each(result.appUrls, (urlObj, cb)=> { - var hcUrl = urlObj.url - var hcMod = hcUrl.replace('$host',result.instanceIP) - logger.info('HEALTH CHECK URL '+ hcMod) - var intervalBusService = setInterval(()=> { - commandCentre.createBusinessService(hcMod, result.chefNodeName, result.chefNodeName, result.chefNodeName, (error, res) => { - - if(!error){ - clearInterval(intervalBusService) - logger.info('Business service event in DBoard triggered successfully for '+ result.instanceIP) - cb() - } - else{ - logger.info(JSON.stringify(error)) - } - }) - }, 3000, 5) - }, (err)=> { - if(!err){ - logger.info('Business Services set created successfully') - } - else{ - logger.info('No response from Command Center. Giving Up') - } - }) - } - else if (result.instanceState === 'failed'){ - jobDone = true - logger.info('Blueprint launch failed') - logger.info(result.body) - clearInterval(instancePollObject) - } - } - }) - }, 10000) + if(err) cbx(err) + else { + var result = resultx[0]; + if(result){ + if (result.instanceState) { + + if (result.instanceState === 'running' && !jobDone) { + logger.info('Blueprint succesfully launched and bootstrapped') + jobDone = true + clearInterval(instancePollObject) + async.each(result.appUrls, (urlObj, cb) => { + var hcUrl = urlObj.url + var hcMod = hcUrl.replace('$host', result.instanceIP) + logger.info('HEALTH CHECK URL ' + hcMod) + var intervalBusService = setInterval(() => { + commandCentre.createBusinessService(hcMod, result.chefNodeName, result.chefNodeName, result.chefNodeName, (error, res) => { + if (!error) { + clearInterval(intervalBusService) + logger.info('Business service event in DBoard triggered successfully for ' + result.instanceIP) + cb() + } + else { + logger.info(JSON.stringify(error)) + } + }) + }, 3000, 5) + }, (err) => { + if (!err) { + logger.info('Business Services set created successfully') + } + else { + logger.info('No response from Command Center. Giving Up') + } + }) + } + else if (result.instanceState === 'failed') { + jobDone = true + logger.info('Blueprint launch failed') + logger.info(result.body) + clearInterval(instancePollObject) + } + } + } + } + }) + }, 10000) callback(null, results); return; } diff --git a/server/install.js b/server/install.js index 8ec09c44b..b5e605639 100755 --- a/server/install.js +++ b/server/install.js @@ -177,6 +177,9 @@ function getDefaultsConfig() { regions: [{ region_name: "US East (N. Virginia)", region: "us-east-1" + },{ + region_name: "US East (Ohio)", + region: "us-east-2" }, { region_name: "US West (Oregon)", region: "us-west-2" @@ -249,7 +252,7 @@ function getDefaultsConfig() { NetworkOut: 'MB' }, costData:{ - regions:['us-east-1','us-west-2','us-west-1','eu-west-1','eu-central-1','ap-southeast-1','ap-northeast-1','ap-southeast-2','sa-east-1'], + regions:['us-east-1','us-east-2','us-west-2','us-west-1','eu-west-1','eu-central-1','ap-southeast-1','ap-northeast-1','ap-southeast-2','sa-east-1'], productName1:['Amazon Elastic Compute Cloud','Amazon RDS Service','Amazon Redshift','Amazon ElastiCache'], productName2:['Amazon CloudFront','Amazon Route 53','Amazon Simple Storage Service','Amazon Virtual Private Cloud'] }, @@ -258,6 +261,9 @@ function getDefaultsConfig() { 'us-east-1': { name: 'US East (N. Virginia)' }, + 'us-east-2': { + name: 'US East (Ohio)' + }, 'us-west-1': { name: 'US West (N. California)' }, From 0e65f1ee2395f41493072ad64e942944956d9fd9 Mon Sep 17 00:00:00 2001 From: Vinod Nair Date: Wed, 18 Jul 2018 13:39:18 +0530 Subject: [PATCH 2/2] Fixed multiple aws key issue --- server/app/lib/utils/masterUtil.js | 3 ++- server/app/services/schedulerService.js | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/server/app/lib/utils/masterUtil.js b/server/app/lib/utils/masterUtil.js index a583e3a35..04eb87ce8 100755 --- a/server/app/lib/utils/masterUtil.js +++ b/server/app/lib/utils/masterUtil.js @@ -2617,7 +2617,8 @@ var MasterUtil = function () { }); }; this.getSensuCookbooks = function(){ - var cookbooks = ['recipe[sensu-client]','recipe[sensu_check_load]','recipe[sensu_check_disk]','recipe[sensu_check_cpu]','recipe[sensu_check_memory]','recipe[consul-client-demo]']; + //var cookbooks = ['recipe[sensu-client]','recipe[sensu_check_load]','recipe[sensu_check_disk]','recipe[sensu_check_cpu]','recipe[sensu_check_memory]','recipe[consul-client-demo]']; + var cookbooks = ['recipe[sensu-client]','recipe[consul-client-demo]','recipe[cft-rlc-demo]']; return cookbooks; }; diff --git a/server/app/services/schedulerService.js b/server/app/services/schedulerService.js index 6cacebc60..e9f24aef2 100644 --- a/server/app/services/schedulerService.js +++ b/server/app/services/schedulerService.js @@ -716,7 +716,17 @@ function startStopManagedInstance(instance,catUser,action,callback){ callback(err); return; } - callback(null, keyPair[0].region); + //Fix for additional regions added for provider - Vinod + var foundRegion = false; + for(var p = 0; p < keyPair.length; p++){ + if(keyPair[p].region == instance.region){ + foundRegion = true; + callback(null, keyPair[p].region); + + } + } + if(!foundRegion) //to support old flow. + callback(null, keyPair[0].region); }); } }