diff options
Diffstat (limited to 'lib/dcae-deployments.js')
-rw-r--r-- | lib/dcae-deployments.js | 48 |
1 files changed, 10 insertions, 38 deletions
diff --git a/lib/dcae-deployments.js b/lib/dcae-deployments.js index 193f6b9..708a949 100644 --- a/lib/dcae-deployments.js +++ b/lib/dcae-deployments.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. @@ -28,6 +28,7 @@ const deploy = require('./deploy'); const middleware = require('./middleware'); const inv = require('./inventory'); const log = require('./logging').getLogger(); +const DEFAULT_TENANT = "default_tenant"; /* Pick up config exported by main */ const config = process.mainModule.exports.config; @@ -63,7 +64,7 @@ const createLinks = function(req, deploymentId, executionId) { var baseURL = req.protocol + '://' + req.get('Host') + req.app.mountpath + '/' + deploymentId; return { self: baseURL, - status: baseURL + '/operation/' + executionId + status: baseURL + '/operation/' + executionId + '?cfy_tenant_name=' + req.query.cfy_tenant_name || DEFAULT_TENANT }; }; @@ -105,31 +106,20 @@ app.put('/:deploymentId', function(req, res, next) { throw e; } - /* Make sure the deploymentId doesn't already exist */ - inventory.verifyUniqueDeploymentId(req, req.params['deploymentId']) - - /* Get the blueprint for this service type */ - .then(function(res) { - return getBlueprint(req, req.body['serviceTypeId']); - }) - - /* Add this new service instance to inventory - * Easier to remove from inventory if deployment fails than vice versa - * Also lets client check for deployed/deploying instances if client wants to limit number of instances - */ - .then(function (blueprintInfo) { - req.dcaeBlueprint = blueprintInfo.blueprint; - return inventory.addService(req, req.params['deploymentId'], blueprintInfo.typeId, "dummyVnfId", "dummyVnfType", "dummyLocation"); - }) + return getBlueprint(req, req.body['serviceTypeId']) /* Upload blueprint, create deployment and start install workflow (but don't wait for completion */ - .then (function() { + .then (function(blueprintInfo) { + req.dcaeBlueprint = blueprintInfo.blueprint; + req.bpTypeId = blueprintInfo.typeId; req.dcaeAddedToInventory = true; - return deploy.launchBlueprint(req, req.params['deploymentId'], req.dcaeBlueprint, req.body['inputs']); + return deploy.launchBlueprint(req, req.params['deploymentId'], req.dcaeBlueprint, + "TID-" + req.bpTypeId, req.body['inputs']); }) /* Send the HTTP response indicating workflow has started */ .then(function(result) { + log.info(req.dcaeReqId, "Result from deployment creation/execution: " + JSON.stringify(result)); res.status(202).json(createResponse(req, result)); log.audit(req, 202, "Execution ID: " + result.executionId); return result; @@ -150,15 +140,6 @@ app.put('/:deploymentId', function(req, res, next) { /* If we haven't already sent a response, let the error handler send response and log the error */ if (!res.headersSent) { - - /* If we made an inventory entry, remove it */ - if (req.dcaeAddedToInventory) { - inventory.deleteService(req, req.params['deploymentId']) - .catch(function(error) { - log.error(error, req); - }); - } - next(error); } else { @@ -179,14 +160,6 @@ app.delete('/:deploymentId', function(req, res, next) { /* Launch the uninstall workflow */ deploy.launchUninstall(req, req.params['deploymentId']) - /* Delete the service from inventory */ - .then(function(result) { - return inventory.deleteService(req, req.params['deploymentId']) - .then (function() { - return result; - }); - }) - /* Send the HTTP response indicating workflow has started */ .then(function(result) { res.status(202).send(createResponse(req, result)); @@ -198,7 +171,6 @@ app.delete('/:deploymentId', function(req, res, next) { .then(function(result) { return deploy.finishUninstall(req, result.deploymentId, result.executionId); }) - /* Log completion in audit log */ .then(function(result) { log.audit(req, 200, "Undeployed id: " + req.params['deploymentId']); |