From afac3121bfacc4d81903b1d8492613b0b77d3298 Mon Sep 17 00:00:00 2001 From: sebdet Date: Thu, 19 Mar 2020 10:29:30 -0700 Subject: Fix the CDS calls Fix the CDS calls for generic tosca policies, the new tosca parser must be interrupted so that clamp can do json schema enrichment Issue-ID: CLAMP-786 Signed-off-by: sebdet Change-Id: Ib7e85a6cc3849f614a3025779d29e8024f7a2ef2 --- .../ToscaConverterWithDictionarySupport.java | 13 +- .../update/execution/ToscaMetadataExecutor.java | 110 +++++ .../update/execution/ToscaMetadataProcess.java | 43 ++ .../execution/cds/ToscaMetadataCdsProcess.java | 113 +++++ .../target/ToscaMetadataTargetProcess.java | 40 ++ .../update/parser/ToscaConverterToJsonSchema.java | 14 +- .../parser/metadata/ToscaMetadataParser.java | 3 +- .../ToscaMetadataParserWithDictionarySupport.java | 53 ++- .../update/templates/JsonTemplateManager.java | 21 +- .../java/org/onap/clamp/loop/LoopController.java | 2 +- .../clamp/loop/template/PolicyModelsService.java | 4 +- src/main/java/org/onap/clamp/policy/Policy.java | 5 +- .../policy/microservice/MicroServicePolicy.java | 13 +- .../microservice/MicroServicePolicyService.java | 8 +- .../policy/operational/OperationalPolicy.java | 16 +- .../OperationalPolicyRepresentationBuilder.java | 36 +- .../operational/OperationalPolicyService.java | 2 +- .../org/onap/clamp/tosca/DictionaryService.java | 6 +- src/main/resources/META-INF/resources/swagger.html | 351 +++++++++------ .../tosca/DictionaryRepositoriesTestItCase.java | 10 +- .../clds/tosca/update/JsonTemplateManagerTest.java | 10 +- .../ToscaConverterWithDictionarySupportItCase.java | 33 +- .../1.0.0?connectionTimeToLive=5000/.file | 10 +- .../1.0.0?connectionTimeToLive=5000/.file | 10 +- .../new-converter/tosca_apex_with_metadata.json | 475 +++++++++++++++++++++ .../tosca_metadata_clamp_possible_values.yaml | 184 ++++++++ 26 files changed, 1342 insertions(+), 243 deletions(-) create mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java create mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/execution/ToscaMetadataProcess.java create mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java create mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java create mode 100644 src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json create mode 100644 src/test/resources/tosca/new-converter/tosca_metadata_clamp_possible_values.yaml (limited to 'src') diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupport.java b/src/main/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupport.java index c1bf1ad80..5832986a1 100644 --- a/src/main/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupport.java +++ b/src/main/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupport.java @@ -32,6 +32,7 @@ import org.onap.clamp.clds.tosca.update.parser.metadata.ToscaMetadataParser; import org.onap.clamp.clds.tosca.update.parser.metadata.ToscaMetadataParserWithDictionarySupport; import org.onap.clamp.clds.tosca.update.templates.JsonTemplateManager; import org.onap.clamp.clds.util.JsonUtils; +import org.onap.clamp.loop.service.Service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -63,15 +64,18 @@ public class ToscaConverterWithDictionarySupport { * * @param toscaFile The tosca file as String * @param policyTypeToDecode The policy type to decode + * @param serviceModel The service model associated so that the clamp enrichment could be done if required by + * the tosca model * @return A json object being a json schema */ - public JsonObject convertToscaToJsonSchemaObject(String toscaFile, String policyTypeToDecode) { + public JsonObject convertToscaToJsonSchemaObject(String toscaFile, String policyTypeToDecode, + Service serviceModel) { try { return new JsonTemplateManager(toscaFile, clampProperties.getFileContent("tosca.converter.default.datatypes"), clampProperties.getFileContent("tosca.converter.json.schema.templates")) .getJsonSchemaForPolicyType(policyTypeToDecode, Boolean.parseBoolean(clampProperties.getStringValue( - "tosca.converter.dictionary.support.enabled")) ? metadataParser : null); + "tosca.converter.dictionary.support.enabled")) ? metadataParser : null, serviceModel); } catch (IOException | UnknownComponentException e) { logger.error("Unable to convert the tosca properly, exception caught during the decoding", e); @@ -85,9 +89,10 @@ public class ToscaConverterWithDictionarySupport { * * @param toscaFile The tosca file as String * @param policyTypeToDecode The policy type to decode + * @param serviceModel The service Model so that clamp enrichment could be done if required by tosca model * @return A String containing the json schema */ - public String convertToscaToJsonSchemaString(String toscaFile, String policyTypeToDecode) { - return JsonUtils.GSON.toJson(this.convertToscaToJsonSchemaObject(toscaFile, policyTypeToDecode)); + public String convertToscaToJsonSchemaString(String toscaFile, String policyTypeToDecode, Service serviceModel) { + return JsonUtils.GSON.toJson(this.convertToscaToJsonSchemaObject(toscaFile, policyTypeToDecode, serviceModel)); } } diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java b/src/main/java/org/onap/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java new file mode 100644 index 000000000..dbd8ee1bc --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2020 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.clds.tosca.update.execution; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.google.gson.JsonObject; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.PostConstruct; +import org.onap.clamp.clds.tosca.update.execution.cds.ToscaMetadataCdsProcess; +import org.onap.clamp.clds.tosca.update.execution.target.ToscaMetadataTargetProcess; +import org.onap.clamp.loop.service.Service; +import org.onap.clamp.tosca.Dictionary; +import org.onap.clamp.tosca.DictionaryElement; +import org.onap.clamp.tosca.DictionaryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This class is used to execute a code based on a key found in the metadata section. + */ +@Component +public class ToscaMetadataExecutor { + + private static final EELFLogger logger = + EELFManager.getInstance().getLogger(ToscaMetadataExecutor.class); + + @Autowired + private DictionaryService dictionaryService; + + private Map mapOfProcesses = new HashMap<>(); + + /** + * 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 + * @param serviceModel The service model associated to do clamp enrichment + */ + public void executeTheProcess(String processInfo, JsonObject childObject, Service serviceModel) { + String[] processParameters = (processInfo + "/ ").split("/"); + logger.info("Executing the Tosca clamp process " + processParameters[0] + " with parameters " + + processParameters[1].trim()); + mapOfProcesses.get(processParameters[0]).executeProcess(processParameters[1].trim(), childObject, serviceModel); + } + + /** + * Init method. + */ + @PostConstruct + public void init() { + mapOfProcesses.put("CDS", new ToscaMetadataCdsProcess()); + mapOfProcesses.put("CSAR_RESOURCES", new ToscaMetadataTargetProcess()); + + preProvisionDictionaryTable(); + } + + private void preProvisionDictionaryTable() { + // Set up dictionary elements + Dictionary actorDictionary = new Dictionary(); + actorDictionary.setName("DefaultActor"); + actorDictionary.setSecondLevelDictionary(0); + actorDictionary.setSubDictionaryType(""); + + DictionaryElement elementSo = new DictionaryElement(); + elementSo.setName("SO"); + elementSo.setShortName("SO"); + elementSo.setType("string"); + elementSo.setDescription("SO component"); + actorDictionary.addDictionaryElements(elementSo); + + DictionaryElement elementSdnc = new DictionaryElement(); + elementSdnc.setName("SDNC"); + elementSdnc.setShortName("SDNC"); + elementSdnc.setType("string"); + elementSdnc.setDescription("SDNC component"); + actorDictionary.addDictionaryElements(elementSdnc); + + DictionaryElement elementCds = new DictionaryElement(); + elementCds.setName("CDS"); + elementCds.setShortName("CDS"); + elementCds.setType("string"); + elementCds.setDescription("CDS component"); + actorDictionary.addDictionaryElements(elementCds); + + dictionaryService.saveOrUpdateDictionary(actorDictionary); + } +} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/execution/ToscaMetadataProcess.java b/src/main/java/org/onap/clamp/clds/tosca/update/execution/ToscaMetadataProcess.java new file mode 100644 index 000000000..214eadb03 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/tosca/update/execution/ToscaMetadataProcess.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2020 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.clds.tosca.update.execution; + +import com.google.gson.JsonObject; +import org.onap.clamp.loop.service.Service; + +/** + * This code is the interface that must be implemented to have a tosca process. + */ +public abstract class ToscaMetadataProcess { + + /** + * This method add some elements to the JsonObject childObject passed in argument. + * The process can take multiple parameters in arguments. + * + * @param parameters The parameters required by the process + * @param childObject The Json Object modified by the current process + * @param serviceModel The service model associated to do clamp enrichment + */ + public abstract void executeProcess(String parameters, JsonObject childObject, Service serviceModel); +} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java b/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java new file mode 100644 index 000000000..cf9e010b3 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2020 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.clds.tosca.update.execution.cds; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import java.util.Map; +import org.onap.clamp.clds.tosca.update.execution.ToscaMetadataProcess; +import org.onap.clamp.loop.service.Service; +import org.onap.clamp.tosca.DictionaryService; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * This class is there to add the JsonObject for CDS in the json Schema according to what is found in the Tosca model. + */ +public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { + + @Autowired + private DictionaryService dictionaryService; + + @Override + public void executeProcess(String parameters, JsonObject childObject, Service serviceModel) { + switch (parameters) { + case "payload": + childObject.add("anyOf", generatePayload(serviceModel)); + break; + case "operation": + childObject.add("enum", generateOperation(serviceModel)); + break; + } + } + + private static JsonArray generatePayload(Service serviceModel) { + JsonArray schemaAnyOf = new JsonArray(); + schemaAnyOf.addAll(generatePayloadPerResource("VF", serviceModel)); + schemaAnyOf.addAll(generatePayloadPerResource("PNF", serviceModel)); + return schemaAnyOf; + } + + private static JsonArray generateOperation(Service serviceModel) { + JsonArray schemaEnum = new JsonArray(); + schemaEnum.addAll(generateOperationPerResource("VF", serviceModel)); + schemaEnum.addAll(generateOperationPerResource("PNF", serviceModel)); + return schemaEnum; + } + + private static JsonArray generateOperationPerResource(String resourceName, Service serviceModel) { + JsonArray schemaEnum = new JsonArray(); + for (Map.Entry entry : serviceModel.getResourceDetails().getAsJsonObject(resourceName) + .entrySet()) { + JsonObject controllerProperties = entry.getValue().getAsJsonObject() + .getAsJsonObject("controllerProperties"); + if (controllerProperties != null) { + for (String workflowsEntry : controllerProperties.getAsJsonObject("workflows").keySet()) { + schemaEnum.add(workflowsEntry); + } + } + } + return schemaEnum; + } + + private static JsonArray generatePayloadPerResource(String resourceName, Service serviceModel) { + JsonArray schemaAnyOf = new JsonArray(); + for (Map.Entry entry : serviceModel.getResourceDetails().getAsJsonObject(resourceName) + .entrySet()) { + JsonObject controllerProperties = entry.getValue().getAsJsonObject() + .getAsJsonObject("controllerProperties"); + if (controllerProperties != null) { + for (Map.Entry workflowsEntry : controllerProperties.getAsJsonObject("workflows") + .entrySet()) { + JsonObject obj = new JsonObject(); + obj.addProperty("title", workflowsEntry.getKey()); + obj.add("properties", createPayloadProperty(workflowsEntry.getValue().getAsJsonObject(), + controllerProperties)); + schemaAnyOf.add(obj); + } + } + } + return schemaAnyOf; + } + + private static JsonObject createPayloadProperty(JsonObject workFlow, JsonObject controllerProperties) { + JsonObject payloadResult = new JsonObject(); + + payloadResult.addProperty("artifact_name", controllerProperties.get("sdnc_model_name").getAsString()); + payloadResult.addProperty("artifact_version", controllerProperties.get("sdnc_model_version").getAsString()); + payloadResult.addProperty("mode", "async"); + payloadResult.add("data", workFlow.getAsJsonObject("inputs")); + return payloadResult; + } +} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java b/src/main/java/org/onap/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java new file mode 100644 index 000000000..8b8fa1784 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/tosca/update/execution/target/ToscaMetadataTargetProcess.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2020 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.clds.tosca.update.execution.target; + +import com.google.gson.JsonObject; +import org.onap.clamp.clds.tosca.update.execution.ToscaMetadataProcess; +import org.onap.clamp.loop.service.Service; +import org.onap.clamp.policy.operational.OperationalPolicyRepresentationBuilder; + +/** + * This class is there to add the JsonObject for CDS in the json Schema according to what is found in the Tosca model. + */ +public class ToscaMetadataTargetProcess extends ToscaMetadataProcess { + + @Override + public void executeProcess(String parameters, JsonObject childObject, Service serviceModel) { + childObject.add("anyOf", OperationalPolicyRepresentationBuilder.createAnyOfArray(serviceModel, false)); + } +} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java b/src/main/java/org/onap/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java index cfc0e42a8..e1d493a35 100644 --- a/src/main/java/org/onap/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java +++ b/src/main/java/org/onap/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java @@ -33,6 +33,7 @@ import org.onap.clamp.clds.tosca.update.elements.ToscaElement; import org.onap.clamp.clds.tosca.update.elements.ToscaElementProperty; import org.onap.clamp.clds.tosca.update.parser.metadata.ToscaMetadataParser; import org.onap.clamp.clds.tosca.update.templates.JsonTemplate; +import org.onap.clamp.loop.service.Service; public class ToscaConverterToJsonSchema { private LinkedHashMap components; @@ -40,19 +41,23 @@ public class ToscaConverterToJsonSchema { private ToscaMetadataParser metadataParser; + private Service serviceModel; + /** * Constructor. * * @param toscaElementsMap All the tosca elements found (policy type + data types + native tosca datatypes) * @param jsonSchemaTemplates All Json schema templates to use * @param metadataParser The metadata parser to use for metadata section + * @param serviceModel The service model for clamp enrichment */ public ToscaConverterToJsonSchema(LinkedHashMap toscaElementsMap, LinkedHashMap jsonSchemaTemplates, - ToscaMetadataParser metadataParser) { + ToscaMetadataParser metadataParser, Service serviceModel) { this.components = toscaElementsMap; this.templates = jsonSchemaTemplates; this.metadataParser = metadataParser; + this.serviceModel = serviceModel; } /** @@ -220,7 +225,7 @@ public class ToscaConverterToJsonSchema { break; case "metadata": if (metadataParser != null) { - metadataParser.processAllMetadataElement(toscaElementProperty).entrySet() + metadataParser.processAllMetadataElement(toscaElementProperty, serviceModel).entrySet() .forEach((jsonEntry) -> { propertiesInJson.add(jsonEntry.getKey(), jsonEntry.getValue()); @@ -238,9 +243,8 @@ public class ToscaConverterToJsonSchema { if (getToscaElement(this.extractSpecificFieldFromMap(toscaElementProperty, "entry_schema")) != null) { String nameComponent = this.extractSpecificFieldFromMap(toscaElementProperty, "entry_schema"); - ToscaConverterToJsonSchema - child = new ToscaConverterToJsonSchema(components, templates, - metadataParser); + ToscaConverterToJsonSchema child = new ToscaConverterToJsonSchema(components, templates, + metadataParser, serviceModel); JsonObject propertiesContainer = new JsonObject(); switch ((String) toscaElementProperty.getItems().get("type")) { diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParser.java b/src/main/java/org/onap/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParser.java index a51818e2e..f4a48139e 100644 --- a/src/main/java/org/onap/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParser.java +++ b/src/main/java/org/onap/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParser.java @@ -25,7 +25,8 @@ package org.onap.clamp.clds.tosca.update.parser.metadata; import com.google.gson.JsonObject; import org.onap.clamp.clds.tosca.update.elements.ToscaElementProperty; +import org.onap.clamp.loop.service.Service; public interface ToscaMetadataParser { - JsonObject processAllMetadataElement(ToscaElementProperty toscaElementProperty); + JsonObject processAllMetadataElement(ToscaElementProperty toscaElementProperty, Service serviceModel); } diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java b/src/main/java/org/onap/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java index 349ccee9e..8aff9668f 100644 --- a/src/main/java/org/onap/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java +++ b/src/main/java/org/onap/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java @@ -29,10 +29,11 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Optional; -import org.json.JSONArray; import org.onap.clamp.clds.tosca.JsonEditorSchemaConstants; import org.onap.clamp.clds.tosca.ToscaSchemaConstants; import org.onap.clamp.clds.tosca.update.elements.ToscaElementProperty; +import org.onap.clamp.clds.tosca.update.execution.ToscaMetadataExecutor; +import org.onap.clamp.loop.service.Service; import org.onap.clamp.tosca.DictionaryElement; import org.onap.clamp.tosca.DictionaryService; import org.springframework.beans.factory.annotation.Autowired; @@ -41,6 +42,9 @@ import org.springframework.stereotype.Component; @Component public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataParser { + @Autowired + private ToscaMetadataExecutor toscaMetadataExecutor; + @Autowired private DictionaryService dictionaryService; @@ -50,9 +54,10 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa * @param toscaElementProperty The property metadata as Json Object * @return The jsonObject structure that must be added to the json schema */ - public JsonObject processAllMetadataElement(ToscaElementProperty toscaElementProperty) { + public JsonObject processAllMetadataElement(ToscaElementProperty toscaElementProperty, Service serviceModel) { if (dictionaryService != null) { - return parseMetadataPossibleValues(toscaElementProperty.getItems(), dictionaryService); + return parseMetadataPossibleValues(toscaElementProperty.getItems(), dictionaryService, serviceModel, + toscaMetadataExecutor); } else { return null; @@ -60,38 +65,32 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa } private static JsonObject parseMetadataPossibleValues(LinkedHashMap childNodeMap, - DictionaryService dictionaryService) { + DictionaryService dictionaryService, Service serviceModel, + ToscaMetadataExecutor toscaMetadataExecutor) { JsonObject childObject = new JsonObject(); if (childNodeMap.containsKey(ToscaSchemaConstants.METADATA) && childNodeMap.get(ToscaSchemaConstants.METADATA) != null) { - LinkedHashMap metadataMap = - (LinkedHashMap) childNodeMap.get(ToscaSchemaConstants.METADATA); - if (metadataMap != null) { - metadataMap.entrySet().stream().forEach(constraint -> { - if (constraint.getKey() - .equalsIgnoreCase(ToscaSchemaConstants.METADATA_CLAMP_POSSIBLE_VALUES)) { - JSONArray validValuesArray = new JSONArray(); - if (constraint.getValue() instanceof ArrayList) { - boolean processDictionary = ((ArrayList) constraint.getValue()) - .stream().anyMatch(value -> (value instanceof String - && ((String) value).contains(ToscaSchemaConstants.DICTIONARY))); - if (processDictionary) { - ((ArrayList) constraint.getValue()).stream().forEach(value -> { - if ((value instanceof String && ((String) value) - .contains(ToscaSchemaConstants.DICTIONARY))) { - processDictionaryElements((String) value, childObject, dictionaryService); - } - - }); - } - } + ((LinkedHashMap) childNodeMap.get(ToscaSchemaConstants.METADATA)).forEach((key, + value) -> { + if (key.equalsIgnoreCase(ToscaSchemaConstants.METADATA_CLAMP_POSSIBLE_VALUES)) { + if (((String) value).contains(ToscaSchemaConstants.DICTIONARY)) { + processDictionaryElements((String) value, childObject, dictionaryService); } - }); - } + if (((String) value).contains("ClampExecution:")) { + executeClampProcess(((String) value).replaceAll("ClampExecution:", ""), childObject, + serviceModel, toscaMetadataExecutor); + } + } + }); } return childObject; } + private static void executeClampProcess(String processInfo, JsonObject childObject, Service serviceModel, + ToscaMetadataExecutor toscaMetadataExecutor) { + toscaMetadataExecutor.executeTheProcess(processInfo, childObject, serviceModel); + } + private static void processDictionaryElements(String dictionaryReference, JsonObject childObject, DictionaryService dictionaryService) { String[] dictionaryKeyArray = diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/templates/JsonTemplateManager.java b/src/main/java/org/onap/clamp/clds/tosca/update/templates/JsonTemplateManager.java index 5e4b66009..0b399ba0b 100644 --- a/src/main/java/org/onap/clamp/clds/tosca/update/templates/JsonTemplateManager.java +++ b/src/main/java/org/onap/clamp/clds/tosca/update/templates/JsonTemplateManager.java @@ -35,6 +35,7 @@ import org.onap.clamp.clds.tosca.update.parser.ToscaConverterToJsonSchema; import org.onap.clamp.clds.tosca.update.parser.ToscaElementParser; import org.onap.clamp.clds.tosca.update.parser.metadata.ToscaMetadataParser; import org.onap.clamp.clds.util.JsonUtils; +import org.onap.clamp.loop.service.Service; public class JsonTemplateManager { private LinkedHashMap jsonSchemaTemplates; @@ -45,7 +46,7 @@ public class JsonTemplateManager { * * @param toscaYamlContent Policy Tosca Yaml content as string * @param nativeToscaDatatypes The tosca yaml with tosca native datatypes - * @param jsonSchemaTemplates template properties as string + * @param jsonSchemaTemplates template properties as string */ public JsonTemplateManager(String toscaYamlContent, String nativeToscaDatatypes, String jsonSchemaTemplates) { if (toscaYamlContent != null && !toscaYamlContent.isEmpty()) { @@ -107,11 +108,13 @@ public class JsonTemplateManager { */ public void updateTemplate(String nameTemplate, JsonTemplateField jsonTemplateField, Boolean operation) { // Operation = true && field is not present => add Field - if (operation && !this.jsonSchemaTemplates.get(nameTemplate).getJsonTemplateFields().contains(jsonTemplateField)) { + if (operation + && !this.jsonSchemaTemplates.get(nameTemplate).getJsonTemplateFields().contains(jsonTemplateField)) { this.jsonSchemaTemplates.get(nameTemplate).addField(jsonTemplateField); } // Operation = false && field is present => remove Field - else if (!operation && this.jsonSchemaTemplates.get(nameTemplate).getJsonTemplateFields().contains(jsonTemplateField)) { + else if (!operation + && this.jsonSchemaTemplates.get(nameTemplate).getJsonTemplateFields().contains(jsonTemplateField)) { this.jsonSchemaTemplates.get(nameTemplate).removeField(jsonTemplateField); } } @@ -135,16 +138,17 @@ public class JsonTemplateManager { /** * For a given policy type, get a corresponding JsonObject from the tosca model. * - * @param policyType The policy type in the tosca + * @param policyType The policy type in the tosca * @param toscaMetadataParser The MetadataParser class that must be used if metadata section are encountered, if null - * they will be skipped + * they will be skipped * @return an json object defining the equivalent json schema from the tosca for a given policy type */ - public JsonObject getJsonSchemaForPolicyType(String policyType, ToscaMetadataParser toscaMetadataParser) + public JsonObject getJsonSchemaForPolicyType(String policyType, ToscaMetadataParser toscaMetadataParser, + Service serviceModel) throws UnknownComponentException { ToscaConverterToJsonSchema toscaConverterToJsonSchema = new ToscaConverterToJsonSchema(toscaElements, jsonSchemaTemplates, - toscaMetadataParser); + toscaMetadataParser, serviceModel); if (toscaConverterToJsonSchema.getToscaElement(policyType) == null) { throw new UnknownComponentException(policyType); } @@ -180,5 +184,4 @@ public class JsonTemplateManager { } return generatedTemplates; } - -} +} \ No newline at end of file diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java index 9c2c71f5f..a2a44631b 100644 --- a/src/main/java/org/onap/clamp/loop/LoopController.java +++ b/src/main/java/org/onap/clamp/loop/LoopController.java @@ -207,7 +207,7 @@ public class LoopController { for (MicroServicePolicy microServicePolicy : loop.getMicroServicePolicies()) { if (microServicePolicy.getName().equals(microServicePolicyName)) { this.microServicePolicyService - .refreshMicroServicePolicyJsonRepresentation(microServicePolicy, toscaConverter); + .refreshMicroServicePolicyJsonRepresentation(microServicePolicy, toscaConverter, loop); } } return loop; diff --git a/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java b/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java index ae66c54b8..98b928916 100644 --- a/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java +++ b/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java @@ -148,7 +148,7 @@ public class PolicyModelsService { public void createPolicyInDbIfNeeded(PolicyModel policyModel) { if (!policyModelsRepository.existsById( new PolicyModelId(policyModel.getPolicyModelType(), policyModel.getVersion()))) { - policyModelsRepository.save(policyModel); + policyModelsRepository.saveAndFlush(policyModel); } } @@ -173,7 +173,7 @@ public class PolicyModelsService { JsonObject supportedPdpJson = new JsonObject(); supportedPdpJson.add("supportedPdpGroups", supportedPdpGroups); policyModel.setPolicyPdpGroup(supportedPdpJson); - policyModelsRepository.save(policyModel); + policyModelsRepository.saveAndFlush(policyModel); } } } diff --git a/src/main/java/org/onap/clamp/policy/Policy.java b/src/main/java/org/onap/clamp/policy/Policy.java index abb16d73f..d84f2c8a0 100644 --- a/src/main/java/org/onap/clamp/policy/Policy.java +++ b/src/main/java/org/onap/clamp/policy/Policy.java @@ -46,6 +46,7 @@ import org.json.JSONObject; import org.onap.clamp.clds.tosca.update.ToscaConverterWithDictionarySupport; import org.onap.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.clamp.loop.common.AuditEntity; +import org.onap.clamp.loop.service.Service; import org.onap.clamp.loop.template.LoopElementModel; import org.onap.clamp.loop.template.PolicyModel; import org.yaml.snakeyaml.Yaml; @@ -171,8 +172,10 @@ public abstract class Policy extends AuditEntity { * Regenerate the Policy Json Representation. * * @param toscaConverter The tosca converter required to regenerate the json schema + * @param serviceModel The service model associated */ - public abstract void updateJsonRepresentation(ToscaConverterWithDictionarySupport toscaConverter); + public abstract void updateJsonRepresentation(ToscaConverterWithDictionarySupport toscaConverter, + Service serviceModel); /** * policyModel getter. diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java index b3bd7e88a..e997b4309 100644 --- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java +++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java @@ -129,10 +129,8 @@ public class MicroServicePolicy extends Policy implements Serializable { ToscaConverterWithDictionarySupport toscaConverter) { this(Policy.generatePolicyName("MICROSERVICE", service.getName(), service.getVersion(), RandomStringUtils.randomAlphanumeric(3), RandomStringUtils.randomAlphanumeric(3)), - loopElementModel.getPolicyModels().first(), false, - new JsonObject(), - loopElementModel, null, null); - this.updateJsonRepresentation(toscaConverter); + loopElementModel.getPolicyModels().first(), false, new JsonObject(), loopElementModel, null, null); + this.updateJsonRepresentation(toscaConverter, service); } @Override @@ -151,9 +149,10 @@ public class MicroServicePolicy extends Policy implements Serializable { } @Override - public void updateJsonRepresentation(ToscaConverterWithDictionarySupport toscaConverter) { - this.setJsonRepresentation(toscaConverter.convertToscaToJsonSchemaObject(this.getPolicyModel().getPolicyModelTosca(), - this.getPolicyModel().getPolicyModelType())); + public void updateJsonRepresentation(ToscaConverterWithDictionarySupport toscaConverter, Service serviceModel) { + this.setJsonRepresentation( + toscaConverter.convertToscaToJsonSchemaObject(this.getPolicyModel().getPolicyModelTosca(), + this.getPolicyModel().getPolicyModelType(), serviceModel)); } public Boolean getShared() { diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java index 0631380f5..37533c1f6 100644 --- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java +++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java @@ -99,11 +99,13 @@ public class MicroServicePolicyService implements PolicyServiceh2{page-b
  • 2. Paths
  • 3. Definitions @@ -736,7 +743,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b

    1.2. URI scheme

    -

    Host : localhost:46291
    +

    Host : localhost:42393
    BasePath : /restservices/clds/
    Schemes : HTTP

    @@ -747,7 +754,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b

    2. Paths

    -

    2.1. GET /v1/healthcheck

    +

    2.1. GET /v1/healthcheck

    2.1.1. Responses

    @@ -784,7 +791,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -818,7 +825,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -855,7 +862,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -892,7 +899,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1141,7 +1148,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1265,7 +1272,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1339,7 +1346,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1411,7 +1418,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1460,7 +1467,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1522,7 +1529,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1559,7 +1566,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1621,7 +1628,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1644,6 +1651,12 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b required

    + + + + +

    string

    Path

    microServicePolicyName
    +required

    string

    @@ -1683,7 +1696,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.18. PUT /v2/loop/removeOperationaPolicy/{loopName}/policyModel/{policyType}/{policyVersion}

    +

    2.18. PUT /v2/loop/refreshOperationalPolicyJsonSchema/{loopName}/{operationalPolicyName}

    2.18.1. Parameters

    @@ -1708,13 +1721,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b - - - - - - @@ -1757,7 +1764,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b

    Path

    policyType
    -required

    string

    Path

    policyVersion
    +

    operationalPolicyName
    required

    string

    @@ -1780,6 +1787,18 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b required

    + + + + + + + + + +

    string

    Path

    policyType
    +required

    string

    Path

    policyVersion
    +required

    string

    @@ -1819,7 +1838,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.20. PUT /v2/loop/stop/{loopName}

    +

    2.20. PUT /v2/loop/restart/{loopName}

    2.20.1. Parameters

    @@ -1881,7 +1900,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1943,7 +1962,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    @@ -1988,7 +2007,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b - +

    200

    Output type

    string

    Loop

    @@ -1998,14 +2017,14 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    • -

      application/xml

      +

      application/json

    -

    2.23. PUT /v2/loop/undeploy/{loopName}

    +

    2.23. GET /v2/loop/svgRepresentation/{loopName}

    2.23.1. Parameters

    @@ -2050,7 +2069,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b - +

    200

    Output type

    Loop

    string

    @@ -2060,14 +2079,14 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    • -

      application/json

      +

      application/xml

    -

    2.24. POST /v2/loop/updateGlobalProperties/{loopName}

    +

    2.24. PUT /v2/loop/undeploy/{loopName}

    2.24.1. Parameters

    @@ -2090,6 +2109,68 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b required

    + +

    string

    +
    +
    +

    2.24.2. Responses

    + +++++ + + + + + + + + + + + + + + +
    HTTP CodeDescriptionSchema

    200

    Output type

    Loop

    +
    +
    +

    2.24.3. Produces

    +
    +
      +
    • +

      application/json

      +
    • +
    +
    +
    +
    +
    +

    2.25. POST /v2/loop/updateGlobalProperties/{loopName}

    +
    +

    2.25.1. Parameters

    + +++++ + + + + + + + + + + + + +
    TypeNameSchema

    Path

    loopName
    +required

    string

    Body

    body
    @@ -2100,7 +2181,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b

    -

    2.24.2. Responses

    +

    2.25.2. Responses

    @@ -2124,7 +2205,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.24.3. Consumes

    +

    2.25.3. Consumes

    • @@ -2134,7 +2215,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.24.4. Produces

    +

    2.25.4. Produces

    • @@ -2145,9 +2226,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.25. POST /v2/loop/updateMicroservicePolicy/{loopName}

    +

    2.26. POST /v2/loop/updateMicroservicePolicy/{loopName}

    -

    2.25.1. Parameters

    +

    2.26.1. Parameters

    @@ -2178,7 +2259,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.25.2. Responses

    +

    2.26.2. Responses

    @@ -2202,7 +2283,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.25.3. Consumes

    +

    2.26.3. Consumes

    • @@ -2212,7 +2293,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.25.4. Produces

    +

    2.26.4. Produces

    • @@ -2223,9 +2304,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.26. POST /v2/loop/updateOperationalPolicies/{loopName}

    +

    2.27. POST /v2/loop/updateOperationalPolicies/{loopName}

    -

    2.26.1. Parameters

    +

    2.27.1. Parameters

    @@ -2256,7 +2337,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.26.2. Responses

    +

    2.27.2. Responses

    @@ -2280,7 +2361,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.26.3. Consumes

    +

    2.27.3. Consumes

    • @@ -2290,7 +2371,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.26.4. Produces

    +

    2.27.4. Produces

    • @@ -2301,9 +2382,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.27. GET /v2/loop/{loopName}

    +

    2.28. GET /v2/loop/{loopName}

    -

    2.27.1. Parameters

    +

    2.28.1. Parameters

    @@ -2328,7 +2409,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.27.2. Responses

    +

    2.28.2. Responses

    @@ -2352,7 +2433,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.27.3. Produces

    +

    2.28.3. Produces

    • @@ -2363,9 +2444,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.28. POST /v2/policyToscaModels

    +

    2.29. POST /v2/policyToscaModels

    -

    2.28.1. Parameters

    +

    2.29.1. Parameters

    @@ -2390,7 +2471,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.28.2. Responses

    +

    2.29.2. Responses

    @@ -2414,7 +2495,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.28.3. Consumes

    +

    2.29.3. Consumes

    • @@ -2424,7 +2505,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.28.4. Produces

    +

    2.29.4. Produces

    • @@ -2435,9 +2516,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.29. GET /v2/policyToscaModels

    +

    2.30. GET /v2/policyToscaModels

    -

    2.29.1. Responses

    +

    2.30.1. Responses

    @@ -2461,7 +2542,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.29.2. Produces

    +

    2.30.2. Produces

    • @@ -2472,9 +2553,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.30. GET /v2/policyToscaModels/yaml/{policyModelType}/{policyModelVersion}

    +

    2.31. GET /v2/policyToscaModels/yaml/{policyModelType}/{policyModelVersion}

    -

    2.30.1. Parameters

    +

    2.31.1. Parameters

    @@ -2505,7 +2586,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.30.2. Responses

    +

    2.31.2. Responses

    @@ -2529,7 +2610,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.30.3. Produces

    +

    2.31.3. Produces

    • @@ -2540,9 +2621,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.31. GET /v2/policyToscaModels/{policyModelType}/{policyModelVersion}

    +

    2.32. GET /v2/policyToscaModels/{policyModelType}/{policyModelVersion}

    -

    2.31.1. Parameters

    +

    2.32.1. Parameters

    @@ -2573,7 +2654,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.31.2. Responses

    +

    2.32.2. Responses

    @@ -2597,7 +2678,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.31.3. Produces

    +

    2.32.3. Produces

    • @@ -2608,9 +2689,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.32. PUT /v2/policyToscaModels/{policyModelType}/{policyModelVersion}

    +

    2.33. PUT /v2/policyToscaModels/{policyModelType}/{policyModelVersion}

    -

    2.32.1. Parameters

    +

    2.33.1. Parameters

    @@ -2647,7 +2728,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.32.2. Responses

    +

    2.33.2. Responses

    @@ -2671,7 +2752,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.32.3. Consumes

    +

    2.33.3. Consumes

    • @@ -2681,7 +2762,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.32.4. Produces

    +

    2.33.4. Produces

    • @@ -2692,9 +2773,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.33. GET /v2/templates

    +

    2.34. GET /v2/templates

    -

    2.33.1. Responses

    +

    2.34.1. Responses

    @@ -2718,7 +2799,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.33.2. Produces

    +

    2.34.2. Produces

    • @@ -2729,9 +2810,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.34. GET /v2/templates/names

    +

    2.35. GET /v2/templates/names

    -

    2.34.1. Responses

    +

    2.35.1. Responses

    @@ -2755,7 +2836,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.34.2. Produces

    +

    2.35.2. Produces

    • @@ -2766,9 +2847,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.35. GET /v2/templates/{templateName}

    +

    2.36. GET /v2/templates/{templateName}

    -

    2.35.1. Parameters

    +

    2.36.1. Parameters

    @@ -2793,7 +2874,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.35.2. Responses

    +

    2.36.2. Responses

    @@ -2817,7 +2898,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.35.3. Produces

    +

    2.36.3. Produces

    • @@ -2828,9 +2909,9 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.36. GET /v2/templates/{templateName}/svgRepresentation

    +

    2.37. GET /v2/templates/{templateName}/svgRepresentation

    -

    2.36.1. Parameters

    +

    2.37.1. Parameters

    @@ -2855,7 +2936,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.36.2. Responses

    +

    2.37.2. Responses

    @@ -2879,7 +2960,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
    -

    2.36.3. Produces

    +

    2.37.3. Produces

    • diff --git a/src/test/java/org/onap/clamp/clds/tosca/DictionaryRepositoriesTestItCase.java b/src/test/java/org/onap/clamp/clds/tosca/DictionaryRepositoriesTestItCase.java index 5208f7ffd..2faf38f0a 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/DictionaryRepositoriesTestItCase.java +++ b/src/test/java/org/onap/clamp/clds/tosca/DictionaryRepositoriesTestItCase.java @@ -76,13 +76,13 @@ public class DictionaryRepositoriesTestItCase { dictionaryRepository.save(dictionaryTest1); List res1 = dictionaryRepository.getAllDictionaryNames(); - assertThat(res1.size()).isEqualTo(1); - assertThat(res1.get(0)).isEqualTo("testDictionary1"); + assertThat(res1.size()).isGreaterThan(1); + assertThat(res1).contains("testDictionary1"); dictionaryRepository.save(dictionaryTest2); List res2 = dictionaryRepository.getAllDictionaryNames(); - assertThat(res2.size()).isEqualTo(2); - assertThat(res2.get(0)).isEqualTo("testDictionary1"); - assertThat(res2.get(1)).isEqualTo("testDictionary2"); + assertThat(res2.size()).isGreaterThan(2); + assertThat(res2).contains("testDictionary1"); + assertThat(res2).contains("testDictionary2"); } } diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/JsonTemplateManagerTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/JsonTemplateManagerTest.java index 693377ee0..0a0710c65 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/JsonTemplateManagerTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/JsonTemplateManagerTest.java @@ -50,7 +50,7 @@ public class JsonTemplateManagerTest extends TestCase { "clds/tosca-converter/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); String componentName = "onap.policies.monitoring.cdap.tca.hi.lo.app"; - jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null); + jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null); } /** @@ -68,7 +68,7 @@ public class JsonTemplateManagerTest extends TestCase { "clds/tosca-converter/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); String componentName = "onap.policies.controlloop.guard.common.FrequencyLimiter"; - jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null); + jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null); } /** @@ -86,7 +86,7 @@ public class JsonTemplateManagerTest extends TestCase { "clds/tosca-converter/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); String componentName = "onap.policies.controlloop.operational.common.Apex"; - jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null); + jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null); } /** @@ -104,7 +104,7 @@ public class JsonTemplateManagerTest extends TestCase { "clds/tosca-converter/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); String componentName = "onap.policies.controlloop.operational.common.Drools"; - jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null); + jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null); } @@ -121,7 +121,7 @@ public class JsonTemplateManagerTest extends TestCase { ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); String componentName = "onap.policies.controlloop.operational.common.Drools"; - jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null); + jsonTemplateManager.getJsonSchemaForPolicyType(componentName, null, null); } /** diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java index b4f8b1245..3ff6ffb33 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights * reserved. - * ================================================================================ + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -29,10 +29,12 @@ import javax.transaction.Transactional; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.Application; +import org.onap.clamp.clds.tosca.update.execution.ToscaMetadataExecutor; import org.onap.clamp.clds.tosca.update.parser.metadata.ToscaMetadataParserWithDictionarySupport; import org.onap.clamp.clds.tosca.update.templates.JsonTemplateManager; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.loop.service.Service; import org.onap.clamp.tosca.Dictionary; import org.onap.clamp.tosca.DictionaryElement; import org.onap.clamp.tosca.DictionaryService; @@ -51,6 +53,9 @@ public class ToscaConverterWithDictionarySupportItCase { @Autowired private ToscaMetadataParserWithDictionarySupport toscaMetadataParserWithDictionarySupport; + @Autowired + private ToscaMetadataExecutor toscaMetadataExecutor; + /** * This Test validates Tosca yaml with metadata tag that contains policy_model_type and acronym * parameters which defines the Tosca Policy name and its short name. @@ -103,16 +108,38 @@ public class ToscaConverterWithDictionarySupportItCase { JsonTemplateManager jsonTemplateManager = new JsonTemplateManager( - ResourceFileUtil.getResourceAsString("tosca/tosca_metadata_clamp_possible_values.yaml"), + ResourceFileUtil.getResourceAsString("tosca/new-converter/tosca_metadata_clamp_possible_values.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); JsonObject jsonSchema = jsonTemplateManager.getJsonSchemaForPolicyType( - "onap.policies.monitoring.cdap.tca.hi.lo.app", toscaMetadataParserWithDictionarySupport); + "onap.policies.monitoring.cdap.tca.hi.lo.app", toscaMetadataParserWithDictionarySupport, null); JSONAssert.assertEquals( ResourceFileUtil .getResourceAsString("tosca/new-converter/tca-with-metadata.json"), JsonUtils.GSON.toJson(jsonSchema), true); } + + @Test + @Transactional + public final void testMetadataClampPossibleValueWithExecutor() throws IOException, UnknownComponentException { + Service service = new Service(ResourceFileUtil.getResourceAsString("tosca/service-details.json"), + ResourceFileUtil.getResourceAsString("tosca/resource-details.json")); + JsonTemplateManager jsonTemplateManager = + new JsonTemplateManager( + ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + + ".policies.controlloop.operational.common.Apex/versions/1.0" + + ".0?connectionTimeToLive=5000/.file"), + ResourceFileUtil.getResourceAsString("clds/tosca-converter/default-tosca-types.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca-converter/templates.json")); + + JsonObject jsonSchema = jsonTemplateManager.getJsonSchemaForPolicyType( + "onap.policies.controlloop.operational.common.Apex", toscaMetadataParserWithDictionarySupport, service); + + JSONAssert.assertEquals( + ResourceFileUtil + .getResourceAsString("tosca/new-converter/tosca_apex_with_metadata.json"), + JsonUtils.GSON.toJson(jsonSchema), true); + } } diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Apex/versions/1.0.0?connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Apex/versions/1.0.0?connectionTimeToLive=5000/.file index 7d694eb8b..ae0dfbfc3 100644 --- a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Apex/versions/1.0.0?connectionTimeToLive=5000/.file +++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Apex/versions/1.0.0?connectionTimeToLive=5000/.file @@ -72,7 +72,7 @@ data_types: entity that generated the ONSET event will be the target. required: false metadata: - clamp_possible_values: test + clamp_possible_values: ClampExecution:CSAR_RESOURCES entry_schema: type: string @@ -85,23 +85,23 @@ data_types: description: The actor performing the operation. required: true metadata: - clamp_possible_values: test + clamp_possible_values: Dictionary:DefaultActor operation: type: string description: The operation the actor is performing. required: true metadata: - clamp_possible_values: test + clamp_possible_values: ClampExecution:CDS/operation target: type: onap.datatype.controlloop.Target description: The resource the operation should be performed on. required: true - metadata: - clamp_possible_values: test payload: type: map description: Name/value pairs of payload information passed by Policy to the actor required: false + metadata: + clamp_possible_values: ClampExecution:CDS/payload entry_schema: type: string diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0?connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0?connectionTimeToLive=5000/.file index 240009932..1f8723c3d 100644 --- a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0?connectionTimeToLive=5000/.file +++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0?connectionTimeToLive=5000/.file @@ -60,7 +60,7 @@ data_types: entity that generated the ONSET event will be the target. required: false metadata: - clamp_possible_values: test + clamp_possible_values: ClampExecution:CSAR_RESOURCES entry_schema: type: string @@ -73,23 +73,23 @@ data_types: description: The actor performing the operation. required: true metadata: - clamp_possible_values: test + clamp_possible_values: Dictionary:DefaultActor operation: type: string description: The operation the actor is performing. required: true metadata: - clamp_possible_values: test + clamp_possible_values: ClampExecution:CDS/operation target: type: onap.datatype.controlloop.Target description: The resource the operation should be performed on. required: true - metadata: - clamp_possible_values: test payload: type: map description: Name/value pairs of payload information passed by Policy to the actor required: false + metadata: + clamp_possible_values: ClampExecution:CDS/payload entry_schema: type: string diff --git a/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json b/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json new file mode 100644 index 000000000..a44b94e07 --- /dev/null +++ b/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json @@ -0,0 +1,475 @@ +{ + "title": "onap.policies.controlloop.operational.common.Apex", + "type": "object", + "description": "Operational policies for Apex PDP", + "required": [ + "id", + "timeout", + "abatement", + "trigger", + "operations", + "engineServiceParameters", + "eventInputParameters", + "eventOutputParameters" + ], + "properties": { + "id": { + "type": "string", + "description": "The unique control loop id." + }, + "timeout": { + "type": "integer", + "description": "Overall timeout for executing all the operations. This timeout should equal or exceed the total\ntimeout for each operation listed.\n" + }, + "abatement": { + "type": "boolean", + "description": "Whether an abatement event message will be expected for the control loop from DCAE.", + "default": false + }, + "trigger": { + "type": "string", + "description": "Initial operation to execute upon receiving an Onset event message for the Control Loop." + }, + "operations": { + "type": "array", + "description": "List of operations to be performed when Control Loop is triggered.", + "items": { + "title": "onap.datatype.controlloop.Operation", + "type": "object", + "description": "An operation supported by an actor", + "required": [ + "id", + "operation", + "timeout", + "retries" + ], + "properties": { + "id": { + "type": "string", + "description": "Unique identifier for the operation" + }, + "description": { + "type": "string", + "description": "A user-friendly description of the intent for the operation" + }, + "operation": { + "title": "onap.datatype.controlloop.Actor", + "type": "object", + "description": "An actor/operation/target definition", + "required": [ + "actor", + "operation", + "target" + ], + "properties": { + "actor": { + "type": "string", + "description": "The actor performing the operation.", + "enum": [ + "CDS", + "SDNC", + "SO" + ], + "options": { + "enum_titles": [ + "CDS", + "SDNC", + "SO" + ] + } + }, + "operation": { + "type": "string", + "description": "The operation the actor is performing.", + "enum": [ + "resource-assignment", + "activate", + "activate-restconf", + "activate-cli", + "assign-activate", + "imperative-test-wf" + ] + }, + "target": { + "title": "onap.datatype.controlloop.Target", + "type": "object", + "description": "Definition for a entity in A&AI to perform a control loop operation on", + "required": [ + "targetType" + ], + "properties": { + "targetType": { + "type": "string", + "description": "Category for the target type", + "enum": [ + "VNF", + "VM", + "VFMODULE", + "PNF" + ] + }, + "entityIds": { + "type": "object", + "description": "Map of values that identify the resource. If none are provided, it is assumed that the\nentity that generated the ONSET event will be the target.\n", + "anyOf": [ + { + "title": "VNF-vLoadBalancerMS 0", + "properties": { + "resourceID": { + "title": "Resource ID", + "type": "string", + "default": "vLoadBalancerMS", + "readOnly": "True" + } + } + }, + { + "title": "VFMODULE-Vloadbalancerms..vpkg..module-1", + "properties": { + "resourceID": { + "title": "Resource ID", + "type": "string", + "default": "Vloadbalancerms..vpkg..module-1", + "readOnly": "True" + }, + "modelInvariantId": { + "title": "Model Invariant Id (ModelInvariantUUID)", + "type": "string", + "default": "ca052563-eb92-4b5b-ad41-9111768ce043", + "readOnly": "True" + }, + "modelVersionId": { + "title": "Model Version Id (ModelUUID)", + "type": "string", + "default": "1e725ccc-b823-4f67-82b9-4f4367070dbc", + "readOnly": "True" + }, + "modelName": { + "title": "Model Name", + "type": "string", + "default": "Vloadbalancerms..vpkg..module-1", + "readOnly": "True" + }, + "modelVersion": { + "title": "Model Version", + "type": "string", + "default": "1", + "readOnly": "True" + }, + "modelCustomizationId": { + "title": "Customization ID", + "type": "string", + "default": "1bffdc31-a37d-4dee-b65c-dde623a76e52", + "readOnly": "True" + } + } + }, + { + "title": "VFMODULE-Vloadbalancerms..vdns..module-3", + "properties": { + "resourceID": { + "title": "Resource ID", + "type": "string", + "default": "Vloadbalancerms..vdns..module-3", + "readOnly": "True" + }, + "modelInvariantId": { + "title": "Model Invariant Id (ModelInvariantUUID)", + "type": "string", + "default": "4c10ba9b-f88f-415e-9de3-5d33336047fa", + "readOnly": "True" + }, + "modelVersionId": { + "title": "Model Version Id (ModelUUID)", + "type": "string", + "default": "4fa73b49-8a6c-493e-816b-eb401567b720", + "readOnly": "True" + }, + "modelName": { + "title": "Model Name", + "type": "string", + "default": "Vloadbalancerms..vdns..module-3", + "readOnly": "True" + }, + "modelVersion": { + "title": "Model Version", + "type": "string", + "default": "1", + "readOnly": "True" + }, + "modelCustomizationId": { + "title": "Customization ID", + "type": "string", + "default": "bafcdab0-801d-4d81-9ead-f464640a38b1", + "readOnly": "True" + } + } + }, + { + "title": "VFMODULE-Vloadbalancerms..base_template..module-0", + "properties": { + "resourceID": { + "title": "Resource ID", + "type": "string", + "default": "Vloadbalancerms..base_template..module-0", + "readOnly": "True" + }, + "modelInvariantId": { + "title": "Model Invariant Id (ModelInvariantUUID)", + "type": "string", + "default": "921f7c96-ebdd-42e6-81b9-1cfc0c9796f3", + "readOnly": "True" + }, + "modelVersionId": { + "title": "Model Version Id (ModelUUID)", + "type": "string", + "default": "63734409-f745-4e4d-a38b-131638a0edce", + "readOnly": "True" + }, + "modelName": { + "title": "Model Name", + "type": "string", + "default": "Vloadbalancerms..base_template..module-0", + "readOnly": "True" + }, + "modelVersion": { + "title": "Model Version", + "type": "string", + "default": "1", + "readOnly": "True" + }, + "modelCustomizationId": { + "title": "Customization ID", + "type": "string", + "default": "86baddea-c730-4fb8-9410-cd2e17fd7f27", + "readOnly": "True" + } + } + }, + { + "title": "VFMODULE-Vloadbalancerms..vlb..module-2", + "properties": { + "resourceID": { + "title": "Resource ID", + "type": "string", + "default": "Vloadbalancerms..vlb..module-2", + "readOnly": "True" + }, + "modelInvariantId": { + "title": "Model Invariant Id (ModelInvariantUUID)", + "type": "string", + "default": "a772a1f4-0064-412c-833d-4749b15828dd", + "readOnly": "True" + }, + "modelVersionId": { + "title": "Model Version Id (ModelUUID)", + "type": "string", + "default": "0f5c3f6a-650a-4303-abb6-fff3e573a07a", + "readOnly": "True" + }, + "modelName": { + "title": "Model Name", + "type": "string", + "default": "Vloadbalancerms..vlb..module-2", + "readOnly": "True" + }, + "modelVersion": { + "title": "Model Version", + "type": "string", + "default": "1", + "readOnly": "True" + }, + "modelCustomizationId": { + "title": "Customization ID", + "type": "string", + "default": "96a78aad-4ffb-4ef0-9c4f-deb03bf1d806", + "readOnly": "True" + } + } + } + ] + } + } + }, + "payload": { + "type": "object", + "description": "Name/value pairs of payload information passed by Policy to the actor", + "anyOf": [ + { + "title": "resource-assignment", + "properties": { + "artifact_name": "baseconfiguration", + "artifact_version": "1.0.0", + "mode": "async", + "data": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + } + }, + { + "title": "activate", + "properties": { + "artifact_name": "baseconfiguration", + "artifact_version": "1.0.0", + "mode": "async", + "data": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + } + }, + { + "title": "activate-restconf", + "properties": { + "artifact_name": "baseconfiguration", + "artifact_version": "1.0.0", + "mode": "async", + "data": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + } + }, + { + "title": "activate-cli", + "properties": { + "artifact_name": "baseconfiguration", + "artifact_version": "1.0.0", + "mode": "async", + "data": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + } + }, + { + "title": "assign-activate", + "properties": { + "artifact_name": "baseconfiguration", + "artifact_version": "1.0.0", + "mode": "async", + "data": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + } + }, + { + "title": "imperative-test-wf", + "properties": { + "artifact_name": "baseconfiguration", + "artifact_version": "1.0.0", + "mode": "async", + "data": { + "resource-assignment-properties": { + "request-id": "", + "service-instance-id": "", + "vnf-id": "", + "action-name": "", + "scope-type": "", + "hostname": "", + "vnf_name": "" + } + } + } + } + ] + } + } + }, + "timeout": { + "type": "integer", + "description": "The amount of time for the actor to perform the operation." + }, + "retries": { + "type": "integer", + "description": "The number of retries the actor should attempt to perform the operation.", + "default": 0 + }, + "success": { + "type": "string", + "description": "Points to the operation to invoke on success. A value of \"final_success\" indicates and end to the operation.", + "default": "final_success" + }, + "failure": { + "type": "string", + "description": "Points to the operation to invoke on Actor operation failure.", + "default": "final_failure" + }, + "failure_timeout": { + "type": "string", + "description": "Points to the operation to invoke when the time out for the operation occurs.", + "default": "final_failure_timeout" + }, + "failure_retries": { + "type": "string", + "description": "Points to the operation to invoke when the current operation has exceeded its max retries.", + "default": "final_failure_retries" + }, + "failure_exception": { + "type": "string", + "description": "Points to the operation to invoke when the current operation causes an exception.", + "default": "final_failure_exception" + }, + "failure_guard": { + "type": "string", + "description": "Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.", + "default": "final_failure_guard" + } + } + } + }, + "engineServiceParameters": { + "type": "string", + "description": "The engine parameters like name, instanceCount, policy implementation, parameters etc." + }, + "eventInputParameters": { + "type": "string", + "description": "The event input parameters." + }, + "eventOutputParameters": { + "type": "string", + "description": "The event output parameters." + }, + "javaProperties": { + "type": "string", + "description": "Name/value pairs of properties to be set for APEX if needed." + } + } +} \ No newline at end of file diff --git a/src/test/resources/tosca/new-converter/tosca_metadata_clamp_possible_values.yaml b/src/test/resources/tosca/new-converter/tosca_metadata_clamp_possible_values.yaml new file mode 100644 index 000000000..7fe9d5398 --- /dev/null +++ b/src/test/resources/tosca/new-converter/tosca_metadata_clamp_possible_values.yaml @@ -0,0 +1,184 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + onap.policies.Monitoring: + derived_from: tosca.policies.Root + description: a base policy type for all policies that governs monitoring provisioning + onap.policies.monitoring.cdap.tca.hi.lo.app: + derived_from: onap.policies.Monitoring + version: 1.0.0 + properties: + tca_policy: + type: map + description: TCA Policy JSON + entry_schema: + type: onap.datatypes.monitoring.tca_policy + metadata: + policy_model_type: onap.policies.monitoring.cdap.tca.hi.lo.app + acronym: tca + +data_types: + onap.datatypes.monitoring.metricsPerEventName: + derived_from: tosca.datatypes.Root + properties: + controlLoopSchemaType: + type: string + required: true + description: Specifies Control Loop Schema Type for the event Name e.g. VNF, VM + constraints: + - valid_values: + - VM + - VNF + eventName: + type: string + required: true + description: Event name to which thresholds need to be applied + policyName: + type: string + required: true + description: TCA Policy Scope Name + policyScope: + type: string + required: true + description: TCA Policy Scope + policyVersion: + type: string + required: true + description: TCA Policy Scope Version + thresholds: + type: list + required: true + description: Thresholds associated with eventName + entry_schema: + type: onap.datatypes.monitoring.thresholds + context: + type: string + required: true + description: TCA Policy Dummy Context + metadata: + clamp_possible_values: Dictionary:Context + + signature: + type: onap.datatypes.monitoring.Dummy_Signature + description: Signature + required: true + + onap.datatypes.monitoring.Dummy_Signature: + derived_from: tosca.datatypes.Root + properties: + filter_clause: + type: string + description: Filter Clause + required: true + metadata: + clamp_possible_values: Dictionary:EventDictionary#Operators + + onap.datatypes.monitoring.tca_policy: + derived_from: tosca.datatypes.Root + properties: + domain: + type: string + required: true + description: Domain name to which TCA needs to be applied + default: measurementsForVfScaling + constraints: + - equal: measurementsForVfScaling + metricsPerEventName: + type: list + required: true + description: Contains eventName and threshold details that need to be applied to given eventName + entry_schema: + type: onap.datatypes.monitoring.metricsPerEventName + onap.datatypes.monitoring.thresholds: + derived_from: tosca.datatypes.Root + properties: + closedLoopControlName: + type: string + required: true + description: Closed Loop Control Name associated with the threshold + closedLoopEventStatus: + type: string + required: true + description: Closed Loop Event Status of the threshold + constraints: + - valid_values: + - ONSET + - ABATED + direction: + type: string + required: true + description: Direction of the threshold + constraints: + - valid_values: + - LESS + - LESS_OR_EQUAL + - GREATER + - GREATER_OR_EQUAL + - EQUAL + fieldPath: + type: string + required: true + description: Json field Path as per CEF message which needs to be analyzed for TCA + constraints: + - valid_values: + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsAccumulated + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuIdle + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageInterrupt + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageNice + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSoftIrq + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSteal + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSystem + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuWait + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].percentUsage + - $.event.measurementsForVfScalingFields.meanRequestLatency + - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryBuffered + - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryCached + - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryConfigured + - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryFree + - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryUsed + - $.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value + severity: + type: string + required: true + description: Threshold Event Severity + constraints: + - valid_values: + - CRITICAL + - MAJOR + - MINOR + - WARNING + - NORMAL + thresholdValue: + type: integer + required: true + description: Threshold value for the field Path inside CEF message + version: + type: string + required: true + description: Version number associated with the threshold -- cgit 1.2.3-korg