aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-05-11 18:29:37 +0200
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-05-11 18:29:37 +0200
commitf92b38ddcb8b5eb80db55fa1ca6ebdb5af40d115 (patch)
treeb4d9eedc3a03ddf1da2106a555b7348d2078a84f
parent86848b8bf5182be52fff9346412743f92e3d9e6a (diff)
Fix Sdc Controller
Add support to decode the entire input parameters provided in the blueprints so that user see them in the Clamp UI + Unit tests Issue-ID: CLAMP-151 Change-Id: I838e03375cb544fd91b0a1f86905d96239ffece2 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java25
-rw-r--r--src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java29
-rw-r--r--src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json49
-rw-r--r--src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca.json36
4 files changed, 131 insertions, 8 deletions
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
index 13af0439..d24b6dba 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
@@ -26,6 +26,7 @@ package org.onap.clamp.clds.sdc.controller.installer;
import com.att.aft.dme2.internal.apache.commons.io.IOUtils;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.IOException;
import java.util.ArrayList;
@@ -50,6 +51,7 @@ import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.service.CldsService;
import org.onap.clamp.clds.service.CldsTemplateService;
import org.onap.clamp.clds.transform.XslTransformer;
+import org.onap.clamp.clds.util.JacksonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
@@ -164,6 +166,25 @@ public class CsarInstallerImpl implements CsarInstaller {
return listConfig.get(0);
}
+ private static String getAllBlueprintParametersInJson(BlueprintArtifact blueprintArtifact) {
+ ObjectNode node = JacksonUtils.getObjectMapperInstance().createObjectNode();
+ Yaml yaml = new Yaml();
+ Map<String, Object> inputsNodes = ((Map<String, Object>) ((Map<String, Object>) yaml
+ .load(blueprintArtifact.getDcaeBlueprint())).get("inputs"));
+ inputsNodes.entrySet().stream().filter(e -> !e.getKey().contains("policy_id")).forEach(elem -> {
+ Object defaultNode = ((Map<String, Object>) elem.getValue()).get("default");
+ if (defaultNode != null && defaultNode instanceof String) {
+ node.put(elem.getKey(), (String) defaultNode);
+ } else if (defaultNode != null) {
+ node.putPOJO(elem.getKey(), defaultNode);
+ } else {
+ node.put(elem.getKey(), "");
+ }
+ });
+ node.put("policy_id", "AUTO_GENERATED_POLICY_ID_AT_SUBMIT");
+ return node.toString();
+ }
+
private static String searchForPolicyScopePrefix(BlueprintArtifact blueprintArtifact)
throws SdcArtifactInstallerException {
String policyName = null;
@@ -265,8 +286,8 @@ public class CsarInstallerImpl implements CsarInstaller {
// Do a test to validate the BPMN
new ModelProperties(cldsModel.getName(), cldsModel.getControlName(), "PUT", false,
cldsBpmnTransformer.doXslTransformToString(cldsTemplate.getBpmnText()), "{}");
- String inputParams = "{\"name\":\"deployParameters\",\"value\":{\n" + "\"policy_id\": \""
- + "AUTO_GENERATED_POLICY_ID_AT_SUBMIT" + "\"" + "}}";
+ String inputParams = "{\"name\":\"deployParameters\",\"value\":"
+ + getAllBlueprintParametersInJson(blueprintArtifact) + "}";
cldsModel.setPropText("{\"global\":[{\"name\":\"service\",\"value\":[\""
+ blueprintArtifact.getBlueprintInvariantServiceUuid() + "\"]},{\"name\":\"vf\",\"value\":[\""
+ blueprintArtifact.getResourceAttached().getResourceInvariantUUID()
diff --git a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
index e0f774b0..222f757e 100644
--- a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java
@@ -56,6 +56,7 @@ import org.onap.sdc.api.notification.IResourceInstance;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -152,26 +153,42 @@ public class CsarInstallerItCase {
String generatedName = RandomStringUtils.randomAlphanumeric(5);
CsarHandler csar = buildFakeCsarHandler(generatedName);
csarInstaller.installTheCsar(csar);
+ CldsModel cldsModel1 = verifyClosedLoopModelLoadedInDb(csar, generatedName, INSTANCE_NAME_RESOURCE1);
+ JSONAssert.assertEquals(
+ IOUtils.toString(
+ ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca.json")),
+ cldsModel1.getPropText(), true);
+ CldsModel cldsModel2 = verifyClosedLoopModelLoadedInDb(csar, generatedName, INSTANCE_NAME_RESOURCE2);
+ JSONAssert.assertEquals(
+ IOUtils.toString(
+ ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca-2.json")),
+ cldsModel2.getPropText(), true);
+ }
+
+ private CldsModel verifyClosedLoopModelLoadedInDb(CsarHandler csar, String generatedName,
+ String instanceNameResource) throws SdcArtifactInstallerException {
// Get the template back from DB
- CldsTemplate templateFromDb = CldsTemplate.retrieve(cldsDao, CsarInstallerImpl.TEMPLATE_NAME_PREFIX
- + CsarInstallerImpl.buildModelName(csar, INSTANCE_NAME_RESOURCE1), false);
+ CldsTemplate templateFromDb = CldsTemplate.retrieve(cldsDao,
+ CsarInstallerImpl.TEMPLATE_NAME_PREFIX + CsarInstallerImpl.buildModelName(csar, instanceNameResource),
+ false);
assertNotNull(templateFromDb);
assertNotNull(templateFromDb.getBpmnText());
assertNotNull(templateFromDb.getImageText());
assertNotNull(templateFromDb.getPropText());
assertTrue(templateFromDb.getPropText().contains("global")
&& templateFromDb.getPropText().contains("node_templates:"));
- assertEquals(templateFromDb.getName(), CsarInstallerImpl.TEMPLATE_NAME_PREFIX
- + CsarInstallerImpl.buildModelName(csar, INSTANCE_NAME_RESOURCE1));
+ assertEquals(templateFromDb.getName(),
+ CsarInstallerImpl.TEMPLATE_NAME_PREFIX + CsarInstallerImpl.buildModelName(csar, instanceNameResource));
// Get the Model back from DB
CldsModel modelFromDb = CldsModel.retrieve(cldsDao,
- CsarInstallerImpl.buildModelName(csar, INSTANCE_NAME_RESOURCE2), true);
+ CsarInstallerImpl.buildModelName(csar, instanceNameResource), true);
assertNotNull(modelFromDb);
assertNotNull(modelFromDb.getBpmnText());
assertNotNull(modelFromDb.getImageText());
assertNotNull(modelFromDb.getPropText());
assertTrue(modelFromDb.getPropText().contains("policy_id"));
- assertEquals(CsarInstallerImpl.buildModelName(csar, INSTANCE_NAME_RESOURCE2), modelFromDb.getName());
+ assertEquals(CsarInstallerImpl.buildModelName(csar, instanceNameResource), modelFromDb.getName());
assertEquals(CsarInstallerImpl.CONTROL_NAME_PREFIX, modelFromDb.getControlNamePrefix());
+ return modelFromDb;
}
}
diff --git a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json
new file mode 100644
index 00000000..41ca2de2
--- /dev/null
+++ b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json
@@ -0,0 +1,49 @@
+{
+ "global": [
+ {
+ "name": "service",
+ "value": [
+ "4cc5b45a-1f63-4194-8100-cd8e14248c92"
+ ]
+ },
+ {
+ "name": "vf",
+ "value": [
+ "023a3f0d-1161-45ff-b4cf-8918a8ccf3ad"
+ ]
+ },
+ {
+ "name": "actionSet",
+ "value": [
+ "vnfRecipe"
+ ]
+ },
+ {
+ "name": "location",
+ "value": [
+ "DC1"
+ ]
+ },
+ {
+ "name": "deployParameters",
+ "value": {
+ "dh_override": "component_dockerhost",
+ "dh_location_id": "zone1",
+ "aaiEnrichmentHost": "none",
+ "aaiEnrichmentPort": 8443,
+ "enableAAIEnrichment": false,
+ "dmaap_host": "dmaap.onap-message-router",
+ "dmaap_port": 3904,
+ "enableRedisCaching": false,
+ "redisHosts": "",
+ "tag_version": "nexus3.onap.org:10001/onap//onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.0.0",
+ "consul_host": "consul-server.onap-consul",
+ "consul_port": "8500",
+ "cbs_host": "config-binding-service.dcae",
+ "cbs_port": "10000",
+ "external_port": "32010",
+ "policy_id": "AUTO_GENERATED_POLICY_ID_AT_SUBMIT"
+ }
+ }
+ ]
+}
diff --git a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca.json b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca.json
new file mode 100644
index 00000000..ce3158d9
--- /dev/null
+++ b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca.json
@@ -0,0 +1,36 @@
+{
+ "global": [
+ {
+ "name": "service",
+ "value": [
+ "4cc5b45a-1f63-4194-8100-cd8e14248c92"
+ ]
+ },
+ {
+ "name": "vf",
+ "value": [
+ "07e266fc-49ab-4cd7-8378-ca4676f1b9ec"
+ ]
+ },
+ {
+ "name": "actionSet",
+ "value": [
+ "vnfRecipe"
+ ]
+ },
+ {
+ "name": "location",
+ "value": [
+ "DC1"
+ ]
+ },
+ {
+ "name": "deployParameters",
+ "value": {
+ "location_id": "",
+ "service_id": "",
+ "policy_id": "AUTO_GENERATED_POLICY_ID_AT_SUBMIT"
+ }
+ }
+ ]
+}