aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java47
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java4
2 files changed, 29 insertions, 22 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 d036468808..73e0da1cd9 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.VduStateType;
import org.onap.so.adapters.vdu.VduStatus;
import org.onap.so.openstack.beans.HeatStatus;
import org.onap.so.openstack.beans.StackInfo;
+import org.onap.so.openstack.exceptions.MsoAdapterException;
import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
import org.onap.so.openstack.exceptions.MsoException;
import org.onap.so.openstack.exceptions.MsoOpenstackException;
@@ -149,8 +150,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
logger.trace("Started MsoMulticloudUtils.createStack");
// Get the directives, if present.
- String oofDirectives = "";
- String sdncDirectives = "";
+ String oofDirectives = "{}";
+ String sdncDirectives = "{}";
String genericVnfId = "";
String vfModuleId = "";
String templateType = "";
@@ -185,26 +186,17 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
MulticloudRequest multicloudRequest= new MulticloudRequest();
- try {
- multicloudRequest.setGenericVnfId(genericVnfId);
- multicloudRequest.setVfModuleId(vfModuleId);
- 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(stack);
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString()));
- }
- } catch (Exception e) {
- logger.debug("ERROR making multicloud JSON body ", e);
- }
- String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, null);
+ multicloudRequest.setGenericVnfId(genericVnfId);
+ multicloudRequest.setVfModuleId(vfModuleId);
+ multicloudRequest.setTemplateType(templateType);
+ multicloudRequest.setTemplateData(stack);
+ multicloudRequest.setOofDirectives(getDirectiveNode(oofDirectives));
+ multicloudRequest.setSdncDirectives(getDirectiveNode(sdncDirectives));
if (logger.isDebugEnabled()) {
- logger.debug(String.format("Multicloud Endpoint is: %s", multicloudEndpoint));
+ logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString()));
}
+
+ String multicloudEndpoint = getMulticloudEndpoint(cloudSiteId, null);
RestClient multicloudClient = getMulticloudClient(multicloudEndpoint);
Response response = multicloudClient.post(multicloudRequest);
@@ -617,6 +609,21 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
return client;
}
+ private JsonNode getDirectiveNode(String directives) throws MsoException {
+ try {
+ return JSON_MAPPER.readTree(directives);
+ } catch (Exception e) {
+ logger.error(String.format("%d %s %s %s %d %s",
+ MessageEnum.RA_CREATE_STACK_ERR,
+ "Create Stack: " + e, "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError,
+ "Exception in Create Stack: Invalid JSON format of directives" + directives));
+ MsoException me = new MsoAdapterException("Invalid JSON format of directives parameter: " + directives);
+ me.addContext(CREATE_STACK);
+ throw me;
+ }
+ }
+
/**
* VduPlugin interface for instantiate function.
*
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
index b6f1ad1dcd..20c2231032 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
@@ -67,8 +67,8 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils{
public void createVfModule() throws Exception {
//expectedException.expect(VnfException.class);
Map<String, String> stackInputs = new HashMap<>();
- stackInputs.put("oof_directives", "{oofDIRECTIVES}");
- stackInputs.put("sdnc_directives", "{sdncDIRECTIVES}");
+ stackInputs.put("oof_directives", "{}");
+ stackInputs.put("sdnc_directives", "{}");
stackInputs.put("generic_vnf_id", "genVNFID");
stackInputs.put("vf_module_id", "vfMODULEID");