summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--extra/docker/clamp/clamp.env2
-rw-r--r--src/main/java/org/onap/clamp/clds/Application.java3
-rw-r--r--src/main/java/org/onap/clamp/clds/client/CdsServices.java24
-rw-r--r--src/main/java/org/onap/clamp/clds/config/EncodedPasswordBasicDataSource.java58
-rw-r--r--src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java14
-rw-r--r--src/main/java/org/onap/clamp/clds/exception/cds/CdsParametersException.java53
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/JsonEditorSchemaConstants.java15
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/ToscaSchemaConstants.java5
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java106
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java60
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopService.java6
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/LegacyOperationalPolicy.java5
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java88
-rw-r--r--src/main/resources/application-noaaf.properties26
-rw-r--r--src/main/resources/application.properties24
-rw-r--r--src/test/java/org/onap/clamp/clds/client/CdsServicesTest.java58
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertorTestItCase.java85
-rw-r--r--src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java13
-rw-r--r--src/test/resources/application.properties24
-rw-r--r--src/test/resources/example/cds-response/vFW-CDS-modify-config-wf-expected-result.json58
-rw-r--r--src/test/resources/example/cds-response/vFW-CDS-modify-config-workflow.json75
-rw-r--r--src/test/resources/example/cds-response/vFW-CDS-resource-assignment-wf-expected-result.json42
-rw-r--r--src/test/resources/example/cds-response/vFW-CDS-resource-assignment-workflow.json78
-rw-r--r--src/test/resources/example/json-editor-schema/tca-policy-json-editor-schema.json2
-rw-r--r--src/test/resources/https/https-test.properties24
-rw-r--r--src/test/resources/tosca/model-properties-cds.json151
-rw-r--r--src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json312
-rw-r--r--src/test/resources/tosca/operational-policy-cds-payload-with-list.json736
-rw-r--r--src/test/resources/tosca/operational-policy-json-schema.json432
-rw-r--r--src/test/resources/tosca/operational-policy-payload-legacy.yaml34
-rw-r--r--src/test/resources/tosca/operational-policy-payload.json2
-rw-r--r--src/test/resources/tosca/operational-policy-payload.yaml34
-rw-r--r--src/test/resources/tosca/operational-policy-properties.json33
-rw-r--r--src/test/resources/tosca/policy-yaml-to-json-with-constraints.json2
-rw-r--r--src/test/resources/tosca/policy-yaml-to-json-with-datatypes.json2
-rw-r--r--src/test/resources/tosca/policy-yaml-to-json.json2
-rw-r--r--src/test/resources/tosca/tosca_metadata_clamp_possible_values_json_schema.json16
-rw-r--r--src/test/resources/tosca/tosca_with_date_time_json_schema.json240
-rw-r--r--ui-react/src/api/LoopService.js13
-rw-r--r--ui-react/src/components/dialogs/Loop/ModifyLoopModal.js27
41 files changed, 2188 insertions, 802 deletions
diff --git a/README.md b/README.md
index 65fc0530..e4309aac 100644
--- a/README.md
+++ b/README.md
@@ -41,9 +41,9 @@ Note that all others configurations can be configured in the JSON as well,
```json
{
- "spring.datasource.cldsdb.url": "jdbc:mysql://anotherDB.onap.org:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3",
- "spring.datasource.cldsdb.username": "admin",
- "spring.datasource.cldsdb.password": "password"
+ "spring.datasource.url": "jdbc:mysql://anotherDB.onap.org:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3",
+ "spring.datasource.username": "admin",
+ "spring.datasource.password": "password"
"clamp.config.dcae.inventory.url": "http://dcaegen2.host:8080",
"clamp.config.dcae.dispatcher.url": "http://dcaegen2.host:8080",
diff --git a/extra/docker/clamp/clamp.env b/extra/docker/clamp/clamp.env
index 3270db2c..fc80be5d 100644
--- a/extra/docker/clamp/clamp.env
+++ b/extra/docker/clamp/clamp.env
@@ -1,2 +1,2 @@
### Be careful, this must be in one line only ###
-SPRING_APPLICATION_JSON={"spring.datasource.cldsdb.url":"jdbc:mariadb:sequential://db:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3","spring.profiles.active":"clamp-default,clamp-default-user,clamp-sdc-controller,clamp-ssl-config","clamp.config.policy.api.url":"http4://third-party-proxy:8085","clamp.config.policy.pap.url":"http4://third-party-proxy:8085","clamp.config.dcae.inventory.url":"http://third-party-proxy:8085","clamp.config.dcae.deployment.url":"http4://third-party-proxy:8085"}
+SPRING_APPLICATION_JSON={"spring.datasource.url":"jdbc:mariadb:sequential://db:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3","spring.profiles.active":"clamp-default,clamp-default-user,clamp-sdc-controller,clamp-ssl-config","clamp.config.policy.api.url":"http4://third-party-proxy:8085","clamp.config.policy.pap.url":"http4://third-party-proxy:8085","clamp.config.dcae.inventory.url":"http://third-party-proxy:8085","clamp.config.dcae.deployment.url":"http4://third-party-proxy:8085"}
diff --git a/src/main/java/org/onap/clamp/clds/Application.java b/src/main/java/org/onap/clamp/clds/Application.java
index 63320d2f..84232999 100644
--- a/src/main/java/org/onap/clamp/clds/Application.java
+++ b/src/main/java/org/onap/clamp/clds/Application.java
@@ -65,8 +65,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@ComponentScan(basePackages = { "org.onap.clamp" })
-@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, SecurityAutoConfiguration.class,
- UserDetailsServiceAutoConfiguration.class })
+@SpringBootApplication(exclude = { SecurityAutoConfiguration.class, UserDetailsServiceAutoConfiguration.class })
@EnableJpaRepositories(basePackages = { "org.onap.clamp" })
@EntityScan(basePackages = { "org.onap.clamp" })
@EnableTransactionManagement
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 f25e8b80..b8eb4194 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,6 +136,9 @@ 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.add(key, entry.getValue());
}
@@ -142,6 +146,24 @@ public class CdsServices {
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/config/EncodedPasswordBasicDataSource.java b/src/main/java/org/onap/clamp/clds/config/EncodedPasswordBasicDataSource.java
deleted file mode 100644
index 0d39cd54..00000000
--- a/src/main/java/org/onap/clamp/clds/config/EncodedPasswordBasicDataSource.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.config;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import java.security.GeneralSecurityException;
-
-import org.apache.commons.codec.DecoderException;
-import org.apache.commons.dbcp.BasicDataSource;
-import org.onap.clamp.clds.util.CryptoUtils;
-
-/**
- * This class is an extension of the standard datasource, it will be used to
- * decode the encoded password defined in the application.properties.
- *
- */
-public class EncodedPasswordBasicDataSource extends BasicDataSource {
- protected static final EELFLogger logger = EELFManager.getInstance()
- .getLogger(EncodedPasswordBasicDataSource.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
-
- /**
- * This method is used automatically by Spring to decode the password.
- */
- @Override
- public synchronized void setPassword(String encodedPassword) {
- try {
- this.password = CryptoUtils.decrypt(encodedPassword);
- } catch (GeneralSecurityException e) {
- logger.error("Unable to decrypt the DB password", e);
- } catch (DecoderException e) {
- logger.error("Exception caught when decoding the HEX String Key for encryption", e);
- }
- }
-} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java b/src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java
index b2478462..14c08c80 100644
--- a/src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java
@@ -23,13 +23,9 @@
package org.onap.clamp.clds.config.spring;
-import javax.sql.DataSource;
-
import org.onap.clamp.clds.config.ClampProperties;
-import org.onap.clamp.clds.config.EncodedPasswordBasicDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
-import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -44,16 +40,6 @@ public class CldsConfiguration {
@Autowired
private ClampProperties refProp;
- /**
- * Clds Identity database DataSource configuration.
- *
- * @return encoded password data source
- */
- @Bean(name = "cldsDataSource")
- @ConfigurationProperties(prefix = "spring.datasource.cldsdb")
- public DataSource cldsDataSource() {
- return new EncodedPasswordBasicDataSource();
- }
/**
* This loads the file system.properties.
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 00000000..73ce31f8
--- /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 fdc94231..e3c66169 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 9601649c..d00c431c 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 666ca670..45bb87ed 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 ce1f9469..c92cad1f 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,6 +23,8 @@
package org.onap.clamp.clds.tosca.update.execution.cds;
+import static org.onap.clamp.clds.tosca.ToscaSchemaConstants.TYPE;
+
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -129,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;
}
@@ -169,53 +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"));
+ "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())));
+ if (inputProperty.get(TYPE) == null) {
+ addDefaultValueForData(entry.getValue().getAsJsonObject(), defaultValue);
} else {
- jsonObject.add(entry.getKey(),
- createCdsInputProperty(key,
- inputProperty.get("type").getAsString(),
- null));
+ defaultValue.addProperty(entry.getKey(), "");
}
}
- return jsonObject;
- }
-
- private static JsonObject createCdsInputProperty(String title,
- String type,
- String defaultValue) {
- JsonObject property = new JsonObject();
- property.addProperty("title", title);
- property.addProperty("type", type);
- if (defaultValue != null) {
- property.addProperty("default", defaultValue);
- }
- property.addProperty("format", "textarea");
- return property;
}
}
diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java
index ca3681b6..3f568a33 100644
--- a/src/main/java/org/onap/clamp/loop/LoopService.java
+++ b/src/main/java/org/onap/clamp/loop/LoopService.java
@@ -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;
}
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 3765277d..a7a344df 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 4e362d84..57d13ef1 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/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties
index 044fcecf..fba41348 100644
--- a/src/main/resources/application-noaaf.properties
+++ b/src/main/resources/application-noaaf.properties
@@ -96,21 +96,21 @@ camel.springboot.xmlRests=classpath:/clds/camel/rest/*.xml
#camel.springboot.typeConversion = false
#clds datasource connection details
-spring.datasource.cldsdb.driverClassName=org.mariadb.jdbc.Driver
-spring.datasource.cldsdb.url=jdbc:mariadb:sequential://localhost:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3
-spring.datasource.cldsdb.username=clds
-spring.datasource.cldsdb.password=4c90a0b48204383f4283448d23e0b885a47237b2a23588e7c4651604f51c1067
-spring.datasource.cldsdb.validationQuery=SELECT 1
-spring.datasource.cldsdb.validationQueryTimeout=20000
-spring.datasource.cldsdb.validationInterval=30000
-spring.datasource.cldsdb.testWhileIdle = true
-spring.datasource.cldsdb.minIdle = 0
-spring.datasource.cldsdb.initialSize=0
+spring.datasource.driverClassName=org.mariadb.jdbc.Driver
+spring.datasource.url=jdbc:mariadb:sequential://localhost:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3
+spring.datasource.username=clds
+spring.datasource.password=sidnnd83K
+spring.datasource.validationQuery=SELECT 1
+spring.datasource.validationQueryTimeout=20000
+spring.datasource.validationInterval=30000
+spring.datasource.testWhileIdle = true
+spring.datasource.minIdle = 0
+spring.datasource.initialSize=0
# Automatically test whether a connection provided is good or not
-spring.datasource.cldsdb.testOnBorrow=true
-spring.datasource.cldsdb.ignoreExceptionOnPreLoad=true
+spring.datasource.testOnBorrow=true
+spring.datasource.ignoreExceptionOnPreLoad=true
# control the sql db initialization (from schema.sql and data.sql)
-spring.datasource.initialize=false
+spring.datasource..initialize=false
spring.jpa.properties.javax.persistence.schema-generation.database.action=none
s#pring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 3069cf63..c5bab26c 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -100,19 +100,19 @@ camel.springboot.xmlRests=classpath:/clds/camel/rest/*.xml
#camel.springboot.typeConversion = false
#clds datasource connection details
-spring.datasource.cldsdb.driverClassName=org.mariadb.jdbc.Driver
-spring.datasource.cldsdb.url=jdbc:mariadb:sequential://localhost:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3
-spring.datasource.cldsdb.username=clds
-spring.datasource.cldsdb.password=4c90a0b48204383f4283448d23e0b885a47237b2a23588e7c4651604f51c1067
-spring.datasource.cldsdb.validationQuery=SELECT 1
-spring.datasource.cldsdb.validationQueryTimeout=20000
-spring.datasource.cldsdb.validationInterval=30000
-spring.datasource.cldsdb.testWhileIdle = true
-spring.datasource.cldsdb.minIdle = 0
-spring.datasource.cldsdb.initialSize=0
+spring.datasource.driverClassName=org.mariadb.jdbc.Driver
+spring.datasource.url=jdbc:mariadb:sequential://localhost:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3
+spring.datasource.username=clds
+spring.datasource.password=sidnnd83K
+spring.datasource.validationQuery=SELECT 1
+spring.datasource.validationQueryTimeout=20000
+spring.datasource.validationInterval=30000
+spring.datasource.testWhileIdle = true
+spring.datasource.minIdle = 0
+spring.datasource.initialSize=0
# Automatically test whether a connection provided is good or not
-spring.datasource.cldsdb.testOnBorrow=true
-spring.datasource.cldsdb.ignoreExceptionOnPreLoad=true
+spring.datasource.testOnBorrow=true
+spring.datasource.ignoreExceptionOnPreLoad=true
spring.jpa.properties.javax.persistence.schema-generation.database.action=none
#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
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 00000000..ec39fc3d
--- /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 a32d4995..b26f3ede 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/policy/operational/OperationalPolicyRepresentationBuilderTest.java b/src/test/java/org/onap/clamp/policy/operational/OperationalPolicyRepresentationBuilderTest.java
index 4e9b5620..a6a49682 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/application.properties b/src/test/resources/application.properties
index ea17836a..a8ec7add 100644
--- a/src/test/resources/application.properties
+++ b/src/test/resources/application.properties
@@ -85,19 +85,19 @@ camel.springboot.xmlRests=classpath:/clds/camel/rest/*.xml
#camel.springboot.typeConversion = false
#clds datasource connection details
-spring.datasource.cldsdb.driverClassName=org.mariadb.jdbc.Driver
-spring.datasource.cldsdb.url=jdbc:mariadb:sequential://localhost:3306,localhost:${docker.mariadb.port.host}/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3
-spring.datasource.cldsdb.username=clds
-spring.datasource.cldsdb.password=4c90a0b48204383f4283448d23e0b885a47237b2a23588e7c4651604f51c1067
-spring.datasource.cldsdb.validationQuery=SELECT 1
-spring.datasource.cldsdb.validationQueryTimeout=20000
-spring.datasource.cldsdb.validationInterval=30000
-spring.datasource.cldsdb.testWhileIdle = true
-spring.datasource.cldsdb.minIdle = 0
-spring.datasource.cldsdb.initialSize=0
+spring.datasource.driverClassName=org.mariadb.jdbc.Driver
+spring.datasource.url=jdbc:mariadb:sequential://localhost:3306,localhost:${docker.mariadb.port.host}/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3
+spring.datasource.username=clds
+spring.datasource.password=sidnnd83K
+spring.datasource.validationQuery=SELECT 1
+spring.datasource.validationQueryTimeout=20000
+spring.datasource.validationInterval=30000
+spring.datasource.testWhileIdle = true
+spring.datasource.minIdle = 0
+spring.datasource.initialSize=0
# Automatically test whether a connection provided is good or not
-spring.datasource.cldsdb.testOnBorrow=true
-spring.datasource.cldsdb.ignoreExceptionOnPreLoad=true
+spring.datasource.testOnBorrow=true
+spring.datasource.ignoreExceptionOnPreLoad=true
spring.jpa.properties.javax.persistence.schema-generation.database.action=none
#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
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 00000000..7e78bb06
--- /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 00000000..e46da676
--- /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 00000000..5b373a45
--- /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 00000000..d0f78cf1
--- /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 11b91dfb..91603972 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/https/https-test.properties b/src/test/resources/https/https-test.properties
index 46bca153..df1823f8 100644
--- a/src/test/resources/https/https-test.properties
+++ b/src/test/resources/https/https-test.properties
@@ -72,19 +72,19 @@ spring.profiles.active=clamp-default, clamp-aaf-authentication,clamp-ssl-config
#clds datasource connection details
-spring.datasource.cldsdb.driverClassName=org.mariadb.jdbc.Driver
-spring.datasource.cldsdb.url=jdbc:mariadb:sequential://localhost:${docker.mariadb.port.host}/cldsdb4?autoReconnect=true&retriesAllDown=2147483647&failoverLoopRetries=2147483647
-spring.datasource.cldsdb.username=clds
-spring.datasource.cldsdb.password=4c90a0b48204383f4283448d23e0b885a47237b2a23588e7c4651604f51c1067
-spring.datasource.cldsdb.validationQuery=SELECT 1
-spring.datasource.cldsdb.validationQueryTimeout=20000
-spring.datasource.cldsdb.validationInterval=30000
-spring.datasource.cldsdb.testWhileIdle = true
-spring.datasource.cldsdb.minIdle = 0
-spring.datasource.cldsdb.initialSize=0
+spring.datasource.driverClassName=org.mariadb.jdbc.Driver
+spring.datasource.url=jdbc:mariadb:sequential://localhost:${docker.mariadb.port.host}/cldsdb4?autoReconnect=true&retriesAllDown=2147483647&failoverLoopRetries=2147483647
+spring.datasource.username=clds
+spring.datasource.password=sidnnd83K
+spring.datasource.validationQuery=SELECT 1
+spring.datasource.validationQueryTimeout=20000
+spring.datasource.validationInterval=30000
+spring.datasource.testWhileIdle = true
+spring.datasource.minIdle = 0
+spring.datasource.initialSize=0
# Automatically test whether a connection provided is good or not
-spring.datasource.cldsdb.testOnBorrow=true
-spring.datasource.cldsdb.ignoreExceptionOnPreLoad=true
+spring.datasource.testOnBorrow=true
+spring.datasource.ignoreExceptionOnPreLoad=true
camel.springboot.consumer-template-cache-size=1000
camel.springboot.producer-template-cache-size=1000
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 00000000..591840b4
--- /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/new-converter/tosca_apex_with_metadata.json b/src/test/resources/tosca/new-converter/tosca_apex_with_metadata.json
index 12edd773..ad985292 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,65 +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",
- "format": "textarea"
+ "readOnly": false
},
"data": {
"title": "data",
- "properties": {
- "resource-assignment-properties": {
- "title": "resource-assignment-properties",
- "type": "object",
- "properties": {
- "request-id": {
- "title": "request-id",
- "type": "string",
- "format": "textarea"
- },
- "service-instance-id": {
- "title": "service-instance-id",
- "type": "string",
- "format": "textarea"
- },
- "vnf-id": {
- "title": "vnf-id",
- "type": "string",
- "format": "textarea"
- },
- "action-name": {
- "title": "action-name",
- "type": "string",
- "format": "textarea"
- },
- "scope-type": {
- "title": "scope-type",
- "type": "string",
- "format": "textarea"
- },
- "hostname": {
- "title": "hostname",
- "type": "string",
- "format": "textarea"
- },
- "vnf_name": {
- "title": "vnf_name",
- "type": "string",
- "format": "textarea"
- }
- }
- }
- }
+ "type": "string",
+ "format": "textarea",
+ "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}"
}
}
},
@@ -145,65 +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",
- "format": "textarea"
+ "readOnly": false
},
"data": {
"title": "data",
- "properties": {
- "resource-assignment-properties": {
- "title": "resource-assignment-properties",
- "type": "object",
- "properties": {
- "request-id": {
- "title": "request-id",
- "type": "string",
- "format": "textarea"
- },
- "service-instance-id": {
- "title": "service-instance-id",
- "type": "string",
- "format": "textarea"
- },
- "vnf-id": {
- "title": "vnf-id",
- "type": "string",
- "format": "textarea"
- },
- "action-name": {
- "title": "action-name",
- "type": "string",
- "format": "textarea"
- },
- "scope-type": {
- "title": "scope-type",
- "type": "string",
- "format": "textarea"
- },
- "hostname": {
- "title": "hostname",
- "type": "string",
- "format": "textarea"
- },
- "vnf_name": {
- "title": "vnf_name",
- "type": "string",
- "format": "textarea"
- }
- }
- }
- }
+ "type": "string",
+ "format": "textarea",
+ "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}"
}
}
},
@@ -214,65 +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",
- "format": "textarea"
+ "readOnly": false
},
"data": {
"title": "data",
- "properties": {
- "resource-assignment-properties": {
- "title": "resource-assignment-properties",
- "type": "object",
- "properties": {
- "request-id": {
- "title": "request-id",
- "type": "string",
- "format": "textarea"
- },
- "service-instance-id": {
- "title": "service-instance-id",
- "type": "string",
- "format": "textarea"
- },
- "vnf-id": {
- "title": "vnf-id",
- "type": "string",
- "format": "textarea"
- },
- "action-name": {
- "title": "action-name",
- "type": "string",
- "format": "textarea"
- },
- "scope-type": {
- "title": "scope-type",
- "type": "string",
- "format": "textarea"
- },
- "hostname": {
- "title": "hostname",
- "type": "string",
- "format": "textarea"
- },
- "vnf_name": {
- "title": "vnf_name",
- "type": "string",
- "format": "textarea"
- }
- }
- }
- }
+ "type": "string",
+ "format": "textarea",
+ "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}"
}
}
},
@@ -283,65 +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",
- "format": "textarea"
+ "readOnly": false
},
"data": {
"title": "data",
- "properties": {
- "resource-assignment-properties": {
- "title": "resource-assignment-properties",
- "type": "object",
- "properties": {
- "request-id": {
- "title": "request-id",
- "type": "string",
- "format": "textarea"
- },
- "service-instance-id": {
- "title": "service-instance-id",
- "type": "string",
- "format": "textarea"
- },
- "vnf-id": {
- "title": "vnf-id",
- "type": "string",
- "format": "textarea"
- },
- "action-name": {
- "title": "action-name",
- "type": "string",
- "format": "textarea"
- },
- "scope-type": {
- "title": "scope-type",
- "type": "string",
- "format": "textarea"
- },
- "hostname": {
- "title": "hostname",
- "type": "string",
- "format": "textarea"
- },
- "vnf_name": {
- "title": "vnf_name",
- "type": "string",
- "format": "textarea"
- }
- }
- }
- }
+ "type": "string",
+ "format": "textarea",
+ "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}"
}
}
},
@@ -352,65 +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",
- "format": "textarea"
+ "readOnly": false
},
"data": {
"title": "data",
- "properties": {
- "resource-assignment-properties": {
- "title": "resource-assignment-properties",
- "type": "object",
- "properties": {
- "request-id": {
- "title": "request-id",
- "type": "string",
- "format": "textarea"
- },
- "service-instance-id": {
- "title": "service-instance-id",
- "type": "string",
- "format": "textarea"
- },
- "vnf-id": {
- "title": "vnf-id",
- "type": "string",
- "format": "textarea"
- },
- "action-name": {
- "title": "action-name",
- "type": "string",
- "format": "textarea"
- },
- "scope-type": {
- "title": "scope-type",
- "type": "string",
- "format": "textarea"
- },
- "hostname": {
- "title": "hostname",
- "type": "string",
- "format": "textarea"
- },
- "vnf_name": {
- "title": "vnf_name",
- "type": "string",
- "format": "textarea"
- }
- }
- }
- }
+ "type": "string",
+ "format": "textarea",
+ "default": "{\"request-id\":\"\",\"service-instance-id\":\"\",\"vnf-id\":\"\",\"action-name\":\"\",\"scope-type\":\"\",\"hostname\":\"\",\"vnf_name\":\"\"}"
}
}
},
@@ -421,65 +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",
- "format": "textarea"
+ "readOnly": false
},
"data": {
"title": "data",
- "properties": {
- "resource-assignment-properties": {
- "title": "resource-assignment-properties",
- "type": "object",
- "properties": {
- "request-id": {
- "title": "request-id",
- "type": "string",
- "format": "textarea"
- },
- "service-instance-id": {
- "title": "service-instance-id",
- "type": "string",
- "format": "textarea"
- },
- "vnf-id": {
- "title": "vnf-id",
- "type": "string",
- "format": "textarea"
- },
- "action-name": {
- "title": "action-name",
- "type": "string",
- "format": "textarea"
- },
- "scope-type": {
- "title": "scope-type",
- "type": "string",
- "format": "textarea"
- },
- "hostname": {
- "title": "hostname",
- "type": "string",
- "format": "textarea"
- },
- "vnf_name": {
- "title": "vnf_name",
- "type": "string",
- "format": "textarea"
- }
- }
- }
- }
+ "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
new file mode 100644
index 00000000..13b468ea
--- /dev/null
+++ b/src/test/resources/tosca/operational-policy-cds-payload-with-list.json
@@ -0,0 +1,736 @@
+{
+ "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",
+ "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"
+ }
+ }
+ }
+ },
+ "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 ffa88eca..9dee089e 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": {
@@ -276,52 +276,38 @@
"mode": {
"title": "mode",
"type": "string",
- "default": "async",
- "format": "textarea"
+ "default": "async"
},
"data": {
"title": "data",
"properties": {
- "resource-assignment-properties": {
- "title": "resource-assignment-properties",
- "type": "object",
- "properties": {
- "request-id": {
- "title": "request-id",
- "type": "string",
- "format": "textarea"
- },
- "service-instance-id": {
- "title": "service-instance-id",
- "type": "string",
- "format": "textarea"
- },
- "vnf-id": {
- "title": "vnf-id",
- "type": "string",
- "format": "textarea"
- },
- "action-name": {
- "title": "action-name",
- "type": "string",
- "format": "textarea"
- },
- "scope-type": {
- "title": "scope-type",
- "type": "string",
- "format": "textarea"
- },
- "hostname": {
- "title": "hostname",
- "type": "string",
- "format": "textarea"
- },
- "vnf_name": {
- "title": "vnf_name",
- "type": "string",
- "format": "textarea"
- }
- }
+ "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"
}
}
}
@@ -342,7 +328,7 @@
}
},
"payload": {
- "title": "Payload (YAML)",
+ "title": "Payload",
"type": "object",
"properties": {
"artifact_name": {
@@ -360,52 +346,38 @@
"mode": {
"title": "mode",
"type": "string",
- "default": "async",
- "format": "textarea"
+ "default": "async"
},
"data": {
"title": "data",
"properties": {
- "resource-assignment-properties": {
- "title": "resource-assignment-properties",
- "type": "object",
- "properties": {
- "request-id": {
- "title": "request-id",
- "type": "string",
- "format": "textarea"
- },
- "service-instance-id": {
- "title": "service-instance-id",
- "type": "string",
- "format": "textarea"
- },
- "vnf-id": {
- "title": "vnf-id",
- "type": "string",
- "format": "textarea"
- },
- "action-name": {
- "title": "action-name",
- "type": "string",
- "format": "textarea"
- },
- "scope-type": {
- "title": "scope-type",
- "type": "string",
- "format": "textarea"
- },
- "hostname": {
- "title": "hostname",
- "type": "string",
- "format": "textarea"
- },
- "vnf_name": {
- "title": "vnf_name",
- "type": "string",
- "format": "textarea"
- }
- }
+ "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"
}
}
}
@@ -426,7 +398,7 @@
}
},
"payload": {
- "title": "Payload (YAML)",
+ "title": "Payload",
"type": "object",
"properties": {
"artifact_name": {
@@ -444,52 +416,38 @@
"mode": {
"title": "mode",
"type": "string",
- "default": "async",
- "format": "textarea"
+ "default": "async"
},
"data": {
"title": "data",
"properties": {
- "resource-assignment-properties": {
- "title": "resource-assignment-properties",
- "type": "object",
- "properties": {
- "request-id": {
- "title": "request-id",
- "type": "string",
- "format": "textarea"
- },
- "service-instance-id": {
- "title": "service-instance-id",
- "type": "string",
- "format": "textarea"
- },
- "vnf-id": {
- "title": "vnf-id",
- "type": "string",
- "format": "textarea"
- },
- "action-name": {
- "title": "action-name",
- "type": "string",
- "format": "textarea"
- },
- "scope-type": {
- "title": "scope-type",
- "type": "string",
- "format": "textarea"
- },
- "hostname": {
- "title": "hostname",
- "type": "string",
- "format": "textarea"
- },
- "vnf_name": {
- "title": "vnf_name",
- "type": "string",
- "format": "textarea"
- }
- }
+ "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"
}
}
}
@@ -510,7 +468,7 @@
}
},
"payload": {
- "title": "Payload (YAML)",
+ "title": "Payload",
"type": "object",
"properties": {
"artifact_name": {
@@ -528,52 +486,38 @@
"mode": {
"title": "mode",
"type": "string",
- "default": "async",
- "format": "textarea"
+ "default": "async"
},
"data": {
"title": "data",
"properties": {
- "resource-assignment-properties": {
- "title": "resource-assignment-properties",
- "type": "object",
- "properties": {
- "request-id": {
- "title": "request-id",
- "type": "string",
- "format": "textarea"
- },
- "service-instance-id": {
- "title": "service-instance-id",
- "type": "string",
- "format": "textarea"
- },
- "vnf-id": {
- "title": "vnf-id",
- "type": "string",
- "format": "textarea"
- },
- "action-name": {
- "title": "action-name",
- "type": "string",
- "format": "textarea"
- },
- "scope-type": {
- "title": "scope-type",
- "type": "string",
- "format": "textarea"
- },
- "hostname": {
- "title": "hostname",
- "type": "string",
- "format": "textarea"
- },
- "vnf_name": {
- "title": "vnf_name",
- "type": "string",
- "format": "textarea"
- }
- }
+ "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"
}
}
}
@@ -594,7 +538,7 @@
}
},
"payload": {
- "title": "Payload (YAML)",
+ "title": "Payload",
"type": "object",
"properties": {
"artifact_name": {
@@ -612,52 +556,38 @@
"mode": {
"title": "mode",
"type": "string",
- "default": "async",
- "format": "textarea"
+ "default": "async"
},
"data": {
"title": "data",
"properties": {
- "resource-assignment-properties": {
- "title": "resource-assignment-properties",
- "type": "object",
- "properties": {
- "request-id": {
- "title": "request-id",
- "type": "string",
- "format": "textarea"
- },
- "service-instance-id": {
- "title": "service-instance-id",
- "type": "string",
- "format": "textarea"
- },
- "vnf-id": {
- "title": "vnf-id",
- "type": "string",
- "format": "textarea"
- },
- "action-name": {
- "title": "action-name",
- "type": "string",
- "format": "textarea"
- },
- "scope-type": {
- "title": "scope-type",
- "type": "string",
- "format": "textarea"
- },
- "hostname": {
- "title": "hostname",
- "type": "string",
- "format": "textarea"
- },
- "vnf_name": {
- "title": "vnf_name",
- "type": "string",
- "format": "textarea"
- }
- }
+ "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"
}
}
}
@@ -678,7 +608,7 @@
}
},
"payload": {
- "title": "Payload (YAML)",
+ "title": "Payload",
"type": "object",
"properties": {
"artifact_name": {
@@ -696,52 +626,38 @@
"mode": {
"title": "mode",
"type": "string",
- "default": "async",
- "format": "textarea"
+ "default": "async"
},
"data": {
"title": "data",
"properties": {
- "resource-assignment-properties": {
- "title": "resource-assignment-properties",
- "type": "object",
- "properties": {
- "request-id": {
- "title": "request-id",
- "type": "string",
- "format": "textarea"
- },
- "service-instance-id": {
- "title": "service-instance-id",
- "type": "string",
- "format": "textarea"
- },
- "vnf-id": {
- "title": "vnf-id",
- "type": "string",
- "format": "textarea"
- },
- "action-name": {
- "title": "action-name",
- "type": "string",
- "format": "textarea"
- },
- "scope-type": {
- "title": "scope-type",
- "type": "string",
- "format": "textarea"
- },
- "hostname": {
- "title": "hostname",
- "type": "string",
- "format": "textarea"
- },
- "vnf_name": {
- "title": "vnf_name",
- "type": "string",
- "format": "textarea"
- }
- }
+ "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 72bbf9ba..1108ec8b 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 e53950af..0bb5582e 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 aaa96276..a756b57d 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 2777a158..aaf9dc37 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"
+ }
}
]
},
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 b2575486..fe9b84d1 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 d470d928..ef9c2c03 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 dd6a9ff3..b83d3f24 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/tosca_metadata_clamp_possible_values_json_schema.json b/src/test/resources/tosca/tosca_metadata_clamp_possible_values_json_schema.json
index af8c1f96..418ee71b 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 00000000..e15942cc
--- /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/src/api/LoopService.js b/ui-react/src/api/LoopService.js
index f10d187c..3b9ed86f 100644
--- a/ui-react/src/api/LoopService.js
+++ b/ui-react/src/api/LoopService.js
@@ -226,18 +226,17 @@ 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, policyName) {
diff --git a/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js b/ui-react/src/components/dialogs/Loop/ModifyLoopModal.js
index 8c674056..5154a880 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,
@@ -166,10 +167,25 @@ 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() {
@@ -198,13 +214,14 @@ 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>