From 1db62bd999239e919c8df2625c453f74596c21dd Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Sat, 6 Apr 2019 00:15:37 -0700 Subject: 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 --- .../org/onap/so/openstack/utils/MsoMulticloudUtils.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'adapters') 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) { -- cgit 1.2.3-korg