aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorShadi Haidar <sh1986@att.com>2018-06-15 16:18:11 -0400
committerShadi Haidar <sh1986@att.com>2018-06-19 11:56:24 -0400
commitb81d08b3260f1da96f87d6c6c6433017a5dce080 (patch)
treef88d3862ca6d4097361f85a8f02a19b662258b99 /lib
parent7a91f8c03b2f177568dd02436df0bd908d8bb293 (diff)
Extend API with tenant name
remove cloudify.uploadBlueprint() from cloudify.js debug log Issue-ID: DCAEGEN2-548 Change-Id: I800766aab4e95a945477c0a6eeb5adfc41a1203d Signed-off-by: Shadi Haidar <sh1986@att.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/cloudify.js59
-rw-r--r--lib/config.js1
2 files changed, 34 insertions, 26 deletions
diff --git a/lib/cloudify.js b/lib/cloudify.js
index 0832dc7..2db460a 100644
--- a/lib/cloudify.js
+++ b/lib/cloudify.js
@@ -22,9 +22,7 @@ const CLOUDIFY = "cloudify-manager";
const FINISHED = [ "terminated", "cancelled", "failed" ];
const RETRY_INTERVAL = 5000; // Every 5 seconds
const MAX_TRIES = 720; // Up to 1 hour
-
-const TENANT = "default_tenant"; // Tenant name for Cloudify 4.x
-
+const DEFAULT_TENANT = "default_tenant";
const doRequest = require('./promise_request').doRequest;
const repeat = require('./repeat');
const admzip = require('adm-zip');
@@ -83,7 +81,9 @@ const getExecutionStatus = function(req, execution_id) {
method : "GET",
uri : cfyAPI + "/executions/" + execution_id
};
- addAuthToOptions(reqOptions);
+
+ addAuthToOptions(reqOptions, req);
+
return doRequest(req, reqOptions, null, CLOUDIFY);
};
@@ -174,7 +174,9 @@ const startWorkflowExecution = function(mainReq, deployment_id, workflow_id, par
"Accept" : "*/*"
}
};
- addAuthToOptions(reqOptions);
+
+ addAuthToOptions(reqOptions, mainReq);
+
var body = {
"deployment_id" : deployment_id,
"workflow_id" : workflow_id
@@ -212,14 +214,14 @@ exports.uploadBlueprint = function(req, bpid, blueprint) {
// Set up the HTTP PUT request
const reqOptions = {
- method : "PUT",
- uri : cfyAPI + "/blueprints/" + bpid,
- headers : {
- "Content-Type" : "application/octet-stream",
- "Accept" : "*/*"
- }
+ method : "PUT",
+ uri : cfyAPI + "/blueprints/" + bpid,
+ headers : {
+ "Content-Type" : "application/octet-stream",
+ "Accept" : "*/*"
+ }
};
- addAuthToOptions(reqOptions);
+ addAuthToOptions(reqOptions, req);
// Initiate PUT request and return the promise for a result
return doRequest(req, reqOptions, zip_buffer, CLOUDIFY);
@@ -237,7 +239,7 @@ exports.createDeployment = function(req, dpid, bpid, inputs) {
"Accept" : "*/*"
}
};
- addAuthToOptions(reqOptions);
+ addAuthToOptions(reqOptions, req);
var body = {
blueprint_id : bpid
@@ -280,7 +282,8 @@ exports.getOutputs = function(req, dpid) {
"Accept" : "*/*"
}
};
- addAuthToOptions(reqOptions);
+
+ addAuthToOptions(reqOptions, req);
return doRequest(req, reqOptions, null, CLOUDIFY);
};
@@ -294,7 +297,8 @@ exports.getOutputDescriptions = function(req, dpid) {
"Accept" : "*/*"
}
};
- addAuthToOptions(reqOptions);
+
+ addAuthToOptions(reqOptions, req);
return doRequest(req, reqOptions, null, CLOUDIFY);
};
@@ -305,7 +309,8 @@ exports.deleteDeployment = function(req, dpid) {
method : "DELETE",
uri : cfyAPI + "/deployments/" + dpid
};
- addAuthToOptions(reqOptions);
+
+ addAuthToOptions(reqOptions, req);
return doRequest(req, reqOptions, null, CLOUDIFY);
};
@@ -316,7 +321,8 @@ exports.deleteBlueprint = function(req, bpid) {
method : "DELETE",
uri : cfyAPI + "/blueprints/" + bpid
};
- addAuthToOptions(reqOptions);
+
+ addAuthToOptions(reqOptions, req);
return doRequest(req, reqOptions, null, CLOUDIFY);
};
@@ -331,16 +337,16 @@ exports.setCredentials = function(user, password) {
cfyAuth = cfyAuth || (user + ':' + password);
};
-function addAuthToOptions(reqOptions) {
+function addAuthToOptions(reqOptions, req) {
+
if (!!cfyAuth && cfyAuth !== "undefined:undefined") {
reqOptions.auth = cfyAuth;
}
- if (reqOptions.headers) {
- reqOptions.headers.Tenant = TENANT;
- }
- else {
- reqOptions.headers = {"Tenant" : TENANT};
- }
+ reqOptions.headers = reqOptions.headers || {};
+ reqOptions.headers.Tenant = req.query.cfy_tenant_name || DEFAULT_TENANT;
+
+ logger.debug(req.dcaeReqId, "Calling " + reqOptions.uri + " with Tenant: " + reqOptions.headers.Tenant );
+
}
// Set a logger
@@ -352,9 +358,10 @@ exports.getNodeInstances = function (mainReq, on_next_node_instances, offset) {
offset = offset || 0;
var reqOptions = {
method : "GET",
- uri : cfyAPI + "/node-instances?_include=id,deployment_id,runtime_properties&_size=1000&_offset=" + offset
+ uri : cfyAPI + "/node-instances?_include=id,deployment_id,runtime_properties&_offset=" + offset
};
- addAuthToOptions(reqOptions);
+
+ addAuthToOptions(reqOptions, mainReq);
logger.info(mainReq.dcaeReqId, "getNodeInstances: " + JSON.stringify(reqOptions));
return doRequest(mainReq, reqOptions, null, CLOUDIFY)
diff --git a/lib/config.js b/lib/config.js
index 700f95d..fd7d38c 100644
--- a/lib/config.js
+++ b/lib/config.js
@@ -214,6 +214,7 @@ exports.configure = function() {
throw new Error ("Required configuration elements missing: " + missing.join(','));
config = null;
}
+ console.log( (new Date()) + ": config -> " + JSON.stringify(config, undefined, 2));
return config;
});
};