private Map<String, ToscaMetadataProcess> mapOfProcesses = new HashMap<>();
/**
- * This method executes the required process specified in processInfo
+ * This method executes the required process specified in processInfo.
*
* @param processInfo A String containing the process to execute, like "cds/param1:value1/param2:value2"
* @param childObject The jsonObject
String[] processParameters = (processInfo + "/ ").split("/");
logger.info("Executing the Tosca clamp process " + processParameters[0] + " with parameters "
+ processParameters[1].trim());
- mapOfProcesses.get(processParameters[0].trim()).executeProcess(processParameters[1].trim(), childObject, serviceModel);
+ mapOfProcesses.get(processParameters[0].trim())
+ .executeProcess(processParameters[1].trim(), childObject, serviceModel);
}
/**
package org.onap.clamp.loop.deploy;
import com.google.gson.JsonObject;
-
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
-
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.loop.Loop;
+import org.onap.clamp.loop.components.external.DcaeComponent;
import org.onap.clamp.policy.microservice.MicroServicePolicy;
import org.yaml.snakeyaml.Yaml;
Set<MicroServicePolicy> microServiceList = loop.getMicroServicePolicies();
for (MicroServicePolicy microService : microServiceList) {
- deploymentParamMap.put(microService.getName(),
- generateDcaeDeployParameter(microService));
+ deploymentParamMap.put(microService.getName(),
+ generateDcaeDeployParameter(microService));
}
return deploymentParamMap;
}
microService.getName());
}
- private static JsonObject generateDcaeDeployParameter(String blueprint, String tabName) {
+ private static JsonObject generateDcaeDeployParameter(String blueprint, String policyId) {
JsonObject deployJsonBody = new JsonObject();
Yaml yaml = new Yaml();
Map<String, Object> inputsNodes = ((Map<String, Object>) ((Map<String, Object>) yaml
Object defaultValue = ((Map<String, Object>) elem.getValue()).get("default");
if (defaultValue != null) {
addPropertyToNode(deployJsonBody, elem.getKey(), defaultValue);
- } else {
+ }
+ else {
deployJsonBody.addProperty(elem.getKey(), "");
}
});
- // For Dublin only one micro service is expected
- deployJsonBody.addProperty("policy_id", tabName);
+ deployJsonBody.addProperty("policy_id", policyId);
return deployJsonBody;
}
private static void addPropertyToNode(JsonObject node, String key, Object value) {
if (value instanceof String) {
node.addProperty(key, (String) value);
- } else if (value instanceof Number) {
+ }
+ else if (value instanceof Number) {
node.addProperty(key, (Number) value);
- } else if (value instanceof Boolean) {
+ }
+ else if (value instanceof Boolean) {
node.addProperty(key, (Boolean) value);
- } else if (value instanceof Character) {
+ }
+ else if (value instanceof Character) {
node.addProperty(key, (Character) value);
- } else {
+ }
+ else {
node.addProperty(key, JsonUtils.GSON.toJson(value));
}
}
JsonObject globalProperties = new JsonObject();
JsonObject deployParamJson = new JsonObject();
if (loop.getLoopTemplate().getUniqueBlueprint()) {
- String tabName = "loop template blueprint";
- deployParamJson.add(tabName, generateDcaeDeployParameter(loop.getLoopTemplate().getBlueprint(), tabName));
- } else {
+ // Normally the unique blueprint could contain multiple microservices but then we can't guess
+ // the policy id params that will be used, so here we expect only one by default.
+ deployParamJson.add(DcaeComponent.UNIQUE_BLUEPRINT_PARAMETERS,
+ generateDcaeDeployParameter(loop.getLoopTemplate().getBlueprint(),
+ ((MicroServicePolicy) loop.getMicroServicePolicies().toArray()[0]).getName()));
+
+ }
+ else {
LinkedHashMap<String, JsonObject> deploymentParamMap = init(loop);
for (Map.Entry<String, JsonObject> mapElement : deploymentParamMap.entrySet()) {
deployParamJson.add(mapElement.getKey(), mapElement.getValue());
private Loop createTestLoop() {
Loop loopTest = new Loop("ControlLoopTest", "<xml></xml>");
loopTest.setGlobalPropertiesJson(
- new Gson().fromJson("{\"dcaeDeployParameters\":{\"loop template blueprint\": {\"policy_id\": \"name\"}}}", JsonObject.class));
+ new Gson().fromJson(
+ "{\"dcaeDeployParameters\":{\"uniqueBlueprintParameters\": {\"policy_id\": \"name\"}}}",
+ JsonObject.class));
loopTest.setLastComputedState(LoopState.DESIGN);
loopTest.setDcaeDeploymentId("123456789");
loopTest.setDcaeDeploymentStatusUrl("http4://localhost:8085");
MicroServicePolicy microServicePolicy = new MicroServicePolicy("configPolicyTest", new PolicyModel("policy1",
- "tosca_definitions_version: tosca_simple_yaml_1_0_0","1.0.0"), true,
+ "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0"), true,
new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), null, null, null);
microServicePolicy.setConfigurationsJson(new Gson().fromJson("{\"param1\":\"value1\"}", JsonObject.class));
/**
* Test the DcaeReponse roughly.
+ *
* @throws IOException In case of issues
*/
@Test
/**
* Test the Converter to DcaeInventoryResponse method.
- * @throws IOException In case of failure
+ *
+ * @throws IOException In case of failure
* @throws ParseException In case of failure
*/
@Test