diff options
author | Vidyashree-Huawei <vidyashree.rama@huawei.com> | 2020-04-20 12:18:50 +0530 |
---|---|---|
committer | Vidyashree-Huawei <vidyashree.rama@huawei.com> | 2020-04-21 20:28:13 +0530 |
commit | 472dc126eb9f30c09df344357db2c62f20d0b92c (patch) | |
tree | ee2ab2696d67547c2822fb5e22d618bc51f9fd5e | |
parent | bd6abe51f90936ecb4a7de92a3f40978675a2886 (diff) |
Payload is expected as string in operational policy
1. converted json to string for legacy operational policy
2. added payload data as default string value for generic operational policy
Change-Id: If63423c24d736623b227537f0f83edeaac819215
Issue-ID: CLAMP-831
Signed-off-by: Vidyashree-Huawei <vidyashree.rama@huawei.com>
10 files changed, 405 insertions, 524 deletions
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 c15641413..c92cad1f5 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,9 +23,7 @@ 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; @@ -133,20 +131,14 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { return result; } - private static JsonObject createAnyOfJsonProperty(String name, String defaultValue) { + private static JsonObject createAnyOfJsonProperty(String name, + String defaultValue, + boolean readOnlyFlag) { JsonObject result = new JsonObject(); result.addProperty("title", name); result.addProperty("type", "string"); result.addProperty("default", defaultValue); - result.addProperty("readOnly", "True"); - return result; - } - - private static JsonObject createAnyOfJsonObject(String name, JsonObject allProperties) { - JsonObject result = new JsonObject(); - result.addProperty("title", name); - result.addProperty("type", "object"); - result.add("properties", allProperties); + result.addProperty("readOnly", readOnlyFlag); return result; } @@ -173,66 +165,37 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess { JsonObject inputs = workFlow.getAsJsonObject("inputs"); JsonObject jsonObject = new JsonObject(); jsonObject.add("artifact_name", createAnyOfJsonProperty( - "artifact name", artifactName)); + "artifact name", artifactName, true)); jsonObject.add("artifact_version", createAnyOfJsonProperty( - "artifact version", artifactVersion)); - jsonObject.add("mode", createCdsInputProperty( - "mode", "string", "async", null)); + "artifact version", artifactVersion, true)); + jsonObject.add("mode", createAnyOfJsonProperty( + "mode", "async", false)); 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)); + data.addProperty("type", "string"); + data.addProperty("format", "textarea"); + JsonObject defaultValue = new JsonObject(); + addDefaultValueForData(inputs, defaultValue); + data.addProperty("default", defaultValue.toString()); return data; } - private static JsonObject addDataFields(JsonObject inputs) { - JsonObject jsonObject = new JsonObject(); + private static void addDefaultValueForData(JsonObject inputs, + JsonObject defaultValue) { 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()))); + addDefaultValueForData(entry.getValue().getAsJsonObject(), defaultValue); } else { - jsonObject.add(entry.getKey(), - createCdsInputProperty(key, - inputProperty.get("type").getAsString(), - null, - entry.getValue().getAsJsonObject())); + defaultValue.addProperty(entry.getKey(), ""); } } - 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/policy/operational/LegacyOperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java index 3765277d8..a7a344df2 100644 --- a/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java +++ b/src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java @@ -234,6 +234,11 @@ public class LegacyOperationalPolicy { JsonObject payloadObject = payloadElem != null ? payloadElem.getAsJsonObject() : null; if (payloadObject != null) { + /* Since policy expects payload to be map of string, + converting data object to string. */ + JsonObject dataObject = payloadObject.get("data").getAsJsonObject(); + payloadObject.remove("data"); + payloadObject.addProperty("data", dataObject.toString()); policy.getAsJsonObject().add(PAYLOAD, payloadObject); } else { 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 4e362d841..57d13ef17 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java @@ -24,8 +24,6 @@ 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; @@ -33,7 +31,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import java.io.IOException; +import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.clds.util.ResourceFileUtil; @@ -44,6 +44,10 @@ public class OperationalPolicyRepresentationBuilder { private static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyRepresentationBuilder.class); + public static final String PROPERTIES = "properties"; + public static final String TYPE = "type"; + public static final String TYPE_LIST = "list"; + /** * This method generates the operational policy json representation that will be * used by ui for rendering. It uses the model (VF and VFModule) defined in the @@ -213,7 +217,7 @@ public class OperationalPolicyRepresentationBuilder { private static JsonObject createPayloadProperty(JsonObject workFlow, JsonObject controllerProperties, String workFlowName) { JsonObject payload = new JsonObject(); - payload.addProperty("title", "Payload (YAML)"); + payload.addProperty("title", "Payload"); payload.addProperty("type", "object"); payload.add("properties", createInputPropertiesForPayload(workFlow, controllerProperties)); @@ -233,4 +237,82 @@ public class OperationalPolicyRepresentationBuilder { recipe.add("options", options); return recipe; } + + /** + * 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", createSchemaProperty( + "artifact name", "string", artifactName, "True", null)); + jsonObject.add("artifact_version", createSchemaProperty( + "artifact version", "string", artifactVersion, "True", null)); + 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"); + JsonObject dataObj = new JsonObject(); + addDataFields(inputs, dataObj); + data.add(PROPERTIES, dataObj); + return data; + } + + private static void addDataFields(JsonObject inputs, + JsonObject dataObj) { + 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) { + addDataFields(entry.getValue().getAsJsonObject(), dataObj); + } else { + dataObj.add(entry.getKey(), + createCdsInputProperty(key, + inputProperty.get(TYPE).getAsString(), + null, + entry.getValue().getAsJsonObject())); + } + } + } + + 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 dataObject = new JsonObject(); + addDataFields(cdsProperty.get(PROPERTIES).getAsJsonObject(), + dataObject); + JsonObject listProperties = new JsonObject(); + listProperties.add(PROPERTIES, dataObject); + property.add("items", listProperties); + } + } else { + property.addProperty(TYPE, type); + } + + if (defaultValue != null) { + property.addProperty("default", defaultValue); + } + return property; + } } 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 793ba5e7f..ad985292c 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 @@ -76,57 +76,25 @@ "title": "artifact name", "type": "string", "default": "baseconfiguration", - "readOnly": "True" + "readOnly": true }, "artifact_version": { "title": "artifact version", "type": "string", "default": "1.0.0", - "readOnly": "True" + "readOnly": true }, "mode": { "title": "mode", "type": "string", - "default": "async" + "default": "async", + "readOnly": false }, "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" - } - } - } - } + "type": "string", + "format": "textarea", + "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}" } } }, @@ -137,57 +105,25 @@ "title": "artifact name", "type": "string", "default": "baseconfiguration", - "readOnly": "True" + "readOnly": true }, "artifact_version": { "title": "artifact version", "type": "string", "default": "1.0.0", - "readOnly": "True" + "readOnly": true }, "mode": { "title": "mode", "type": "string", - "default": "async" + "default": "async", + "readOnly": false }, "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" - } - } - } - } + "type": "string", + "format": "textarea", + "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}" } } }, @@ -198,57 +134,25 @@ "title": "artifact name", "type": "string", "default": "baseconfiguration", - "readOnly": "True" + "readOnly": true }, "artifact_version": { "title": "artifact version", "type": "string", "default": "1.0.0", - "readOnly": "True" + "readOnly": true }, "mode": { "title": "mode", "type": "string", - "default": "async" + "default": "async", + "readOnly": false }, "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" - } - } - } - } + "type": "string", + "format": "textarea", + "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}" } } }, @@ -259,57 +163,25 @@ "title": "artifact name", "type": "string", "default": "baseconfiguration", - "readOnly": "True" + "readOnly": true }, "artifact_version": { "title": "artifact version", "type": "string", "default": "1.0.0", - "readOnly": "True" + "readOnly": true }, "mode": { "title": "mode", "type": "string", - "default": "async" + "default": "async", + "readOnly": false }, "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" - } - } - } - } + "type": "string", + "format": "textarea", + "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}" } } }, @@ -320,57 +192,25 @@ "title": "artifact name", "type": "string", "default": "baseconfiguration", - "readOnly": "True" + "readOnly": true }, "artifact_version": { "title": "artifact version", "type": "string", "default": "1.0.0", - "readOnly": "True" + "readOnly": true }, "mode": { "title": "mode", "type": "string", - "default": "async" + "default": "async", + "readOnly": false }, "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" - } - } - } - } + "type": "string", + "format": "textarea", + "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}" } } }, @@ -381,57 +221,25 @@ "title": "artifact name", "type": "string", "default": "baseconfiguration", - "readOnly": "True" + "readOnly": true }, "artifact_version": { "title": "artifact version", "type": "string", "default": "1.0.0", - "readOnly": "True" + "readOnly": true }, "mode": { "title": "mode", "type": "string", - "default": "async" + "default": "async", + "readOnly": false }, "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" - } - } - } - } + "type": "string", + "format": "textarea", + "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}" } } } 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 index 24269ec79..13b468ea0 100644 --- a/src/test/resources/tosca/operational-policy-cds-payload-with-list.json +++ b/src/test/resources/tosca/operational-policy-cds-payload-with-list.json @@ -258,7 +258,7 @@ } }, "payload": { - "title": "Payload (YAML)", + "title": "Payload", "type": "object", "properties": { "artifact_name": { @@ -297,15 +297,9 @@ } } }, - "resource-assignment-properties": { - "title": "resource-assignment-properties", - "type": "object", - "properties": { - "private1-prefix-id": { - "title": "private1-prefix-id", - "type": "string" - } - } + "private1-prefix-id": { + "title": "private1-prefix-id", + "type": "string" } } } diff --git a/src/test/resources/tosca/operational-policy-json-schema.json b/src/test/resources/tosca/operational-policy-json-schema.json index 87457f1d2..9dee089e0 100644 --- a/src/test/resources/tosca/operational-policy-json-schema.json +++ b/src/test/resources/tosca/operational-policy-json-schema.json @@ -258,7 +258,7 @@ } }, "payload": { - "title": "Payload (YAML)", + "title": "Payload", "type": "object", "properties": { "artifact_name": { @@ -281,39 +281,33 @@ "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" - } - } + "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" } } } @@ -334,7 +328,7 @@ } }, "payload": { - "title": "Payload (YAML)", + "title": "Payload", "type": "object", "properties": { "artifact_name": { @@ -357,39 +351,33 @@ "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" - } - } + "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" } } } @@ -410,7 +398,7 @@ } }, "payload": { - "title": "Payload (YAML)", + "title": "Payload", "type": "object", "properties": { "artifact_name": { @@ -433,39 +421,33 @@ "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" - } - } + "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" } } } @@ -486,7 +468,7 @@ } }, "payload": { - "title": "Payload (YAML)", + "title": "Payload", "type": "object", "properties": { "artifact_name": { @@ -509,39 +491,33 @@ "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" - } - } + "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" } } } @@ -562,7 +538,7 @@ } }, "payload": { - "title": "Payload (YAML)", + "title": "Payload", "type": "object", "properties": { "artifact_name": { @@ -585,39 +561,33 @@ "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" - } - } + "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" } } } @@ -638,7 +608,7 @@ } }, "payload": { - "title": "Payload (YAML)", + "title": "Payload", "type": "object", "properties": { "artifact_name": { @@ -661,39 +631,33 @@ "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" - } - } + "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" } } } diff --git a/src/test/resources/tosca/operational-policy-payload-legacy.yaml b/src/test/resources/tosca/operational-policy-payload-legacy.yaml index 72bbf9bad..1108ec8b9 100644 --- a/src/test/resources/tosca/operational-policy-payload-legacy.yaml +++ b/src/test/resources/tosca/operational-policy-payload-legacy.yaml @@ -50,15 +50,7 @@ policies: 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 + 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"}}' mode: async recipe: resource-assignment retry: 0 @@ -72,3 +64,27 @@ 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: policy4 + payload: + artifact_name: baseconfiguration + artifact_version: 1.0.0 + data: '{}' + mode: async + recipe: modify-config + 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 e53950af3..0bb5582eb 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-+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" + "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+%27%7B%22resource-assignment-properties%22%3A%7B%22request-id%22%3A%22request-id%22%2C%22service-instance-id%22%3A%22service-instance-id%22%2C%22vnf-id%22%3A%22vnf-id%22%2C%22action-name%22%3A%22action-name%22%2C%22scope-type%22%3A%22scope-type%22%2C%22hostname%22%3A%22hostname%22%2C%22vnf_name%22%3A%22vnf_name%22%7D%7D%27%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-+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+policy4%0A++payload%3A%0A++++artifact_name%3A+baseconfiguration%0A++++artifact_version%3A+1.0.0%0A++++data%3A+%27%7B%7D%27%0A++++mode%3A+async%0A++recipe%3A+modify-config%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 aaa962769..a756b57d6 100644 --- a/src/test/resources/tosca/operational-policy-payload.yaml +++ b/src/test/resources/tosca/operational-policy-payload.yaml @@ -73,12 +73,28 @@ topology_template: 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 + 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: policy4 + 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: modify-config + payload: + artifact_name: baseconfiguration + artifact_version: 1.0.0 + mode: async + data: '{}' diff --git a/src/test/resources/tosca/operational-policy-properties.json b/src/test/resources/tosca/operational-policy-properties.json index 2777a158c..aaf9dc378 100644 --- a/src/test/resources/tosca/operational-policy-properties.json +++ b/src/test/resources/tosca/operational-policy-properties.json @@ -93,6 +93,39 @@ "modelVersion": "1", "modelCustomizationId": "1bffdc31-a37d-4dee-b65c-dde623a76e52" } + }, + { + "actor": { + "actor": "CDS", + "recipe": { + "recipe": "modify-config", + "payload": { + "artifact_name": "baseconfiguration", + "artifact_version": "1.0.0", + "mode": "async", + "data": { + } + } + } + }, + "id": "policy4", + "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" + } } ] }, |