summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-adapter-utils')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java29
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java21
2 files changed, 19 insertions, 31 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 051d8134f1..3451b766cf 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
@@ -31,8 +31,6 @@ import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriBuilderException;
import javax.ws.rs.core.Response;
-import org.onap.so.db.catalog.beans.CloudIdentity;
-import org.onap.so.utils.CryptoUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.onap.so.adapters.vdu.CloudInfo;
@@ -64,6 +62,8 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.woorea.openstack.heat.model.CreateStackParam;
@@ -173,35 +173,20 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
CreateStackParam stack = createStackParam(stackName, heatTemplate, stackInputs, timeoutMinutes, environment, files, heatFiles);
MulticloudRequest multicloudRequest= new MulticloudRequest();
- HttpEntity<MulticloudRequest> request = null;
try {
multicloudRequest.setGenericVnfId(genericVnfId);
multicloudRequest.setVfModuleId(vfModuleId);
- multicloudRequest.setOofDirectives(oofDirectives);
- multicloudRequest.setSdncDirectives(sdncDirectives);
+ multicloudRequest.setOofDirectives(JSON_MAPPER.readTree(oofDirectives));
+ multicloudRequest.setSdncDirectives(JSON_MAPPER.readTree(sdncDirectives));
multicloudRequest.setTemplateType(templateType);
if (logger.isDebugEnabled()) {
logger.debug(String.format("Stack Template Data is: %s", stack.toString().substring(16)));
}
- multicloudRequest.setTemplateData(JSON_MAPPER.writeValueAsString(stack));
+ multicloudRequest.setTemplateData(stack);
if (logger.isDebugEnabled()) {
logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString()));
}
-
- CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() ->
- new MsoCloudSiteNotFound(cloudSiteId));
- CloudIdentity cloudIdentity = cloudSite.getIdentityService();
- HttpHeaders headers = new HttpHeaders();
- headers.set ("X-Auth-User", cloudIdentity.getMsoId ());
- headers.set ("X-Auth-Key", CryptoUtils.decryptCloudConfigPassword(cloudIdentity.getMsoPass ()));
- headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
- headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
-
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("Multicloud Request Headers: %s", headers.toString()));
- }
- request = new HttpEntity<>(multicloudRequest, headers);
} catch (Exception e) {
logger.debug("ERROR making multicloud JSON body ", e);
}
@@ -211,7 +196,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
}
RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
- Response response = multicloudClient.post(request);
+ Response response = multicloudClient.post(multicloudRequest);
StackInfo createInfo = new StackInfo();
createInfo.setName(stackName);
@@ -609,7 +594,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
private RestClient getMulticloudClient(String endpoint) {
RestClient client = null;
try {
- client= new HttpClient(UriBuilder.fromUri(endpoint).build().toURL(),
+ client = new HttpClient(UriBuilder.fromUri(endpoint).build().toURL(),
MediaType.APPLICATION_JSON.toString(), TargetEntity.MULTICLOUD);
} catch (MalformedURLException e) {
logger.debug(String.format("Encountered malformed URL error getting multicloud rest client %s", e.getMessage()));
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
index fefc0951f6..4204813cec 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java
@@ -24,6 +24,9 @@ import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.woorea.openstack.heat.model.CreateStackParam;
+
import org.apache.commons.lang.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@@ -43,13 +46,13 @@ public class MulticloudRequest implements Serializable {
@JsonProperty("vf-module-id")
private String vfModuleId;
@JsonProperty("oof_directives")
- private String oofDirectives;
+ private JsonNode oofDirectives;
@JsonProperty("sdnc_directives")
- private String sdncDirectives;
+ private JsonNode sdncDirectives;
@JsonProperty("template_type")
private String templateType;
@JsonProperty("template_data")
- private String templateData;
+ private CreateStackParam templateData;
@JsonProperty("generic-vnf-id")
@@ -73,22 +76,22 @@ public class MulticloudRequest implements Serializable {
}
@JsonProperty("oof_directives")
- public String getOofDirectives() {
+ public JsonNode getOofDirectives() {
return oofDirectives;
}
@JsonProperty("oof_directives")
- public void setOofDirectives(String oofDirectives) {
+ public void setOofDirectives(JsonNode oofDirectives) {
this.oofDirectives = oofDirectives;
}
@JsonProperty("sdnc_directives")
- public String getSdncDirectives() {
+ public JsonNode getSdncDirectives() {
return sdncDirectives;
}
@JsonProperty("sdnc_directives")
- public void setSdncDirectives(String sdncDirectives) {
+ public void setSdncDirectives(JsonNode sdncDirectives) {
this.sdncDirectives = sdncDirectives;
}
@@ -103,12 +106,12 @@ public class MulticloudRequest implements Serializable {
}
@JsonProperty("template_data")
- public String getTemplateData() {
+ public CreateStackParam getTemplateData() {
return templateData;
}
@JsonProperty("template_data")
- public void setTemplateData(String templateData) {
+ public void setTemplateData(CreateStackParam templateData) {
this.templateData = templateData;
}