diff options
83 files changed, 4140 insertions, 1270 deletions
@@ -26,7 +26,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.onap.clamp</groupId> <artifactId>clds</artifactId> - <version>5.0.3-SNAPSHOT</version> + <version>5.0.5-SNAPSHOT</version> <name>clamp</name> @@ -544,6 +544,17 @@ <artifactId>snakeyaml</artifactId> <version>1.26</version> </dependency> + <dependency> + <groupId>org.dom4j</groupId> + <artifactId>dom4j</artifactId> + <version>2.1.3</version> + </dependency> + <dependency> + <groupId>org.springframework.security</groupId> + <artifactId>spring-security-web</artifactId> + <version>5.2.3.RELEASE</version> + </dependency> + <!-- TESTING --> <dependency> <groupId>org.assertj</groupId> diff --git a/releases/5.0.4-container.yaml b/releases/5.0.4-container.yaml new file mode 100644 index 000000000..94e8afaa1 --- /dev/null +++ b/releases/5.0.4-container.yaml @@ -0,0 +1,10 @@ +distribution_type: 'container' +container_release_tag: '5.0.4' +project: 'clamp' +log_dir: 'clamp-maven-docker-stage-master/389/' +ref: 9698b59ab5eab72437d8a0f501b21da22b302df3 +containers: + - name: 'clamp-backend' + version: '5.0-STAGING-20200420T122047Z' + - name: 'clamp-frontend' + version: '5.0-STAGING-20200420T122047Z'
\ No newline at end of file diff --git a/releases/5.0.4.yaml b/releases/5.0.4.yaml new file mode 100644 index 000000000..335c79c77 --- /dev/null +++ b/releases/5.0.4.yaml @@ -0,0 +1,5 @@ +--- +distribution_type: 'maven' +version: '5.0.4' +project: 'clamp' +log_dir: 'clamp-maven-stage-master/400/' diff --git a/src/main/java/org/onap/clamp/clds/client/CdsServices.java b/src/main/java/org/onap/clamp/clds/client/CdsServices.java index fe1937ab1..b8eb41946 100644 --- a/src/main/java/org/onap/clamp/clds/client/CdsServices.java +++ b/src/main/java/org/onap/clamp/clds/client/CdsServices.java @@ -34,6 +34,7 @@ import java.util.Map; import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.builder.ExchangeBuilder;
+import org.onap.clamp.clds.exception.cds.CdsParametersException;
import org.onap.clamp.clds.model.cds.CdsBpWorkFlowListResponse;
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.clds.util.LoggingUtils;
@@ -117,7 +118,7 @@ public class CdsServices { return null;
}
- private JsonObject parseCdsResponse(String response) {
+ protected JsonObject parseCdsResponse(String response) {
JsonObject root = JsonParser.parseString(response).getAsJsonObject();
JsonObject inputs = root.getAsJsonObject("workFlowData").getAsJsonObject("inputs");
JsonObject dataTypes = root.getAsJsonObject("dataTypes");
@@ -135,13 +136,34 @@ public class CdsServices { String type = inputProperty.get("type").getAsString();
if (isComplexType(type, dataTypes)) {
inputObject.add(key, handleComplexType(type, dataTypes));
+ } else if (type.equalsIgnoreCase("list")) {
+ inputObject.add(key, handleListType(key, inputProperty,
+ dataTypes));
} else {
- inputObject.addProperty(key, "");
+ inputObject.add(key, entry.getValue());
}
}
return inputObject;
}
+ private JsonObject handleListType(String propertyName,
+ JsonObject inputProperty,
+ JsonObject dataTypes) {
+ if (inputProperty.get("entry_schema") != null) {
+ String type = inputProperty.get("entry_schema").getAsJsonObject().get(
+ "type").getAsString();
+ if (dataTypes.get(type) != null) {
+ JsonObject jsonObject = new JsonObject();
+ jsonObject.addProperty("type", "list");
+ jsonObject.add("properties", handleComplexType(type, dataTypes));
+ return jsonObject;
+ } else {
+ return inputProperty;
+ }
+ }
+ throw new CdsParametersException("Entry schema is null for " + propertyName);
+ }
+
private JsonObject handleComplexType(String key, JsonObject dataTypes) {
JsonObject properties = dataTypes.get(key).getAsJsonObject().get("properties").getAsJsonObject();
return getInputProperties(properties, dataTypes);
diff --git a/src/main/java/org/onap/clamp/clds/exception/cds/CdsParametersException.java b/src/main/java/org/onap/clamp/clds/exception/cds/CdsParametersException.java new file mode 100644 index 000000000..73ce31f89 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/exception/cds/CdsParametersException.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * ================================================================================ + * 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.exception.cds; + +/** + * Exception while parsing CDS response. + */ +public class CdsParametersException extends RuntimeException { + + /** + * serialization id. + */ + private static final long serialVersionUID = 8425657297510362736L; + + /** + * This constructor can be used to create a new CdsParametersException. + * + * @param message The message to dump + */ + public CdsParametersException(final String message) { + super(message); + } + + /** + * This constructor can be used to create a new CdsParametersException. + * + * @param message The message to dump + * @param cause The Throwable cause object + */ + public CdsParametersException(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/src/main/java/org/onap/clamp/clds/tosca/JsonEditorSchemaConstants.java b/src/main/java/org/onap/clamp/clds/tosca/JsonEditorSchemaConstants.java index fdc94231f..e3c661698 100644 --- a/src/main/java/org/onap/clamp/clds/tosca/JsonEditorSchemaConstants.java +++ b/src/main/java/org/onap/clamp/clds/tosca/JsonEditorSchemaConstants.java @@ -28,8 +28,10 @@ public class JsonEditorSchemaConstants { //Data types in JSON Schema public static final String TYPE_OBJECT = "object"; public static final String TYPE_ARRAY = "array"; + public static final String TYPE_MAP = "map"; public static final String TYPE_STRING = "string"; public static final String TYPE_INTEGER = "integer"; + public static final String TYPE_DATE_TIME = "datetime"; //Key elements in JSON Schema public static final String TYPE = "type"; @@ -43,6 +45,9 @@ public class JsonEditorSchemaConstants { public static final String ITEMS = "items"; public static final String PROPERTIES = "properties"; public static final String PROPERTY_ORDER = "propertyOrder"; + public static final String VALUES = "values"; + public static final String HEADER_TEMPLATE = "headerTemplate"; + public static final String HEADER_TEMPLATE_VALUE = "{{self.name}}"; public static final String MINIMUM = "minimum"; public static final String MAXIMUM = "maximum"; @@ -50,9 +55,13 @@ public class JsonEditorSchemaConstants { public static final String MAX_LENGTH = "maxLength"; public static final String EXCLUSIVE_MINIMUM = "exclusiveMinimum"; public static final String EXCLUSIVE_MAXIMUM = "exclusiveMaximum"; + public static final String MINITEMS = "minItems"; + public static final String MAXITEMS = "maxItems"; public static final String CUSTOM_KEY_FORMAT = "format"; public static final String CUSTOM_KEY_FORMAT_TABS_TOP = "tabs-top"; + public static final String CUSTOM_KEY_FORMAT_TABS = "tabs"; + public static final String CUSTOM_KEY_FORMAT_INPUT = "input"; public static final String FORMAT_SELECT = "select"; public static final String UNIQUE_ITEMS = "uniqueItems"; public static final String TRUE = "true"; @@ -67,5 +76,11 @@ public class JsonEditorSchemaConstants { public static final String SCHEMA = "schema"; public static final String CURRENT_VALUES = "currentValues"; + public static final String PLUGIN = "plugin"; + public static final String DATE_TIME_PICKER = "datetimepicker"; + public static final String VALIDATION = "validation"; + public static final String DATE_TIME_FORMAT = "YYYY/MM/DD HH:mm:ss"; + public static final String INPUT_EVENT = "input_event"; + public static final String DP_CHANGE = "dp.change"; } diff --git a/src/main/java/org/onap/clamp/clds/tosca/ToscaSchemaConstants.java b/src/main/java/org/onap/clamp/clds/tosca/ToscaSchemaConstants.java index 9601649c9..d00c431c8 100644 --- a/src/main/java/org/onap/clamp/clds/tosca/ToscaSchemaConstants.java +++ b/src/main/java/org/onap/clamp/clds/tosca/ToscaSchemaConstants.java @@ -30,8 +30,11 @@ public class ToscaSchemaConstants { public static final String TYPE_MAP = "map"; public static final String TYPE_STRING = "string"; public static final String TYPE_INTEGER = "integer"; + public static final String TYPE_NUMBER = "number"; + public static final String TYPE_DATE_TIME = "datetime"; public static final String TYPE_FLOAT = "float"; public static final String TYPE_BOOLEAN = "boolean"; + public static final String TYPE_USER_DEFINED = "userDefined"; // Key elements in Tosca public static final String NODE_TYPES = "policy_types"; @@ -46,6 +49,8 @@ public class ToscaSchemaConstants { public static final String METADATA = "metadata"; public static final String METADATA_POLICY_MODEL_TYPE = "policy_model_type"; public static final String METADATA_ACRONYM = "acronym"; + public static final String METADATA_ELEMENT_NAME = "element_name"; + public static final String METADATA_HEADER_TEMPLATE = "header_template"; public static final String METADATA_CLAMP_POSSIBLE_VALUES = "clamp_possible_values"; // Constraints diff --git a/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java b/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java index 666ca6702..45bb87ed8 100644 --- a/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java +++ b/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java @@ -38,6 +38,7 @@ import java.util.stream.Collectors; import org.json.JSONArray; import org.json.JSONObject; import org.onap.clamp.clds.config.ClampProperties; +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; @@ -142,6 +143,13 @@ public class ToscaYamlToJsonConvertor { parseNodeAndDataType(loadedYaml, nodeTypes, dataNodes); populateJsonEditorObject(loadedYaml, nodeTypes, dataNodes, jsonParentObject, jsonTempObject, modelTypeToUse); + + String headerTemplate = getValueFromMetadata(validateAndConvertToJson(yamlString), + ToscaSchemaConstants.METADATA_HEADER_TEMPLATE); + if (headerTemplate != null) { + jsonParentObject.put(JsonEditorSchemaConstants.HEADER_TEMPLATE, + JsonEditorSchemaConstants.HEADER_TEMPLATE_VALUE); + } if (jsonTempObject.length() > 0) { jsonParentObject = jsonTempObject; } @@ -234,7 +242,7 @@ public class ToscaYamlToJsonConvertor { jsonTempObject.put(JsonEditorSchemaConstants.ITEMS, jsonParentObject); jsonTempObject.put(JsonEditorSchemaConstants.FORMAT, - JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_TABS_TOP); + JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_TABS); jsonTempObject.put(JsonEditorSchemaConstants.UNIQUE_ITEMS, JsonEditorSchemaConstants.TRUE); } @@ -652,12 +660,43 @@ public class ToscaYamlToJsonConvertor { Optional.ofNullable(cldsDictionaryElements).get().stream().forEach(c -> { JSONObject jsonObject = new JSONObject(); + if (c.getSubDictionary() != null) { + Dictionary subDictionary = + dictionaryService.getDictionary(c.getSubDictionary()); + if (subDictionary != null + && !subDictionary.getDictionaryElements().isEmpty()) { + + jsonObject.put(JsonEditorSchemaConstants.CUSTOM_KEY_FORMAT_INPUT, + JsonEditorSchemaConstants.FORMAT_SELECT); + + List<String> shortNames = new ArrayList<>(); + subDictionary.getDictionaryElements().stream().forEach(c1 -> { + shortNames.add(c1.getShortName()); + }); + jsonObject.put(JsonEditorSchemaConstants.VALUES, shortNames); + } + } jsonObject.put(JsonEditorSchemaConstants.TYPE, getJsonType(c.getType())); + if (c.getType() != null - && c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) { + && (c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING) + || c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_DATE_TIME) + || c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_MAP))) { jsonObject.put(JsonEditorSchemaConstants.MIN_LENGTH, 1); + if (c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_DATE_TIME)) { + jsonObject.put(JsonEditorSchemaConstants.PLUGIN, + JsonEditorSchemaConstants.DATE_TIME_PICKER); + jsonObject.put(JsonEditorSchemaConstants.INPUT_EVENT, + JsonEditorSchemaConstants.DP_CHANGE); + JSONObject formatJsonObject = new JSONObject(); + formatJsonObject.put(JsonEditorSchemaConstants.FORMAT, + JsonEditorSchemaConstants.DATE_TIME_FORMAT); + jsonObject.put(JsonEditorSchemaConstants.VALIDATION, + formatJsonObject); + } } + jsonObject.put(JsonEditorSchemaConstants.ID, c.getName()); jsonObject.put(JsonEditorSchemaConstants.LABEL, c.getShortName()); jsonObject.put(JsonEditorSchemaConstants.OPERATORS, subCldsDictionaryNames); @@ -678,32 +717,44 @@ public class ToscaYamlToJsonConvertor { String dictionaryKey = dictionaryReference.substring( dictionaryReference.indexOf(ToscaSchemaConstants.DICTIONARY) + 11, dictionaryReference.length()); + if (dictionaryKey != null) { - List<DictionaryElement> cldsDictionaryElements = - dictionaryService.getDictionary(dictionaryKey).getDictionaryElements().stream() - .collect(Collectors.toList()); - if (cldsDictionaryElements != null) { - List<String> cldsDictionaryNames = new ArrayList<>(); - List<String> cldsDictionaryFullNames = new ArrayList<>(); - cldsDictionaryElements.stream().forEach(c -> { - // Json type will be translated before Policy creation - if (c.getType() != null && !c.getType().equalsIgnoreCase("json")) { - cldsDictionaryFullNames.add(c.getName()); + if (dictionaryKey.contains(ToscaSchemaConstants.TYPE_USER_DEFINED)) { + childObject.put(JsonEditorSchemaConstants.ENUM, new ArrayList<>()); + // Add Enum titles for generated translated values during + // JSON instance generation + JSONObject enumTitles = new JSONObject(); + enumTitles.put(JsonEditorSchemaConstants.ENUM_TITLES, new ArrayList<>()); + childObject.put(JsonEditorSchemaConstants.OPTIONS, enumTitles); + } else { + List<DictionaryElement> cldsDictionaryElements = + dictionaryService.getDictionary(dictionaryKey).getDictionaryElements() + .stream().collect(Collectors.toList()); + if (cldsDictionaryElements != null) { + List<String> cldsDictionaryNames = new ArrayList<>(); + List<String> cldsDictionaryFullNames = new ArrayList<>(); + cldsDictionaryElements.stream().forEach(c -> { + // Json type will be translated before Policy creation + if (c.getType() != null && !c.getType().equalsIgnoreCase("json")) { + cldsDictionaryFullNames.add(c.getName()); + } + cldsDictionaryNames.add(c.getShortName()); + }); + + if (!cldsDictionaryFullNames.isEmpty()) { + childObject.put(JsonEditorSchemaConstants.ENUM, + cldsDictionaryFullNames); + // Add Enum titles for generated translated values during JSON instance + // generation + JSONObject enumTitles = new JSONObject(); + enumTitles.put(JsonEditorSchemaConstants.ENUM_TITLES, + cldsDictionaryNames); + childObject.put(JsonEditorSchemaConstants.OPTIONS, enumTitles); + } else { + childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryNames); } - cldsDictionaryNames.add(c.getShortName()); - }); - if (!cldsDictionaryFullNames.isEmpty()) { - childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryFullNames); - // Add Enum titles for generated translated values during JSON instance - // generation - JSONObject enumTitles = new JSONObject(); - enumTitles.put(JsonEditorSchemaConstants.ENUM_TITLES, cldsDictionaryNames); - childObject.put(JsonEditorSchemaConstants.OPTIONS, enumTitles); - } else { - childObject.put(JsonEditorSchemaConstants.ENUM, cldsDictionaryNames); } - } } } @@ -711,10 +762,15 @@ public class ToscaYamlToJsonConvertor { private String getJsonType(String toscaType) { String jsonType = null; - if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_INTEGER)) { + if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_INTEGER) + || toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_NUMBER)) { jsonType = JsonEditorSchemaConstants.TYPE_INTEGER; + } else if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_DATE_TIME)) { + jsonType = JsonEditorSchemaConstants.TYPE_DATE_TIME; } else if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_LIST)) { jsonType = JsonEditorSchemaConstants.TYPE_ARRAY; + } else if (toscaType.equalsIgnoreCase(ToscaSchemaConstants.TYPE_MAP)) { + jsonType = JsonEditorSchemaConstants.TYPE_MAP; } else { jsonType = JsonEditorSchemaConstants.TYPE_STRING; } 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 index 81e30cf43..c15641413 100644 --- 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 @@ -23,10 +23,17 @@ package org.onap.clamp.clds.tosca.update.execution.cds; +import static org.onap.clamp.clds.tosca.ToscaSchemaConstants.PROPERTIES; +import static org.onap.clamp.clds.tosca.ToscaSchemaConstants.TYPE; +import static org.onap.clamp.clds.tosca.ToscaSchemaConstants.TYPE_LIST; + import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; + import java.util.Map; +import java.util.Set; + import org.onap.clamp.clds.tosca.update.execution.ToscaMetadataProcess; import org.onap.clamp.loop.service.Service; import org.onap.clamp.tosca.DictionaryService; @@ -58,9 +65,11 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { } private static void generatePayload(JsonObject childObject, Service serviceModel) { - generatePayloadPerResource(childObject, "VF", serviceModel); - generatePayloadPerResource(childObject, "PNF", serviceModel); - addToJsonArray(childObject, "anyOf", createBlankEntry()); + JsonArray schemaAnyOf = new JsonArray(); + schemaAnyOf.addAll(createBlankEntry()); + schemaAnyOf.addAll(generatePayloadPerResource("VF", serviceModel)); + schemaAnyOf.addAll(generatePayloadPerResource("PNF", serviceModel)); + addToJsonArray(childObject, "anyOf", schemaAnyOf); } private static void generateOperation(JsonObject childObject, Service serviceModel) { @@ -92,8 +101,8 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { } - private static void generatePayloadPerResource(JsonObject childObject, String resourceName, - Service serviceModel) { + private static JsonArray generatePayloadPerResource(String resourceName, + Service serviceModel) { JsonArray schemaAnyOf = new JsonArray(); for (Map.Entry<String, JsonElement> entry : serviceModel.getResourceDetails().getAsJsonObject(resourceName) @@ -105,13 +114,14 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { .entrySet()) { JsonObject obj = new JsonObject(); obj.addProperty("title", workflowsEntry.getKey()); - obj.add("properties", createPayloadProperty(workflowsEntry.getValue().getAsJsonObject(), - controllerProperties)); + obj.add("properties", + createInputPropertiesForPayload(workflowsEntry.getValue().getAsJsonObject(), + controllerProperties)); schemaAnyOf.add(obj); } } } - addToJsonArray(childObject, "anyOf", schemaAnyOf); + return schemaAnyOf; } private static JsonArray createBlankEntry() { @@ -123,20 +133,6 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { return result; } - private static JsonObject createPayloadProperty(JsonObject workFlow, JsonObject controllerProperties) { - JsonObject payloadResult = new JsonObject(); - - payloadResult.add("artifact_name", - createAnyOfJsonProperty("artifact_name", controllerProperties.get("sdnc_model_name").getAsString())); - payloadResult.add("artifact_version", - createAnyOfJsonProperty("artifact_version", - controllerProperties.get("sdnc_model_version").getAsString())); - payloadResult.add("mode", createAnyOfJsonProperty("mode", "async")); - - payloadResult.add("data", createAnyOfJsonObject("data", workFlow.getAsJsonObject("inputs"))); - return payloadResult; - } - private static JsonObject createAnyOfJsonProperty(String name, String defaultValue) { JsonObject result = new JsonObject(); result.addProperty("title", name); @@ -157,9 +153,86 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { private static void addToJsonArray(JsonObject childObject, String section, JsonArray value) { if (childObject.getAsJsonArray(section) != null) { childObject.getAsJsonArray(section).addAll(value); - } - else { + } else { childObject.add(section, value); } } + + /** + * Returns the properties of payload based on the cds work flows. + * + * @param workFlow cds work flows to update payload + * @param controllerProperties cds properties to get blueprint name and + * version + * @return returns the properties of payload + */ + public static JsonObject createInputPropertiesForPayload(JsonObject workFlow, + JsonObject controllerProperties) { + String artifactName = controllerProperties.get("sdnc_model_name").getAsString(); + String artifactVersion = controllerProperties.get("sdnc_model_version").getAsString(); + JsonObject inputs = workFlow.getAsJsonObject("inputs"); + JsonObject jsonObject = new JsonObject(); + jsonObject.add("artifact_name", createAnyOfJsonProperty( + "artifact name", artifactName)); + jsonObject.add("artifact_version", createAnyOfJsonProperty( + "artifact version", artifactVersion)); + jsonObject.add("mode", createCdsInputProperty( + "mode", "string", "async", null)); + jsonObject.add("data", createDataProperty(inputs)); + + return jsonObject; + } + + private static JsonObject createDataProperty(JsonObject inputs) { + JsonObject data = new JsonObject(); + data.addProperty("title", "data"); + data.add(PROPERTIES, addDataFields(inputs)); + return data; + } + + private static JsonObject addDataFields(JsonObject inputs) { + JsonObject jsonObject = new JsonObject(); + Set<Map.Entry<String, JsonElement>> entrySet = inputs.entrySet(); + for (Map.Entry<String, JsonElement> entry : entrySet) { + String key = entry.getKey(); + JsonObject inputProperty = inputs.getAsJsonObject(key); + if (inputProperty.get(TYPE) == null) { + jsonObject.add(entry.getKey(), + createAnyOfJsonObject(key, + addDataFields(entry.getValue().getAsJsonObject()))); + } else { + jsonObject.add(entry.getKey(), + createCdsInputProperty(key, + inputProperty.get("type").getAsString(), + null, + entry.getValue().getAsJsonObject())); + } + } + return jsonObject; + } + + private static JsonObject createCdsInputProperty(String title, + String type, + String defaultValue, + JsonObject cdsProperty) { + JsonObject property = new JsonObject(); + property.addProperty("title", title); + + if (TYPE_LIST.equalsIgnoreCase(type)) { + property.addProperty(TYPE, "array"); + if (cdsProperty.get(PROPERTIES) != null) { + JsonObject listProperties = new JsonObject(); + listProperties.add(PROPERTIES, + addDataFields(cdsProperty.get(PROPERTIES).getAsJsonObject())); + property.add("items", listProperties); + } + } else { + property.addProperty(TYPE, type); + } + + if (defaultValue != null) { + property.addProperty("default", defaultValue); + } + return property; + } } diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java index 19a17dbb0..081331337 100644 --- a/src/main/java/org/onap/clamp/loop/Loop.java +++ b/src/main/java/org/onap/clamp/loop/Loop.java @@ -331,6 +331,36 @@ public class Loop extends AuditEntity implements Serializable { } /** + * Return the operationalPolicy object with the opPolicyName. + * + * @param opPolicyName The operationalPolicy name + * @return The OperationalPolicy object found in loop object + */ + public OperationalPolicy getOperationalPolicy(String opPolicyName) { + for (OperationalPolicy operationalPolicy : this.getOperationalPolicies()) { + if (operationalPolicy.getName().equals(opPolicyName)) { + return operationalPolicy; + } + } + return null; + } + + /** + * Return the microServicePolicy object with the msPolicyName. + * + * @param msPolicyName The microServicePolicy name + * @return The MicroServicePolicy object found in loop object + */ + public MicroServicePolicy getMicroServicePolicy(String msPolicyName) { + for (MicroServicePolicy microServicePolicy : this.getMicroServicePolicies()) { + if (microServicePolicy.getName().equals(msPolicyName)) { + return microServicePolicy; + } + } + return null; + } + + /** * Generate the loop name. * * @param serviceName The service name diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java index a2a44631b..fad93bc7d 100644 --- a/src/main/java/org/onap/clamp/loop/LoopController.java +++ b/src/main/java/org/onap/clamp/loop/LoopController.java @@ -137,11 +137,11 @@ public class LoopController { } /** - * This method remove an operational policy to a loop instance. + * This method removes an operational policy from a loop instance. * * @param loopName The loop name * @param policyType The policy model type - * @param policyVersion The policy model version + * @param policyVersion The policy model version * @return The loop modified */ public Loop removeOperationalPolicy(String loopName, String policyType, String policyVersion) { diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java index af1f58ba7..3f568a331 100644 --- a/src/main/java/org/onap/clamp/loop/LoopService.java +++ b/src/main/java/org/onap/clamp/loop/LoopService.java @@ -98,7 +98,7 @@ public class LoopService { public void updateDcaeDeploymentFields(Loop loop, String deploymentId, String deploymentUrl) { loop.setDcaeDeploymentId(deploymentId); loop.setDcaeDeploymentStatusUrl(deploymentUrl); - loopsRepository.save(loop); + loopsRepository.saveAndFlush(loop); } public void updateLoopState(Loop loop, String newState) { @@ -118,6 +118,12 @@ public class LoopService { Loop addOperationalPolicy(String loopName, String policyType, String policyVersion) throws IOException { Loop loop = getLoop(loopName); PolicyModel policyModel = policyModelsService.getPolicyModel(policyType, policyVersion); + Set<OperationalPolicy> opPolicySet = loop.getOperationalPolicies(); + for (OperationalPolicy opPolicy : opPolicySet) { + if (opPolicy.getPolicyModel().equals(policyModel)) { + throw new IllegalArgumentException("This type of Operational Policy is already added to the loop. Please choose another one."); + } + } if (policyModel == null) { return null; } @@ -131,7 +137,7 @@ public class LoopService { * * @param loopName The loop name * @param policyType The policy model type - * @param policyVersion The policy model version + * @param policyVersion The policy model version * @return The loop modified */ Loop removeOperationalPolicy(String loopName, String policyType, String policyVersion) { diff --git a/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java b/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java index 8270a96e3..227f40a72 100644 --- a/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java +++ b/src/main/java/org/onap/clamp/loop/components/external/PolicyComponent.java @@ -28,7 +28,6 @@ import com.att.eelf.configuration.EELFManager; import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -76,25 +75,33 @@ public class PolicyComponent extends ExternalComponent { /** * Generates the Json that must be sent to policy to add all policies to Active * PDP group. - * + * @param loop the loop object + * @param action POST (to add policy to group) or DELETE (to delete policy from group) * @return The json, payload to send */ - public static String createPoliciesPayloadPdpGroup(Loop loop) { + public static String createPoliciesPayloadPdpGroup(Loop loop, String action) { Map<String, Map<String, List<JsonObject>>> pdpGroupMap = new HashMap<>(); for (OperationalPolicy opPolicy : loop.getOperationalPolicies()) { updatePdpGroupMap(opPolicy.getPdpGroup(), opPolicy.getPdpSubgroup(), opPolicy.getName(), - opPolicy.getPolicyModel().getVersion(), pdpGroupMap); + "1.0.0", pdpGroupMap); + if (opPolicy.isLegacy()) { + for (String guardName:opPolicy.createGuardPolicyPayloads().keySet()) { + updatePdpGroupMap(opPolicy.getPdpGroup(), opPolicy.getPdpSubgroup(), + guardName, + "1.0.0", pdpGroupMap); + } + } } for (MicroServicePolicy msPolicy : loop.getMicroServicePolicies()) { updatePdpGroupMap(msPolicy.getPdpGroup(), msPolicy.getPdpSubgroup(), msPolicy.getName(), - msPolicy.getPolicyModel().getVersion(), pdpGroupMap); + "1.0.0", pdpGroupMap); } String payload = new GsonBuilder().setPrettyPrinting().create() - .toJson(generateActivatePdpGroupPayload(pdpGroupMap)); + .toJson(generateActivatePdpGroupPayload(pdpGroupMap, action)); logger.info("PdpGroup policy payload: " + payload); return payload; } @@ -102,12 +109,12 @@ public class PolicyComponent extends ExternalComponent { private static void updatePdpGroupMap(String pdpGroup, String pdpSubGroup, String policyName, - String policyModelVersion, + String policyVersion, Map<String, Map<String, List<JsonObject>>> pdpGroupMap) { JsonObject policyJson = new JsonObject(); policyJson.addProperty("name", policyName); - policyJson.addProperty("version", policyModelVersion); + policyJson.addProperty("version", policyVersion); Map<String, List<JsonObject>> pdpSubGroupMap; List<JsonObject> policyList; if (pdpGroupMap.get(pdpGroup) == null) { @@ -129,7 +136,7 @@ public class PolicyComponent extends ExternalComponent { } private static JsonObject generateActivatePdpGroupPayload( - Map<String, Map<String, List<JsonObject>>> pdpGroupMap) { + Map<String, Map<String, List<JsonObject>>> pdpGroupMap, String action) { JsonArray payloadArray = new JsonArray(); for (Entry<String, Map<String, List<JsonObject>>> pdpGroupInfo : pdpGroupMap.entrySet()) { JsonObject pdpGroupNode = new JsonObject(); @@ -141,7 +148,7 @@ public class PolicyComponent extends ExternalComponent { JsonObject pdpSubGroupNode = new JsonObject(); subPdpArray.add(pdpSubGroupNode); pdpSubGroupNode.addProperty("pdpType", pdpSubGroupInfo.getKey()); - pdpSubGroupNode.addProperty("action", "POST"); + pdpSubGroupNode.addProperty("action", action); JsonArray policyArray = new JsonArray(); pdpSubGroupNode.add("policies", policyArray); @@ -157,25 +164,6 @@ public class PolicyComponent extends ExternalComponent { return jsonObject; } - /** - * Generates the list of policy names that must be send/remove to/from active - * PDP group. - * - * @return A list of policy names - */ - public static List<String> listPolicyNamesPdpGroup(Loop loop) { - List<String> policyNamesList = new ArrayList<>(); - for (OperationalPolicy opPolicy : loop.getOperationalPolicies()) { - policyNamesList.add(opPolicy.getName()); - policyNamesList.addAll(opPolicy.createGuardPolicyPayloads().keySet()); - } - for (MicroServicePolicy microServicePolicy : loop.getMicroServicePolicies()) { - policyNamesList.add(microServicePolicy.getName()); - } - logger.info("Policies that will be removed from PDP: " + policyNamesList); - return policyNamesList; - } - private static ExternalComponentState findNewState(boolean found, boolean deployed) { ExternalComponentState newState = NOT_SENT; diff --git a/src/main/java/org/onap/clamp/policy/Policy.java b/src/main/java/org/onap/clamp/policy/Policy.java index d84f2c8a0..65e88d182 100644 --- a/src/main/java/org/onap/clamp/policy/Policy.java +++ b/src/main/java/org/onap/clamp/policy/Policy.java @@ -284,4 +284,6 @@ public abstract class Policy extends AuditEntity { .append(blueprintFilename.replaceAll(".yaml", "")); return buffer.toString().replace('.', '_').replaceAll(" ", ""); } + + public abstract Boolean isLegacy(); } 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 77627a31a..127f495cc 100644 --- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java +++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java @@ -157,6 +157,11 @@ public class MicroServicePolicy extends Policy implements Serializable { this.getPolicyModel().getPolicyModelType(), serviceModel)); } + @Override + public Boolean isLegacy() { + return false; + } + public Boolean getShared() { return shared; } 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 37533c1f6..060e79a63 100644 --- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java +++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java @@ -91,7 +91,7 @@ public class MicroServicePolicyService implements PolicyService<MicroServicePoli String deploymentUrl) { microServicePolicy.setDcaeDeploymentId(deploymentId); microServicePolicy.setDcaeDeploymentStatusUrl(deploymentUrl); - microServiceRepository.save(microServicePolicy); + microServiceRepository.saveAndFlush(microServicePolicy); } diff --git a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java index 033f2cebb..3765277d8 100644 --- a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java +++ b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java @@ -201,11 +201,13 @@ public class LegacyOperationalPolicy { policy.getAsJsonObject().remove(ACTOR); String actorStr = actor.getAsJsonObject().get(ACTOR).getAsString(); policy.getAsJsonObject().addProperty(ACTOR, actorStr); - policy.getAsJsonObject().addProperty(RECIPE, getRecipe(actor)); if ("CDS".equalsIgnoreCase(actorStr)) { - addPayloadAttributes(actor.getAsJsonObject(ACTOR).getAsJsonObject(RECIPE), policy); + policy.getAsJsonObject().addProperty(RECIPE, getRecipe(actor)); + addCdsPayloadAttributes(actor.getAsJsonObject(RECIPE), policy); } else { + policy.getAsJsonObject().addProperty(RECIPE, + actor.getAsJsonObject().get(RECIPE).getAsString()); addPayloadAttributes(actor, policy); } } @@ -226,7 +228,20 @@ public class LegacyOperationalPolicy { } } + private static void addCdsPayloadAttributes(JsonObject jsonObject, + JsonElement policy) { + JsonElement payloadElem = jsonObject.getAsJsonObject().get(PAYLOAD); + JsonObject payloadObject = payloadElem != null ? + payloadElem.getAsJsonObject() : null; + if (payloadObject != null) { + policy.getAsJsonObject().add(PAYLOAD, + payloadObject); + } else { + policy.getAsJsonObject().addProperty(PAYLOAD, ""); + } + } + private static String getRecipe(JsonObject actor) { - return actor.getAsJsonObject().get("type").getAsString(); + return actor.getAsJsonObject().get("recipe").getAsJsonObject().get("recipe").getAsString(); } } diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java index 44ee11970..4e362d841 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java @@ -24,13 +24,17 @@ package org.onap.clamp.policy.operational; +import static org.onap.clamp.clds.tosca.update.execution.cds.ToscaMetadataCdsProcess.createInputPropertiesForPayload; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; + import java.io.IOException; import java.util.Map.Entry; + import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.clds.util.ResourceFileUtil; import org.onap.clamp.loop.service.Service; @@ -70,7 +74,7 @@ public class OperationalPolicyRepresentationBuilder { for (JsonElement actor : actors) { if ("CDS".equalsIgnoreCase(actor.getAsJsonObject().get("title").getAsString())) { - actor.getAsJsonObject().get("properties").getAsJsonObject().get("type").getAsJsonObject() + actor.getAsJsonObject().get("properties").getAsJsonObject().get("recipe").getAsJsonObject() .get("anyOf").getAsJsonArray() .addAll(createAnyOfArrayForCdsRecipe(modelJson)); } @@ -195,8 +199,9 @@ public class OperationalPolicyRepresentationBuilder { for (Entry<String, JsonElement> workflowsEntry : workflows.entrySet()) { JsonObject obj = new JsonObject(); obj.addProperty("title", workflowsEntry.getKey()); + obj.addProperty("type", "object"); obj.add("properties", createPayloadProperty(workflowsEntry.getValue().getAsJsonObject(), - controllerProperties)); + controllerProperties, workflowsEntry.getKey())); schemaArray.add(obj); } @@ -205,26 +210,27 @@ public class OperationalPolicyRepresentationBuilder { return schemaArray; } - private static JsonObject createPayloadProperty(JsonObject workFlow, JsonObject controllerProperties) { - JsonObject type = new JsonObject(); - type.addProperty("title", "Payload (YAML)"); - type.addProperty("type", "string"); - type.addProperty("default", createDefaultStringForPayload(workFlow, controllerProperties)); - type.addProperty("format", "textarea"); + private static JsonObject createPayloadProperty(JsonObject workFlow, + JsonObject controllerProperties, String workFlowName) { + JsonObject payload = new JsonObject(); + payload.addProperty("title", "Payload (YAML)"); + payload.addProperty("type", "object"); + payload.add("properties", createInputPropertiesForPayload(workFlow, + controllerProperties)); JsonObject properties = new JsonObject(); - properties.add("type", type); + properties.add("recipe", createRecipeForCdsWorkflow(workFlowName)); + properties.add("payload", payload); return properties; } - private static String createDefaultStringForPayload(JsonObject workFlow, JsonObject controllerProperties) { - String artifactName = controllerProperties.get("sdnc_model_name").toString(); - String artifactVersion = controllerProperties.get("sdnc_model_version").toString(); - String data = workFlow.getAsJsonObject("inputs").toString(); - StringBuilder builder = new StringBuilder("'").append("artifact_name : ").append(artifactName).append("\n") - .append("artifact_version : ").append(artifactVersion).append("\n") - .append("mode : async").append("\n") - .append("data : ").append("'").append("\\").append("'").append(data).append("\\").append("'") - .append("'"); - return builder.toString(); + private static JsonObject createRecipeForCdsWorkflow(String workflow) { + JsonObject recipe = new JsonObject(); + recipe.addProperty("title", "recipe"); + recipe.addProperty("type", "string"); + recipe.addProperty("default", workflow); + JsonObject options = new JsonObject(); + options.addProperty("hidden", true); + recipe.add("options", options); + return recipe; } } diff --git a/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/src/main/resources/clds/camel/rest/clamp-api-v2.xml index e6741d6f8..879c9b707 100644 --- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -605,48 +605,62 @@ uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DELETE request','INFO',${exchangeProperty[loopObject]})" /> <to uri="direct:undeploy-loop" /> <to uri="direct:remove-all-policy-from-active-pdp-group" /> + <log loggingLevel="INFO" + message="Deleting all MICRO-SERVICES policies defined in loop ${exchangeProperty[loopObject].getName()}" /> <split> <simple>${exchangeProperty[loopObject].getMicroServicePolicies()} </simple> - <setProperty propertyName="microServicePolicy"> + <setProperty propertyName="policy"> <simple>${body}</simple> </setProperty> <log loggingLevel="INFO" - message="Processing Micro Service Policy: ${exchangeProperty[microServicePolicy].getName()}" /> - <to uri="direct:delete-micro-service-policy" /> + message="Deleting Micro Service Policy: ${exchangeProperty[policy].getName()}" /> + <setProperty propertyName="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">false</simple> + </setProperty> + <to uri="direct:delete-policy" /> </split> - <log loggingLevel="INFO" - message="Processing all OPERATIONAL policies defined in loop ${exchangeProperty[loopObject].getName()}" /> + message="Deleting all OPERATIONAL policies defined in loop ${exchangeProperty[loopObject].getName()}" /> <split> <simple>${exchangeProperty[loopObject].getOperationalPolicies()} </simple> - <setProperty propertyName="operationalPolicy"> + <setProperty propertyName="policy"> <simple>${body}</simple> </setProperty> <log loggingLevel="INFO" - message="Processing Operational Policy: ${exchangeProperty[operationalPolicy].getName()}" /> - <to uri="direct:delete-operational-policy" /> - <log loggingLevel="INFO" - message="Processing all GUARD policies defined in loop ${exchangeProperty[loopObject].getName()}" /> - <split> - <simple>${exchangeProperty[operationalPolicy].createGuardPolicyPayloads().entrySet()} - </simple> - <setProperty propertyName="guardPolicy"> - <simple>${body}</simple> - </setProperty> - <log loggingLevel="INFO" - message="Processing Guard Policy: ${exchangeProperty[guardPolicy].getKey()}" /> - <to uri="direct:delete-guard-policy" /> - </split> + message="Deleting Operational Policy: ${exchangeProperty[policy].getName()}" /> + <setProperty propertyName="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">false</simple> + </setProperty> + <to uri="direct:delete-policy" /> + <choice> + <when> + <simple>${exchangeProperty['policy'].isLegacy()} == true + </simple> + <log loggingLevel="INFO" + message="Deleting all GUARD policies (LEGACY) defined in loop ${exchangeProperty[loopObject].getName()}" /> + <split> + <simple>${exchangeProperty[operationalPolicy].createGuardPolicyPayloads().entrySet()} + </simple> + <setProperty propertyName="guardPolicy"> + <simple>${body}</simple> + </setProperty> + <log loggingLevel="INFO" + message="Deleting Guard Policy: ${exchangeProperty[guardPolicy].getKey()}" /> + <setProperty propertyName="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">false</simple> + </setProperty> + <to uri="direct:delete-guard-policy" /> + </split> + </when> + </choice> </split> <to - uri="bean:org.onap.clamp.loop.log.LoopController?method=deleteLoop(${header.loopName})" /> + uri="bean:org.onap.clamp.loop.LoopController?method=deleteLoop(${header.loopName})" /> <log loggingLevel="INFO" message="DELETE request successfully executed for loop: ${header.loopName}" /> <to - uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('DELETE request successfully executed','INFO',${exchangeProperty[loopObject]})" /> - <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> <doCatch> <exception>java.lang.Exception</exception> @@ -683,16 +697,14 @@ <to uri="direct:load-loop" /> <to uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('GET STATUS request','INFO',${exchangeProperty[loopObject]})" /> - <doTry> - <to uri="direct:update-policy-status-for-loop" /> - <to uri="direct:update-dcae-status-for-loop" /> - <to uri="direct:update-loop-state" /> + <to uri="direct:update-policy-status-for-loop" /> + <to uri="direct:update-dcae-status-for-loop" /> + <to uri="direct:update-loop-state" /> - <to + <to uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('GET STATUS request successfully executed','INFO',${exchangeProperty[loopObject]})" /> - <to + <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=endLog()" /> - </doTry> <doCatch> <exception>java.lang.Exception</exception> <handled> @@ -704,17 +716,14 @@ message="GET STATUS request FAILED for loop: ${header.loopName}, ${exception.stacktrace}" /> <to uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('GET STATUS request failed, Error reported: ${exception} - Body: ${exception.responseBody}','ERROR',${exchangeProperty[loopObject]})" /> - <setHeader headerName="CamelHttpResponseCode"> - <constant>500</constant> - </setHeader> - <setBody> - <simple>GET STATUS request FAILED</simple> - </setBody> </doCatch> <doFinally> <setBody> <simple>${exchangeProperty[loopObject]}</simple> </setBody> + <setHeader headerName="CamelHttpResponseCode"> + <constant>200</constant> + </setHeader> </doFinally> </doTry> </route> @@ -756,15 +765,29 @@ </doTry> </route> </put> - <put uri="/v2/loop/removeOperationaPolicy/{loopName}/policyModel/{policyType}/{policyVersion}" outType="org.onap.clamp.loop.Loop" produces="application/json"> + <put uri="/v2/loop/removeOperationaPolicy/{loopName}/policyModel/{policyType}/{policyVersion}/{policyName}" outType="org.onap.clamp.loop.Loop" produces="application/json"> <route> - <removeHeaders pattern="*" excludePattern="loopName|policyType|policyVersion" /> + <removeHeaders pattern="*" excludePattern="loopName|policyType|policyVersion|policyName" /> <doTry> <to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=startLog(*, 'REMOVE operational Policy')" /> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" /> <to uri="direct:load-loop" /> + <setProperty propertyName="policyName"> + <simple>${header.policyName}</simple> + </setProperty> + <setProperty propertyName="policy"> + <simple>${exchangeProperty[loopObject].getOperationalPolicy(header.policyName)}</simple> + </setProperty> + <setProperty propertyName="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">false</simple> + </setProperty> + <to uri="direct:remove-one-policy-from-active-pdp-group" /> + <setProperty propertyName="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">false</simple> + </setProperty> + <to uri="direct:delete-policy" /> <to uri="bean:org.onap.clamp.loop.LoopController?method=removeOperationalPolicy(${header.loopName},${header.policyType},${header.policyVersion})" /> <to diff --git a/src/main/resources/clds/camel/routes/dcae-flows.xml b/src/main/resources/clds/camel/routes/dcae-flows.xml index f40207cc7..e36f28abf 100644 --- a/src/main/resources/clds/camel/routes/dcae-flows.xml +++ b/src/main/resources/clds/camel/routes/dcae-flows.xml @@ -371,6 +371,17 @@ message="Endpoint to query Closed Loop status: ${exchangeProperty[getStatusUrl]}"></log> <toD uri="${exchangeProperty[getStatusUrl]}?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.dcae.deployment.userName}}&authPassword={{clamp.config.dcae.deployment.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=30000&authenticationPreemptive=true&connectionClose=true" /> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>true</constant> + </handled> + + <log loggingLevel="ERROR" + message="GET policy request FAILED for loop: ${header.loopName}, ${exception.stacktrace}" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('GET policy request failed, Error reported: ${exception.message}','ERROR',${exchangeProperty[loopObject]})" /> + </doCatch> <doFinally> <to uri="direct:reset-raise-http-exception-flag" /> <to diff --git a/src/main/resources/clds/camel/routes/loop-flows.xml b/src/main/resources/clds/camel/routes/loop-flows.xml index 8c22743a3..2f4d9c8cf 100644 --- a/src/main/resources/clds/camel/routes/loop-flows.xml +++ b/src/main/resources/clds/camel/routes/loop-flows.xml @@ -40,6 +40,9 @@ <setProperty propertyName="policyType"> <simple>${body.getPolicyModel().getPolicyModelType()}</simple> </setProperty> + <setProperty propertyName="policyTypeVersion"> + <simple>${body.getPolicyModel().getVersion()}</simple> + </setProperty> <setProperty propertyName="policyVersion"> <simple>1.0.0</simple> </setProperty> @@ -61,9 +64,22 @@ <setProperty propertyName="policyType"> <simple>${body.getPolicyModel().getPolicyModelType()}</simple> </setProperty> - <setProperty propertyName="policyVersion"> - <simple>1.0.0</simple> + <setProperty propertyName="policyTypeVersion"> + <simple>${body.getPolicyModel().getVersion()}</simple> </setProperty> + <choice> + <when> + <simple>${body.isLegacy()} == true</simple> + <setProperty propertyName="policyVersion"> + <simple>1</simple> + </setProperty> + </when> + <otherwise> + <setProperty propertyName="policyVersion"> + <simple>1.0.0</simple> + </setProperty> + </otherwise> + </choice> <setProperty propertyName="operationalPolicy"> <simple>${body}</simple> </setProperty> @@ -84,6 +100,9 @@ <setProperty propertyName="policyType"> <simple>onap.policies.controlloop.Guard</simple> </setProperty> + <setProperty propertyName="policyTypeVersion"> + <simple>1.0.0</simple> + </setProperty> <setProperty propertyName="policyVersion"> <simple>1</simple> </setProperty> diff --git a/src/main/resources/clds/camel/routes/policy-flows.xml b/src/main/resources/clds/camel/routes/policy-flows.xml index a2c7a4ca3..1731308ee 100644 --- a/src/main/resources/clds/camel/routes/policy-flows.xml +++ b/src/main/resources/clds/camel/routes/policy-flows.xml @@ -1,717 +1,601 @@ - <routes xmlns="http://camel.apache.org/schema/spring"> - <route id="verify-one-policy"> - <from uri="direct:verify-one-policy"/> - <setProperty propertyName="raiseHttpExceptionFlag"> - <simple resultType="java.lang.Boolean">false</simple> - </setProperty> - <to uri="direct:get-policy"/> - <when> - <simple> ${header.CamelHttpResponseCode} != 200 </simple> - <setProperty propertyName="policyFound"> - <simple resultType="java.lang.Boolean">false</simple> - </setProperty> - <log loggingLevel="WARN" - message="At least one policy has not been found on policy engine: ${exchangeProperty[policyName]}"/> - </when> - <setProperty propertyName="raiseHttpExceptionFlag"> - <simple resultType="java.lang.Boolean">false</simple> - </setProperty> - <to uri="direct:get-deployment-policy"/> - <when> - <simple> ${header.CamelHttpResponseCode} != 200 </simple> - <setProperty propertyName="policyDeployed"> - <simple resultType="java.lang.Boolean">false</simple> - </setProperty> - <log loggingLevel="WARN" - message="At least one policy has not been deployed on policy engine: ${exchangeProperty[policyName]}"/> - </when> - <setProperty propertyName="newPolicyState"> - <simple>${exchangeProperty[policyComponent].computeState(*)}</simple> - </setProperty> - </route> - - <route id="get-policy"> - <from uri="direct:get-policy"/> - <doTry> - <log loggingLevel="INFO" - message="Getting Policy: ${exchangeProperty[policyName]}"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Get Policy')"/> - <setHeader headerName="CamelHttpMethod"> - <constant>GET</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to get policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/1.0.0/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}"></log> - <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/1.0.0/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> - <simple>${exchangeProperty[policyName]} GET - Policy status - </simple> - </setProperty> - <setProperty propertyName="logComponent"> - <simple>POLICY</simple> - </setProperty> - <to uri="direct:dump-loop-log-http-response"/> - </doFinally> - </doTry> - </route> - - <route id="get-deployment-policy"> - <from uri="direct:get-deployment-policy"/> - <doTry> - <log loggingLevel="INFO" - message="Getting the policy deployment in PDP: ${exchangeProperty[policyName]}"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policy deployment in PDP')"/> - <setHeader headerName="CamelHttpMethod"> - <constant>GET</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to get policy deployment status: {{clamp.config.policy.pap.url}}/policy/pap/v1/policies/deployed/${exchangeProperty[policyName]}/1.0.0"></log> - <toD - uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/policies/deployed/${exchangeProperty[policyName]}/1.0.0?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> - <simple>${exchangeProperty[policyName]} GET Policy deployment - status - </simple> - </setProperty> - <setProperty propertyName="logComponent"> - <simple>POLICY</simple> - </setProperty> - <to uri="direct:dump-loop-log-http-response"/> - </doFinally> - </doTry> - </route> - <route id="get-all-policy-models"> - <from uri="direct:get-all-policy-models"/> - <doTry> - <log loggingLevel="INFO" message="Getting all the policy models"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting all the policy models')"/> - <setHeader headerName="CamelHttpMethod"> - <constant>GET</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to get all policy models: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes"></log> - <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <convertBodyTo type="java.lang.String"/> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - </doFinally> - </doTry> - </route> - <route id="get-policy-model"> - <from uri="direct:get-policy-model"/> - <doTry> - <log loggingLevel="INFO" - message="Getting the policy model: ${exchangeProperty[policyModelName]}/${exchangeProperty[policyModelVersion]}"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policy model')"/> - <setHeader headerName="CamelHttpMethod"> - <constant>GET</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to get policy model: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelName]}/versions/${exchangeProperty[policyModelVersion]}"></log> - <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelName]}/versions/${exchangeProperty[policyModelVersion]}?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <convertBodyTo type="java.lang.String"/> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - </doFinally> - </doTry> - </route> - <route id="create-policy"> - <from uri="direct:create-policy"/> - <doTry> - <log loggingLevel="INFO" - message="Creating Policy: ${exchangeProperty[policy].getName()}"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Policy')"/> - <setBody> - <simple>${exchangeProperty[policy].createPolicyPayload()} - </simple> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>POST</constant> - </setHeader> - <setHeader headerName="Content-Type"> - <constant>application/json</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to create policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies"></log> - <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> - <simple>${exchangeProperty[policy].getName()} creation - status - </simple> - </setProperty> - <setProperty propertyName="logComponent"> - <simple>POLICY</simple> - </setProperty> - <to uri="direct:dump-loop-log-http-response"/> - </doFinally> - </doTry> - </route> + <route id="verify-one-policy"> + <from uri="direct:verify-one-policy"/> + <setProperty propertyName="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">false</simple> + </setProperty> + <to uri="direct:get-policy"/> + <when> + <simple>${header.CamelHttpResponseCode} != 200</simple> + <setProperty propertyName="policyFound"> + <simple resultType="java.lang.Boolean">false</simple> + </setProperty> + <log loggingLevel="WARN" + message="At least one policy has not been found on policy engine: ${exchangeProperty[policyName]}"/> + </when> + <setProperty propertyName="raiseHttpExceptionFlag"> + <simple resultType="java.lang.Boolean">false</simple> + </setProperty> + <to uri="direct:get-deployment-policy"/> + <when> + <simple>${header.CamelHttpResponseCode} != 200</simple> + <setProperty propertyName="policyDeployed"> + <simple resultType="java.lang.Boolean">false</simple> + </setProperty> + <log loggingLevel="WARN" + message="At least one policy has not been deployed on policy engine: ${exchangeProperty[policyName]}"/> + </when> + <setProperty propertyName="newPolicyState"> + <simple>${exchangeProperty[policyComponent].computeState(*)}</simple> + </setProperty> + </route> - <route id="delete-policy"> - <from uri="direct:delete-policy"/> - <doTry> - <log loggingLevel="INFO" - message="Deleting Policy: ${exchangeProperty[policy].getName()}"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Policy')"/> - <setBody> - <constant>null</constant> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>DELETE</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to delete microservice policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies/${exchangeProperty[policy].getName()}/versions/1.0.0"></log> - <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies/${exchangeProperty[policy].getName()}/versions/1.0.0?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + <route id="get-policy"> + <from uri="direct:get-policy"/> + <doTry> + <log loggingLevel="INFO" + message="Getting Policy: ${exchangeProperty[policyName]}"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Get Policy')"/> + <setHeader headerName="CamelHttpMethod"> + <constant>GET</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to get policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/${exchangeProperty[policyTypeVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}"></log> + <toD + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyType]}/versions/${exchangeProperty[policyTypeVersion]}/policies/${exchangeProperty[policyName]}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>true</constant> + </handled> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> - <simple>${exchangeProperty[policy].getName()} removal - status - </simple> - </setProperty> - <setProperty propertyName="logComponent"> - <simple>POLICY</simple> - </setProperty> - <to uri="direct:dump-loop-log-http-response"/> - </doFinally> - </doTry> - </route> - <route id="create-micro-service-policy"> - <from uri="direct:create-micro-service-policy"/> - <doTry> - <log loggingLevel="INFO" - message="Creating Micro Service Policy: ${exchangeProperty[microServicePolicy].getName()}"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Micro Service Policy')"/> - <setBody> - <simple>${exchangeProperty[microServicePolicy].createPolicyPayload()} - </simple> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>POST</constant> - </setHeader> - <setHeader headerName="Content-Type"> - <constant>application/json</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to create microservice policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getPolicyModel().getPolicyModelType()}/versions/1.0.0/policies"></log> - <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getPolicyModel().getPolicyModelType()}/versions/1.0.0/policies?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> - <simple>${exchangeProperty[microServicePolicy].getName()} creation - status - </simple> - </setProperty> - <setProperty propertyName="logComponent"> - <simple>POLICY</simple> - </setProperty> - <to uri="direct:dump-loop-log-http-response"/> - </doFinally> - </doTry> - </route> + <log loggingLevel="ERROR" + message="GET policy request FAILED for loop: ${header.loopName}, ${exception.stacktrace}" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('GET policy request failed, Error reported: ${exception.message}','ERROR',${exchangeProperty[loopObject]})" /> + </doCatch> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + <setProperty propertyName="logMessage"> + <simple>${exchangeProperty[policyName]} GET + Policy status + </simple> + </setProperty> + <setProperty propertyName="logComponent"> + <simple>POLICY</simple> + </setProperty> + <to uri="direct:dump-loop-log-http-response"/> + </doFinally> + </doTry> + </route> - <route id="delete-micro-service-policy"> - <from uri="direct:delete-micro-service-policy"/> - <doTry> - <log loggingLevel="INFO" - message="Deleting Micro Service Policy: ${exchangeProperty[microServicePolicy].getName()}"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Micro Service Policy')"/> - <setBody> - <constant>null</constant> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>DELETE</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to delete microservice policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getPolicyModel().getPolicyModelType()}/versions/1.0.0/policies/${exchangeProperty[microServicePolicy].getName()}/versions/1.0.0"></log> - <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[microServicePolicy].getPolicyModel().getPolicyModelType()}/versions/1.0.0/policies/${exchangeProperty[microServicePolicy].getName()}/versions/1.0.0?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + <route id="get-deployment-policy"> + <from uri="direct:get-deployment-policy"/> + <doTry> + <log loggingLevel="INFO" + message="Getting the policy deployment in PDP: ${exchangeProperty[policyName]}"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policy deployment in PDP')"/> + <setHeader headerName="CamelHttpMethod"> + <constant>GET</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to get policy deployment status: {{clamp.config.policy.pap.url}}/policy/pap/v1/policies/deployed/${exchangeProperty[policyName]}/1.0.0"></log> + <toD + uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/policies/deployed/${exchangeProperty[policyName]}/1.0.0?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>true</constant> + </handled> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> - <simple>${exchangeProperty[microServicePolicy].getName()} removal - status - </simple> - </setProperty> - <setProperty propertyName="logComponent"> - <simple>POLICY</simple> - </setProperty> - <to uri="direct:dump-loop-log-http-response"/> - </doFinally> - </doTry> - </route> + <log loggingLevel="ERROR" + message="GET policy request FAILED for loop: ${header.loopName}, ${exception.stacktrace}" /> + <to + uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('GET policy request failed, Error reported: ${exception.message}','ERROR',${exchangeProperty[loopObject]})" /> + </doCatch> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + <setProperty propertyName="logMessage"> + <simple>${exchangeProperty[policyName]} GET Policy deployment + status + </simple> + </setProperty> + <setProperty propertyName="logComponent"> + <simple>POLICY</simple> + </setProperty> + <to uri="direct:dump-loop-log-http-response"/> + </doFinally> + </doTry> + </route> + <route id="get-all-policy-models"> + <from uri="direct:get-all-policy-models"/> + <doTry> + <log loggingLevel="INFO" message="Getting all the policy models"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting all the policy models')"/> + <setHeader headerName="CamelHttpMethod"> + <constant>GET</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to get all policy models: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes"></log> + <toD + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + <convertBodyTo type="java.lang.String"/> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + </doFinally> + </doTry> + </route> + <route id="get-policy-model"> + <from uri="direct:get-policy-model"/> + <doTry> + <log loggingLevel="INFO" + message="Getting the policy model: ${exchangeProperty[policyModelName]}/${exchangeProperty[policyModelVersion]}"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the policy model')"/> + <setHeader headerName="CamelHttpMethod"> + <constant>GET</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to get policy model: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelName]}/versions/${exchangeProperty[policyModelVersion]}"></log> + <toD + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelName]}/versions/${exchangeProperty[policyModelVersion]}?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + <convertBodyTo type="java.lang.String"/> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + </doFinally> + </doTry> + </route> + <route id="create-policy"> + <from uri="direct:create-policy"/> + <doTry> + <log loggingLevel="INFO" + message="Creating Policy: ${exchangeProperty[policy].getName()}"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Policy')"/> + <setBody> + <simple>${exchangeProperty[policy].createPolicyPayload()} + </simple> + </setBody> + <setHeader headerName="CamelHttpMethod"> + <constant>POST</constant> + </setHeader> + <setHeader headerName="Content-Type"> + <constant>application/json</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to create policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies"></log> + <toD + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + <setProperty propertyName="logMessage"> + <simple>${exchangeProperty[policy].getName()} creation + status + </simple> + </setProperty> + <setProperty propertyName="logComponent"> + <simple>POLICY</simple> + </setProperty> + <to uri="direct:dump-loop-log-http-response"/> + </doFinally> + </doTry> + </route> - <route id="create-operational-policy"> - <from uri="direct:create-operational-policy"/> - <doTry> - <log loggingLevel="INFO" - message="Creating Operational Policy: ${exchangeProperty[operationalPolicy].getName()}"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Operational Policy')"/> - <setBody> - <simple>${exchangeProperty[operationalPolicy].createPolicyPayload()} - </simple> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>POST</constant> - </setHeader> - <setHeader headerName="Content-Type"> - <constant>application/json</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to create operational policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies"></log> - <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> - <simple>${exchangeProperty[operationalPolicy].getName()} creation - status - </simple> - </setProperty> - <setProperty propertyName="logComponent"> - <simple>POLICY</simple> - </setProperty> - <to uri="direct:dump-loop-log-http-response"/> - </doFinally> - </doTry> - </route> + <route id="delete-policy"> + <from uri="direct:delete-policy"/> + <doTry> + <log loggingLevel="INFO" + message="Deleting Policy: ${exchangeProperty[policy].getName()}"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Policy')"/> + <setBody> + <constant>null</constant> + </setBody> + <setHeader headerName="CamelHttpMethod"> + <constant>DELETE</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <choice> + <when> + <simple>${exchangeProperty[policy].isLegacy()} == true</simple> + <setProperty propertyName="policyVersion"> + <simple>1</simple> + </setProperty> + </when> + <otherwise> + <setProperty propertyName="policyVersion"> + <simple>1.0.0</simple> + </setProperty> + </otherwise> + </choice> + <log loggingLevel="INFO" + message="Endpoint to delete policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies/${exchangeProperty[policy].getName()}/versions/${exchangeProperty[policyVersion]}"></log> + <toD + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policy].getPolicyModel().getPolicyModelType()}/versions/${exchangeProperty[policy].getPolicyModel().getVersion()}/policies/${exchangeProperty[policy].getName()}/versions/${exchangeProperty[policyVersion]}?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <route id="delete-operational-policy"> - <from uri="direct:delete-operational-policy"/> - <doTry> - <log loggingLevel="INFO" - message="Deleting Operational Policy: ${exchangeProperty[operationalPolicy].getName()}"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Operational Policy')"/> - <setBody> - <constant>null</constant> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>DELETE</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to delete operational policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicy].getName()}/versions/1"></log> - <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/${exchangeProperty[operationalPolicy].getName()}/versions/1?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> - <simple>${exchangeProperty[operationalPolicy].getName()} removal - status - </simple> - </setProperty> - <setProperty propertyName="logComponent"> - <simple>POLICY</simple> - </setProperty> - <to uri="direct:dump-loop-log-http-response"/> - </doFinally> - </doTry> - </route> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + <setProperty propertyName="logMessage"> + <simple>${exchangeProperty[policy].getName()} removal + status + </simple> + </setProperty> + <setProperty propertyName="logComponent"> + <simple>POLICY</simple> + </setProperty> + <to uri="direct:dump-loop-log-http-response"/> + </doFinally> + </doTry> + </route> + <route id="create-guard-policy"> + <from uri="direct:create-guard-policy"/> + <doTry> + <log loggingLevel="INFO" + message="Creating Guard Policy: ${exchangeProperty[guardPolicy].getKey()}"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Guard Policy')"/> + <setBody> + <simple>${exchangeProperty[guardPolicy].getValue()} + </simple> + </setBody> + <setHeader headerName="CamelHttpMethod"> + <constant>POST</constant> + </setHeader> + <setHeader headerName="Content-Type"> + <constant>application/json</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to create guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies"></log> + <toD + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + <setProperty propertyName="logMessage"> + <simple>${exchangeProperty[guardPolicy].getKey()} creation status + </simple> + </setProperty> + <setProperty propertyName="logComponent"> + <simple>POLICY</simple> + </setProperty> + <to uri="direct:dump-loop-log-http-response"/> + </doFinally> + </doTry> + </route> - <route id="create-guard-policy"> - <from uri="direct:create-guard-policy"/> - <doTry> - <log loggingLevel="INFO" - message="Creating Guard Policy: ${exchangeProperty[guardPolicy].getKey()}"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Create Guard Policy')"/> - <setBody> - <simple>${exchangeProperty[guardPolicy].getValue()} - </simple> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>POST</constant> - </setHeader> - <setHeader headerName="Content-Type"> - <constant>application/json</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to create guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies"></log> - <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> - <simple>${exchangeProperty[guardPolicy].getKey()} creation status - </simple> - </setProperty> - <setProperty propertyName="logComponent"> - <simple>POLICY</simple> - </setProperty> - <to uri="direct:dump-loop-log-http-response"/> - </doFinally> - </doTry> - </route> + <route id="delete-guard-policy"> + <from uri="direct:delete-guard-policy"/> + <doTry> + <log loggingLevel="INFO" + message="Deleting Guard Policy: ${exchangeProperty[guardPolicy].getKey()}"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Guard Policy')"/> + <setBody> + <constant>null</constant> + </setBody> + <setHeader headerName="CamelHttpMethod"> + <constant>DELETE</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to delete guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1"></log> + <toD + uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <route id="delete-guard-policy"> - <from uri="direct:delete-guard-policy"/> - <doTry> - <log loggingLevel="INFO" - message="Deleting Guard Policy: ${exchangeProperty[guardPolicy].getKey()}"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Delete Guard Policy')"/> - <setBody> - <constant>null</constant> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>DELETE</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to delete guard policy: {{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1"></log> - <toD - uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${exchangeProperty[guardPolicy].getKey()}/versions/1?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&deleteWithBody=false&mapHttpMessageBody=false&mapHttpMessageFormUrlEncodedBody=false&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + <setProperty propertyName="logMessage"> + <simple>${exchangeProperty[guardPolicy].getKey()} removal status + </simple> + </setProperty> + <setProperty propertyName="logComponent"> + <simple>POLICY</simple> + </setProperty> + <to uri="direct:dump-loop-log-http-response"/> + </doFinally> + </doTry> + </route> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> - <simple>${exchangeProperty[guardPolicy].getKey()} removal status - </simple> - </setProperty> - <setProperty propertyName="logComponent"> - <simple>POLICY</simple> - </setProperty> - <to uri="direct:dump-loop-log-http-response"/> - </doFinally> - </doTry> - </route> + <route id="add-all-to-active-pdp-group"> + <from uri="direct:add-all-to-active-pdp-group"/> + <doTry> + <log loggingLevel="INFO" + message="Adding loop policies to PDP Group: ${exchangeProperty[loopObject].getName()}"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Add policies to PDP group')"/> + <setBody> + <simple> + ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"POST")} + </simple> + </setBody> + <setHeader headerName="CamelHttpMethod"> + <constant>POST</constant> + </setHeader> + <setHeader headerName="Content-Type"> + <constant>application/json</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to add policies to PDP Group: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch"></log> + <toD + uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch?bridgeEndpoint=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&useSystemProperties=true&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <route id="add-all-to-active-pdp-group"> - <from uri="direct:add-all-to-active-pdp-group"/> - <doTry> - <log loggingLevel="INFO" - message="Adding loop policies to PDP Group: ${exchangeProperty[loopObject].getName()}"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Add policies to PDP group')"/> - <setBody> - <simple>${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject])} - </simple> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>POST</constant> - </setHeader> - <setHeader headerName="Content-Type"> - <constant>application/json</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to add policies to PDP Group: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch"></log> - <toD - uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch?bridgeEndpoint=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&useSystemProperties=true&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + <setProperty propertyName="logMessage"> + <simple>PDP Group push ALL status</simple> + </setProperty> + <setProperty propertyName="logComponent"> + <simple>POLICY</simple> + </setProperty> + <to uri="direct:dump-loop-log-http-response"/> + </doFinally> + </doTry> + </route> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - <setProperty propertyName="logMessage"> - <simple>PDP Group push ALL status</simple> - </setProperty> - <setProperty propertyName="logComponent"> - <simple>POLICY</simple> - </setProperty> - <to uri="direct:dump-loop-log-http-response"/> - </doFinally> - </doTry> - </route> + <route id="remove-all-policy-from-active-pdp-group"> + <from uri="direct:remove-all-policy-from-active-pdp-group"/> + <doTry> + <log loggingLevel="INFO" + message="Removing loop policies from PDP Group: ${exchangeProperty[loopObject].getName()}"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Remove policies from PDP group')"/> + <setBody> + <simple> + ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject],"DELETE")} + </simple> + </setBody> + <setHeader headerName="CamelHttpMethod"> + <constant>POST</constant> + </setHeader> + <setHeader headerName="Content-Type"> + <constant>application/json</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to remove policies from PDP Group: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch"></log> + <toD + uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch?bridgeEndpoint=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&useSystemProperties=true&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <route id="remove-all-policy-from-active-pdp-group"> - <from uri="direct:remove-all-policy-from-active-pdp-group"/> - <doTry> - <log loggingLevel="INFO" - message="Removing policies from active PDP group for loop: ${exchangeProperty[loopObject].getName()}"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Removing policies PDP group')"/> - <split> - <simple>${exchangeProperty[loopObject].getComponent("POLICY").listPolicyNamesPdpGroup(exchangeProperty[loopObject])} - </simple> - <setProperty propertyName="policyName"> - <simple>${body}</simple> - </setProperty> - <setBody> - <constant>null</constant> - </setBody> - <setHeader headerName="CamelHttpMethod"> - <constant>DELETE</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to delete policy from PDP Group: {{clamp.config.policy.pap.url}}/pdps/deployments/batch/${exchangeProperty[policyName]}/versions/1.0.0"></log> - <toD - uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/deployments/batch/${exchangeProperty[policyName]}/versions/1.0.0?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <setProperty propertyName="logMessage"> - <simple>${exchangeProperty[policyName]} PDP Group removal status - </simple> - </setProperty> - <setProperty propertyName="logComponent"> - <simple>POLICY</simple> - </setProperty> - <to uri="direct:dump-loop-log-http-response"/> - </split> - <doCatch> - <exception>java.lang.Exception</exception> - <handled> - <constant>false</constant> - </handled> - <setProperty propertyName="logMessage"> - <simple>PDP Group removal, Error reported: ${exception}</simple> - </setProperty> - <setProperty propertyName="logComponent"> - <simple>POLICY</simple> - </setProperty> - <to uri="direct:dump-loop-log-http-response"/> - </doCatch> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - </doFinally> - </doTry> - </route> - <route id="get-all-pdp-groups"> - <from uri="direct:get-all-pdp-groups"/> - <doTry> - <log loggingLevel="INFO" - message="Getting the list of PDP Groups"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the PDP Group list')"/> - <setHeader headerName="CamelHttpMethod"> - <constant>GET</constant> - </setHeader> - <setHeader headerName="X-ONAP-RequestID"> - <simple>${exchangeProperty[X-ONAP-RequestID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-InvocationID"> - <simple>${exchangeProperty[X-ONAP-InvocationID]} - </simple> - </setHeader> - <setHeader headerName="X-ONAP-PartnerName"> - <simple>${exchangeProperty[X-ONAP-PartnerName]} - </simple> - </setHeader> - <log loggingLevel="INFO" - message="Endpoint to get policy model: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps"></log> - <toD - uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <convertBodyTo type="java.lang.String" /> - <doFinally> - <to uri="direct:reset-raise-http-exception-flag"/> - <to - uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> - </doFinally> - </doTry> - </route> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + <setProperty propertyName="logMessage"> + <simple>PDP Group remove ALL status</simple> + </setProperty> + <setProperty propertyName="logComponent"> + <simple>POLICY</simple> + </setProperty> + <to uri="direct:dump-loop-log-http-response"/> + </doFinally> + </doTry> + </route> + <route id="get-all-pdp-groups"> + <from uri="direct:get-all-pdp-groups"/> + <doTry> + <log loggingLevel="INFO" + message="Getting the list of PDP Groups"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the PDP Group list')"/> + <setHeader headerName="CamelHttpMethod"> + <constant>GET</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to get policy model: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps"></log> + <toD + uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + <convertBodyTo type="java.lang.String"/> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + </doFinally> + </doTry> + </route> + <route id="remove-one-policy-from-active-pdp-group"> + <from uri="direct:remove-one-policy-from-active-pdp-group"/> + <doTry> + <log loggingLevel="INFO" + message="Removing policy from active PDP group for loop: ${exchangeProperty[loopObject].getName()}"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Removing one policy PDP group')"/> + <setBody> + <constant>null</constant> + </setBody> + <setHeader headerName="CamelHttpMethod"> + <constant>DELETE</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to delete policy from PDP Group: {{clamp.config.policy.pap.url}}/pdps/policies/${exchangeProperty[policyName]}/versions/1.0.0"></log> + <toD + uri="{{clamp.config.policy.pap.url}}/policy/pap/v1/pdps/policies/${exchangeProperty[policyName]}/versions/1.0.0?bridgeEndpoint=true&useSystemProperties=true&mapHttpMessageHeaders=false&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authUsername={{clamp.config.policy.pap.userName}}&authPassword={{clamp.config.policy.pap.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + <setProperty propertyName="logMessage"> + <simple>${exchangeProperty[policyName]} PDP Group removal status + </simple> + </setProperty> + <setProperty propertyName="logComponent"> + <simple>POLICY</simple> + </setProperty> + <to uri="direct:dump-loop-log-http-response"/> + <doCatch> + <exception>java.lang.Exception</exception> + <handled> + <constant>false</constant> + </handled> + <setProperty propertyName="logMessage"> + <simple>PDP Group removal, Error reported: ${exception}</simple> + </setProperty> + <setProperty propertyName="logComponent"> + <simple>POLICY</simple> + </setProperty> + <to uri="direct:dump-loop-log-http-response"/> + </doCatch> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + </doFinally> + </doTry> + </route> </routes>
\ No newline at end of file diff --git a/src/main/resources/clds/json-schema/operational_policies/operational_policy.json b/src/main/resources/clds/json-schema/operational_policies/operational_policy.json index 49d7878a8..7214b022c 100644 --- a/src/main/resources/clds/json-schema/operational_policies/operational_policy.json +++ b/src/main/resources/clds/json-schema/operational_policies/operational_policy.json @@ -99,6 +99,7 @@ "anyOf": [ { "title": "APPC", + "type": "object", "properties": { "actor": { "title": "actor", @@ -108,7 +109,7 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", "default": "", @@ -129,6 +130,7 @@ }, { "title": "SO", + "type": "object", "properties": { "actor": { "title": "actor", @@ -138,7 +140,7 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", "default": "", @@ -156,6 +158,7 @@ }, { "title": "SDNC", + "type": "object", "properties": { "actor": { "title": "actor", @@ -165,7 +168,7 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", "default": "", @@ -183,6 +186,7 @@ }, { "title": "VFC", + "type": "object", "properties": { "actor": { "title": "actor", @@ -192,12 +196,9 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", - "required": [ - "payload" - ], "default": "", "enum": [ "ModifyConfig" @@ -212,6 +213,7 @@ }, { "title": "CDS", + "type": "object", "properties": { "actor": { "title": "actor", @@ -221,17 +223,21 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "object", - "required": [ - "payload" - ], "anyOf": [ { "title": "user-defined", + "type": "object", "properties": { - "type": { + "recipe": { + "title": "recipe", + "type": "string", + "default": "user-defined", + "format": "textarea" + }, + "payload": { "title": "Payload (YAML)", "type": "string", "default": "", diff --git a/src/test/java/org/onap/clamp/clds/client/CdsServicesTest.java b/src/test/java/org/onap/clamp/clds/client/CdsServicesTest.java new file mode 100644 index 000000000..ec39fc3db --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/client/CdsServicesTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * ================================================================================ + * 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.client; + +import com.google.gson.JsonObject; + +import java.io.IOException; + +import org.junit.Test; +import org.onap.clamp.clds.util.JsonUtils; +import org.onap.clamp.clds.util.ResourceFileUtil; +import org.skyscreamer.jsonassert.JSONAssert; + +public class CdsServicesTest { + + @Test + public void testParseCdsListTypeProperties() throws IOException { + String cdsResponse = ResourceFileUtil + .getResourceAsString("example/cds-response/vFW-CDS-resource-assignment-workflow.json"); + CdsServices services = new CdsServices(); + JsonObject output = services.parseCdsResponse(cdsResponse); + JSONAssert.assertEquals(ResourceFileUtil + .getResourceAsString("example/cds-response/vFW-CDS-resource-assignment-wf-expected-result.json"), + JsonUtils.GSON.toJson(output), true); + } + + @Test + public void testParseCdsResponse() throws IOException { + String cdsResponse = ResourceFileUtil + .getResourceAsString("example/cds-response/vFW-CDS-modify-config-workflow.json"); + CdsServices services = new CdsServices(); + JsonObject output = services.parseCdsResponse(cdsResponse); + JSONAssert.assertEquals(ResourceFileUtil + .getResourceAsString("example/cds-response/vFW-CDS-modify-config-wf-expected-result.json"), + JsonUtils.GSON.toJson(output), true); + } + +}
\ No newline at end of file diff --git a/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTestItCase.java b/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTestItCase.java index a32d4995e..b26f3ede8 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTestItCase.java +++ b/src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTestItCase.java @@ -57,7 +57,7 @@ public class ToscaYamlToJsonConvertorTestItCase { * Schema. * * @throws IOException In case of issue when opening the tosca yaml file and - * converted json file + * converted json file */ @Test public final void testParseToscaYaml() throws IOException { @@ -65,11 +65,11 @@ public class ToscaYamlToJsonConvertorTestItCase { ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor(); String parsedJsonSchema = - convertor.parseToscaYaml(toscaModelYaml, "onap.policies.monitoring.cdap.tca.hi.lo.app"); + convertor.parseToscaYaml(toscaModelYaml, "onap.policies.monitoring.cdap.tca.hi.lo.app"); assertNotNull(parsedJsonSchema); JSONAssert.assertEquals( - ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json.json"), - parsedJsonSchema, true); + ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json.json"), + parsedJsonSchema, true); } /** @@ -77,20 +77,20 @@ public class ToscaYamlToJsonConvertorTestItCase { * based on JSON Editor Schema. * * @throws IOException In case of issue when opening the tosca yaml file and - * converted json file + * converted json file */ @Test public final void testParseToscaYamlWithConstraints() throws IOException { String toscaModelYaml = - ResourceFileUtil.getResourceAsString("tosca/tosca-with-constraints.yaml"); + ResourceFileUtil.getResourceAsString("tosca/tosca-with-constraints.yaml"); ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor(); String parsedJsonSchema = - convertor.parseToscaYaml(toscaModelYaml, "onap.policies.monitoring.example.app"); + convertor.parseToscaYaml(toscaModelYaml, "onap.policies.monitoring.example.app"); assertNotNull(parsedJsonSchema); JSONAssert.assertEquals( - ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json-with-constraints.json"), - parsedJsonSchema, true); + ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json-with-constraints.json"), + parsedJsonSchema, true); } /** @@ -98,20 +98,20 @@ public class ToscaYamlToJsonConvertorTestItCase { * conversion based on JSON Editor Schema. * * @throws IOException In case of issue when opening the tosca yaml file and - * converted json file + * converted json file */ @Test public final void testParseToscaYamlWithTypes() throws IOException { String toscaModelYaml = - ResourceFileUtil.getResourceAsString("tosca/tosca-with-datatypes.yaml"); + ResourceFileUtil.getResourceAsString("tosca/tosca-with-datatypes.yaml"); ToscaYamlToJsonConvertor convertor = new ToscaYamlToJsonConvertor(); String parsedJsonSchema = - convertor.parseToscaYaml(toscaModelYaml, "onap.policies.monitoring.example.app"); + convertor.parseToscaYaml(toscaModelYaml, "onap.policies.monitoring.example.app"); assertNotNull(parsedJsonSchema); JSONAssert.assertEquals( - ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json-with-datatypes.json"), - parsedJsonSchema, true); + ResourceFileUtil.getResourceAsString("tosca/policy-yaml-to-json-with-datatypes.json"), + parsedJsonSchema, true); } /** @@ -119,11 +119,35 @@ public class ToscaYamlToJsonConvertorTestItCase { * parameters which defines the Tosca Policy name and its short name. * * @throws IOException In case of issue when opening the tosca yaml file and - * converted json file + * converted json file */ @Test @Transactional public final void testMetadataClampPossibleValues() throws IOException { + setupDictionary(); + String toscaModelYaml = + ResourceFileUtil.getResourceAsString("tosca/tosca_metadata_clamp_possible_values.yaml"); + + JsonObject jsonObject = toscaYamlToJsonConvertor.validateAndConvertToJson(toscaModelYaml); + assertNotNull(jsonObject); + String policyModelType = toscaYamlToJsonConvertor.getValueFromMetadata(jsonObject, + ToscaSchemaConstants.METADATA_POLICY_MODEL_TYPE); + String acronym = toscaYamlToJsonConvertor.getValueFromMetadata(jsonObject, + ToscaSchemaConstants.METADATA_ACRONYM); + String parsedJsonSchema = + toscaYamlToJsonConvertor.parseToscaYaml(toscaModelYaml, policyModelType); + + assertNotNull(parsedJsonSchema); + assertEquals("onap.policies.monitoring.cdap.tca.hi.lo.app", policyModelType); + assertEquals("tca", acronym); + JSONAssert.assertEquals( + ResourceFileUtil + .getResourceAsString("tosca/tosca_metadata_clamp_possible_values_json_schema.json"), + parsedJsonSchema, true); + + } + + private void setupDictionary() { // Set up dictionary elements Dictionary dictionaryTest = new Dictionary(); @@ -150,6 +174,15 @@ public class ToscaYamlToJsonConvertorTestItCase { element1.setDescription("Alarm Condition"); dictionaryTest1.addDictionaryElements(element1); + dictionaryTest1 = dictionaryService.saveOrUpdateDictionary(dictionaryTest1); + + DictionaryElement element3 = new DictionaryElement(); + element3.setName("timeEpoch"); + element3.setShortName("timeEpoch"); + element3.setType("datetime"); + element3.setDescription("Time Epoch"); + dictionaryTest1.addDictionaryElements(element3); + dictionaryService.saveOrUpdateDictionary(dictionaryTest1); Dictionary dictionaryTest2 = new Dictionary(); @@ -159,30 +192,10 @@ public class ToscaYamlToJsonConvertorTestItCase { DictionaryElement element2 = new DictionaryElement(); element2.setName("equals"); element2.setShortName("equals"); - element2.setType("string"); + element2.setType("string|datetime"); element2.setDescription("equals"); dictionaryTest2.addDictionaryElements(element2); dictionaryService.saveOrUpdateDictionary(dictionaryTest2); - - String toscaModelYaml = - ResourceFileUtil.getResourceAsString("tosca/tosca_metadata_clamp_possible_values.yaml"); - - JsonObject jsonObject = toscaYamlToJsonConvertor.validateAndConvertToJson(toscaModelYaml); - assertNotNull(jsonObject); - String policyModelType = toscaYamlToJsonConvertor.getValueFromMetadata(jsonObject, - ToscaSchemaConstants.METADATA_POLICY_MODEL_TYPE); - String acronym = toscaYamlToJsonConvertor.getValueFromMetadata(jsonObject, - ToscaSchemaConstants.METADATA_ACRONYM); - String parsedJsonSchema = - toscaYamlToJsonConvertor.parseToscaYaml(toscaModelYaml, policyModelType); - - assertNotNull(parsedJsonSchema); - assertEquals("onap.policies.monitoring.cdap.tca.hi.lo.app", policyModelType); - assertEquals("tca", acronym); - JSONAssert.assertEquals( - ResourceFileUtil - .getResourceAsString("tosca/tosca_metadata_clamp_possible_values_json_schema.json"), - parsedJsonSchema, true); } } diff --git a/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java b/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java index 432de6065..6449a8966 100644 --- a/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java +++ b/src/test/java/org/onap/clamp/loop/PolicyComponentTest.java @@ -24,7 +24,6 @@ package org.onap.clamp.loop; import static org.assertj.core.api.Assertions.assertThat; - import com.google.gson.Gson; import com.google.gson.JsonObject; import java.io.IOException; @@ -32,6 +31,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Message; import org.junit.Test; import org.mockito.Mockito; +import org.onap.clamp.clds.config.LegacyOperationalPolicyController; import org.onap.clamp.clds.util.ResourceFileUtil; import org.onap.clamp.loop.components.external.ExternalComponentState; import org.onap.clamp.loop.components.external.PolicyComponent; @@ -267,7 +267,8 @@ public class PolicyComponentTest { new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), null, "pdpGroup2", "pdpSubgroup1"); loopTest.addMicroServicePolicy(microServicePolicy2); - PolicyModel policyModel2 = new PolicyModel("onap.policies.controlloop.Operational", null, "1.0.0"); + PolicyModel policyModel2 = new PolicyModel(LegacyOperationalPolicyController.OPERATIONAL_POLICY_LEGACY, null, + "1.0.0"); OperationalPolicy opPolicy = new OperationalPolicy("opPolicy", new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), new Gson().fromJson("{\"jsonschema\":\"schema\"}", JsonObject.class), policyModel2, null, @@ -275,16 +276,22 @@ public class PolicyComponentTest { "pdpSubgroup2"); loopTest.addOperationalPolicy(opPolicy); + OperationalPolicy opLegacyPolicy = + new OperationalPolicy("opLegacyPolicy", new Gson().fromJson( + "{\"guard_policies\":[{\"policy-id\":\"guard1\"}]}", JsonObject.class), + new Gson().fromJson("{\"jsonschema\":\"schema\"}", JsonObject.class), policyModel2, null, + "pdpGroup2", + "pdpSubgroup2"); + + loopTest.addOperationalPolicy(opLegacyPolicy); LoopTemplate loopTemplate = new LoopTemplate("test", "yaml", "svg", 1, null); loopTemplate.setDcaeBlueprintId("UUID-blueprint"); loopTest.setLoopTemplate(loopTemplate); - String payload = PolicyComponent.createPoliciesPayloadPdpGroup(loopTest); + String payload = PolicyComponent.createPoliciesPayloadPdpGroup(loopTest, "POST"); String expectedRes = ResourceFileUtil.getResourceAsString("tosca/pdp-group-policy-payload.json"); assertThat(payload).isEqualTo(expectedRes); - - assertThat(PolicyComponent.listPolicyNamesPdpGroup(loopTest)).containsExactlyInAnyOrder("opPolicy","configPolicyTest","configPolicyTest2"); } } diff --git a/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java b/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java index 4e9b56206..a6a496821 100644 --- a/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java +++ b/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java @@ -50,4 +50,17 @@ public class OperationalPolicyRepresentationBuilderTest { new GsonBuilder().create().toJson(jsonSchema), false); } + @Test + public void testOperationalPolicyPayloadConstructionForCds() throws IOException { + JsonObject jsonModel = new GsonBuilder().create() + .fromJson(ResourceFileUtil.getResourceAsString("tosca/model-properties-cds.json"), JsonObject.class); + Service service = new Service(jsonModel.get("serviceDetails").getAsJsonObject(), + jsonModel.get("resourceDetails").getAsJsonObject(), + "1.0"); + + JsonObject jsonSchema = OperationalPolicyRepresentationBuilder.generateOperationalPolicySchema(service); + assertThat(jsonSchema).isNotNull(); + JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/operational-policy-cds-payload-with-list.json"), + new GsonBuilder().create().toJson(jsonSchema), false); + } } diff --git a/src/test/resources/example/cds-response/vFW-CDS-modify-config-wf-expected-result.json b/src/test/resources/example/cds-response/vFW-CDS-modify-config-wf-expected-result.json new file mode 100644 index 000000000..7e78bb062 --- /dev/null +++ b/src/test/resources/example/cds-response/vFW-CDS-modify-config-wf-expected-result.json @@ -0,0 +1,58 @@ +{ + "inputs": { + "resolution-key": { + "required": true, + "type": "string" + }, + "modify-config-properties": { + "vpg_onap_private_ip_0": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } + }, + "service-instance.service-instance-id": { + "type": "string" + }, + "vnf-id": { + "type": "string" + }, + "data": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "dt-data" + } + }, + "service-instance-id": { + "type": "string" + }, + "update-active-streams": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "dt-data" + } + }, + "generic-vnf.vnf-id": { + "type": "string" + } + } + } +}
\ No newline at end of file diff --git a/src/test/resources/example/cds-response/vFW-CDS-modify-config-workflow.json b/src/test/resources/example/cds-response/vFW-CDS-modify-config-workflow.json new file mode 100644 index 000000000..e46da6760 --- /dev/null +++ b/src/test/resources/example/cds-response/vFW-CDS-modify-config-workflow.json @@ -0,0 +1,75 @@ +{ + "blueprintName": "vFW-CDS", + "version": "1.0.0", + "workFlowData": { + "workFlowName": "modify-config", + "inputs": { + "resolution-key": { + "required": true, + "type": "string" + }, + "modify-config-properties": { + "description": "Dynamic PropertyDefinition for workflow(modify-config).", + "required": true, + "type": "dt-modify-config-properties" + } + } + }, + "dataTypes": { + "dt-modify-config-properties": { + "description": "Dynamic DataType definition for workflow(modify-config).", + "version": "1.0.0", + "properties": { + "vpg_onap_private_ip_0": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } + }, + "service-instance.service-instance-id": { + "type": "string" + }, + "vnf-id": { + "type": "string" + }, + "data": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "dt-data" + } + }, + "service-instance-id": { + "type": "string" + }, + "update-active-streams": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "dt-data" + } + }, + "generic-vnf.vnf-id": { + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Dynamic" + } + } +}
\ No newline at end of file diff --git a/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-wf-expected-result.json b/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-wf-expected-result.json new file mode 100644 index 000000000..5b373a45e --- /dev/null +++ b/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-wf-expected-result.json @@ -0,0 +1,42 @@ +{ + "inputs": { + "template-prefix": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "template-prefix-with-complex-type": { + "type": "list", + "properties": { + "prefix-id": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } + } + } + }, + "resource-assignment-properties": { + "private1-prefix-id": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } + } + } + } +}
\ No newline at end of file diff --git a/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-workflow.json b/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-workflow.json new file mode 100644 index 000000000..d0f78cf1d --- /dev/null +++ b/src/test/resources/example/cds-response/vFW-CDS-resource-assignment-workflow.json @@ -0,0 +1,78 @@ +{ + "blueprintName": "vFW-CDS", + "version": "1.0.0", + "workFlowData": { + "workFlowName": "resource-assignment", + "inputs": { + "template-prefix": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "template-prefix-with-complex-type": { + "required": true, + "type": "list", + "entry_schema": { + "type": "dt-template-prefix-properties" + } + }, + "resource-assignment-properties": { + "description": "Dynamic PropertyDefinition for workflow(resource-assignment).", + "required": true, + "type": "dt-resource-assignment-properties" + } + }, + "outputs": { + "meshed-template": { + "type": "json", + "value": { + "get_attribute": [ + "resource-assignment", + "assignment-params" + ] + } + } + } + }, + "dataTypes": { + "dt-resource-assignment-properties": { + "description": "Dynamic DataType definition for workflow(resource-assignment).", + "version": "1.0.0", + "properties": { + "private1-prefix-id": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } + } + }, + "derived_from": "tosca.datatypes.Dynamic" + }, + "dt-template-prefix-properties": { + "description": "Dynamic DataType definition for workflow(template-prefix).", + "version": "1.0.0", + "properties": { + "prefix-id": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } + } + } + } + } +}
\ No newline at end of file diff --git a/src/test/resources/example/json-editor-schema/tca-policy-json-editor-schema.json b/src/test/resources/example/json-editor-schema/tca-policy-json-editor-schema.json index 11b91dfb4..91603972d 100644 --- a/src/test/resources/example/json-editor-schema/tca-policy-json-editor-schema.json +++ b/src/test/resources/example/json-editor-schema/tca-policy-json-editor-schema.json @@ -1,7 +1,7 @@ { "schema": { "uniqueItems": "true", - "format": "tabs-top", + "format": "tabs", "type": "array", "title": "Thresholds", "items": { diff --git a/src/test/resources/tosca/model-properties-cds.json b/src/test/resources/tosca/model-properties-cds.json new file mode 100644 index 000000000..591840b49 --- /dev/null +++ b/src/test/resources/tosca/model-properties-cds.json @@ -0,0 +1,151 @@ +{ + "serviceDetails": { + "serviceType": "", + "namingPolicy": "", + "environmentContext": "General_Revenue-Bearing", + "serviceEcompNaming": "true", + "serviceRole": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "30ec5b59-4799-48d8-ac5f-1058a6b0e48f", + "ecompGeneratedNaming": "true", + "category": "Network L4+", + "type": "Service", + "UUID": "63cac700-ab9a-4115-a74f-7eac85e3fce0", + "instantiationType": "A-la-carte" + }, + "resourceDetails": { + "CP": {}, + "VL": {}, + "VF": { + "vLoadBalancerMS 0": { + "resourceVendor": "Test", + "resourceVendorModelNumber": "", + "name": "vLoadBalancerMS", + "description": "vLBMS", + "invariantUUID": "1a31b9f2-e50d-43b7-89b3-a040250cf506", + "subcategory": "Load Balancer", + "category": "Application L4+", + "type": "VF", + "UUID": "b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6", + "version": "1.0", + "resourceVendorRelease": "1.0", + "customizationUUID": "465246dc-7748-45f4-a013-308d92922552", + "controllerProperties": { + "sdnc_model_name": "baseconfiguration", + "sdnc_model_version": "1.0.0", + "workflows": { + "resource-assignment": { + "inputs": { + "template-prefix": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "template-prefix-with-complex-type": { + "type": "list", + "properties": { + "prefix-id": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } + } + } + }, + "resource-assignment-properties": { + "private1-prefix-id": { + "description": "", + "required": false, + "type": "string", + "status": "", + "constraints": [ + {} + ], + "entry_schema": { + "type": "" + } + } + } + } + } + } + } + } + }, + "CR": {}, + "VFC": {}, + "PNF": {}, + "Service": {}, + "CVFC": {}, + "Service Proxy": {}, + "Configuration": {}, + "AllottedResource": {}, + "VFModule": { + "Vloadbalancerms..vpkg..module-1": { + "vfModuleModelInvariantUUID": "ca052563-eb92-4b5b-ad41-9111768ce043", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vpkg..module-1", + "vfModuleModelUUID": "1e725ccc-b823-4f67-82b9-4f4367070dbc", + "vfModuleModelCustomizationUUID": "1bffdc31-a37d-4dee-b65c-dde623a76e52", + "min_vf_module_instances": 0, + "vf_module_label": "vpkg", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..vdns..module-3": { + "vfModuleModelInvariantUUID": "4c10ba9b-f88f-415e-9de3-5d33336047fa", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vdns..module-3", + "vfModuleModelUUID": "4fa73b49-8a6c-493e-816b-eb401567b720", + "vfModuleModelCustomizationUUID": "bafcdab0-801d-4d81-9ead-f464640a38b1", + "min_vf_module_instances": 0, + "vf_module_label": "vdns", + "max_vf_module_instances": 50, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + }, + "Vloadbalancerms..base_template..module-0": { + "vfModuleModelInvariantUUID": "921f7c96-ebdd-42e6-81b9-1cfc0c9796f3", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..base_template..module-0", + "vfModuleModelUUID": "63734409-f745-4e4d-a38b-131638a0edce", + "vfModuleModelCustomizationUUID": "86baddea-c730-4fb8-9410-cd2e17fd7f27", + "min_vf_module_instances": 1, + "vf_module_label": "base_template", + "max_vf_module_instances": 1, + "vf_module_type": "Base", + "isBase": true, + "initial_count": 1, + "volume_group": false + }, + "Vloadbalancerms..vlb..module-2": { + "vfModuleModelInvariantUUID": "a772a1f4-0064-412c-833d-4749b15828dd", + "vfModuleModelVersion": "1", + "vfModuleModelName": "Vloadbalancerms..vlb..module-2", + "vfModuleModelUUID": "0f5c3f6a-650a-4303-abb6-fff3e573a07a", + "vfModuleModelCustomizationUUID": "96a78aad-4ffb-4ef0-9c4f-deb03bf1d806", + "min_vf_module_instances": 0, + "vf_module_label": "vlb", + "max_vf_module_instances": 1, + "vf_module_type": "Expansion", + "isBase": false, + "initial_count": 0, + "volume_group": false + } + } + } +}
\ No newline at end of file diff --git a/src/test/resources/tosca/model-properties.json b/src/test/resources/tosca/model-properties.json index c405964ee..688a09ab4 100644 --- a/src/test/resources/tosca/model-properties.json +++ b/src/test/resources/tosca/model-properties.json @@ -40,78 +40,204 @@ "resource-assignment": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "activate": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "activate-restconf": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "activate-cli": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "assign-activate": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "imperative-test-wf": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } } 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 index 58dff236e..793ba5e7f 100644 --- a/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json +++ b/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json @@ -66,16 +66,20 @@ "description": "Name/value pairs of payload information passed by Policy to the actor", "anyOf": [ { + "title": "User defined", + "properties": {} + }, + { "title": "resource-assignment", "properties": { "artifact_name": { - "title": "artifact_name", + "title": "artifact name", "type": "string", "default": "baseconfiguration", "readOnly": "True" }, "artifact_version": { - "title": "artifact_version", + "title": "artifact version", "type": "string", "default": "1.0.0", "readOnly": "True" @@ -83,21 +87,44 @@ "mode": { "title": "mode", "type": "string", - "default": "async", - "readOnly": "True" + "default": "async" }, "data": { "title": "data", - "type": "object", "properties": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string" + }, + "action-name": { + "title": "action-name", + "type": "string" + }, + "scope-type": { + "title": "scope-type", + "type": "string" + }, + "hostname": { + "title": "hostname", + "type": "string" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string" + } + } } } } @@ -107,13 +134,13 @@ "title": "activate", "properties": { "artifact_name": { - "title": "artifact_name", + "title": "artifact name", "type": "string", "default": "baseconfiguration", "readOnly": "True" }, "artifact_version": { - "title": "artifact_version", + "title": "artifact version", "type": "string", "default": "1.0.0", "readOnly": "True" @@ -121,21 +148,44 @@ "mode": { "title": "mode", "type": "string", - "default": "async", - "readOnly": "True" + "default": "async" }, "data": { "title": "data", - "type": "object", "properties": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string" + }, + "action-name": { + "title": "action-name", + "type": "string" + }, + "scope-type": { + "title": "scope-type", + "type": "string" + }, + "hostname": { + "title": "hostname", + "type": "string" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string" + } + } } } } @@ -145,13 +195,13 @@ "title": "activate-restconf", "properties": { "artifact_name": { - "title": "artifact_name", + "title": "artifact name", "type": "string", "default": "baseconfiguration", "readOnly": "True" }, "artifact_version": { - "title": "artifact_version", + "title": "artifact version", "type": "string", "default": "1.0.0", "readOnly": "True" @@ -159,21 +209,44 @@ "mode": { "title": "mode", "type": "string", - "default": "async", - "readOnly": "True" + "default": "async" }, "data": { "title": "data", - "type": "object", "properties": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string" + }, + "action-name": { + "title": "action-name", + "type": "string" + }, + "scope-type": { + "title": "scope-type", + "type": "string" + }, + "hostname": { + "title": "hostname", + "type": "string" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string" + } + } } } } @@ -183,13 +256,13 @@ "title": "activate-cli", "properties": { "artifact_name": { - "title": "artifact_name", + "title": "artifact name", "type": "string", "default": "baseconfiguration", "readOnly": "True" }, "artifact_version": { - "title": "artifact_version", + "title": "artifact version", "type": "string", "default": "1.0.0", "readOnly": "True" @@ -197,21 +270,44 @@ "mode": { "title": "mode", "type": "string", - "default": "async", - "readOnly": "True" + "default": "async" }, "data": { "title": "data", - "type": "object", "properties": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string" + }, + "action-name": { + "title": "action-name", + "type": "string" + }, + "scope-type": { + "title": "scope-type", + "type": "string" + }, + "hostname": { + "title": "hostname", + "type": "string" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string" + } + } } } } @@ -221,13 +317,13 @@ "title": "assign-activate", "properties": { "artifact_name": { - "title": "artifact_name", + "title": "artifact name", "type": "string", "default": "baseconfiguration", "readOnly": "True" }, "artifact_version": { - "title": "artifact_version", + "title": "artifact version", "type": "string", "default": "1.0.0", "readOnly": "True" @@ -235,21 +331,44 @@ "mode": { "title": "mode", "type": "string", - "default": "async", - "readOnly": "True" + "default": "async" }, "data": { "title": "data", - "type": "object", "properties": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string" + }, + "action-name": { + "title": "action-name", + "type": "string" + }, + "scope-type": { + "title": "scope-type", + "type": "string" + }, + "hostname": { + "title": "hostname", + "type": "string" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string" + } + } } } } @@ -259,13 +378,13 @@ "title": "imperative-test-wf", "properties": { "artifact_name": { - "title": "artifact_name", + "title": "artifact name", "type": "string", "default": "baseconfiguration", "readOnly": "True" }, "artifact_version": { - "title": "artifact_version", + "title": "artifact version", "type": "string", "default": "1.0.0", "readOnly": "True" @@ -273,29 +392,48 @@ "mode": { "title": "mode", "type": "string", - "default": "async", - "readOnly": "True" + "default": "async" }, "data": { "title": "data", - "type": "object", "properties": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string" + }, + "action-name": { + "title": "action-name", + "type": "string" + }, + "scope-type": { + "title": "scope-type", + "type": "string" + }, + "hostname": { + "title": "hostname", + "type": "string" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string" + } + } } } } } - }, - { - "title": "User defined", - "properties": {} } ] }, diff --git a/src/test/resources/tosca/operational-policy-cds-payload-with-list.json b/src/test/resources/tosca/operational-policy-cds-payload-with-list.json new file mode 100644 index 000000000..24269ec79 --- /dev/null +++ b/src/test/resources/tosca/operational-policy-cds-payload-with-list.json @@ -0,0 +1,742 @@ +{ + "type": "object", + "title": "Configuration", + "required": [ + "operational_policy", + "guard_policies" + ], + "properties": { + "operational_policy": { + "type": "object", + "title": "Related Parameters", + "required": [ + "controlLoop", + "policies" + ], + "properties": { + "controlLoop": { + "type": "object", + "title": "Control Loop details", + "required": [ + "timeout", + "abatement", + "trigger_policy", + "controlLoopName" + ], + "properties": { + "timeout": { + "type": "string", + "title": "Overall Time Limit", + "default": "0", + "format": "number" + }, + "abatement": { + "type": "string", + "title": "Abatement", + "enum": [ + "True", + "False" + ] + }, + "trigger_policy": { + "type": "string", + "title": "Policy Decision Entry" + }, + "controlLoopName": { + "type": "string", + "title": "Control loop name", + "readOnly": "True" + } + } + }, + "policies": { + "uniqueItems": "true", + "id": "policies_array", + "type": "array", + "title": "Policy Decision Tree", + "format": "tabs-top", + "items": { + "title": "Policy Decision", + "type": "object", + "id": "policy_item", + "headerTemplate": "{{self.id}} - {{self.recipe}}", + "format": "categories", + "basicCategoryTitle": "recipe", + "required": [ + "id", + "retry", + "timeout", + "actor", + "success", + "failure", + "failure_timeout", + "failure_retries", + "failure_exception", + "failure_guard", + "target" + ], + "properties": { + "id": { + "default": "Policy 1", + "title": "Policy ID", + "type": "string" + }, + "retry": { + "default": "0", + "title": "Number of Retry", + "type": "string", + "format": "number" + }, + "timeout": { + "default": "0", + "title": "Timeout", + "type": "string", + "format": "number" + }, + "actor": { + "type": "object", + "title": "Actor", + "anyOf": [ + { + "title": "APPC", + "type": "object", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "APPC", + "options": { + "hidden": true + } + }, + "recipe": { + "title": "recipe", + "type": "string", + "default": "", + "enum": [ + "Restart", + "Rebuild", + "Migrate", + "Health-Check", + "ModifyConfig" + ] + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + } + } + }, + { + "title": "SO", + "type": "object", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "SO", + "options": { + "hidden": true + } + }, + "recipe": { + "title": "recipe", + "type": "string", + "default": "", + "enum": [ + "VF Module Create", + "VF Module Delete" + ] + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + } + } + }, + { + "title": "SDNC", + "type": "object", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "SDNC", + "options": { + "hidden": true + } + }, + "recipe": { + "title": "recipe", + "type": "string", + "default": "", + "enum": [ + "Reroute", + "BandwidthOnDemand" + ] + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + } + } + }, + { + "title": "VFC", + "type": "object", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "VFC", + "options": { + "hidden": true + } + }, + "recipe": { + "title": "recipe", + "type": "string", + "default": "", + "enum": [ + "ModifyConfig" + ] + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "format": "textarea" + } + } + }, + { + "title": "CDS", + "type": "object", + "properties": { + "actor": { + "title": "actor", + "type": "string", + "default": "CDS", + "options": { + "hidden": true + } + }, + "recipe": { + "title": "recipe", + "type": "object", + "anyOf": [ + { + "title": "user-defined", + "type": "object", + "properties": { + "recipe": { + "title": "recipe", + "type": "string", + "default": "user-defined", + "format": "textarea" + }, + "payload": { + "title": "Payload (YAML)", + "type": "string", + "default": "", + "format": "textarea" + } + } + }, + { + "title": "resource-assignment", + "type": "object", + "properties": { + "recipe": { + "title": "recipe", + "type": "string", + "default": "resource-assignment", + "options": { + "hidden": true + } + }, + "payload": { + "title": "Payload (YAML)", + "type": "object", + "properties": { + "artifact_name": { + "title": "artifact name", + "type": "string", + "default": "baseconfiguration", + "readOnly": "True" + }, + "artifact_version": { + "title": "artifact version", + "type": "string", + "default": "1.0.0", + "readOnly": "True" + }, + "mode": { + "title": "mode", + "type": "string", + "default": "async" + }, + "data": { + "title": "data", + "properties": { + "template-prefix": { + "title": "template-prefix", + "type": "array" + }, + "template-prefix-with-complex-type": { + "title": "template-prefix-with-complex-type", + "type": "array", + "items": { + "properties": { + "prefix-id": { + "title": "prefix-id", + "type": "string" + } + } + } + }, + "resource-assignment-properties": { + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "private1-prefix-id": { + "title": "private1-prefix-id", + "type": "string" + } + } + } + } + } + } + } + } + } + ] + } + } + } + ] + }, + "success": { + "default": "final_success", + "title": "When Success", + "type": "string" + }, + "failure": { + "default": "final_failure", + "title": "When Failure", + "type": "string" + }, + "failure_timeout": { + "default": "final_failure_timeout", + "title": "When Failure Timeout", + "type": "string" + }, + "failure_retries": { + "default": "final_failure_retries", + "title": "When Failure Retries", + "type": "string" + }, + "failure_exception": { + "default": "final_failure_exception", + "title": "When Failure Exception", + "type": "string" + }, + "failure_guard": { + "default": "final_failure_guard", + "title": "When Failure Guard", + "type": "string" + }, + "target": { + "type": "object", + "required": [ + "type", + "resourceID" + ], + "anyOf": [ + { + "title": "User Defined", + "additionalProperties": "True", + "properties": { + "type": { + "title": "Target type", + "type": "string", + "default": "", + "enum": [ + "VNF", + "VFMODULE", + "VM" + ] + }, + "resourceID": { + "title": "Target type", + "type": "string", + "default": "" + } + } + }, + { + "title": "VNF-vLoadBalancerMS 0", + "properties": { + "type": { + "title": "Type", + "type": "string", + "default": "VNF", + "readOnly": "True" + }, + "resourceID": { + "title": "Resource ID", + "type": "string", + "default": "vLoadBalancerMS", + "readOnly": "True" + } + } + }, + { + "title": "VFMODULE-Vloadbalancerms..vpkg..module-1", + "properties": { + "type": { + "title": "Type", + "type": "string", + "default": "VFMODULE", + "readOnly": "True" + }, + "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": { + "type": { + "title": "Type", + "type": "string", + "default": "VFMODULE", + "readOnly": "True" + }, + "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": { + "type": { + "title": "Type", + "type": "string", + "default": "VFMODULE", + "readOnly": "True" + }, + "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": { + "type": { + "title": "Type", + "type": "string", + "default": "VFMODULE", + "readOnly": "True" + }, + "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" + } + } + } + ] + } + } + } + } + } + }, + "guard_policies": { + "type": "array", + "format": "tabs-top", + "title": "Associated Guard policies", + "items": { + "headerTemplate": "{{self.policy-id}} - {{self.content.recipe}}", + "anyOf": [ + { + "title": "Guard MinMax", + "type": "object", + "properties": { + "policy-id": { + "type": "string", + "default": "guard.minmax.new", + "pattern": "^(guard.minmax\\..*)$" + }, + "content": { + "properties": { + "actor": { + "type": "string", + "enum": [ + "APPC", + "SO", + "VFC", + "SDNC", + "SDNR" + ] + }, + "recipe": { + "type": "string", + "enum": [ + "Restart", + "Rebuild", + "Migrate", + "Health-Check", + "ModifyConfig", + "VF Module Create", + "VF Module Delete", + "Reroute" + ] + }, + "targets": { + "type": "string", + "default": ".*" + }, + "clname": { + "type": "string", + "template": "{{loopName}}", + "watch": { + "loopName": "operational_policy.controlLoop.controlLoopName" + } + }, + "guardActiveStart": { + "type": "string", + "default": "00:00:00Z" + }, + "guardActiveEnd": { + "type": "string", + "default": "10:00:00Z" + }, + "min": { + "type": "string", + "default": "0" + }, + "max": { + "type": "string", + "default": "1" + } + } + } + } + }, + { + "title": "Guard Frequency", + "type": "object", + "properties": { + "policy-id": { + "type": "string", + "default": "guard.frequency.new", + "pattern": "^(guard.frequency\\..*)$" + }, + "content": { + "properties": { + "actor": { + "type": "string", + "enum": [ + "APPC", + "SO", + "VFC", + "SDNC", + "SDNR" + ] + }, + "recipe": { + "type": "string", + "enum": [ + "Restart", + "Rebuild", + "Migrate", + "Health-Check", + "ModifyConfig", + "VF Module Create", + "VF Module Delete", + "Reroute" + ] + }, + "targets": { + "type": "string", + "default": ".*" + }, + "clname": { + "type": "string", + "template": "{{loopName}}", + "watch": { + "loopName": "operational_policy.controlLoop.controlLoopName" + } + }, + "guardActiveStart": { + "type": "string", + "default": "00:00:00Z" + }, + "guardActiveEnd": { + "type": "string", + "default": "10:00:00Z" + }, + "limit": { + "type": "string" + }, + "timeWindow": { + "type": "string" + }, + "timeUnits": { + "type": "string", + "enum": [ + "minute", + "hour", + "day", + "week", + "month", + "year" + ] + } + } + } + } + } + ] + } + } + } +}
\ No newline at end of file diff --git a/src/test/resources/tosca/operational-policy-json-schema.json b/src/test/resources/tosca/operational-policy-json-schema.json index 6ab84a8cf..87457f1d2 100644 --- a/src/test/resources/tosca/operational-policy-json-schema.json +++ b/src/test/resources/tosca/operational-policy-json-schema.json @@ -99,6 +99,7 @@ "anyOf": [ { "title": "APPC", + "type": "object", "properties": { "actor": { "title": "actor", @@ -108,7 +109,7 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", "default": "", @@ -129,6 +130,7 @@ }, { "title": "SO", + "type": "object", "properties": { "actor": { "title": "actor", @@ -138,7 +140,7 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", "default": "", @@ -156,6 +158,7 @@ }, { "title": "SDNC", + "type": "object", "properties": { "actor": { "title": "actor", @@ -165,7 +168,7 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", "default": "", @@ -183,6 +186,7 @@ }, { "title": "VFC", + "type": "object", "properties": { "actor": { "title": "actor", @@ -192,12 +196,9 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "string", - "required": [ - "payload" - ], "default": "", "enum": [ "ModifyConfig" @@ -212,6 +213,7 @@ }, { "title": "CDS", + "type": "object", "properties": { "actor": { "title": "actor", @@ -221,17 +223,21 @@ "hidden": true } }, - "type": { + "recipe": { "title": "recipe", "type": "object", - "required": [ - "payload" - ], "anyOf": [ { "title": "user-defined", + "type": "object", "properties": { - "type": { + "recipe": { + "title": "recipe", + "type": "string", + "default": "user-defined", + "format": "textarea" + }, + "payload": { "title": "Payload (YAML)", "type": "string", "default": "", @@ -241,67 +247,457 @@ }, { "title": "resource-assignment", + "type": "object", "properties": { - "type": { - "title": "Payload (YAML)", + "recipe": { + "title": "recipe", "type": "string", - "default": "\u0027artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : \u0027\\\u0027{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\\u0027\u0027", - "format": "textarea" + "default": "resource-assignment", + "options": { + "hidden": true + } + }, + "payload": { + "title": "Payload (YAML)", + "type": "object", + "properties": { + "artifact_name": { + "title": "artifact name", + "type": "string", + "default": "baseconfiguration", + "readOnly": "True" + }, + "artifact_version": { + "title": "artifact version", + "type": "string", + "default": "1.0.0", + "readOnly": "True" + }, + "mode": { + "title": "mode", + "type": "string", + "default": "async" + }, + "data": { + "title": "data", + "properties": { + "resource-assignment-properties": { + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string" + }, + "action-name": { + "title": "action-name", + "type": "string" + }, + "scope-type": { + "title": "scope-type", + "type": "string" + }, + "hostname": { + "title": "hostname", + "type": "string" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string" + } + } + } + } + } + } } } }, { "title": "activate", + "type": "object", "properties": { - "type": { - "title": "Payload (YAML)", + "recipe": { + "title": "recipe", "type": "string", - "default": "\u0027artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : \u0027\\\u0027{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\\u0027\u0027", - "format": "textarea" + "default": "activate", + "options": { + "hidden": true + } + }, + "payload": { + "title": "Payload (YAML)", + "type": "object", + "properties": { + "artifact_name": { + "title": "artifact name", + "type": "string", + "default": "baseconfiguration", + "readOnly": "True" + }, + "artifact_version": { + "title": "artifact version", + "type": "string", + "default": "1.0.0", + "readOnly": "True" + }, + "mode": { + "title": "mode", + "type": "string", + "default": "async" + }, + "data": { + "title": "data", + "properties": { + "resource-assignment-properties": { + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string" + }, + "action-name": { + "title": "action-name", + "type": "string" + }, + "scope-type": { + "title": "scope-type", + "type": "string" + }, + "hostname": { + "title": "hostname", + "type": "string" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string" + } + } + } + } + } + } } } }, { "title": "activate-restconf", + "type": "object", "properties": { - "type": { - "title": "Payload (YAML)", + "recipe": { + "title": "recipe", "type": "string", - "default": "\u0027artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : \u0027\\\u0027{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\\u0027\u0027", - "format": "textarea" + "default": "activate-restconf", + "options": { + "hidden": true + } + }, + "payload": { + "title": "Payload (YAML)", + "type": "object", + "properties": { + "artifact_name": { + "title": "artifact name", + "type": "string", + "default": "baseconfiguration", + "readOnly": "True" + }, + "artifact_version": { + "title": "artifact version", + "type": "string", + "default": "1.0.0", + "readOnly": "True" + }, + "mode": { + "title": "mode", + "type": "string", + "default": "async" + }, + "data": { + "title": "data", + "properties": { + "resource-assignment-properties": { + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string" + }, + "action-name": { + "title": "action-name", + "type": "string" + }, + "scope-type": { + "title": "scope-type", + "type": "string" + }, + "hostname": { + "title": "hostname", + "type": "string" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string" + } + } + } + } + } + } } } }, { "title": "activate-cli", + "type": "object", "properties": { - "type": { - "title": "Payload (YAML)", + "recipe": { + "title": "recipe", "type": "string", - "default": "\u0027artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : \u0027\\\u0027{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\\u0027\u0027", - "format": "textarea" + "default": "activate-cli", + "options": { + "hidden": true + } + }, + "payload": { + "title": "Payload (YAML)", + "type": "object", + "properties": { + "artifact_name": { + "title": "artifact name", + "type": "string", + "default": "baseconfiguration", + "readOnly": "True" + }, + "artifact_version": { + "title": "artifact version", + "type": "string", + "default": "1.0.0", + "readOnly": "True" + }, + "mode": { + "title": "mode", + "type": "string", + "default": "async" + }, + "data": { + "title": "data", + "properties": { + "resource-assignment-properties": { + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string" + }, + "action-name": { + "title": "action-name", + "type": "string" + }, + "scope-type": { + "title": "scope-type", + "type": "string" + }, + "hostname": { + "title": "hostname", + "type": "string" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string" + } + } + } + } + } + } } } }, { "title": "assign-activate", + "type": "object", "properties": { - "type": { - "title": "Payload (YAML)", + "recipe": { + "title": "recipe", "type": "string", - "default": "\u0027artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : \u0027\\\u0027{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\\u0027\u0027", - "format": "textarea" + "default": "assign-activate", + "options": { + "hidden": true + } + }, + "payload": { + "title": "Payload (YAML)", + "type": "object", + "properties": { + "artifact_name": { + "title": "artifact name", + "type": "string", + "default": "baseconfiguration", + "readOnly": "True" + }, + "artifact_version": { + "title": "artifact version", + "type": "string", + "default": "1.0.0", + "readOnly": "True" + }, + "mode": { + "title": "mode", + "type": "string", + "default": "async" + }, + "data": { + "title": "data", + "properties": { + "resource-assignment-properties": { + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string" + }, + "action-name": { + "title": "action-name", + "type": "string" + }, + "scope-type": { + "title": "scope-type", + "type": "string" + }, + "hostname": { + "title": "hostname", + "type": "string" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string" + } + } + } + } + } + } } } }, { "title": "imperative-test-wf", + "type": "object", "properties": { - "type": { - "title": "Payload (YAML)", + "recipe": { + "title": "recipe", "type": "string", - "default": "\u0027artifact_name : \"baseconfiguration\"\nartifact_version : \"1.0.0\"\nmode : async\ndata : \u0027\\\u0027{\"resource-assignment-properties\":{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}}\\\u0027\u0027", - "format": "textarea" + "default": "imperative-test-wf", + "options": { + "hidden": true + } + }, + "payload": { + "title": "Payload (YAML)", + "type": "object", + "properties": { + "artifact_name": { + "title": "artifact name", + "type": "string", + "default": "baseconfiguration", + "readOnly": "True" + }, + "artifact_version": { + "title": "artifact version", + "type": "string", + "default": "1.0.0", + "readOnly": "True" + }, + "mode": { + "title": "mode", + "type": "string", + "default": "async" + }, + "data": { + "title": "data", + "properties": { + "resource-assignment-properties": { + "title": "resource-assignment-properties", + "type": "object", + "properties": { + "request-id": { + "title": "request-id", + "type": "string" + }, + "service-instance-id": { + "title": "service-instance-id", + "type": "string" + }, + "vnf-id": { + "title": "vnf-id", + "type": "string" + }, + "action-name": { + "title": "action-name", + "type": "string" + }, + "scope-type": { + "title": "scope-type", + "type": "string" + }, + "hostname": { + "title": "hostname", + "type": "string" + }, + "vnf_name": { + "title": "vnf_name", + "type": "string" + } + } + } + } + } + } } } } @@ -731,4 +1127,4 @@ } } } -}
\ No newline at end of file +} diff --git a/src/test/resources/tosca/operational-policy-payload-legacy.yaml b/src/test/resources/tosca/operational-policy-payload-legacy.yaml index f4708ebc3..72bbf9bad 100644 --- a/src/test/resources/tosca/operational-policy-payload-legacy.yaml +++ b/src/test/resources/tosca/operational-policy-payload-legacy.yaml @@ -40,3 +40,35 @@ policies: resourceID: Vloadbalancerms..vpkg..module-1 type: VFMODULE timeout: 0 +- actor: CDS + failure: final_failure + failure_exception: final_failure_exception + failure_guard: final_failure_guard + failure_retries: final_failure_retries + failure_timeout: final_failure_timeout + id: policy3 + payload: + artifact_name: baseconfiguration + artifact_version: 1.0.0 + data: + resource-assignment-properties: + action-name: action-name + hostname: hostname + request-id: request-id + scope-type: scope-type + service-instance-id: service-instance-id + vnf-id: vnf-id + vnf_name: vnf_name + mode: async + recipe: resource-assignment + retry: 0 + success: final_success + target: + modelCustomizationId: 1bffdc31-a37d-4dee-b65c-dde623a76e52 + modelInvariantId: ca052563-eb92-4b5b-ad41-9111768ce043 + modelName: Vloadbalancerms..vpkg..module-1 + modelVersion: 1 + modelVersionId: 1e725ccc-b823-4f67-82b9-4f4367070dbc + resourceID: Vloadbalancerms..vpkg..module-1 + type: VFMODULE + timeout: 0 diff --git a/src/test/resources/tosca/operational-policy-payload.json b/src/test/resources/tosca/operational-policy-payload.json index 033eecd17..e53950af3 100644 --- a/src/test/resources/tosca/operational-policy-payload.json +++ b/src/test/resources/tosca/operational-policy-payload.json @@ -1,4 +1,4 @@ { "policy-id": "testPolicy.legacy", - "content": "controlLoop%3A%0A++abatement%3A+true%0A++controlLoopName%3A+LOOP_ASJOy_v1_0_ResourceInstanceName1_tca%0A++timeout%3A+0%0A++trigger_policy%3A+policy1%0Apolicies%3A%0A-+actor%3A+APPC%0A++failure%3A+policy2%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy1%0A++payload%3A%0A++++configurationParameters%3A+%27%5B%7B%22ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B10%5D.value%22%2C%22oam-ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B15%5D.value%22%2C%22enabled%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B22%5D.value%22%7D%5D%27%0A++++requestParameters%3A+%27%7B%22usePreload%22%3Atrue%2C%22userParams%22%3A%5B%5D%7D%27%0A++recipe%3A+Restart%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++resourceID%3A+vLoadBalancerMS%0A++++type%3A+VNF%0A++timeout%3A+0%0A-+actor%3A+SO%0A++failure%3A+final_failure%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy2%0A++recipe%3A+VF+Module+Create%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++modelCustomizationId%3A+1bffdc31-a37d-4dee-b65c-dde623a76e52%0A++++modelInvariantId%3A+ca052563-eb92-4b5b-ad41-9111768ce043%0A++++modelName%3A+Vloadbalancerms..vpkg..module-1%0A++++modelVersion%3A+1%0A++++modelVersionId%3A+1e725ccc-b823-4f67-82b9-4f4367070dbc%0A++++resourceID%3A+Vloadbalancerms..vpkg..module-1%0A++++type%3A+VFMODULE%0A++timeout%3A+0%0A" + "content": "controlLoop%3A%0A++abatement%3A+true%0A++controlLoopName%3A+LOOP_ASJOy_v1_0_ResourceInstanceName1_tca%0A++timeout%3A+0%0A++trigger_policy%3A+policy1%0Apolicies%3A%0A-+actor%3A+APPC%0A++failure%3A+policy2%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy1%0A++payload%3A%0A++++configurationParameters%3A+%27%5B%7B%22ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B10%5D.value%22%2C%22oam-ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B15%5D.value%22%2C%22enabled%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B22%5D.value%22%7D%5D%27%0A++++requestParameters%3A+%27%7B%22usePreload%22%3Atrue%2C%22userParams%22%3A%5B%5D%7D%27%0A++recipe%3A+Restart%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++resourceID%3A+vLoadBalancerMS%0A++++type%3A+VNF%0A++timeout%3A+0%0A-+actor%3A+SO%0A++failure%3A+final_failure%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy2%0A++recipe%3A+VF+Module+Create%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++modelCustomizationId%3A+1bffdc31-a37d-4dee-b65c-dde623a76e52%0A++++modelInvariantId%3A+ca052563-eb92-4b5b-ad41-9111768ce043%0A++++modelName%3A+Vloadbalancerms..vpkg..module-1%0A++++modelVersion%3A+1%0A++++modelVersionId%3A+1e725ccc-b823-4f67-82b9-4f4367070dbc%0A++++resourceID%3A+Vloadbalancerms..vpkg..module-1%0A++++type%3A+VFMODULE%0A++timeout%3A+0%0A-+actor%3A+CDS%0A++failure%3A+final_failure%0A++failure_exception%3A+final_failure_exception%0A++failure_guard%3A+final_failure_guard%0A++failure_retries%3A+final_failure_retries%0A++failure_timeout%3A+final_failure_timeout%0A++id%3A+policy3%0A++payload%3A%0A++++artifact_name%3A+baseconfiguration%0A++++artifact_version%3A+1.0.0%0A++++data%3A%0A++++++resource-assignment-properties%3A%0A++++++++action-name%3A+action-name%0A++++++++hostname%3A+hostname%0A++++++++request-id%3A+request-id%0A++++++++scope-type%3A+scope-type%0A++++++++service-instance-id%3A+service-instance-id%0A++++++++vnf-id%3A+vnf-id%0A++++++++vnf_name%3A+vnf_name%0A++++mode%3A+async%0A++recipe%3A+resource-assignment%0A++retry%3A+0%0A++success%3A+final_success%0A++target%3A%0A++++modelCustomizationId%3A+1bffdc31-a37d-4dee-b65c-dde623a76e52%0A++++modelInvariantId%3A+ca052563-eb92-4b5b-ad41-9111768ce043%0A++++modelName%3A+Vloadbalancerms..vpkg..module-1%0A++++modelVersion%3A+1%0A++++modelVersionId%3A+1e725ccc-b823-4f67-82b9-4f4367070dbc%0A++++resourceID%3A+Vloadbalancerms..vpkg..module-1%0A++++type%3A+VFMODULE%0A++timeout%3A+0%0A" }
\ No newline at end of file diff --git a/src/test/resources/tosca/operational-policy-payload.yaml b/src/test/resources/tosca/operational-policy-payload.yaml index 69c86cc84..aaa962769 100644 --- a/src/test/resources/tosca/operational-policy-payload.yaml +++ b/src/test/resources/tosca/operational-policy-payload.yaml @@ -50,3 +50,35 @@ topology_template: actor: SO recipe: VF Module Create payload: '' + - id: policy3 + retry: '0' + timeout: '0' + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + failure_guard: final_failure_guard + target: + type: VFMODULE + resourceID: Vloadbalancerms..vpkg..module-1 + modelInvariantId: ca052563-eb92-4b5b-ad41-9111768ce043 + modelVersionId: 1e725ccc-b823-4f67-82b9-4f4367070dbc + modelName: Vloadbalancerms..vpkg..module-1 + modelVersion: '1' + modelCustomizationId: 1bffdc31-a37d-4dee-b65c-dde623a76e52 + actor: CDS + recipe: resource-assignment + payload: + artifact_name: baseconfiguration + artifact_version: 1.0.0 + mode: async + data: + resource-assignment-properties: + request-id: request-id + service-instance-id: service-instance-id + vnf-id: vnf-id + action-name: action-name + scope-type: scope-type + hostname: hostname + vnf_name: vnf_name diff --git a/src/test/resources/tosca/operational-policy-properties.json b/src/test/resources/tosca/operational-policy-properties.json index a2de76a98..2777a158c 100644 --- a/src/test/resources/tosca/operational-policy-properties.json +++ b/src/test/resources/tosca/operational-policy-properties.json @@ -10,7 +10,7 @@ { "actor": { "actor": "APPC", - "type": "Restart", + "recipe": "Restart", "payload": "requestParameters: '{\"usePreload\":true,\"userParams\":[]}'\r\nconfigurationParameters: '[{\"ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[10].value\",\"oam-ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[15].value\",\"enabled\":\"$.vf-module-topology.vf-module-parameters.param[22].value\"}]'" }, "id": "policy1", @@ -27,11 +27,11 @@ "resourceID": "vLoadBalancerMS" } }, - { + { "actor": { - "actor": "SO", - "type": "VF Module Create", - "payload": "" + "actor": "SO", + "recipe": "VF Module Create", + "payload": "" }, "id": "policy2", "retry": "0", @@ -51,6 +51,48 @@ "modelVersion": "1", "modelCustomizationId": "1bffdc31-a37d-4dee-b65c-dde623a76e52" } + }, + { + "actor": { + "actor": "CDS", + "recipe": { + "recipe": "resource-assignment", + "payload": { + "artifact_name": "baseconfiguration", + "artifact_version": "1.0.0", + "mode": "async", + "data": { + "resource-assignment-properties": { + "request-id": "request-id", + "service-instance-id": "service-instance-id", + "vnf-id": "vnf-id", + "action-name": "action-name", + "scope-type": "scope-type", + "hostname": "hostname", + "vnf_name": "vnf_name" + } + } + } + } + }, + "id": "policy3", + "retry": "0", + "timeout": "0", + "success": "final_success", + "failure": "final_failure", + "failure_timeout": "final_failure_timeout", + "failure_retries": "final_failure_retries", + "failure_exception": "final_failure_exception", + "failure_guard": "final_failure_guard", + "target": { + "type": "VFMODULE", + "resourceID": "Vloadbalancerms..vpkg..module-1", + "modelInvariantId": "ca052563-eb92-4b5b-ad41-9111768ce043", + "modelVersionId": "1e725ccc-b823-4f67-82b9-4f4367070dbc", + "modelName": "Vloadbalancerms..vpkg..module-1", + "modelVersion": "1", + "modelCustomizationId": "1bffdc31-a37d-4dee-b65c-dde623a76e52" + } } ] }, diff --git a/src/test/resources/tosca/pdp-group-policy-payload.json b/src/test/resources/tosca/pdp-group-policy-payload.json index c81440e73..dce740fcd 100644 --- a/src/test/resources/tosca/pdp-group-policy-payload.json +++ b/src/test/resources/tosca/pdp-group-policy-payload.json @@ -23,6 +23,14 @@ "action": "POST", "policies": [ { + "name": "opLegacyPolicy", + "version": "1.0.0" + }, + { + "name": "guard1", + "version": "1.0.0" + }, + { "name": "opPolicy", "version": "1.0.0" } diff --git a/src/test/resources/tosca/policy-yaml-to-json-with-constraints.json b/src/test/resources/tosca/policy-yaml-to-json-with-constraints.json index b2575486c..fe9b84d13 100644 --- a/src/test/resources/tosca/policy-yaml-to-json-with-constraints.json +++ b/src/test/resources/tosca/policy-yaml-to-json-with-constraints.json @@ -1,7 +1,7 @@ { "schema": { "uniqueItems": "true", - "format": "tabs-top", + "format": "tabs", "type": "array", "title": "Properties with constraints", "items": { diff --git a/src/test/resources/tosca/policy-yaml-to-json-with-datatypes.json b/src/test/resources/tosca/policy-yaml-to-json-with-datatypes.json index d470d928d..ef9c2c03a 100644 --- a/src/test/resources/tosca/policy-yaml-to-json-with-datatypes.json +++ b/src/test/resources/tosca/policy-yaml-to-json-with-datatypes.json @@ -1,7 +1,7 @@ { "schema": { "uniqueItems": "true", - "format": "tabs-top", + "format": "tabs", "type": "array", "title": "Properties with different types", "items": { diff --git a/src/test/resources/tosca/policy-yaml-to-json.json b/src/test/resources/tosca/policy-yaml-to-json.json index dd6a9ff3b..b83d3f24f 100644 --- a/src/test/resources/tosca/policy-yaml-to-json.json +++ b/src/test/resources/tosca/policy-yaml-to-json.json @@ -1,7 +1,7 @@ { "schema": { "uniqueItems": "true", - "format": "tabs-top", + "format": "tabs", "type": "array", "title": "TCA Policy JSON", "items": { diff --git a/src/test/resources/tosca/resource-details.json b/src/test/resources/tosca/resource-details.json index a638c350d..dc47b44db 100644 --- a/src/test/resources/tosca/resource-details.json +++ b/src/test/resources/tosca/resource-details.json @@ -24,78 +24,204 @@ "resource-assignment": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "activate": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "activate-restconf": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "activate-cli": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "assign-activate": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } }, "imperative-test-wf": { "inputs": { "resource-assignment-properties": { - "request-id": "", - "service-instance-id": "", - "vnf-id": "", - "action-name": "", - "scope-type": "", - "hostname": "", - "vnf_name": "" + "request-id": { + "type": "string", + "required": true + }, + "service-instance-id": { + "type": "string", + "required": true + }, + "vnf-id": { + "type": "string", + "required": true + }, + "action-name": { + "type": "string", + "required": true + }, + "scope-type": { + "type": "string", + "required": true + }, + "hostname": { + "type": "string", + "required": true + }, + "vnf_name": { + "type": "string", + "required": true + } } } } diff --git a/src/test/resources/tosca/tosca_metadata_clamp_possible_values_json_schema.json b/src/test/resources/tosca/tosca_metadata_clamp_possible_values_json_schema.json index af8c1f961..418ee71be 100644 --- a/src/test/resources/tosca/tosca_metadata_clamp_possible_values_json_schema.json +++ b/src/test/resources/tosca/tosca_metadata_clamp_possible_values_json_schema.json @@ -1,7 +1,7 @@ { "schema":{ "uniqueItems":"true", - "format":"tabs-top", + "format":"tabs", "type":"array", "title":"TCA Policy JSON", "items":{ @@ -185,6 +185,20 @@ "id":"alarmCondition", "label":"alarmCondition", "type":"string" + }, + { + "plugin":"datetimepicker", + "operators":[ + "equals" + ], + "minLength":1, + "id":"timeEpoch", + "label":"timeEpoch", + "type":"datetime", + "input_event":"dp.change", + "validation":{ + "format":"YYYY/MM/DD HH:mm:ss" + } } ] }, diff --git a/src/test/resources/tosca/tosca_with_date_time_json_schema.json b/src/test/resources/tosca/tosca_with_date_time_json_schema.json new file mode 100644 index 000000000..e15942cc5 --- /dev/null +++ b/src/test/resources/tosca/tosca_with_date_time_json_schema.json @@ -0,0 +1,240 @@ +{ + "schema":{ + "uniqueItems":"true", + "format":"tabs", + "type":"array", + "title":"TCA Policy JSON", + "items":{ + "type":"object", + "title":"TCA Policy JSON", + "required":[ + "domain", + "metricsPerEventName" + ], + "properties":{ + "domain":{ + "propertyOrder":1001, + "default":"measurementsForVfScaling", + "title":"Domain name to which TCA needs to be applied", + "type":"string" + }, + "metricsPerEventName":{ + "propertyOrder":1002, + "uniqueItems":"true", + "format":"tabs-top", + "title":"Contains eventName and threshold details that need to be applied to given eventName", + "type":"array", + "items":{ + "type":"object", + "required":[ + "controlLoopSchemaType", + "eventName", + "policyName", + "policyScope", + "policyVersion", + "thresholds", + "context", + "signature" + ], + "properties":{ + "policyVersion":{ + "propertyOrder":1007, + "title":"TCA Policy Scope Version", + "type":"string" + }, + "thresholds":{ + "propertyOrder":1008, + "uniqueItems":"true", + "format":"tabs-top", + "title":"Thresholds associated with eventName", + "type":"array", + "items":{ + "type":"object", + "required":[ + "closedLoopControlName", + "closedLoopEventStatus", + "direction", + "fieldPath", + "severity", + "thresholdValue", + "version" + ], + "properties":{ + "severity":{ + "propertyOrder":1013, + "title":"Threshold Event Severity", + "type":"string", + "enum":[ + "CRITICAL", + "MAJOR", + "MINOR", + "WARNING", + "NORMAL" + ] + }, + "fieldPath":{ + "propertyOrder":1012, + "title":"Json field Path as per CEF message which needs to be analyzed for TCA", + "type":"string", + "enum":[ + "$.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" + ] + }, + "thresholdValue":{ + "propertyOrder":1014, + "title":"Threshold value for the field Path inside CEF message", + "type":"integer" + }, + "closedLoopEventStatus":{ + "propertyOrder":1010, + "title":"Closed Loop Event Status of the threshold", + "type":"string", + "enum":[ + "ONSET", + "ABATED" + ] + }, + "closedLoopControlName":{ + "propertyOrder":1009, + "title":"Closed Loop Control Name associated with the threshold", + "type":"string" + }, + "version":{ + "propertyOrder":1015, + "title":"Version number associated with the threshold", + "type":"string" + }, + "direction":{ + "propertyOrder":1011, + "title":"Direction of the threshold", + "type":"string", + "enum":[ + "LESS", + "LESS_OR_EQUAL", + "GREATER", + "GREATER_OR_EQUAL", + "EQUAL" + ] + } + } + } + }, + "policyName":{ + "propertyOrder":1005, + "title":"TCA Policy Scope Name", + "type":"string" + }, + "signature":{ + "propertyOrder":1017, + "title":"Signature", + "required":[ + "filter_clause" + ], + "properties":{ + "filter_clause":{ + "propertyOrder":30002, + "qschema":{ + "filters":[ + { + "plugin":"datetimepicker", + "operators":[ + "equals" + ], + "minLength":1, + "id":"timeEpoch", + "label":"timeEpoch", + "type":"datetime", + "input_event":"dp.change", + "validation":{ + "format":"YYYY/MM/DD HH:mm:ss" + } + } + ] + }, + "minLength":1, + "title":"Filter Clause", + "type":"qbldr" + } + } + }, + "controlLoopSchemaType":{ + "propertyOrder":1003, + "title":"Specifies Control Loop Schema Type for the event Name e.g. VNF, VM", + "type":"string", + "enum":[ + "VM", + "VNF" + ] + }, + "policyScope":{ + "propertyOrder":1006, + "title":"TCA Policy Scope", + "type":"string" + }, + "context":{ + "propertyOrder":1016, + "options":{ + "enum_titles":[ + "PROD" + ] + }, + "title":"TCA Policy Dummy Context", + "type":"string", + "enum":[ + "PROD" + ] + }, + "eventName":{ + "propertyOrder":1004, + "title":"Event name to which thresholds need to be applied", + "type":"string" + } + } + } + } + } + } + } +}
\ No newline at end of file diff --git a/ui-react-lib/libIndex.js b/ui-react-lib/libIndex.js index fae47e7fd..da98df43c 100755 --- a/ui-react-lib/libIndex.js +++ b/ui-react-lib/libIndex.js @@ -33,13 +33,19 @@ export { default as LoopService } from './src/api/LoopService'; export { default as LoopStatus } from './src/components/loop_viewer/status/LoopStatus'; export { default as LoopSvg } from './src/components/loop_viewer/svg/LoopSvg'; export { default as LoopUI } from './src/LoopUI'; +export { default as ManageDictionaries } from './src/components/dialogs/ManageDictionaries/ManageDictionaries'; export { default as MenuBar } from './src/components/menu/MenuBar'; +export { default as ModifyLoopModal } from './src/components/dialogs/Loop/ModifyLoopModal'; export { default as NotFound } from './src/NotFound'; export { default as OpenLoopModal } from './src/components/dialogs/Loop/OpenLoopModal'; export { default as CreateLoopModal } from './src/components/dialogs/Loop/CreateLoopModal'; export { default as OperationalPolicyModal } from './src/components/dialogs/OperationalPolicy/OperationalPolicyModal'; export { default as PerformActions } from './src/components/dialogs/PerformActions'; +export { default as PolicyToscaService } from './src/api/PolicyToscaService'; export { default as RefreshStatus } from './src/components/dialogs/RefreshStatus'; +export { default as TemplateService } from './src/api/TemplateService'; export { default as UserInfoModal } from './src/components/dialogs/UserInfoModal'; export { default as UserService } from './src/api/UserService'; +export { default as UploadToscaPolicyModal } from './src/components/dialogs/Tosca/UploadToscaPolicyModal'; +export { default as ViewLoopTemplatesModal } from './src/components/dialogs/Tosca/ViewLoopTemplatesModal'; export { default as ViewToscaPolicyModal } from './src/components/dialogs/Tosca/ViewToscaPolicyModal'; diff --git a/ui-react/src/LoopUI.js b/ui-react/src/LoopUI.js index bc3f2355e..efd02b41f 100644 --- a/ui-react/src/LoopUI.js +++ b/ui-react/src/LoopUI.js @@ -109,7 +109,8 @@ export default class LoopUI extends React.Component { userName: null, loopName: OnapConstants.defaultLoopName, loopCache: new LoopCache({}), - showAlert: false + showSucAlert: false, + showFailAlert: false }; constructor() { @@ -119,7 +120,8 @@ export default class LoopUI extends React.Component { this.updateLoopCache = this.updateLoopCache.bind(this); this.loadLoop = this.loadLoop.bind(this); this.closeLoop = this.closeLoop.bind(this); - this.showAlert = this.showAlert.bind(this); + this.showSucAlert = this.showSucAlert.bind(this); + this.showFailAlert = this.showFailAlert.bind(this); this.disableAlert = this.disableAlert.bind(this); } @@ -168,9 +170,14 @@ export default class LoopUI extends React.Component { renderAlertBar() { return ( - <Alert variant="danger" show={this.state.showAlert} onClose={this.disableAlert} dismissible> + <div> + <Alert variant="success" show={this.state.showSucAlert} onClose={this.disableAlert} dismissible> {this.state.showMessage} </Alert> + <Alert variant="danger" show={this.state.showFailAlert} onClose={this.disableAlert} dismissible> + {this.state.showMessage} + </Alert> + </div> ); } @@ -188,7 +195,7 @@ export default class LoopUI extends React.Component { renderLoopViewHeader() { return ( <LoopViewHeaderDivStyled> - Loop Viewer - {this.state.loopName} + Loop Viewer - {this.state.loopName} - ({this.state.loopCache.getTemplateName()}) </LoopViewHeaderDivStyled> ); } @@ -223,12 +230,16 @@ export default class LoopUI extends React.Component { console.info(this.state.loopName+" loop loaded successfully"); } - showAlert(message) { - this.setState ({ showAlert: true, showMessage:message }); + showSucAlert(message) { + this.setState ({ showSucAlert: true, showMessage:message }); } + showFailAlert(message) { + this.setState ({ showFailAlert: true, showMessage:message }); + } + disableAlert() { - this.setState ({ showAlert: false }); + this.setState ({ showSucAlert: false, showFailAlert: false }); } loadLoop(loopName) { @@ -258,7 +269,7 @@ export default class LoopUI extends React.Component { <Route path="/ViewLoopTemplatesModal" render={(routeProps) => (<ViewLoopTemplatesModal {...routeProps} />)} /> <Route path="/ManageDictionaries" render={(routeProps) => (<ManageDictionaries {...routeProps} />)} /> <Route path="/operationalPolicyModal" - render={(routeProps) => (<OperationalPolicyModal {...routeProps} loopCache={this.getLoopCache()} loadLoopFunction={this.loadLoop} updateLoopFunction={this.updateLoopCache} showAlert={this.showAlert}/>)} /> + render={(routeProps) => (<OperationalPolicyModal {...routeProps} loopCache={this.getLoopCache()} loadLoopFunction={this.loadLoop} updateLoopFunction={this.updateLoopCache} showSucAlert={this.showSucAlert} showFailAlert={this.showFailAlert}/>)} /> <Route path="/policyModal/:policyInstanceType/:policyName" render={(routeProps) => (<PolicyModal {...routeProps} loopCache={this.getLoopCache()} loadLoopFunction={this.loadLoop}/>)} /> <Route path="/configurationPolicyModal/:policyName" render={(routeProps) => (<ConfigurationPolicyModal {...routeProps} loopCache={this.getLoopCache()} loadLoopFunction={this.loadLoop}/>)} /> <Route path="/createLoop" render={(routeProps) => (<CreateLoopModal {...routeProps} loadLoopFunction={this.loadLoop} />)} /> @@ -268,13 +279,13 @@ export default class LoopUI extends React.Component { <Route path="/userInfo" render={(routeProps) => (<UserInfoModal {...routeProps} />)} /> <Route path="/closeLoop" render={this.closeLoop} /> - <Route path="/submit" render={(routeProps) => (<PerformAction {...routeProps} loopAction="submit" loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showAlert={this.showAlert}/>)} /> - <Route path="/stop" render={(routeProps) => (<PerformAction {...routeProps} loopAction="stop" loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showAlert={this.showAlert}/>)} /> - <Route path="/restart" render={(routeProps) => (<PerformAction {...routeProps} loopAction="restart" loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showAlert={this.showAlert}/>)} /> - <Route path="/delete" render={(routeProps) => (<PerformAction {...routeProps} loopAction="delete" loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showAlert={this.showAlert}/>)} /> - <Route path="/undeploy" render={(routeProps) => (<PerformAction {...routeProps} loopAction="undeploy" loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showAlert={this.showAlert}/>)} /> - <Route path="/deploy" render={(routeProps) => (<DeployLoopModal {...routeProps} loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showAlert={this.showAlert}/>)} /> - <Route path="/refreshStatus" render={(routeProps) => (<RefreshStatus {...routeProps} loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showAlert={this.showAlert}/>)} /> + <Route path="/submit" render={(routeProps) => (<PerformAction {...routeProps} loopAction="submit" loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showSucAlert={this.showSucAlert} showFailAlert={this.showFailAlert}/>)} /> + <Route path="/stop" render={(routeProps) => (<PerformAction {...routeProps} loopAction="stop" loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showSucAlert={this.showSucAlert} showFailAlert={this.showFailAlert}/>)} /> + <Route path="/restart" render={(routeProps) => (<PerformAction {...routeProps} loopAction="restart" loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showSucAlert={this.showSucAlert} showFailAlert={this.showFailAlert}/>)} /> + <Route path="/delete" render={(routeProps) => (<PerformAction {...routeProps} loopAction="delete" loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showSucAlert={this.showSucAlert} showFailAlert={this.showFailAlert}/>)} /> + <Route path="/undeploy" render={(routeProps) => (<PerformAction {...routeProps} loopAction="undeploy" loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showSucAlert={this.showSucAlert} showFailAlert={this.showFailAlert}/>)} /> + <Route path="/deploy" render={(routeProps) => (<DeployLoopModal {...routeProps} loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showSucAlert={this.showSucAlert} showFailAlert={this.showFailAlert}/>)} /> + <Route path="/refreshStatus" render={(routeProps) => (<RefreshStatus {...routeProps} loopCache={this.getLoopCache()} updateLoopFunction={this.updateLoopCache} showSucAlert={this.showSucAlert} showFailAlert={this.showFailAlert}/>)} /> <Route path="/logout" render={this.logout} /> <GlobalClampStyle /> {this.renderAlertBar()} diff --git a/ui-react/src/LoopUI.test.js b/ui-react/src/LoopUI.test.js index d1b76aa9a..6885e7932 100644 --- a/ui-react/src/LoopUI.test.js +++ b/ui-react/src/LoopUI.test.js @@ -66,7 +66,8 @@ describe('Verify LoopUI', () => { const component = shallow(<LoopUI />) component.setState({ loopName: "testLoopName", - showAlert: false + showSucAlert: false, + showFailAlert: false }); await flushPromises(); expect(component).toMatchSnapshot(); @@ -158,15 +159,22 @@ describe('Verify LoopUI', () => { test('Test alert methods', () => { const component = shallow(<LoopUI />) - expect(component.state('showAlert')).toEqual(false); + expect(component.state('showSucAlert')).toEqual(false); const instance = component.instance(); - instance.showAlert("testAlert"); - expect(component.state('showAlert')).toEqual(true); + instance.showSucAlert("testAlert"); + expect(component.state('showSucAlert')).toEqual(true); + expect(component.state('showFailAlert')).toEqual(false); expect(component.state('showMessage')).toEqual("testAlert"); instance.disableAlert(); - expect(component.state('showAlert')).toEqual(false); + expect(component.state('showSucAlert')).toEqual(false); + expect(component.state('showFailAlert')).toEqual(false); + + instance.showFailAlert("testAlert2"); + expect(component.state('showSucAlert')).toEqual(false); + expect(component.state('showFailAlert')).toEqual(true); + expect(component.state('showMessage')).toEqual("testAlert2"); }) }); diff --git a/ui-react/src/__snapshots__/LoopUI.test.js.snap b/ui-react/src/__snapshots__/LoopUI.test.js.snap index 9de232dd6..ff08f7afb 100644 --- a/ui-react/src/__snapshots__/LoopUI.test.js.snap +++ b/ui-react/src/__snapshots__/LoopUI.test.js.snap @@ -89,27 +89,50 @@ exports[`Verify LoopUI Test the render method 1`] = ` render={[Function]} /> <GlobalStyleComponent /> - <Alert - closeLabel="Close alert" - dismissible={true} - onClose={[Function]} - show={false} - transition={ - Object { - "$$typeof": Symbol(react.forward_ref), - "defaultProps": Object { - "appear": false, - "in": false, - "mountOnEnter": false, - "timeout": 300, - "unmountOnExit": false, - }, - "displayName": "Fade", - "render": [Function], + <div> + <Alert + closeLabel="Close alert" + dismissible={true} + onClose={[Function]} + show={false} + transition={ + Object { + "$$typeof": Symbol(react.forward_ref), + "defaultProps": Object { + "appear": false, + "in": false, + "mountOnEnter": false, + "timeout": 300, + "unmountOnExit": false, + }, + "displayName": "Fade", + "render": [Function], + } } - } - variant="danger" - /> + variant="success" + /> + <Alert + closeLabel="Close alert" + dismissible={true} + onClose={[Function]} + show={false} + transition={ + Object { + "$$typeof": Symbol(react.forward_ref), + "defaultProps": Object { + "appear": false, + "in": false, + "mountOnEnter": false, + "timeout": 300, + "unmountOnExit": false, + }, + "displayName": "Fade", + "render": [Function], + } + } + variant="danger" + /> + </div> <Navbar collapseOnSelect={false} expand={true} @@ -153,6 +176,8 @@ exports[`Verify LoopUI Test the render method 1`] = ` <styled.div> Loop Viewer - testLoopName + - ( + ) </styled.div> <styled.div> <withRouter(LoopViewSvg) diff --git a/ui-react/src/__snapshots__/OnapClamp.test.js.snap b/ui-react/src/__snapshots__/OnapClamp.test.js.snap index 91812b7c5..93dc44286 100644 --- a/ui-react/src/__snapshots__/OnapClamp.test.js.snap +++ b/ui-react/src/__snapshots__/OnapClamp.test.js.snap @@ -13,6 +13,8 @@ exports[`Verify OnapClamp Test the render method 1`] = ` "fontNormal": "black", "fontSize": "16px", "fontWarning": "#eb238e", + "loopLogsHeaderBackgroundColor": "white", + "loopLogsHeaderFontColor": "black", "loopViewerBackgroundColor": "white", "loopViewerFontColor": "yellow", "loopViewerHeaderBackgroundColor": "#337ab7", @@ -114,27 +116,50 @@ exports[`Verify OnapClamp Test the render method 1`] = ` render={[Function]} /> <GlobalStyleComponent /> - <Alert - closeLabel="Close alert" - dismissible={true} - onClose={[Function]} - show={false} - transition={ - Object { - "$$typeof": Symbol(react.forward_ref), - "defaultProps": Object { - "appear": false, - "in": false, - "mountOnEnter": false, - "timeout": 300, - "unmountOnExit": false, - }, - "displayName": "Fade", - "render": [Function], + <div> + <Alert + closeLabel="Close alert" + dismissible={true} + onClose={[Function]} + show={false} + transition={ + Object { + "$$typeof": Symbol(react.forward_ref), + "defaultProps": Object { + "appear": false, + "in": false, + "mountOnEnter": false, + "timeout": 300, + "unmountOnExit": false, + }, + "displayName": "Fade", + "render": [Function], + } } - } - variant="danger" - /> + variant="success" + /> + <Alert + closeLabel="Close alert" + dismissible={true} + onClose={[Function]} + show={false} + transition={ + Object { + "$$typeof": Symbol(react.forward_ref), + "defaultProps": Object { + "appear": false, + "in": false, + "mountOnEnter": false, + "timeout": 300, + "unmountOnExit": false, + }, + "displayName": "Fade", + "render": [Function], + } + } + variant="danger" + /> + </div> <Navbar collapseOnSelect={false} expand={true} @@ -176,6 +201,8 @@ exports[`Verify OnapClamp Test the render method 1`] = ` <styled.div> Loop Viewer - Empty (NO loop loaded yet) + - ( + ) </styled.div> <styled.div> <withRouter(LoopViewSvg) diff --git a/ui-react/src/api/LoopCache.js b/ui-react/src/api/LoopCache.js index c54337f2f..4f22dc2bb 100644 --- a/ui-react/src/api/LoopCache.js +++ b/ui-react/src/api/LoopCache.js @@ -219,4 +219,11 @@ export default class LoopCache { getComponentStates() { return this.loopJsonCache.components; } + + getTemplateName() { + if (this.loopJsonCache["loopTemplate"] !== undefined) { + return this.loopJsonCache["loopTemplate"].name; + } + return null; + } } diff --git a/ui-react/src/api/LoopService.js b/ui-react/src/api/LoopService.js index 698ee28c2..3b9ed86fa 100644 --- a/ui-react/src/api/LoopService.js +++ b/ui-react/src/api/LoopService.js @@ -226,22 +226,21 @@ export default class LoopService { credentials: 'same-origin' }) .then(function (response) { - console.debug("Add Operational Policy response received: ", response.status); + console.debug("Add Operational Policy response received: ", response.status); if (response.ok) { return response.json(); } else { - console.error("Add Operational Policy query failed"); - return {}; + return response.text(); } }) - .catch(function (error) { - console.error("Add Operational Policy error received", error); - return {}; - }); + .then(function (object) { + console.error("Add Operational Policy query failed"); + throw new Error(object); + }) } - static removeOperationalPolicyType(loopName, policyType, policyVersion) { - return fetch('/restservices/clds/v2/loop/removeOperationaPolicy/' + loopName + '/policyModel/' + policyType +'/' + policyVersion , { + static removeOperationalPolicyType(loopName, policyType, policyVersion, policyName) { + return fetch('/restservices/clds/v2/loop/removeOperationaPolicy/' + loopName + '/policyModel/' + policyType +'/' + policyVersion + '/' + policyName , { method: 'PUT', headers: { "Content-Type": "application/json" diff --git a/ui-react/src/components/dialogs/ConfigurationPolicy/ConfigurationPolicyModal.js b/ui-react/src/components/dialogs/ConfigurationPolicy/ConfigurationPolicyModal.js index da65ac9f1..3ff1ebec7 100644 --- a/ui-react/src/components/dialogs/ConfigurationPolicy/ConfigurationPolicyModal.js +++ b/ui-react/src/components/dialogs/ConfigurationPolicy/ConfigurationPolicyModal.js @@ -104,7 +104,7 @@ export default class ConfigurationPolicyModal extends React.Component { render() { return ( - <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose}> + <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false} > <Modal.Header closeButton> <Modal.Title>Configuration policies</Modal.Title> </Modal.Header> diff --git a/ui-react/src/components/dialogs/Loop/CreateLoopModal.js b/ui-react/src/components/dialogs/Loop/CreateLoopModal.js index c5762a8d4..e98b59566 100644 --- a/ui-react/src/components/dialogs/Loop/CreateLoopModal.js +++ b/ui-react/src/components/dialogs/Loop/CreateLoopModal.js @@ -34,13 +34,20 @@ import TemplateService from '../../../api/TemplateService'; const ModalStyled = styled(Modal)` background-color: transparent; ` -const LoopViewSvgDivStyled = styled.div` - overflow: hidden; +const LoopViewSvgDivStyled = styled.svg` + display: flex; + flex-direction: row; + overflow-x: scroll; background-color: ${props => (props.theme.loopViewerBackgroundColor)}; border-color: ${props => (props.theme.loopViewerHeaderColor)}; + margin-top: 3em; margin-left: auto; margin-right:auto; + margin-bottom: -1em; text-align: center; + align-items: center; + height: 100%; + width: 100%; ` export default class CreateLoopModal extends React.Component { @@ -118,24 +125,28 @@ export default class CreateLoopModal extends React.Component { render() { return ( - <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose}> + <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false} > <Modal.Header closeButton> <Modal.Title>Create Model</Modal.Title> </Modal.Header> <Modal.Body> <Form.Group as={Row} controlId="formPlaintextEmail"> - <Form.Label column sm="2">Template Name</Form.Label> + <Form.Label column sm="2">Template Name:</Form.Label> <Col sm="10"> <Select onChange={this.handleDropdownListChange} options={this.state.templateNames} /> </Col> </Form.Group> - <Form.Group controlId="formPlaintextEmail"> - <LoopViewSvgDivStyled dangerouslySetInnerHTML={{ __html: this.state.content }} value={this.state.content} > - </LoopViewSvgDivStyled> - </Form.Group> - <Form.Group controlId="formPlaintextEmail"> + <Form.Group as={Row} style={{alignItems: 'center'}} controlId="formSvgPreview"> + <Form.Label column sm="2">Model Preview:</Form.Label> + <Col sm="10"> + <LoopViewSvgDivStyled dangerouslySetInnerHTML={{ __html: this.state.content }} + value={this.state.content} > + </LoopViewSvgDivStyled> + </Col> + </Form.Group> + <Form.Group as={Row} controlId="formPlaintextEmail"> <Form.Label column sm="2">Model Name:</Form.Label> - <input type="text" style={{width: '50%'}} + <input type="text" style={{width: '50%', marginLeft: '1em' }} value={this.state.modelName} onChange={this.handleModelName} /> @@ -148,4 +159,4 @@ export default class CreateLoopModal extends React.Component { </ModalStyled> ); } -}
\ No newline at end of file +} diff --git a/ui-react/src/components/dialogs/Loop/DeployLoopModal.js b/ui-react/src/components/dialogs/Loop/DeployLoopModal.js index d034ee5d7..2155977f6 100644 --- a/ui-react/src/components/dialogs/Loop/DeployLoopModal.js +++ b/ui-react/src/components/dialogs/Loop/DeployLoopModal.js @@ -29,6 +29,12 @@ import Form from 'react-bootstrap/Form'; import Tabs from 'react-bootstrap/Tabs'; import Tab from 'react-bootstrap/Tab'; import styled from 'styled-components'; +import Spinner from 'react-bootstrap/Spinner' + +const StyledSpinnerDiv = styled.div` + justify-content: center !important; + display: flex !important; +`; const ModalStyled = styled(Modal)` background-color: transparent; @@ -48,6 +54,7 @@ export default class DeployLoopModal extends React.Component { this.handleChange = this.handleChange.bind(this); this.refreshStatus = this.refreshStatus.bind(this); this.renderDeployParam = this.renderDeployParam.bind(this); + this.renderSpinner = this.renderSpinner.bind(this); const propertiesJson = JSON.parse(JSON.stringify(this.props.loopCache.getGlobalProperties())); this.state = { @@ -79,31 +86,48 @@ export default class DeployLoopModal extends React.Component { this.props.history.push('/'); } + renderSpinner() { + if (this.state.deploying) { + return ( + <StyledSpinnerDiv> + <Spinner animation="border" role="status"> + <span className="sr-only">Loading...</span> + </Spinner> + </StyledSpinnerDiv> + ); + } else { + return (<div></div>); + } + } + handleSave() { const loopName = this.props.loopCache.getLoopName(); // save the global propserties + this.setState({ deploying: true }); LoopService.updateGlobalProperties(loopName, this.state.temporaryPropertiesJson).then(resp => { LoopActionService.performAction(loopName, "deploy").then(pars => { - this.props.showAlert("Action deploy successfully performed"); + this.props.showSucAlert("Action deploy successfully performed"); // refresh status and update loop logs this.refreshStatus(loopName); }) .catch(error => { - this.props.showAlert("Action deploy failed"); + this.props.showFailAlert("Action deploy failed"); // refresh status and update loop logs this.refreshStatus(loopName); }); }); - this.setState({ show: false }); - this.props.history.push('/'); } refreshStatus(loopName) { LoopActionService.refreshStatus(loopName).then(data => { this.props.updateLoopFunction(data); + this.setState({ show: false, deploying: false }); + this.props.history.push('/'); }) .catch(error => { - this.props.showAlert("Refresh status failed"); + this.props.showFailAlert("Refresh status failed"); + this.setState({ show: false, deploying: false }); + this.props.history.push('/'); }); } handleChange(event) { @@ -137,13 +161,14 @@ export default class DeployLoopModal extends React.Component { } render() { return ( - <ModalStyled size="lg" show={this.state.show} onHide={this.handleClose} > + <ModalStyled size="lg" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false} > <Modal.Header closeButton> <Modal.Title>Deployment parameters</Modal.Title> </Modal.Header> <Tabs id="controlled-tab-example" activeKey={this.state.key} onSelect={key => this.setState({ key })}> {this.renderDeployParamTabs()} </Tabs> + {this.renderSpinner()} <Modal.Footer> <Button variant="secondary" type="null" onClick={this.handleClose}>Cancel</Button> <Button variant="primary" type="submit" onClick={this.handleSave}>Deploy</Button> diff --git a/ui-react/src/components/dialogs/Loop/DeployLoopModal.test.js b/ui-react/src/components/dialogs/Loop/DeployLoopModal.test.js index 5f1dcd5fc..84dbfd1f6 100644 --- a/ui-react/src/components/dialogs/Loop/DeployLoopModal.test.js +++ b/ui-react/src/components/dialogs/Loop/DeployLoopModal.test.js @@ -63,7 +63,8 @@ describe('Verify DeployLoopModal', () => { const flushPromises = () => new Promise(setImmediate); const historyMock = { push: jest.fn() }; const updateLoopFunction = jest.fn(); - const showAlert = jest.fn(); + const showSucAlert = jest.fn(); + const showFailAlert = jest.fn(); const handleSave = jest.spyOn(DeployLoopModal.prototype,'handleSave'); LoopService.updateGlobalProperties = jest.fn().mockImplementation(() => { return Promise.resolve({ @@ -88,7 +89,7 @@ describe('Verify DeployLoopModal', () => { }); const component = shallow(<DeployLoopModal history={historyMock} - loopCache={loopCache} updateLoopFunction={updateLoopFunction} showAlert={showAlert} />) + loopCache={loopCache} updateLoopFunction={updateLoopFunction} showSucAlert={showSucAlert} showFailAlert={showFailAlert} />) component.find('[variant="primary"]').prop('onClick')(); await flushPromises(); diff --git a/ui-react/src/components/dialogs/Loop/LoopPropertiesModal.js b/ui-react/src/components/dialogs/Loop/LoopPropertiesModal.js index 73946f45d..c0a2084f5 100644 --- a/ui-react/src/components/dialogs/Loop/LoopPropertiesModal.js +++ b/ui-react/src/components/dialogs/Loop/LoopPropertiesModal.js @@ -102,7 +102,7 @@ export default class LoopPropertiesModal extends React.Component { render() { return ( - <ModalStyled size="lg" show={this.state.show} onHide={this.handleClose} > + <ModalStyled size="lg" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false} > <Modal.Header closeButton> <Modal.Title>Model Properties</Modal.Title> </Modal.Header> diff --git a/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js b/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js index 42c03daca..5154a880b 100644 --- a/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js +++ b/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js @@ -37,7 +37,7 @@ import Search from '@material-ui/icons/Search'; import LoopService from '../../../api/LoopService'; import Tabs from 'react-bootstrap/Tabs'; import Tab from 'react-bootstrap/Tab'; - +import Alert from 'react-bootstrap/Alert'; const ModalStyled = styled(Modal)` background-color: transparent; @@ -65,6 +65,7 @@ export default class ModifyLoopModal extends React.Component { toscaPolicyModelsData: [], selectedPolicyModelsData: [], key: 'add', + showFailAlert: false, toscaColumns: [ { title: "#", field: "index", render: rowData => rowData.tableData.id + 1, cellStyle: cellStyle, @@ -78,6 +79,10 @@ export default class ModifyLoopModal extends React.Component { cellStyle: cellStyle, headerStyle: headerStyle }, + { title: "Policy Name", field: "policyName", + cellStyle: cellStyle, + headerStyle: headerStyle + }, { title: "Version", field: "version", cellStyle: cellStyle, headerStyle: headerStyle @@ -90,7 +95,7 @@ export default class ModifyLoopModal extends React.Component { cellStyle: cellStyle, headerStyle: headerStyle }, - { title: "Add", field: "updatedDate", editable: 'never', + { title: "Created Date", field: "createdDate", editable: 'never', cellStyle: cellStyle, headerStyle: headerStyle } @@ -128,7 +133,9 @@ export default class ModifyLoopModal extends React.Component { var operationalPolicies = this.state.loopCache.getOperationalPolicies(); var selectedPolicyModels = []; for (var policy in operationalPolicies) { - selectedPolicyModels.push(operationalPolicies[policy]["policyModel"]); + var newRow = operationalPolicies[policy]["policyModel"]; + newRow["policyName"] = operationalPolicies[policy].name; + selectedPolicyModels.push(newRow); } PolicyToscaService.getToscaPolicyModels().then(allToscaModels => { @@ -160,21 +167,36 @@ export default class ModifyLoopModal extends React.Component { this.props.history.push('/'); } + renderAlert() { + return ( + <div> + <Alert variant="danger" show={this.state.showFailAlert} onClose={this.disableAlert} dismissible> + {this.state.showMessage} + </Alert> + </div> + ); + } + handleAdd() { - LoopService.addOperationalPolicyType(this.state.loopCache.getLoopName(),this.state.selectedRowData.policyModelType,this.state.selectedRowData.version); - this.props.loadLoopFunction(this.state.loopCache.getLoopName()); - this.handleClose(); + LoopService.addOperationalPolicyType(this.state.loopCache.getLoopName(),this.state.selectedRowData.policyModelType,this.state.selectedRowData.version) + .then(pars => { + this.props.loadLoopFunction(this.state.loopCache.getLoopName()); + this.handleClose(); + }) + .catch(error => { + this.setState({ showFailAlert: true, showMessage: "Adding failed with error: " + error.message}); + }); } handleRemove() { - LoopService.removeOperationalPolicyType(this.state.loopCache.getLoopName(),this.state.selectedRowData.policyModelType,this.state.selectedRowData.version); + LoopService.removeOperationalPolicyType(this.state.loopCache.getLoopName(),this.state.selectedRowData.policyModelType,this.state.selectedRowData.version,this.state.selectedRowData.policyName); this.props.loadLoopFunction(this.state.loopCache.getLoopName()); this.handleClose(); } render() { return ( - <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose}> + <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false} > <Modal.Header closeButton> <Modal.Title>Modify Loop Operational Policies</Modal.Title> </Modal.Header> @@ -192,18 +214,19 @@ export default class ModifyLoopModal extends React.Component { rowStyle: rowData => ({ backgroundColor: (this.state.selectedRowData !== {} && this.state.selectedRowData.tableData !== undefined && this.state.selectedRowData.tableData.id === rowData.tableData.id) ? '#EEE' : '#FFF' - }) + }) }} /> <div> <TextModal value={this.state.content} onChange={this.handleYamlContent}/> </div> </Modal.Body> + {this.renderAlert()} </Tab> <Tab eventKey="remove" title="Remove Operational Policies"> <Modal.Body> <MaterialTable - title={"Already added Tosca Policy Models"} + title={"Tosca Policy Models already added"} data={this.state.selectedPolicyModelsData} columns={this.state.toscaColumns} icons={this.state.tableIcons} diff --git a/ui-react/src/components/dialogs/Loop/OpenLoopModal.js b/ui-react/src/components/dialogs/Loop/OpenLoopModal.js index 7c98fab4d..c04883443 100644 --- a/ui-react/src/components/dialogs/Loop/OpenLoopModal.js +++ b/ui-react/src/components/dialogs/Loop/OpenLoopModal.js @@ -37,13 +37,20 @@ const ModalStyled = styled(Modal)` const CheckBoxStyled = styled(FormCheck.Input)` margin-left:3rem; ` -const LoopViewSvgDivStyled = styled.div` - overflow: hidden; +const LoopViewSvgDivStyled = styled.svg` + overflow-x: scroll; + display: flex; + flex-direction: row; background-color: ${props => (props.theme.loopViewerBackgroundColor)}; border-color: ${props => (props.theme.loopViewerHeaderColor)}; + margin-top: 2em; margin-left: auto; margin-right:auto; + margin-bottom: -3em; text-align: center; + align-items: center; + height: 100%; + width: 100%; ` export default class OpenLoopModal extends React.Component { @@ -54,6 +61,7 @@ export default class OpenLoopModal extends React.Component { this.handleOpen = this.handleOpen.bind(this); this.handleClose = this.handleClose.bind(this); this.handleDropdownListChange = this.handleDropdownListChange.bind(this); + this.showReadOnly = props.showReadOnly ? props.showReadOnly : true; this.state = { show: true, chosenLoopName: '', @@ -101,28 +109,34 @@ export default class OpenLoopModal extends React.Component { render() { return ( - <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose}> + <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false} > <Modal.Header closeButton> <Modal.Title>Open Model</Modal.Title> </Modal.Header> <Modal.Body> <Form.Group as={Row} controlId="formPlaintextEmail"> - <Form.Label column sm="2">Model Name</Form.Label> + <Form.Label column sm="2">Model Name:</Form.Label> <Col sm="10"> <Select onChange={this.handleDropdownListChange} options={this.state.loopNames} /> </Col> </Form.Group> - <Form.Group controlId="formPlaintextEmail"> - <LoopViewSvgDivStyled dangerouslySetInnerHTML={{ __html: this.state.content }} value={this.state.content} > - </LoopViewSvgDivStyled> - </Form.Group> - <Form.Group controlId="formBasicChecbox"> - <Form.Check> - <FormCheck.Label>Read Only</FormCheck.Label> - <CheckBoxStyled type="checkbox" /> - </Form.Check> + <Form.Group as={Row} style={{alignItems: 'center'}} controlId="formSvgPreview"> + <Form.Label column sm="2">Model Preview:</Form.Label> + <Col sm="10"> + <LoopViewSvgDivStyled dangerouslySetInnerHTML={{ __html: this.state.content }} + value={this.state.content} > + </LoopViewSvgDivStyled> + </Col> </Form.Group> + {this.showReadOnly === true ? + <Form.Group as={Row} controlId="formBasicChecbox"> + <Form.Check> + <FormCheck.Label>Read Only Mode:</FormCheck.Label> + <CheckBoxStyled style={{marginLeft: '3.5em'}} type="checkbox" /> + </Form.Check> + </Form.Group> + : null} </Modal.Body> <Modal.Footer> <Button variant="secondary" type="null" onClick={this.handleClose}>Cancel</Button> diff --git a/ui-react/src/components/dialogs/Loop/__snapshots__/DeployLoopModal.test.js.snap b/ui-react/src/components/dialogs/Loop/__snapshots__/DeployLoopModal.test.js.snap index 0f86aa340..8d0faa5f7 100644 --- a/ui-react/src/components/dialogs/Loop/__snapshots__/DeployLoopModal.test.js.snap +++ b/ui-react/src/components/dialogs/Loop/__snapshots__/DeployLoopModal.test.js.snap @@ -2,6 +2,8 @@ exports[`Verify DeployLoopModal Test the render method 1`] = ` <Styled(Bootstrap(Modal)) + backdrop="static" + keyboard={false} onHide={[Function]} show={true} size="lg" @@ -56,6 +58,7 @@ exports[`Verify DeployLoopModal Test the render method 1`] = ` </Styled(FormGroup)> </Tab> </Tabs> + <div /> <ModalFooter> <Button active={false} diff --git a/ui-react/src/components/dialogs/Loop/__snapshots__/LoopPropertiesModal.test.js.snap b/ui-react/src/components/dialogs/Loop/__snapshots__/LoopPropertiesModal.test.js.snap index fe9aee2ab..233c560ab 100644 --- a/ui-react/src/components/dialogs/Loop/__snapshots__/LoopPropertiesModal.test.js.snap +++ b/ui-react/src/components/dialogs/Loop/__snapshots__/LoopPropertiesModal.test.js.snap @@ -2,6 +2,8 @@ exports[`Verify LoopPropertiesModal Test the render method 1`] = ` <Styled(Bootstrap(Modal)) + backdrop="static" + keyboard={false} onHide={[Function]} show={true} size="lg" diff --git a/ui-react/src/components/dialogs/Loop/__snapshots__/OpenLoopModal.test.js.snap b/ui-react/src/components/dialogs/Loop/__snapshots__/OpenLoopModal.test.js.snap index 1aa0b5ae9..196854446 100644 --- a/ui-react/src/components/dialogs/Loop/__snapshots__/OpenLoopModal.test.js.snap +++ b/ui-react/src/components/dialogs/Loop/__snapshots__/OpenLoopModal.test.js.snap @@ -2,6 +2,8 @@ exports[`Verify OpenLoopModal Test the render method 1`] = ` <Styled(Bootstrap(Modal)) + backdrop="static" + keyboard={false} onHide={[Function]} show={true} size="xl" @@ -32,7 +34,7 @@ exports[`Verify OpenLoopModal Test the render method 1`] = ` sm="2" srOnly={false} > - Model Name + Model Name: </FormLabel> <Col sm="10" @@ -47,18 +49,52 @@ exports[`Verify OpenLoopModal Test the render method 1`] = ` </Col> </FormGroup> <FormGroup - controlId="formPlaintextEmail" + as={ + Object { + "$$typeof": Symbol(react.forward_ref), + "defaultProps": Object { + "noGutters": false, + }, + "render": [Function], + } + } + controlId="formSvgPreview" + style={ + Object { + "alignItems": "center", + } + } > - <styled.div - dangerouslySetInnerHTML={ - Object { - "__html": "", + <FormLabel + column={true} + sm="2" + srOnly={false} + > + Model Preview: + </FormLabel> + <Col + sm="10" + > + <styled.svg + dangerouslySetInnerHTML={ + Object { + "__html": "", + } } - } - value="" - /> + value="" + /> + </Col> </FormGroup> <FormGroup + as={ + Object { + "$$typeof": Symbol(react.forward_ref), + "defaultProps": Object { + "noGutters": false, + }, + "render": [Function], + } + } controlId="formBasicChecbox" > <FormCheck @@ -70,9 +106,14 @@ exports[`Verify OpenLoopModal Test the render method 1`] = ` type="checkbox" > <FormCheckLabel> - Read Only + Read Only Mode: </FormCheckLabel> <Styled(FormCheckInput) + style={ + Object { + "marginLeft": "3.5em", + } + } type="checkbox" /> </FormCheck> diff --git a/ui-react/src/components/dialogs/ManageDictionaries/ManageDictionaries.js b/ui-react/src/components/dialogs/ManageDictionaries/ManageDictionaries.js index d8065ede6..2af1b7ce4 100644 --- a/ui-react/src/components/dialogs/ManageDictionaries/ManageDictionaries.js +++ b/ui-react/src/components/dialogs/ManageDictionaries/ManageDictionaries.js @@ -376,7 +376,7 @@ export default class ManageDictionaries extends React.Component { render() { return ( - <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose}> + <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false} > <Modal.Header closeButton> <Modal.Title>Manage Dictionaries</Modal.Title> </Modal.Header> diff --git a/ui-react/src/components/dialogs/ManageDictionaries/__snapshots__/ManageDictionaries.test.js.snap b/ui-react/src/components/dialogs/ManageDictionaries/__snapshots__/ManageDictionaries.test.js.snap index e78292216..71cc393b8 100644 --- a/ui-react/src/components/dialogs/ManageDictionaries/__snapshots__/ManageDictionaries.test.js.snap +++ b/ui-react/src/components/dialogs/ManageDictionaries/__snapshots__/ManageDictionaries.test.js.snap @@ -2,6 +2,8 @@ exports[`Verify ManageDictionaries Test API Successful 1`] = ` <Styled(Bootstrap(Modal)) + backdrop="static" + keyboard={false} onHide={[Function]} show={true} size="xl" diff --git a/ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.js b/ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.js index 89e70795e..77dce1656 100644 --- a/ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.js +++ b/ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.js @@ -56,7 +56,7 @@ export default class OperationalPolicyModal extends React.Component { if (errors.length !== 0) { console.error("Errors detected during config policy data validation ", errors); - this.props.showAlert(errors); + this.props.showFailAlert(errors); } else { console.info("NO validation errors found in config policy data"); @@ -147,7 +147,7 @@ export default class OperationalPolicyModal extends React.Component { render() { return ( - <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose}> + <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false} > <Modal.Header closeButton> <Modal.Title>Operational policies</Modal.Title> </Modal.Header> diff --git a/ui-react/src/components/dialogs/PerformActions.js b/ui-react/src/components/dialogs/PerformActions.js index 66b192863..cf5a3c20e 100644 --- a/ui-react/src/components/dialogs/PerformActions.js +++ b/ui-react/src/components/dialogs/PerformActions.js @@ -52,12 +52,12 @@ export default class PerformActions extends React.Component { const loopName = this.state.loopName; LoopActionService.performAction(loopName, action).then(pars => { - this.props.showAlert("Action " + action + " successfully performed"); + this.props.showSucAlert("Action " + action + " successfully performed"); // refresh status and update loop logs this.refreshStatus(loopName); }) .catch(error => { - this.props.showAlert("Action " + action + " failed"); + this.props.showFailAlert("Action " + action + " failed"); // refresh status and update loop logs this.refreshStatus(loopName); }); diff --git a/ui-react/src/components/dialogs/PerformActions.test.js b/ui-react/src/components/dialogs/PerformActions.test.js index 0b0786290..b833a929d 100644 --- a/ui-react/src/components/dialogs/PerformActions.test.js +++ b/ui-react/src/components/dialogs/PerformActions.test.js @@ -36,7 +36,8 @@ describe('Verify PerformActions', () => { const flushPromises = () => new Promise(setImmediate); const historyMock = { push: jest.fn() }; const updateLoopFunction = jest.fn(); - const showAlert = jest.fn(); + const showSucAlert = jest.fn(); + const showFailAlert = jest.fn(); LoopActionService.refreshStatus = jest.fn().mockImplementation(() => { return Promise.resolve({ @@ -46,7 +47,7 @@ describe('Verify PerformActions', () => { }); }); const component = shallow(<PerformActions loopCache={loopCache} - loopAction="submit" history={historyMock} updateLoopFunction={updateLoopFunction} showAlert={showAlert} />) + loopAction="submit" history={historyMock} updateLoopFunction={updateLoopFunction} showSucAlert={showSucAlert} showFailAlert={showFailAlert} />) await flushPromises(); component.update(); @@ -57,7 +58,8 @@ describe('Verify PerformActions', () => { const flushPromises = () => new Promise(setImmediate); const historyMock = { push: jest.fn() }; const updateLoopFunction = jest.fn(); - const showAlert = jest.fn(); + const showSucAlert = jest.fn(); + const showFailAlert = jest.fn(); LoopActionService.performAction = jest.fn().mockImplementation(() => { return Promise.resolve({ @@ -74,7 +76,7 @@ describe('Verify PerformActions', () => { }); }); const component = shallow(<PerformActions loopCache={loopCache} - loopAction="submit" history={historyMock} updateLoopFunction={updateLoopFunction} showAlert={showAlert} />) + loopAction="submit" history={historyMock} updateLoopFunction={updateLoopFunction} showSucAlert={showSucAlert} showFailAlert={showFailAlert} />) await flushPromises(); component.update(); diff --git a/ui-react/src/components/dialogs/Policy/PolicyModal.js b/ui-react/src/components/dialogs/Policy/PolicyModal.js index 8b49d9150..5930386c2 100644 --- a/ui-react/src/components/dialogs/Policy/PolicyModal.js +++ b/ui-react/src/components/dialogs/Policy/PolicyModal.js @@ -74,6 +74,10 @@ export default class PolicyModal extends React.Component { if (errors.length !== 0) { console.error("Errors detected during policy data validation ", errors); + this.setState({ + showFailAlert: true, + showMessage: "Errors detected during policy data validation " + errors + }); return; } else { @@ -252,7 +256,7 @@ export default class PolicyModal extends React.Component { render() { return ( - <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose}> + <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose } backdrop="static"> <Modal.Header closeButton> <Modal.Title>Edit the policy</Modal.Title> </Modal.Header> diff --git a/ui-react/src/components/dialogs/RefreshStatus.js b/ui-react/src/components/dialogs/RefreshStatus.js index 64b35d99b..bb0939152 100644 --- a/ui-react/src/components/dialogs/RefreshStatus.js +++ b/ui-react/src/components/dialogs/RefreshStatus.js @@ -44,12 +44,12 @@ export default class RefreshStatus extends React.Component { componentDidMount() { // refresh status and update loop logs LoopActionService.refreshStatus(this.state.loopName).then(data => { - this.props.showAlert("Status successfully refreshed"); + this.props.showSucAlert("Status successfully refreshed"); this.props.updateLoopFunction(data); this.props.history.push('/'); }) .catch(error => { - this.props.showAlert("Status refreshing failed"); + this.props.showFailAlert("Status refreshing failed"); this.props.history.push('/'); }); } diff --git a/ui-react/src/components/dialogs/RefreshStatus.test.js b/ui-react/src/components/dialogs/RefreshStatus.test.js index 3038eb321..e08c50d2e 100644 --- a/ui-react/src/components/dialogs/RefreshStatus.test.js +++ b/ui-react/src/components/dialogs/RefreshStatus.test.js @@ -35,9 +35,10 @@ describe('Verify RefreshStatus', () => { it('Test refresh status failed', async () => { const flushPromises = () => new Promise(setImmediate); const historyMock = { push: jest.fn() }; - const showAlert = jest.fn(); + const showSucAlert = jest.fn(); + const showFailAlert = jest.fn(); - const component = shallow(<RefreshStatus loopCache={loopCache} history={historyMock} showAlert={showAlert} />) + const component = shallow(<RefreshStatus loopCache={loopCache} history={historyMock} showSucAlert={showSucAlert} showFailAlert={showFailAlert} />) await flushPromises(); component.update(); @@ -48,7 +49,8 @@ describe('Verify RefreshStatus', () => { const flushPromises = () => new Promise(setImmediate); const historyMock = { push: jest.fn() }; const updateLoopFunction = jest.fn(); - const showAlert = jest.fn(); + const showSucAlert = jest.fn(); + const showFailAlert = jest.fn(); LoopActionService.refreshStatus = jest.fn().mockImplementation(() => { return Promise.resolve({ @@ -59,7 +61,7 @@ describe('Verify RefreshStatus', () => { }); const component = shallow(<RefreshStatus loopCache={loopCache} - loopAction="submit" history={historyMock} updateLoopFunction={updateLoopFunction} showAlert={showAlert} />) + loopAction="submit" history={historyMock} updateLoopFunction={updateLoopFunction} showSucAlert={showSucAlert} showFailAlert={showFailAlert} />) await flushPromises(); component.update(); diff --git a/ui-react/src/components/dialogs/Tosca/UploadToscaPolicyModal.js b/ui-react/src/components/dialogs/Tosca/UploadToscaPolicyModal.js index 1937485b0..fa95ca977 100644 --- a/ui-react/src/components/dialogs/Tosca/UploadToscaPolicyModal.js +++ b/ui-react/src/components/dialogs/Tosca/UploadToscaPolicyModal.js @@ -86,14 +86,14 @@ export default class UploadToscaPolicyModal extends React.Component { render() { return ( - <ModalStyled size="lg" show={this.state.show} onHide={this.handleClose}> + <ModalStyled size="lg" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false} > <Modal.Header closeButton> <Modal.Title>Upload Tosca Model</Modal.Title> </Modal.Header> <Modal.Body> <Form.Group as={Row} controlId="formPlaintextEmail"> <Col sm="10"> - <input style={{display: 'none'}} type="file" name="file" accept=".yaml" onChange={this.fileSelectedHandler} + <input style={{display: 'none'}} type="file" name="file" accept=".yaml,.yml" onChange={this.fileSelectedHandler} ref={fileInput => this.fileInput = fileInput}/> <button onClick={() => this.fileInput.click()}>Pick Tosca File</button> <Alert variant="secondary"> diff --git a/ui-react/src/components/dialogs/Tosca/ViewLoopTemplatesModal.js b/ui-react/src/components/dialogs/Tosca/ViewLoopTemplatesModal.js index cec6722d0..7cf02f711 100644 --- a/ui-react/src/components/dialogs/Tosca/ViewLoopTemplatesModal.js +++ b/ui-react/src/components/dialogs/Tosca/ViewLoopTemplatesModal.js @@ -38,16 +38,24 @@ import MaterialTable from "material-table"; const ModalStyled = styled(Modal)` background-color: transparent; ` -const LoopViewSvgDivStyled = styled.div` - overflow: hidden; +const LoopViewSvgDivStyled = styled.svg` + overflow-x: scroll; background-color: ${props => (props.theme.loopViewerBackgroundColor)}; border-color: ${props => (props.theme.loopViewerHeaderColor)}; - margin-left: auto; + margin-top: 3em; + margin-left: 2em; margin-right:auto; text-align: center; - margin-top: 20px; + height: 100%; + width: 100%; + display: flex; + flex-direction: row; + align-items: center; + ` const SvgContainerDivStyled = styled.div` + display: flex; + align-items: center; border: 1px solid; ` @@ -133,7 +141,7 @@ export default class ViewLoopTemplatesModal extends React.Component { render() { return ( - <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose}> + <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false}> <Modal.Header closeButton> </Modal.Header> <Modal.Body> diff --git a/ui-react/src/components/dialogs/Tosca/ViewToscaPolicyModal.js b/ui-react/src/components/dialogs/Tosca/ViewToscaPolicyModal.js index 650080520..d49232f2d 100644 --- a/ui-react/src/components/dialogs/Tosca/ViewToscaPolicyModal.js +++ b/ui-react/src/components/dialogs/Tosca/ViewToscaPolicyModal.js @@ -139,7 +139,7 @@ export default class ViewToscalPolicyModal extends React.Component { render() { return ( - <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose}> + <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose} backdrop="static" keyboard={false}> <Modal.Header closeButton> </Modal.Header> <Modal.Body> diff --git a/ui-react/src/components/dialogs/Tosca/__snapshots__/ViewLoopTemplatesModal.test.js.snap b/ui-react/src/components/dialogs/Tosca/__snapshots__/ViewLoopTemplatesModal.test.js.snap index 253820f86..3f6dc9482 100644 --- a/ui-react/src/components/dialogs/Tosca/__snapshots__/ViewLoopTemplatesModal.test.js.snap +++ b/ui-react/src/components/dialogs/Tosca/__snapshots__/ViewLoopTemplatesModal.test.js.snap @@ -2,6 +2,8 @@ exports[`Verify ViewLoopTemplatesModal Test the tosca model view render method 1`] = ` <Styled(Bootstrap(Modal)) + backdrop="static" + keyboard={false} onHide={[Function]} show={true} size="xl" @@ -141,7 +143,7 @@ exports[`Verify ViewLoopTemplatesModal Test the tosca model view render method 1 title="View Blueprint MicroService Templates" /> <styled.div> - <styled.div + <styled.svg dangerouslySetInnerHTML={ Object { "__html": "Please select a loop template to display it", diff --git a/ui-react/src/components/dialogs/Tosca/__snapshots__/ViewToscaPolicyModal.test.js.snap b/ui-react/src/components/dialogs/Tosca/__snapshots__/ViewToscaPolicyModal.test.js.snap index fc5eef024..5f19a9b7d 100644 --- a/ui-react/src/components/dialogs/Tosca/__snapshots__/ViewToscaPolicyModal.test.js.snap +++ b/ui-react/src/components/dialogs/Tosca/__snapshots__/ViewToscaPolicyModal.test.js.snap @@ -2,6 +2,8 @@ exports[`Verify ViewToscaPolicyModal Test the tosca model view render method 1`] = ` <Styled(Bootstrap(Modal)) + backdrop="static" + keyboard={false} onHide={[Function]} show={true} size="xl" diff --git a/ui-react/src/components/loop_viewer/logs/LoopLogs.js b/ui-react/src/components/loop_viewer/logs/LoopLogs.js index 6abdc4b4f..b3f052626 100644 --- a/ui-react/src/components/loop_viewer/logs/LoopLogs.js +++ b/ui-react/src/components/loop_viewer/logs/LoopLogs.js @@ -26,9 +26,9 @@ import LoopCache from '../../../api/LoopCache'; import styled from 'styled-components'; const LoopLogsHeaderDivStyled = styled.div` - background-color: ${props => props.theme.loopViewerHeaderBackgroundColor}; + background-color: ${props => props.theme.loopLogsHeaderBackgroundColor}; padding: 10px 10px; - color: ${props => props.theme.loopViewerHeaderFontColor}; + color: ${props => props.theme.loopLogsHeaderFontColor}; ` const TableStyled = styled(Table)` diff --git a/ui-react/src/components/loop_viewer/svg/LoopSvg.js b/ui-react/src/components/loop_viewer/svg/LoopSvg.js index 4bbf608df..048f63044 100644 --- a/ui-react/src/components/loop_viewer/svg/LoopSvg.js +++ b/ui-react/src/components/loop_viewer/svg/LoopSvg.js @@ -27,14 +27,20 @@ import { withRouter } from "react-router-dom"; import LoopService from '../../../api/LoopService'; import LoopComponentConverter from './LoopComponentConverter'; -const LoopViewSvgDivStyled = styled.div` - overflow: hidden; +const LoopViewSvgDivStyled = styled.svg` + display: flex; + flex-direction: row; + overflow-x: scroll; background-color: ${props => (props.theme.loopViewerBackgroundColor)}; border: 1px solid; border-color: ${props => (props.theme.loopViewerHeaderColor)}; + margin-top: 1em; margin-left: auto; margin-right:auto; - text-align: center; + margin-bottom: -3em; + align-items: center; + height: 100%; + width: 100%; ` @@ -101,4 +107,4 @@ class LoopViewSvg extends React.Component { } } -export default withRouter(LoopViewSvg);
\ No newline at end of file +export default withRouter(LoopViewSvg); diff --git a/ui-react/src/components/loop_viewer/svg/__snapshots__/LoopSvg.test.js.snap b/ui-react/src/components/loop_viewer/svg/__snapshots__/LoopSvg.test.js.snap index cecfb425a..e05f1c794 100644 --- a/ui-react/src/components/loop_viewer/svg/__snapshots__/LoopSvg.test.js.snap +++ b/ui-react/src/components/loop_viewer/svg/__snapshots__/LoopSvg.test.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Verify LoopSvg Test the render method 1`] = ` -<styled.div +<styled.svg dangerouslySetInnerHTML={ Object { "__html": "<svg><text x=\\"20\\" y=\\"40\\">No LOOP (SVG)</text></svg>", @@ -12,7 +12,7 @@ exports[`Verify LoopSvg Test the render method 1`] = ` `; exports[`Verify LoopSvg Test the render method no loopName 1`] = ` -<styled.div +<styled.svg dangerouslySetInnerHTML={ Object { "__html": "<svg><text x=\\"20\\" y=\\"40\\">No LOOP (SVG)</text></svg>", @@ -23,7 +23,7 @@ exports[`Verify LoopSvg Test the render method no loopName 1`] = ` `; exports[`Verify LoopSvg Test the render method svg not empty 1`] = ` -<styled.div +<styled.svg dangerouslySetInnerHTML={ Object { "__html": "<svg><text test</text></svg>", diff --git a/ui-react/src/theme/globalStyle.js b/ui-react/src/theme/globalStyle.js index 3656f9e98..64fd7c5d9 100644 --- a/ui-react/src/theme/globalStyle.js +++ b/ui-react/src/theme/globalStyle.js @@ -87,6 +87,9 @@ export const DefaultClampTheme = { loopViewerHeaderBackgroundColor: '#337ab7', loopViewerHeaderFontColor: 'white', + loopLogsHeaderBackgroundColor: 'white', + loopLogsHeaderFontColor: 'black', + menuBackgroundColor: 'white', menuFontColor: 'black', menuHighlightedBackgroundColor: '#337ab7', diff --git a/version.properties b/version.properties index 578d597a3..cdbe71c1f 100644 --- a/version.properties +++ b/version.properties @@ -27,7 +27,7 @@ major=5 minor=0 -patch=3 +patch=5 base_version=${major}.${minor}.${patch} |