diff options
author | 2020-01-14 13:31:20 -0500 | |
---|---|---|
committer | 2020-08-19 17:51:07 -0400 | |
commit | 3d364e4ffa2bfdbffa75679ad67fbaa93ce0b8bf (patch) | |
tree | 6dfefbd3a80f38b567f06f37621cda1f524572c2 /lib/deploy.js | |
parent | d6a5b946f05f43a9942d3d564d66a0a3396933a5 (diff) |
DH install/uninstall improvements
Install workflow changes:
-Use inventory blueprint (BP) typeId when uploading BP to Cloudify/CFY
-Set global visibility when uploading BP to CFY for multi-tenant access
-Re-use BP if it exists in CFY rather than alawys uploading a new BP
-Do not add a new service in inventory anymore
Un-Install workflow changes:
-Retreive associated BP against the deployment
-Check if any other deployments still exist against the BP
-If no associated deployments, get the associated tenant for the BP
-Only delete BP if there are no more associated BPs
-Do not remove associated service from inventory (it won't exist)
Coverage summary
Statements : 78.01% ( 997/1278 )
Branches : 56.45% ( 302/535 )
Functions : 74.89% ( 164/219 )
Lines : 78.54% ( 988/1258 )
Issue-ID: DCAEGEN2-2022
Signed-off-by: Shadi Haidar <sh1986@att.com>
Change-Id: I9cb197edc3a0276c5ca95f9c936fc7300d849f56
Signed-off-by: Shadi Haidar <sh1986@att.com>
Signed-off-by: Shadi Haidar (sh1986) <sh1986@att.com>
Signed-off-by: Shadi Haidar <sh1986@att.com>
Diffstat (limited to 'lib/deploy.js')
-rw-r--r-- | lib/deploy.js | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/lib/deploy.js b/lib/deploy.js index cb78f6f..d4ce1d4 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -1,5 +1,5 @@ /* -Copyright(c) 2017-2018 AT&T Intellectual Property. All rights reserved. +Copyright(c) 2017-2020 AT&T Intellectual Property. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -130,19 +130,32 @@ var delay = function(dtime) { // Go through the Cloudify API call sequence to upload blueprint, create deployment, and launch install workflow // (but don't wait for the workflow to finish) -exports.launchBlueprint = function(req, id, blueprint, inputs) { +exports.launchBlueprint = function(req, id, blueprint, bpid, inputs) { + const log_blueprint_id = "blueprintId(" + bpid + "): "; const log_deployment_id = "deploymentId(" + id + "): "; - var step_log = log_deployment_id + "uploading blueprint"; + var step_log = log_blueprint_id + "uploading blueprint"; logger.info(req.dcaeReqId, step_log); - return cfy.uploadBlueprint(req, id, blueprint) + + return cfy.checkBlueprintExits(req, bpid) + + .then (function (result) { + logger.info(req.dcaeReqId, " checkBlueprintExits result " + result); + // Upload blueprint + if ( result === false ) { + logger.info(req.dcaeReqId, " blueprint with id: " + log_blueprint_id + " does not exist. Uploading"); + return cfy.uploadBlueprint(req, bpid, blueprint) + } + else { + logger.info(req.dcaeReqId, " blueprint with id: " + log_blueprint_id + " already exits. No need to upload"); + } + }) .then (function(result) { step_log = log_deployment_id + "creating deployment"; logger.info(req.dcaeReqId, step_log); // Create deployment - return cfy.createDeployment(req, id, id, inputs); + return cfy.createDeployment(req, id, bpid, inputs); }) - // create the deployment and keep checking, for up to 5 minutes, until creation is complete .then(function(result) { step_log = log_deployment_id + "waiting for deployment creation"; @@ -210,22 +223,43 @@ exports.launchUninstall = function(req, deploymentId) { exports.finishUninstall = function(req, deploymentId, executionId) { logger.info(req.dcaeReqId, "finishUninstall: " + deploymentId + " -- executionId: " + executionId); + var bid = ""; return cfy.waitForWorkflowExecution(req, executionId) .then (function(result){ logger.info(req.dcaeReqId, "deploymentId: " + deploymentId + " uninstall workflow successfully executed"); + logger.info(req.dcaeReqId, "deploymentId: " + deploymentId + " getting associated blueprint_id"); + return cfy.getBlueprintIdFromDeployment(req, deploymentId); + }) + .then (function(result){ + bid = result.json.blueprint_id; + logger.info(req.dcaeReqId, "deploymentId: " + deploymentId + " associated blueprint_id: " + bid); // Delete the deployment return delay(DELAY_DELETE_DEPLOYMENT).then(function() { return cfy.deleteDeployment(req, deploymentId); - }); + }); }) .then (function(result){ logger.info(req.dcaeReqId, "deploymentId: " + deploymentId + " deployment deleted"); - // Delete the blueprint - return delay(DELAY_DELETE_BLUEPRINT).then(function() { - return cfy.deleteBlueprint(req, deploymentId); + return delay(DELAY_DELETE_DEPLOYMENT).then(function() { + return cfy.shouldBlueprintGetDeleted(req, bid); }); }) + .then (function (result) { + logger.info(req.dcaeReqId, "deploymentId: " + deploymentId + " shouldBlueprintGetDeleted: " + result); + if ( result === true ) { + return cfy.getBlueprintTenantName(req, bid) + .then (function(result){ + const tenant = result.json.items[0].tenant_name; + logger.info(req.dcaeReqId, "deploymentId: " + deploymentId + " deleting bluerpint with id: " + + bid + " and tenant_name: " + tenant); + // Delete the blueprint + req.query.cfy_tenant_name = tenant; + return cfy.deleteBlueprint(req, bid); + }); + } + }) .then (function(result){ + logger.info(req.dcaeReqId, "deploymentId: " + deploymentId + " done with uninstall"); return result; }) .catch (function(err){ |