aboutsummaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2019-04-06 00:15:37 -0700
committerEric Multanen <eric.w.multanen@intel.com>2019-04-06 00:43:01 -0700
commit1db62bd999239e919c8df2625c453f74596c21dd (patch)
tree5064640f1aee08b36fefa707bde1eb502400b171 /adapters
parent0fee038584a0e66db618d24eada8ba6e0da05001 (diff)
Add tenantId to multicloud request header
The multicloud API can take the tenantId as an item in the header. Add the tenantId to the request headers of the multicloud plugin. Change-Id: I7ff11cd52eea429e0c694092b006887f13de2fda Issue-ID: SO-1446 Signed-off-by: Eric Multanen <eric.w.multanen@intel.com>
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java16
1 files changed, 10 insertions, 6 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
index 1fabcb279c..6d4deeb0f1 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
@@ -45,6 +45,7 @@ import org.onap.so.adapters.vdu.VduModelInfo;
import org.onap.so.adapters.vdu.VduPlugin;
import org.onap.so.adapters.vdu.VduStateType;
import org.onap.so.adapters.vdu.VduStatus;
+import org.onap.so.client.HttpClient;
import org.onap.so.client.HttpClientFactory;
import org.onap.so.client.RestClient;
import org.onap.so.logger.ErrorCode;
@@ -207,7 +208,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
}
String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, cloudOwner, null);
- RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
+ RestClient multicloudClient = getMulticloudClient(multicloudEndpoint, tenantId);
if (multicloudClient == null) {
MsoOpenstackException me = new MsoOpenstackException(0, "", "Multicloud client could not be initialized");
@@ -289,7 +290,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
returnInfo.setName(stackName);
String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, cloudOwner, stackId);
- RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
+ RestClient multicloudClient = getMulticloudClient(multicloudEndpoint, tenantId);
if (multicloudClient != null) {
Response response = multicloudClient.get();
@@ -343,7 +344,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
Response response = null;
String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, cloudOwner, stackId);
- RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
+ RestClient multicloudClient = getMulticloudClient(multicloudEndpoint, tenantId);
if (multicloudClient != null) {
response = multicloudClient.delete();
@@ -392,7 +393,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
multicloudRequest.setVfModuleId(vfModuleId);
String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, cloudOwner, workloadId);
- RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
+ RestClient multicloudClient = getMulticloudClient(multicloudEndpoint, tenantId);
if (multicloudClient == null) {
if (logger.isDebugEnabled())
@@ -708,12 +709,15 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
}
}
- private RestClient getMulticloudClient(String endpoint) {
- RestClient client = null;
+ private RestClient getMulticloudClient(String endpoint, String tenantId) {
+ HttpClient client = null;
try {
client = httpClientFactory.newJsonClient(
new URL(endpoint),
TargetEntity.MULTICLOUD);
+ if (tenantId != null && !tenantId.isEmpty()) {
+ client.addAdditionalHeader("Project", tenantId);
+ }
} catch (MalformedURLException e) {
logger.debug(String.format("Encountered malformed URL error getting multicloud rest client %s", e.getMessage()));
} catch (IllegalArgumentException e) {