aboutsummaryrefslogtreecommitdiffstats
path: root/lib/cloudify.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cloudify.js')
-rw-r--r--lib/cloudify.js93
1 files changed, 92 insertions, 1 deletions
diff --git a/lib/cloudify.js b/lib/cloudify.js
index 77e6d72..2c7af6e 100644
--- a/lib/cloudify.js
+++ b/lib/cloudify.js
@@ -92,6 +92,17 @@ const getDeploymentCreationStatus = function(req, deployment_id) {
return doRequest(req, reqOptions, null, CLOUDIFY);
};
+// Get blueprint_id for a particular deployment
+exports.getBlueprintIdFromDeployment = function(req, deployment_id) {
+ const reqOptions = {
+ method : "GET",
+ uri : cfyAPI + "/deployments/" + deployment_id + "?_include=blueprint_id"
+ };
+ addAuthToOptions(reqOptions, req);
+
+ return doRequest(req, reqOptions, null, CLOUDIFY);
+};
+
// Poll for the result of a workflow execution until it's done
// Return a promise for the final result of a workflow execution
exports.waitForWorkflowExecution = function(mainReq, execution_id) {
@@ -243,7 +254,7 @@ exports.uploadBlueprint = function(req, bpid, blueprint) {
// Set up the HTTP PUT request
const reqOptions = {
method : "PUT",
- uri : cfyAPI + "/blueprints/" + bpid,
+ uri : cfyAPI + "/blueprints/" + bpid + "?visibility=global",
headers : {
"Content-Type" : "application/octet-stream",
"Accept" : "*/*"
@@ -255,6 +266,86 @@ exports.uploadBlueprint = function(req, bpid, blueprint) {
return doRequest(req, reqOptions, zip_buffer, CLOUDIFY);
};
+// Checks if a blueprint exists in cloudify
+exports.checkBlueprintExits = function(req, bpid) {
+
+ // Set up the HTTP GET request
+ var reqOptions = {
+ method : "GET",
+ uri : cfyAPI + "/blueprints?id=" + bpid,
+ headers : {
+ "Content-Type" : "application/json",
+ "Accept" : "*/*"
+ }
+ };
+ addAuthToOptions(reqOptions, req);
+
+ return doRequest(req, reqOptions, null, CLOUDIFY)
+
+ .then (function(result) {
+ if (result.json.metadata.pagination.total > 0 ) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ })
+ .catch(function(error) {
+ logger.debug(req.dcaeReqId, "Error getting BP from Cloudify for deployment id: " + req.params['deploymentId'] + " and blueprint id: " + bpid );
+ throw(error);
+ });
+};
+
+// Get the tenant_name associated with a blueprint
+exports.getBlueprintTenantName = function(req, bpid) {
+
+ // Set up the HTTP GET request
+ var reqOptions = {
+ method : "GET",
+ uri : cfyAPI + "/blueprints?id=" + bpid + "&_include=tenant_name",
+ headers : {
+ "Content-Type" : "application/json",
+ "Accept" : "*/*"
+ }
+ };
+ addAuthToOptions(reqOptions, req);
+
+ return doRequest(req, reqOptions, null, CLOUDIFY);
+};
+
+// Checks if a blueprint should be deleted from cloudify due to no associated deployments
+exports.shouldBlueprintGetDeleted = function(req, bpid) {
+
+ // Set up the HTTP GET request
+ var reqOptions = {
+ method : "GET",
+ uri : cfyAPI + "/deployments?blueprint_id=" + bpid + "&_all_tenants=true&_include=id",
+ headers : {
+ "Content-Type" : "application/json",
+ "Accept" : "*/*"
+ }
+ };
+ const tenant = req.query.cfy_tenant_name;
+ req.query.cfy_tenant_name = DEFAULT_TENANT;
+ addAuthToOptions(reqOptions, req);
+ req.query.cfy_tenant_name = tenant;
+
+ return doRequest(req, reqOptions, null, CLOUDIFY)
+
+ .then (function(result) {
+ if (result.json.metadata.pagination.total > 0 ) {
+ return false;
+ }
+ else {
+ return true;
+ }
+ })
+ .catch(function(error) {
+ logger.debug(req.dcaeReqId, "Error getting deployments info from Cloudify for deployment id: " + req.params['deploymentId'] + " and blueprint id: " + bpid );
+ throw(error);
+ });
+};
+
// Creates a deployment from a blueprint
exports.createDeployment = function(req, dpid, bpid, inputs) {