summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/update/Extractor.java23
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/update/Field.java147
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/update/ParserToJson.java74
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/update/Template.java148
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/update/TemplateManagement.java57
-rw-r--r--src/main/java/org/onap/clamp/policy/Policy.java23
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java27
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java7
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java16
-rw-r--r--src/main/resources/META-INF/resources/swagger.html6
-rw-r--r--src/main/resources/application-noaaf.properties5
-rw-r--r--src/main/resources/application.properties2
-rw-r--r--src/main/resources/clds/tosca_update/defaultToscaTypes.yaml87
-rw-r--r--src/main/resources/clds/tosca_update/templates.json398
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java5
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java3
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java5
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java6
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java109
-rw-r--r--src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java4
-rw-r--r--src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java15
-rw-r--r--src/test/resources/application.properties5
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes?connectionTimeToLive=5000/.file10
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.Blacklist/versions/1.0.0?connectionTimeToLive=5000/.file40
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.FrequencyLimiter/versions/1.0.0?connectionTimeToLive=5000/.file50
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.MinMax/versions/1.0.0?connectionTimeToLive=5000/.file44
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.Blacklist/versions/1.0.0?connectionTimeToLive=5000/.file38
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.Blacklist/versions/1.0.0?connectionTimeToLive=5000/.header (renamed from src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.Blacklist/versions/1.0.0?connectionTimeToLive=5000/.header)0
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter/versions/1.0.0?connectionTimeToLive=5000/.file47
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter/versions/1.0.0?connectionTimeToLive=5000/.header (renamed from src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.FrequencyLimiter/versions/1.0.0?connectionTimeToLive=5000/.header)0
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.MinMax/versions/2.0.0?connectionTimeToLive=5000/.file40
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.MinMax/versions/2.0.0?connectionTimeToLive=5000/.header (renamed from src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.MinMax/versions/1.0.0?connectionTimeToLive=5000/.header)0
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Apex/versions/1.0.0?connectionTimeToLive=5000/.file158
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Apex/versions/1.0.0?connectionTimeToLive=5000/.header1
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0?connectionTimeToLive=5000/.file146
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0?connectionTimeToLive=5000/.header1
-rw-r--r--src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0?connectionTimeToLive=5000/.file7
-rw-r--r--src/test/resources/http-cache/example/policy/pap/v1/pdps?connectionTimeToLive=5000/.file6
-rw-r--r--src/test/resources/tosca/new-converter/tca-schema.json175
-rw-r--r--src/test/resources/tosca/templates.properties7
40 files changed, 1681 insertions, 261 deletions
diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/Extractor.java b/src/main/java/org/onap/clamp/clds/tosca/update/Extractor.java
index 032edbaa8..c6eabcd34 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/update/Extractor.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/update/Extractor.java
@@ -28,13 +28,21 @@ import java.util.Map.Entry;
import org.yaml.snakeyaml.Yaml;
public class Extractor {
-
- private LinkedHashMap<String, Component> allItems = new LinkedHashMap<>();
+ private LinkedHashMap<String, Component> allItems;
private String source;
+ private String nativeComponent;
+
+ /**
+ * Constructor.
+ *
+ * @param toParse Tosca to parse
+ * @param nativeComponent The policy type to scan
+ */
+ public Extractor(String toParse, String nativeComponent) {
- @SuppressWarnings("unchecked")
- public Extractor(String toParse) {
this.source = toParse;
+ this.nativeComponent = nativeComponent;
+ allItems = new LinkedHashMap<String, Component>();
getAllAsMaps();
}
@@ -60,10 +68,17 @@ public class Extractor {
(LinkedHashMap<String, LinkedHashMap<String, Object>>) contentFile;
// Get DataTypes
LinkedHashMap<String, Object> dataTypes = file.get("data_types");
+ dataTypes = (dataTypes == null) ? (new LinkedHashMap<>()) : dataTypes;
// Get Policies : first, get topology and after extract policies from it
LinkedHashMap<String, Object> policyTypes = file.get("policy_types");
// Put the policies and datatypes in the same collection
dataTypes.putAll(policyTypes);
+
+ Object contentNativeFile = yaml.load(nativeComponent);
+ LinkedHashMap<String, Object> dataTypesEmbedded =
+ ((LinkedHashMap<String, LinkedHashMap<String, Object>>) contentNativeFile).get("data_types");
+ dataTypes.putAll(dataTypesEmbedded);
+
parseInComponent(dataTypes);
return dataTypes;
}
diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/Field.java b/src/main/java/org/onap/clamp/clds/tosca/update/Field.java
new file mode 100644
index 000000000..e01f14c43
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/tosca/update/Field.java
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.tosca.update;
+
+public class Field {
+ private String title;
+ private Object value;
+ private Boolean visible;
+ private Boolean staticValue;
+
+ public Field(String title) {
+ this.title = title;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param title The title
+ * @param value The value
+ * @param visible visible or not
+ * @param staticValue The static value
+ */
+ public Field(String title, Object value, Boolean visible, Boolean staticValue) {
+ this.title = title;
+ this.value = value;
+ this.visible = visible;
+ this.staticValue = staticValue;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ public Boolean getVisible() {
+ return visible;
+ }
+
+ public void setVisible(Boolean visible) {
+ this.visible = visible;
+ }
+
+ public Boolean getStaticValue() {
+ return staticValue;
+ }
+
+ public void setStaticValue(Boolean staticValue) {
+ this.staticValue = staticValue;
+ }
+
+ public String toString() {
+ return title + " " + value + " " + visible + " " + staticValue;
+ }
+
+ /**
+ * This method compares two fields.
+ *
+ * @param otherField Compare the current object with the one specified
+ * @return true if they are totally equals, false otherwise
+ */
+ public boolean compareWithField(Object otherField) {
+ if (this == otherField) {
+ return true;
+ }
+ if (otherField == null || getClass() != otherField.getClass()) {
+ return false;
+ }
+
+ Field field = (Field) otherField;
+
+ if (title != null ? !title.equals(field.title) : field.title != null) {
+ return false;
+ }
+ if (value != null ? !value.equals(field.value) : field.value != null) {
+ return false;
+ }
+ if (visible != null ? !visible.equals(field.visible) : field.visible != null) {
+ return false;
+ }
+ return staticValue != null ? staticValue.equals(field.staticValue) : field.staticValue == null;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object == null || getClass() != object.getClass()) {
+ return false;
+ }
+
+ Field field = (Field) object;
+
+ return title != null ? title.equals(field.title) : field.title == null;
+ }
+
+ @Override
+ public int hashCode() {
+ return title != null ? title.hashCode() : 0;
+ }
+
+ /**
+ * This method test the entire equality.
+ *
+ * @param field1 object one
+ * @param field2 object two
+ * @return true if they are totally equals (all attributes, false otherwise
+ */
+ public static boolean fieldsEquals(Field field1, Field field2) {
+ return (field2.getTitle().equals(field1.getTitle()) && field2.getValue().equals(field1.getValue())
+ && field2.getVisible().equals(field1.getVisible())
+ && field2.getStaticValue().equals(field1.getStaticValue()));
+ }
+
+}
diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/ParserToJson.java b/src/main/java/org/onap/clamp/clds/tosca/update/ParserToJson.java
index 6da55eaec..3c5cf975b 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/update/ParserToJson.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/update/ParserToJson.java
@@ -45,14 +45,16 @@ public class ParserToJson {
* @param nameComponent name components
* @return return
*/
- public JsonObject getJsonProcess(String nameComponent) {
- JsonObject glob = this.getGeneralField(matchComponent(nameComponent));
- if (templates.get("object").hasFields("required")) {
- glob.add("required", this.getRequirements(nameComponent));
+ public JsonObject getJsonProcess(String nameComponent, String typeComponent) {
+ JsonObject glob = new JsonObject();
+
+ if (typeComponent.equals("object")) {
+ glob = this.getFieldAsObject(matchComponent(nameComponent));
}
- if (templates.get("object").hasFields("properties")) {
- glob.add("properties", this.deploy(nameComponent));
+ else {
+ /*glob = this.getFieldAsArray(matchComponent(nameComponent));*/
}
+
return glob;
}
@@ -62,7 +64,7 @@ public class ParserToJson {
* @param component the compo
* @return a json object
*/
- public JsonObject getGeneralField(Component component) {
+ public JsonObject getFieldAsObject(Component component) {
JsonObject globalFields = new JsonObject();
if (templates.get("object").hasFields("title")) {
@@ -76,6 +78,12 @@ public class ParserToJson {
globalFields.addProperty("description", component.getDescription());
}
}
+ if (templates.get("object").hasFields("required")) {
+ globalFields.add("required", this.getRequirements(component.getName()));
+ }
+ if (templates.get("object").hasFields("properties")) {
+ globalFields.add("properties", this.deploy(component.getName()));
+ }
return globalFields;
}
@@ -124,7 +132,7 @@ public class ParserToJson {
for (Entry<String, Property> property : toParse.getProperties().entrySet()) {
if (matchComponent((String) property.getValue().getItems().get("type")) != null) {
jsonSchema.add(property.getValue().getName(),
- this.getJsonProcess((String) property.getValue().getItems().get("type")));
+ this.getJsonProcess((String) property.getValue().getItems().get("type"), "object"));
}
else {
jsonSchema.add(property.getValue().getName(), this.complexParse(property.getValue()));
@@ -166,8 +174,11 @@ public class ParserToJson {
switch (propertyField) {
case "type":
if (currentPropertyTemplate.hasFields(propertyField)) {
- switch ((String) property.getItems().get(propertyField)) {
+ String fieldtype = (String) property.getItems().get(propertyField);
+ switch (fieldtype.toLowerCase()) {
case "list":
+ propertiesInJson.addProperty("type", "array");
+ break;
case "map":
propertiesInJson.addProperty("type", "object");
break;
@@ -180,6 +191,9 @@ public class ParserToJson {
propertiesInJson.addProperty("type", "string");
propertiesInJson.addProperty("format", "date-time");
break;
+ case "float":
+ propertiesInJson.addProperty("type", "number");
+ break;
case "range":
propertiesInJson.addProperty("type", "integer");
if (!checkConstraintPresence(property, "greater_than")
@@ -205,19 +219,41 @@ public class ParserToJson {
currentPropertyTemplate);
break;
case "entry_schema":
+ //Here, a way to check if entry is a component (datatype) or a simple string
if (matchComponent(this.extractSpecificFieldFromMap(property, "entry_schema")) != null) {
+ String nameComponent = this.extractSpecificFieldFromMap(property, "entry_schema");
ParserToJson child = new ParserToJson(components, templates);
- JsonObject componentAsProperty =
- child.getJsonProcess(this.extractSpecificFieldFromMap(property, "entry_schema"));
JsonObject propertiesContainer = new JsonObject();
- propertiesContainer
- .add(this.extractSpecificFieldFromMap(property, "entry_schema"), componentAsProperty);
- if (currentPropertyTemplate.hasFields("properties")) {
- propertiesInJson.add("properties", propertiesContainer);
+
+ switch ((String) property.getItems().get("type")) {
+ case "map": // Get it as an object
+ JsonObject componentAsProperty = child.getJsonProcess(nameComponent, "object");
+ propertiesContainer.add(nameComponent, componentAsProperty);
+ if (currentPropertyTemplate.hasFields("properties")) {
+ propertiesInJson.add("properties", propertiesContainer);
+ }
+ break;
+ default://list : get it as an Array
+ JsonObject componentAsItem = child.getJsonProcess(nameComponent, "object");
+ if (currentPropertyTemplate.hasFields("properties")) {
+ propertiesInJson.add("items", componentAsItem);
+ }
+ break;
}
+
+ }
+ // Native cases
+ else if (property.getItems().get("type").equals("list")) {
+ JsonObject itemContainer = new JsonObject();
+ String valueInEntrySchema = this.extractSpecificFieldFromMap(property, "entry_schema");
+ itemContainer.addProperty("type", valueInEntrySchema);
+ propertiesInJson.add("items", itemContainer);
}
+ // MAP Case, for now nothing
+
break;
- default://Each classical field : type, description, default..
+ default:
+ //Each classical field : type, description, default..
if (currentPropertyTemplate.hasFields(propertyField) && !propertyField.equals("required")) {
property.addFieldToJson(propertiesInJson, propertyField,
property.getItems().get(propertyField));
@@ -236,8 +272,10 @@ public class ParserToJson {
*/
public Component matchComponent(String name) {
Component correspondingComponent = null;
- Collection<Component> listofComponent = components.values();
- for (Component component : listofComponent) {
+ if (components == null) {
+ return null;
+ }
+ for (Component component : components.values()) {
if (component.getName().equals(name)) {
correspondingComponent = component;
}
diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/Template.java b/src/main/java/org/onap/clamp/clds/tosca/update/Template.java
index 34459067f..4507e3d71 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/update/Template.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/update/Template.java
@@ -23,7 +23,9 @@
package org.onap.clamp.clds.tosca.update;
+import com.google.gson.JsonObject;
import java.util.ArrayList;
+import java.util.List;
public class Template {
@@ -31,14 +33,14 @@ public class Template {
* name parameter is used as "key", in the LinkedHashMap of Templates.
*/
private String name;
- private ArrayList<String> fields;
+ private List<Field> fields;
public Template(String name) {
this.name = name;
- this.fields = new ArrayList<String>();
+ this.fields = new ArrayList<>();
}
- public Template(String name, ArrayList<String> fields) {
+ public Template(String name, List<Field> fields) {
this.name = name;
this.fields = fields;
}
@@ -51,42 +53,110 @@ public class Template {
this.name = name;
}
- public ArrayList<String> getFields() {
+ public List<Field> getFields() {
return fields;
}
- public void setFields(ArrayList<String> fields) {
+ public void setFields(List<Field> fields) {
this.fields = fields;
}
- public boolean hasFields(String name) {
- return fields.contains(name);
+ /**
+ * Search in fields if fieldName exists.
+ *
+ * @param fieldName The field name
+ * @return Ture if it exists, false otherwise
+ */
+ public boolean hasFields(String fieldName) {
+ for (Field field : this.getFields()) {
+ if (field.getTitle().equals(fieldName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get a specific Field.
+ *
+ * @param fieldName The field name
+ * @return THe Field found
+ */
+ public Field getSpecificField(String fieldName) {
+ for (Field field : this.getFields()) {
+ if (field.getTitle().equals(fieldName)) {
+ return field;
+ }
+ }
+ return null;
}
- public void addField(String field) {
+ public void addField(Field field) {
fields.add(field);
}
- public void removeField(String field) {
+ public void removeField(Field field) {
fields.remove(field);
}
/**
+ * Enable or disable the visibility.
+ *
+ * @param nameField THe field name
+ * @param state True or false
+ */
+ public void setVisibility(String nameField, boolean state) {
+ for (Field field : this.fields) {
+ if (field.getTitle().equals(nameField)) {
+ field.setVisible(state);
+ }
+ }
+ }
+
+ /**
+ * This method defines if a field is static or not.
+ *
+ * @param nameField The name of the field
+ * @param state true or false
+ */
+ public void setStatic(String nameField, boolean state) {
+ for (Field field : this.fields) {
+ if (field.getTitle().equals(nameField)) {
+ field.setStaticValue(state);
+ }
+ }
+ }
+
+ /**
+ * This method updates the value of a specfic field.
+ *
+ * @param nameField The name of the field
+ * @param newValue The new value as Object
+ */
+ public void updateValueField(String nameField, Object newValue) {
+ for (Field field : this.fields) {
+ if (field.getTitle().equals(nameField)) {
+ field.setValue(newValue);
+ }
+ }
+ }
+
+ /**
* Compare two templates : size and their contents.
*
* @param template the template
* @return a boolean
*/
public boolean checkFields(Template template) {
-
boolean duplicateFields = false;
if (template.getFields().size() == this.getFields().size()) {
int countMatchingFields = 0;
//loop each component of first
- for (String templateField : template.getFields()) {
- //if component.key is present in the second
- if (this.getFields().contains(templateField)) {
- countMatchingFields++;
+ for (Field templateFieldToCheck : template.getFields()) {
+ for (Field templateField : this.getFields()) {
+ if (templateFieldToCheck.compareWithField(templateField)) {
+ countMatchingFields++;
+ }
}
}
@@ -97,6 +167,56 @@ public class Template {
return duplicateFields;
}
+ /**
+ * This method gets the specific field status.
+ *
+ * @param field The field name
+ * @return true or false
+ */
+ public boolean fieldStaticStatus(String field) {
+ if (this.hasFields(field) && this.getSpecificField(field).getStaticValue().equals(true)
+ && this.getSpecificField(field).getValue() != null) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isVisible(String field) {
+ return this.getSpecificField(field).getVisible();
+ }
+
+ /**
+ * Set the value of a property of the Field in the json.
+ *
+ * @param jsonSchema The Json schema
+ * @param fieldName The Field name
+ * @param value The value
+ */
+ public void setValue(JsonObject jsonSchema, String fieldName, String value) {
+ if (isVisible(fieldName)) {
+ if (fieldStaticStatus(fieldName)) {
+ String defaultValue = (String) this.getSpecificField(fieldName).getValue();
+ jsonSchema.addProperty(fieldName, defaultValue);
+ }
+ else {
+ jsonSchema.addProperty(fieldName, value);
+ }
+ }
+ }
+
+ /**
+ * Inject a static value in the json.
+ *
+ * @param jsonSchema The json schema object
+ * @param fieldName The field name
+ */
+ public void injectStaticValue(JsonObject jsonSchema, String fieldName) {
+ if (isVisible(fieldName)) {
+ Field toInject = this.getSpecificField(fieldName);
+ jsonSchema.addProperty(fieldName, (String) toInject.getValue());
+ }
+ }
+
@Override
public String toString() {
return " fields : " + fields;
diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/TemplateManagement.java b/src/main/java/org/onap/clamp/clds/tosca/update/TemplateManagement.java
index 4b510cb75..743077151 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/update/TemplateManagement.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/update/TemplateManagement.java
@@ -23,14 +23,14 @@
package org.onap.clamp.clds.tosca.update;
+import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.io.IOException;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
-import java.util.Properties;
+import java.util.List;
+import java.util.Map;
+import org.onap.clamp.clds.util.JsonUtils;
public class TemplateManagement {
@@ -46,9 +46,10 @@ public class TemplateManagement {
* @param templateProperties template properties as string
* @throws IOException in case of failure
*/
- public TemplateManagement(String yamlContent, String templateProperties) throws IOException {
+ public TemplateManagement(String yamlContent, String nativeComponent, String templateProperties)
+ throws IOException {
if (yamlContent != null && !yamlContent.isEmpty()) {
- this.extractor = new Extractor(yamlContent);
+ this.extractor = new Extractor(yamlContent, nativeComponent);
this.components = extractor.getAllItems();
this.templates = initializeTemplates(templateProperties);
}
@@ -92,7 +93,7 @@ public class TemplateManagement {
* @param name name
* @param fields fields
*/
- public void addTemplate(String name, ArrayList<String> fields) {
+ public void addTemplate(String name, List<Field> fields) {
Template template = new Template(name, fields);
//If it is true, the operation does not have any interest :
// replace OR put two different object with the same body
@@ -114,17 +115,17 @@ public class TemplateManagement {
* Update Template : adding with true flag, removing with false.
*
* @param nameTemplate name template
- * @param fieldName field name
+ * @param field field name
* @param operation operation
*/
- public void updateTemplate(String nameTemplate, String fieldName, Boolean operation) {
+ public void updateTemplate(String nameTemplate, Field field, Boolean operation) {
// Operation = true && field is not present => add Field
- if (operation && !this.templates.get(nameTemplate).getFields().contains(fieldName)) {
- this.templates.get(nameTemplate).addField(fieldName);
+ if (operation && !this.templates.get(nameTemplate).getFields().contains(field)) {
+ this.templates.get(nameTemplate).addField(field);
}
// Operation = false && field is present => remove Field
- else if (!operation && this.templates.get(nameTemplate).getFields().contains(fieldName)) {
- this.templates.get(nameTemplate).removeField(fieldName);
+ else if (!operation && this.templates.get(nameTemplate).getFields().contains(field)) {
+ this.templates.get(nameTemplate).removeField(field);
}
}
@@ -155,26 +156,36 @@ public class TemplateManagement {
if (parserToJson.matchComponent(componentName) == null) {
throw new UnknownComponentException(componentName);
}
- return parserToJson.getJsonProcess(componentName);
+ return parserToJson.getJsonProcess(componentName, "object");
}
/**
* Create and complete several Templates from file.properties.
*
- * @param templateProperties The template properties as String
+ * @param jsonTemplates The template properties as String
* @return a map
*/
- private LinkedHashMap<String, Template> initializeTemplates(String templateProperties) throws IOException {
- LinkedHashMap<String, Template> generatedTemplates = new LinkedHashMap<>();
- Properties templates = new Properties();
- templates.load(new StringReader(templateProperties));
+ @SuppressWarnings("unused")
+ private LinkedHashMap<String, Template> initializeTemplates(String jsonTemplates) {
- for (Object key : templates.keySet()) {
- String fields = (String) templates.get(key);
- String[] fieldsInArray = fields.split(",");
- Template template = new Template((String) key, new ArrayList<>(Arrays.asList(fieldsInArray)));
+ LinkedHashMap<String, Template> generatedTemplates = new LinkedHashMap<>();
+ JsonObject templates = JsonUtils.GSON.fromJson(jsonTemplates, JsonObject.class);
+
+ for (Map.Entry<String, JsonElement> templateAsJson : templates.entrySet()) {
+ Template template = new Template(templateAsJson.getKey());
+ JsonObject templateBody = (JsonObject) templateAsJson.getValue();
+ for (Map.Entry<String, JsonElement> field : templateBody.entrySet()) {
+ String fieldName = field.getKey();
+ JsonObject bodyFieldAsJson = (JsonObject) field.getValue();
+ Object fieldValue = bodyFieldAsJson.get("defaultValue").getAsString();
+ Boolean fieldVisible = bodyFieldAsJson.get("visible").getAsBoolean();
+ Boolean fieldStatic = bodyFieldAsJson.get("static").getAsBoolean();
+ Field bodyField = new Field(fieldName, fieldValue, fieldVisible, fieldStatic);
+ template.getFields().add(bodyField);
+ }
generatedTemplates.put(template.getName(), template);
}
return generatedTemplates;
}
+
}
diff --git a/src/main/java/org/onap/clamp/policy/Policy.java b/src/main/java/org/onap/clamp/policy/Policy.java
index ebeb84fd6..d52e418e3 100644
--- a/src/main/java/org/onap/clamp/policy/Policy.java
+++ b/src/main/java/org/onap/clamp/policy/Policy.java
@@ -30,7 +30,7 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
-
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import javax.persistence.Column;
@@ -44,6 +44,9 @@ import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import org.json.JSONObject;
+import org.onap.clamp.clds.tosca.update.TemplateManagement;
+import org.onap.clamp.clds.tosca.update.UnknownComponentException;
+import org.onap.clamp.clds.util.ResourceFileUtil;
import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.clamp.loop.common.AuditEntity;
import org.onap.clamp.loop.template.LoopElementModel;
@@ -284,4 +287,22 @@ public abstract class Policy extends AuditEntity {
return buffer.toString().replace('.', '_').replaceAll(" ", "");
}
+ /**
+ * This method can be used to generate the json Schema used by the UI.
+ *
+ * @param policyToscaModel The tosca model as String that must be converted
+ * @param policyModelType The tosca model type (the policy_type entry in the tosca) that will used to create the
+ * json schema
+ * @return THe Json Schema as JsonObject
+ * @throws IOException In case of failure when opening the templates.json file
+ * @throws UnknownComponentException If the policyModelType is not found in the tosca model
+ */
+ public static JsonObject generateJsonRepresentationFromToscaModel(String policyToscaModel,
+ String policyModelType)
+ throws IOException, UnknownComponentException {
+ return new TemplateManagement(policyToscaModel,ResourceFileUtil.getResourceAsString(
+ "clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"))
+ .launchTranslation(policyModelType);
+ }
}
diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
index c4037ffb6..b8093ccf1 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java
@@ -27,6 +27,7 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
+import java.io.IOException;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@@ -39,8 +40,7 @@ import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
-import org.onap.clamp.clds.tosca.ToscaYamlToJsonConvertor;
-import org.onap.clamp.clds.util.JsonUtils;
+import org.onap.clamp.clds.tosca.update.UnknownComponentException;
import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.clamp.loop.Loop;
import org.onap.clamp.loop.template.LoopElementModel;
@@ -104,9 +104,18 @@ public class MicroServicePolicy extends Policy implements Serializable {
* @param shared The flag indicate whether the MicroService is shared
*/
public MicroServicePolicy(String name, PolicyModel policyModel, Boolean shared, LoopElementModel loopElementModel) {
- this(name, policyModel, shared, JsonUtils.GSON_JPA_MODEL
- .fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyModel.getPolicyModelTosca(),
- policyModel.getPolicyModelType()), JsonObject.class), loopElementModel,null,null);
+ this.name = name;
+ this.setPolicyModel(policyModel);
+ this.shared = shared;
+ try {
+ this.setJsonRepresentation(
+ Policy.generateJsonRepresentationFromToscaModel(policyModel.getPolicyModelTosca(),
+ policyModel.getPolicyModelType()));
+ } catch (UnknownComponentException | NullPointerException | IOException e) {
+ logger.error("Unable to generate the microservice policy Schema ... ", e);
+ this.setJsonRepresentation(new JsonObject());
+ }
+ this.setLoopElementModel(loopElementModel);
}
/**
@@ -116,14 +125,15 @@ public class MicroServicePolicy extends Policy implements Serializable {
* @param name The name of the MicroService
* @param policyModel The policy model type of the MicroService
* @param shared The flag indicate whether the MicroService is
- * shared
+ * shared
* @param jsonRepresentation The UI representation in json format
* @param loopElementModel The loop element model from which this instance should be created
* @param pdpGroup The Pdp Group info
* @param pdpSubgroup The Pdp Subgrouop info
*/
public MicroServicePolicy(String name, PolicyModel policyModel, Boolean shared,
- JsonObject jsonRepresentation, LoopElementModel loopElementModel, String pdpGroup, String pdpSubgroup) {
+ JsonObject jsonRepresentation, LoopElementModel loopElementModel, String pdpGroup,
+ String pdpSubgroup) {
this.name = name;
this.setPolicyModel(policyModel);
this.shared = shared;
@@ -258,7 +268,8 @@ public class MicroServicePolicy extends Policy implements Serializable {
if (other.name != null) {
return false;
}
- } else if (!name.equals(other.name)) {
+ }
+ else if (!name.equals(other.name)) {
return false;
}
return true;
diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java
index 3ad97c598..9bc641c6d 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java
@@ -63,11 +63,12 @@ public class MicroServicePolicyService implements PolicyService<MicroServicePoli
return repository.save(
repository.findById(policy.getName()).map(p -> updateMicroservicePolicyProperties(p, policy, loop))
.orElse(new MicroServicePolicy(policy.getName(), policy.getPolicyModel(),
- policy.getShared(), policy.getJsonRepresentation(),null, policy.getPdpGroup(), policy.getPdpSubgroup())));
+ policy.getShared(), policy.getJsonRepresentation(), null, policy.getPdpGroup(),
+ policy.getPdpSubgroup())));
}
private MicroServicePolicy updateMicroservicePolicyProperties(MicroServicePolicy oldPolicy,
- MicroServicePolicy newPolicy, Loop loop) {
+ MicroServicePolicy newPolicy, Loop loop) {
oldPolicy.setConfigurationsJson(newPolicy.getConfigurationsJson());
if (!oldPolicy.getUsedByLoops().contains(loop)) {
oldPolicy.getUsedByLoops().add(loop);
@@ -85,7 +86,7 @@ public class MicroServicePolicyService implements PolicyService<MicroServicePoli
* @param deploymentUrl The Deployment URL as returned by DCAE
*/
public void updateDcaeDeploymentFields(MicroServicePolicy microServicePolicy, String deploymentId,
- String deploymentUrl) {
+ String deploymentUrl) {
microServicePolicy.setDcaeDeploymentId(deploymentId);
microServicePolicy.setDcaeDeploymentStatusUrl(deploymentUrl);
repository.save(microServicePolicy);
diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
index b0e8b0c3d..9cf516330 100644
--- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
+++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
@@ -45,14 +45,12 @@ import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
-import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
-import org.onap.clamp.clds.tosca.ToscaYamlToJsonConvertor;
-import org.onap.clamp.clds.util.JsonUtils;
+import org.onap.clamp.clds.tosca.update.UnknownComponentException;
import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.clamp.loop.Loop;
import org.onap.clamp.loop.template.LoopElementModel;
@@ -120,17 +118,15 @@ public class OperationalPolicy extends Policy implements Serializable {
if (isLegacy()) {
// Op policy Legacy case
LegacyOperationalPolicy.preloadConfiguration(jsonReturned, loop);
- this.setJsonRepresentation(
- OperationalPolicyRepresentationBuilder.generateOperationalPolicySchema(loop.getModelService()));
+ jsonReturned =
+ OperationalPolicyRepresentationBuilder.generateOperationalPolicySchema(loop.getModelService());
} else {
// Generic Case
- this.setJsonRepresentation(JsonUtils.GSON
- .fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyModel.getPolicyModelTosca(),
- policyModel.getPolicyModelType()), JsonObject.class));
+ jsonReturned = Policy.generateJsonRepresentationFromToscaModel(policyModel.getPolicyModelTosca(),
+ policyModel.getPolicyModelType());
}
- } catch (JsonSyntaxException | IOException | NullPointerException e) {
+ } catch (UnknownComponentException | IOException | NullPointerException e) {
logger.error("Unable to generate the operational policy Schema ... ", e);
- this.setJsonRepresentation(new JsonObject());
}
return jsonReturned;
}
diff --git a/src/main/resources/META-INF/resources/swagger.html b/src/main/resources/META-INF/resources/swagger.html
index 9c4c9fff2..69e9c7c15 100644
--- a/src/main/resources/META-INF/resources/swagger.html
+++ b/src/main/resources/META-INF/resources/swagger.html
@@ -692,7 +692,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<div class="sect2">
<h3 id="_uri_scheme"><a class="anchor" href="#_uri_scheme"></a><a class="link" href="#_uri_scheme">1.2. URI scheme</a></h3>
<div class="paragraph">
-<p><em>Host</em> : localhost:39099<br>
+<p><em>Host</em> : localhost:39237<br>
<em>BasePath</em> : /restservices/clds/<br>
<em>Schemes</em> : HTTP</p>
</div>
@@ -3544,7 +3544,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
</tr>
<tr>
-<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>pdpSubGroup</strong><br>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>pdpSubgroup</strong><br>
<em>optional</em></p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
</tr>
@@ -3642,7 +3642,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
</tr>
<tr>
-<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>pdpSubGroup</strong><br>
+<td class="tableblock halign-left valign-middle"><p class="tableblock"><strong>pdpSubgroup</strong><br>
<em>optional</em></p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
</tr>
diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties
index 320e0c2a3..288511b3b 100644
--- a/src/main/resources/application-noaaf.properties
+++ b/src/main/resources/application-noaaf.properties
@@ -173,4 +173,7 @@ clamp.config.security.permission.type.template=org.onap.clamp.clds.template
clamp.config.security.permission.type.tosca=org.onap.clamp.clds.tosca
#This one indicates the type of instances (dev|prod|perf...), this must be set accordingly in clds-users.properties
clamp.config.security.permission.instance=dev
-clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal \ No newline at end of file
+clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal
+
+## Tosca converter
+clamp.config.tosca.converter.templates=classpath:/clds/tosca_updates/templates.json \ No newline at end of file
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index ed7f4ef4a..a249d2d00 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -189,7 +189,7 @@ clamp.config.cadi.aafUrl=https://AAF_LOCATE_URL/onap.org.osaaf.aaf.service:2.1
clamp.config.cadi.cadiX509Issuers=CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_7, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_9, OU=OSAAF, O=ONAP, C=US
## Tosca converter
-clamp.config.tosca.converter.templates=classpath:/clds/tosca_updates/templates.properties
+clamp.config.tosca.converter.templates=classpath:/clds/tosca_updates/templates.json
# Configuration settings for CDS
clamp.config.cds.url=http4://blueprints-processor-http:8080
diff --git a/src/main/resources/clds/tosca_update/defaultToscaTypes.yaml b/src/main/resources/clds/tosca_update/defaultToscaTypes.yaml
new file mode 100644
index 000000000..a11a73698
--- /dev/null
+++ b/src/main/resources/clds/tosca_update/defaultToscaTypes.yaml
@@ -0,0 +1,87 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+data_types:
+ tosca.datatypes.Root:
+ description: The TOSCA root Data Type all other TOSCA base Data Types derive from
+ tosca.datatypes.Credential:
+ derived_from: tosca.datatypes.Root
+ properties:
+ protocol:
+ type: string
+ required: false
+ token_type:
+ type: string
+ default: password
+ token:
+ type: string
+ keys:
+ type: map
+ required: false
+ entry_schema:
+ type: string
+ user:
+ type: string
+ required: false
+ tosca.datatypes.TimeInterval:
+ derived_from: tosca.datatypes.Root
+ properties:
+ start_time:
+ type: timestamp
+ required: true
+ end_time:
+ type: timestamp
+ required: true
+ tosca.datatypes.network.NetworkInfo:
+ derived_from: tosca.datatypes.Root
+ properties:
+ network_name:
+ type: string
+ network_id:
+ type: string
+ addresses:
+ type: list
+ entry_schema:
+ type: string
+ tosca.datatypes.network.PortInfo:
+ derived_from: tosca.datatypes.Root
+ properties:
+ port_name:
+ type: string
+ port_id:
+ type: string
+ network_id:
+ type: string
+ mac_address:
+ type: string
+ addresses:
+ type: list
+ entry_schema:
+ type: string
+ # tosca.datatypes.network.PortDef:
+ # derived_from: integer
+ # constraints:
+ # - in_range: [ 1, 65535 ]
+ # tosca.datatypes.network.PortSpec:
+ # derived_from: tosca.datatypes.Root
+ # properties:
+ # protocol:
+ # type: string
+ # required: true
+ # default: tcp
+ # constraints:
+ # - valid_values: [ udp, tcp, igmp ]
+ # target:
+ # type: PortDef
+ # required: false
+ # target_range:
+ # type: range
+ # required: false
+ # constraints:
+ # - in_range: [ 1, 65535 ]
+ # source:
+ # type: PortDef
+ # required: false
+ # source_range:
+ # type: range
+ # required: false
+ # constraints:
+ # - in_range: [ 1, 65535 ] \ No newline at end of file
diff --git a/src/main/resources/clds/tosca_update/templates.json b/src/main/resources/clds/tosca_update/templates.json
new file mode 100644
index 000000000..f709e2f6d
--- /dev/null
+++ b/src/main/resources/clds/tosca_update/templates.json
@@ -0,0 +1,398 @@
+{
+ "integer":{
+ "type":{
+ "defaultValue":"integer",
+ "visible":true,
+ "static":false
+ },
+ "description":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "title":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+
+ },
+ "deprecated":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "default":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "enum":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "const":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "multipleOf":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "maximum":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "exclusiveMaximum":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "minimum":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "exclusiveMinimum":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ }
+ },
+ "number":{
+ "type":{
+ "defaultValue":"number",
+ "visible":true,
+ "static":false
+ },
+ "description":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "title":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+
+ },
+ "deprecated":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "default":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "enum":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "const":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "multipleOf":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "maximum":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "exclusiveMaximum":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "minimum":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "exclusiveMinimum":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ }
+ },
+ "boolean":{
+ "type":{
+ "defaultValue":"boolean",
+ "visible":true,
+ "static":false
+ },
+ "description":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "title":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "deprecated":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "default":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "const":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ }
+ },
+ "string":{
+ "type":{
+ "defaultValue":"string",
+ "visible":true,
+ "static":false
+ },
+ "description":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "title":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "deprecated":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "default":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "enum":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "const":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "length":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "minLength":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "maxLength":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "pattern":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "format":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ }
+ },
+ "timestamp":{
+ "type":{
+ "defaultValue":"string",
+ "visible":true,
+ "static":false
+ },
+ "description":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "title":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "deprecated":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "default":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "enum":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "const":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "length":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "minLength":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "maxLength":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "pattern":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "format":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ }
+ },
+ "array":{
+ "type":{
+ "defaultValue":"array",
+ "visible":true,
+ "static":false
+ },
+ "description":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "title":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "deprecated":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "default":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "const":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "uniqueItems":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "properties":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "minContains":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "maxContains":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "minItems":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "maxItems":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ }
+ },
+ "object":{
+ "type":{
+ "defaultValue":"object",
+ "visible":true,
+ "static":false
+ },
+ "description":{
+ "defaultValue":"",
+ "visible":true,
+ "static":true
+ },
+ "title":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "format":{
+ "defaultValue":"tabs",
+ "visible":true,
+ "static":true
+ },
+ "required":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "minProperties":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "maxProperties":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "properties":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "dependentRequired":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ },
+ "dependencies":{
+ "defaultValue":"",
+ "visible":true,
+ "static":false
+ }
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java
index abf65c366..a99d4ab56 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java
@@ -38,8 +38,9 @@ public class ArrayFieldTest extends TestCase {
*/
public void testDeploy() throws IOException {
TemplateManagement templateManagement = new TemplateManagement(ResourceFileUtil.getResourceAsString(
- "tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"),
- ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ "tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"),ResourceFileUtil.getResourceAsString(
+ "clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Actor");
Property property = component.getProperties().get("actor");
ArrayField arrayParser = new ArrayField((ArrayList<Object>) property.getItems().get("default"));
diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java
index 0494ee11d..565547e4b 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java
@@ -41,7 +41,8 @@ public class ComponentTest extends TestCase {
TemplateManagement templateManagement =
new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
- ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Actor");
assertEquals(reference, component.propertiesNames());
}
diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java
index a71ea8ac4..a4d329e29 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java
@@ -33,7 +33,8 @@ public class ConstraintTest extends TestCase {
TemplateManagement templateManagement = new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/constraints.yaml"),
- ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Operation");
@@ -41,7 +42,7 @@ public class ConstraintTest extends TestCase {
}
/**
- * Test get value array.
+ * Test get value array.
*/
public void testGetValuesArray() {
Property property = component.getProperties().get("timeout");
diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java
index cf183af81..62def32b8 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java
@@ -42,7 +42,8 @@ public class PropertyTest extends TestCase {
public void testParseArray() throws IOException {
TemplateManagement templateManagement = new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"),
- ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Actor");
Property property = component.getProperties().get("actor");
JsonArray toTest = property.parseArray((ArrayList<Object>) property.getItems().get("default"));
@@ -57,7 +58,8 @@ public class PropertyTest extends TestCase {
public void testAddConstraintsAsJson() throws IOException {
TemplateManagement templateManagement = new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
- ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
Component component = templateManagement.getComponents().get("onap.datatype.controlloop.operation.Failure");
Property property = component.getProperties().get("category");
Template template = templateManagement.getTemplates().get("string");
diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java
index 8e411069c..aaa549386 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java
@@ -26,12 +26,93 @@ package org.onap.clamp.clds.tosca.update;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import junit.framework.TestCase;
import org.onap.clamp.clds.util.ResourceFileUtil;
public class TemplateManagementTest extends TestCase {
/**
+ * Test the launch translation wit operational policies.
+ *
+ * @throws IOException In case of failure
+ * @throws UnknownComponentException In case of failure
+ */
+ public void testLaunchTranslationTca() throws IOException, UnknownComponentException {
+ TemplateManagement templateManagement =
+ new TemplateManagement(
+ ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap"
+ + ".policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0&#63;"
+ + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString(
+ "clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
+ assertNull(templateManagement.getParseToJson());
+ String componentName = "onap.policies.monitoring.cdap.tca.hi.lo.app";
+ templateManagement.launchTranslation(componentName);
+ assertNotNull(templateManagement.getParseToJson());
+ }
+
+ /**
+ * Test the launch translation wit operational policies.
+ *
+ * @throws IOException In case of failure
+ * @throws UnknownComponentException In case of failure
+ */
+ public void testLaunchTranslationFrequencyLimiter() throws IOException, UnknownComponentException {
+ TemplateManagement templateManagement =
+ new TemplateManagement(
+ ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap"
+ + ".policies.controlloop.guard.common.FrequencyLimiter/versions/1.0.0&#63;"
+ + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString(
+ "clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
+ assertNull(templateManagement.getParseToJson());
+ String componentName = "onap.policies.controlloop.guard.common.FrequencyLimiter";
+ templateManagement.launchTranslation(componentName);
+ assertNotNull(templateManagement.getParseToJson());
+ }
+
+ /**
+ * Test the launch translation wit operational policies.
+ *
+ * @throws IOException In case of failure
+ * @throws UnknownComponentException In case of failure
+ */
+ public void testLaunchTranslationApex() throws IOException, UnknownComponentException {
+ TemplateManagement templateManagement =
+ new TemplateManagement(
+ ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap"
+ + ".policies.controlloop.operational.common.Apex/versions/1.0.0&#63;"
+ + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString(
+ "clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
+ assertNull(templateManagement.getParseToJson());
+ String componentName = "onap.policies.controlloop.operational.common.Apex";
+ templateManagement.launchTranslation(componentName);
+ assertNotNull(templateManagement.getParseToJson());
+ }
+
+ /**
+ * Test the launch translation wit operational policies.
+ *
+ * @throws IOException In case of failure
+ * @throws UnknownComponentException In case of failure
+ */
+ public void testLaunchTranslationDrools() throws IOException, UnknownComponentException {
+ TemplateManagement templateManagement =
+ new TemplateManagement(
+ ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap"
+ + ".policies.controlloop.operational.common.Drools/versions/1.0.0&#63;"
+ + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString(
+ "clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
+ assertNull(templateManagement.getParseToJson());
+ String componentName = "onap.policies.controlloop.operational.common.Drools";
+ templateManagement.launchTranslation(componentName);
+ assertNotNull(templateManagement.getParseToJson());
+ }
+
+ /**
* Test the launch translation.
*
* @throws IOException In case of failure
@@ -41,7 +122,8 @@ public class TemplateManagementTest extends TestCase {
TemplateManagement templateManagement =
new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
- ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
assertNull(templateManagement.getParseToJson());
String componentName = "onap.policies.controlloop.operational.common.Drools";
templateManagement.launchTranslation(componentName);
@@ -57,10 +139,13 @@ public class TemplateManagementTest extends TestCase {
TemplateManagement templateManagement =
new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
- ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
int count = templateManagement.getTemplates().size();
- ArrayList<String> templateFields =
- new ArrayList<>(Arrays.asList("type", "description", "required", "metadata", "constraints"));
+ List<Field> templateFields = new ArrayList<>(Arrays.asList(new Field("type"), new Field("description"),
+ new Field(
+ "required"),
+ new Field("metadata"), new Field("constraints")));
templateManagement.addTemplate("test", templateFields);
assertNotSame(count, templateManagement.getTemplates().size());
}
@@ -74,7 +159,8 @@ public class TemplateManagementTest extends TestCase {
TemplateManagement templateManagement =
new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
- ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
int count = templateManagement.getTemplates().size();
templateManagement.removeTemplate("string");
assertNotSame(count, templateManagement.getTemplates().size());
@@ -89,9 +175,10 @@ public class TemplateManagementTest extends TestCase {
TemplateManagement templateManagement =
new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
- ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
int count = templateManagement.getTemplates().get("integer").getFields().size();
- templateManagement.updateTemplate("integer", "type", false);
+ templateManagement.updateTemplate("integer", new Field("type"), false);
assertNotSame(count, templateManagement.getTemplates().get("integer").getFields().size());
}
@@ -104,10 +191,12 @@ public class TemplateManagementTest extends TestCase {
TemplateManagement templateManagement =
new TemplateManagement(
ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
- ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.properties"));
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"),
+ ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json"));
boolean has = true;
- ArrayList<String> templateFieldsString =
- new ArrayList<>(Arrays.asList("type", "description", "required", "metadata", "constraints"));
+ List<Field> templateFieldsString =
+ new ArrayList<>(Arrays.asList(new Field("type"), new Field("description"), new Field("required"),
+ new Field("metadata"), new Field("constraints")));
Template templateTest = new Template("String", templateFieldsString);
has = templateManagement.hasTemplate(templateTest);
assertEquals(false, has);
diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java
index ebc119f0d..4ffb4e28e 100644
--- a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java
+++ b/src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java
@@ -25,6 +25,7 @@ package org.onap.clamp.clds.tosca.update;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import junit.framework.TestCase;
public class TemplateTest extends TestCase {
@@ -34,7 +35,8 @@ public class TemplateTest extends TestCase {
*/
public void testCheckFields() {
Template toTest = new Template("toTest");
- ArrayList<String> fields = new ArrayList<>(Arrays.asList("type", "description", "enum"));
+ List<Field> fields = new ArrayList<>(Arrays.asList(new Field("type"), new Field("description"),new Field(
+ "enum")));
toTest.setFields(fields);
Template reference = new Template("toTest");
reference.setFields(fields);
diff --git a/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java b/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java
index 2cd301850..03b2e506d 100644
--- a/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java
+++ b/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java
@@ -69,11 +69,16 @@ public class PolicyEngineControllerTestItCase {
assertThat(firstExecution).isNotNull();
List<PolicyModel> policyModelsList = policyModelsRepository.findAll();
assertThat(policyModelsList.size()).isGreaterThanOrEqualTo(5);
- assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.operational.Drools", null, "1.0.0"));
- assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.operational.Apex", null, "1.0.0"));
- assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.guard.FrequencyLimiter", null, "1.0.0"));
- assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.guard.Blacklist", null, "1.0.0"));
- assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.guard.MinMax", null, "2.0.0"));
+ assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.operational.common.Drools",
+ null, "1.0.0"));
+ assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.operational.common.Apex",
+ null, "1.0.0"));
+ assertThat(policyModelsList)
+ .contains(new PolicyModel("onap.policies.controlloop.guard.common.FrequencyLimiter", null, "1.0.0"));
+ assertThat(policyModelsList)
+ .contains(new PolicyModel("onap.policies.controlloop.guard.common.Blacklist", null, "1.0.0"));
+ assertThat(policyModelsList)
+ .contains(new PolicyModel("onap.policies.controlloop.guard.common.MinMax", null, "2.0.0"));
// Re-do it to check that there is no issue with duplicate key
policyController.synchronizeAllPolicies();
diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties
index 54ba0900c..0e453535c 100644
--- a/src/test/resources/application.properties
+++ b/src/test/resources/application.properties
@@ -165,4 +165,7 @@ clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Princ
# Configuration settings for CDS
clamp.config.cds.url=http4://localhost:${docker.http-cache.port.host}
clamp.config.cds.userName=ccsdkapps
-clamp.config.cds.password=ccsdkapps \ No newline at end of file
+clamp.config.cds.password=ccsdkapps
+
+## Tosca converter
+clamp.config.tosca.converter.templates=classpath:/clds/tosca_updates/templates.json \ No newline at end of file
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes&#63;connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes&#63;connectionTimeToLive=5000/.file
index 4b27438cc..0cce9c3d9 100644
--- a/src/test/resources/http-cache/example/policy/api/v1/policytypes&#63;connectionTimeToLive=5000/.file
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes&#63;connectionTimeToLive=5000/.file
@@ -1,34 +1,34 @@
tosca_definitions_version: tosca_simple_yaml_1_0_0
policy_types:
- - onap.policies.controlloop.operational.Drools:
+ - onap.policies.controlloop.operational.common.Drools:
version: 1.0.0
description: Operational Policy for Control Loops using the Drools PDP
derived_from: onapy.policies.controlloop.Operational
properties:
# Omitted for brevity, see Section 1
- - onap.policies.controlloop.operational.Apex:
+ - onap.policies.controlloop.operational.common.Apex:
version: 1.0.0
description: Operational Policy for Control Loops using the APEX PDP
derived_from: onap.policies.controlloop.Operational
properties:
# Omitted for brevity, see Section 1
- - onap.policies.controlloop.guard.FrequencyLimiter:
+ - onap.policies.controlloop.guard.common.FrequencyLimiter:
version: 1.0.0
description: Supports limiting the frequency of actions being taken by a Actor.
derived_from: onap.policies.controlloop.Guard
properties:
# Omitted for brevity, see Section 1
- - onap.policies.controlloop.guard.Blacklist:
+ - onap.policies.controlloop.guard.common.Blacklist:
version: 1.0.0
description: Supports blacklist of VNF's from performing control loop actions on.
derived_from: onap.policies.controlloop.Guard
properties:
# Omitted for brevity, see Section 1
- - onap.policies.controlloop.guard.MinMax:
+ - onap.policies.controlloop.guard.common.MinMax:
version: 2.0.0
description: Supports Min/Max number of VF Modules
derived_from: onap.policies.controlloop.Guard
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.Blacklist/versions/1.0.0&#63;connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.Blacklist/versions/1.0.0&#63;connectionTimeToLive=5000/.file
deleted file mode 100644
index 91a825212..000000000
--- a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.Blacklist/versions/1.0.0&#63;connectionTimeToLive=5000/.file
+++ /dev/null
@@ -1,40 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-policy_types:
- onap.policies.controlloop.Guard:
- derived_from: tosca.policies.Root
- version: 1.0.0
- description: Guard Policies for Control Loop Operational Policies
- onap.policies.controlloop.guard.Blacklist:
- derived_from: onap.policies.controlloop.Guard
- version: 1.0.0
- description: Supports blacklist of VNF's from performing control loop actions on.
- properties:
- blacklist_policy:
- type: map
- description: null
- entry_schema:
- type: onap.datatypes.guard.Blacklist
-data_types:
- onap.datatypes.guard.Blacklist:
- derived_from: tosca.datatypes.Root
- properties:
- actor:
- type: string
- description: Specifies the Actor
- required: true
- recipe:
- type: string
- description: Specified the Recipe
- required: true
- time_range:
- type: tosca.datatypes.TimeInterval
- description: An optional range of time during the day the blacklist is valid for.
- required: false
- controlLoopName:
- type: string
- description: An optional specific control loop to apply this guard to.
- required: false
- blacklist:
- type: list
- description: List of VNF's
- required: true \ No newline at end of file
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.FrequencyLimiter/versions/1.0.0&#63;connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.FrequencyLimiter/versions/1.0.0&#63;connectionTimeToLive=5000/.file
deleted file mode 100644
index 45e5471fc..000000000
--- a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.FrequencyLimiter/versions/1.0.0&#63;connectionTimeToLive=5000/.file
+++ /dev/null
@@ -1,50 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-policy_types:
- onap.policies.controlloop.Guard:
- derived_from: tosca.policies.Root
- version: 1.0.0
- description: Guard Policies for Control Loop Operational Policies
- onap.policies.controlloop.guard.FrequencyLimiter:
- derived_from: onap.policies.controlloop.Guard
- version: 1.0.0
- description: Supports limiting the frequency of actions being taken by a Actor.
- properties:
- frequency_policy:
- type: map
- description: null
- entry_schema:
- type: onap.datatypes.guard.FrequencyLimiter
-data_types:
- onap.datatypes.guard.FrequencyLimiter:
- derived_from: tosca.datatypes.Root
- properties:
- actor:
- type: string
- description: Specifies the Actor
- required: true
- recipe:
- type: string
- description: Specified the Recipe
- required: true
- time_window:
- type: scalar-unit.time
- description: The time window to count the actions against.
- required: true
- limit:
- type: integer
- description: The limit
- required: true
- constraints:
- - greater_than: 0
- time_range:
- type: tosca.datatypes.TimeInterval
- description: An optional range of time during the day the frequency is valid for.
- required: false
- controlLoopName:
- type: string
- description: An optional specific control loop to apply this guard to.
- required: false
- target:
- type: string
- description: An optional specific VNF to apply this guard to.
- required: false \ No newline at end of file
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.MinMax/versions/1.0.0&#63;connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.MinMax/versions/1.0.0&#63;connectionTimeToLive=5000/.file
deleted file mode 100644
index 54c4204e2..000000000
--- a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.MinMax/versions/1.0.0&#63;connectionTimeToLive=5000/.file
+++ /dev/null
@@ -1,44 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0_0
-policy_types:
- onap.policies.controlloop.Guard:
- derived_from: tosca.policies.Root
- version: 1.0.0
- description: Guard Policies for Control Loop Operational Policies
- onap.policies.controlloop.guard.MinMax:
- derived_from: onap.policies.controlloop.Guard
- version: 1.0.0
- description: Supports Min/Max number of VF Modules
- properties:
- minmax_policy:
- type: map
- description: null
- entry_schema:
- type: onap.datatypes.guard.MinMax
-data_types:
- onap.datatypes.guard.MinMax:
- derived_from: tosca.datatypes.Root
- properties:
- actor:
- type: string
- description: Specifies the Actor
- required: true
- recipe:
- type: string
- description: Specified the Recipe
- required: true
- time_range:
- type: tosca.datatypes.TimeInterval
- description: An optional range of time during the day the Min/Max limit is valid for.
- required: false
- controlLoopName:
- type: string
- description: An optional specific control loop to apply this guard to.
- required: false
- min_vf_module_instances:
- type: integer
- required: true
- description: The minimum instances of this VF-Module
- max_vf_module_instances:
- type: integer
- required: false
- description: The maximum instances of this VF-Module \ No newline at end of file
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.Blacklist/versions/1.0.0&#63;connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.Blacklist/versions/1.0.0&#63;connectionTimeToLive=5000/.file
new file mode 100644
index 000000000..79e79f0fe
--- /dev/null
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.Blacklist/versions/1.0.0&#63;connectionTimeToLive=5000/.file
@@ -0,0 +1,38 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.guard.Common:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ description: |
+ This is the base Policy Type for Guard policies that guard the execution of Operational
+ Policies.
+ properties:
+ actor:
+ type: string
+ description: Specifies the Actor the guard applies to.
+ required: true
+ operation:
+ type: string
+ description: Specified the operation that the actor is performing the guard applies to.
+ required: true
+ timeRange:
+ type: tosca.datatypes.TimeInterval
+ description: |
+ An optional range of time during the day the guard policy is valid for.
+ required: false
+ id:
+ type: string
+ description: The Control Loop id this applies to.
+ required: false
+ onap.policies.controlloop.guard.common.Blacklist:
+ derived_from: onap.policies.controlloop.guard.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ description: Supports blacklist of entity id's from performing control loop actions on.
+ properties:
+ blacklist:
+ type: list
+ description: List of entity id's
+ required: true
+ entry_schema:
+ type: string \ No newline at end of file
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.Blacklist/versions/1.0.0&#63;connectionTimeToLive=5000/.header b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.Blacklist/versions/1.0.0&#63;connectionTimeToLive=5000/.header
index 6a280d972..6a280d972 100644
--- a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.Blacklist/versions/1.0.0&#63;connectionTimeToLive=5000/.header
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.Blacklist/versions/1.0.0&#63;connectionTimeToLive=5000/.header
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter/versions/1.0.0&#63;connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter/versions/1.0.0&#63;connectionTimeToLive=5000/.file
new file mode 100644
index 000000000..163027e46
--- /dev/null
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter/versions/1.0.0&#63;connectionTimeToLive=5000/.file
@@ -0,0 +1,47 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.guard.Common:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ description: |
+ This is the base Policy Type for Guard policies that guard the execution of Operational
+ Policies.
+ properties:
+ actor:
+ type: string
+ description: Specifies the Actor the guard applies to.
+ required: true
+ operation:
+ type: string
+ description: Specified the operation that the actor is performing the guard applies to.
+ required: true
+ timeRange:
+ type: tosca.datatypes.TimeInterval
+ description: |
+ An optional range of time during the day the guard policy is valid for.
+ required: false
+ id:
+ type: string
+ description: The Control Loop id this applies to.
+ required: false
+ onap.policies.controlloop.guard.common.FrequencyLimiter:
+ derived_from: onap.policies.controlloop.guard.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ description: Supports limiting the frequency of actions being taken by a Actor.
+ properties:
+ timeWindow:
+ type: integer
+ description: The time window to count the actions against.
+ required: true
+ timeUnits:
+ type: string
+ description: The units of time the window is counting.
+ constraints:
+ - valid_values: ["second", "minute", "hour", "day", "week", "month", "year"]
+ limit:
+ type: integer
+ description: The limit
+ required: true
+ constraints:
+ - greater_than: 0 \ No newline at end of file
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.FrequencyLimiter/versions/1.0.0&#63;connectionTimeToLive=5000/.header b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter/versions/1.0.0&#63;connectionTimeToLive=5000/.header
index 6a280d972..6a280d972 100644
--- a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.FrequencyLimiter/versions/1.0.0&#63;connectionTimeToLive=5000/.header
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.FrequencyLimiter/versions/1.0.0&#63;connectionTimeToLive=5000/.header
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.MinMax/versions/2.0.0&#63;connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.MinMax/versions/2.0.0&#63;connectionTimeToLive=5000/.file
new file mode 100644
index 000000000..78bdde746
--- /dev/null
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.MinMax/versions/2.0.0&#63;connectionTimeToLive=5000/.file
@@ -0,0 +1,40 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.guard.Common:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ description: |
+ This is the base Policy Type for Guard policies that guard the execution of Operational
+ Policies.
+ properties:
+ actor:
+ type: string
+ description: Specifies the Actor the guard applies to.
+ required: true
+ operation:
+ type: string
+ description: Specified the operation that the actor is performing the guard applies to.
+ required: true
+ timeRange:
+ type: tosca.datatypes.TimeInterval
+ description: |
+ An optional range of time during the day the guard policy is valid for.
+ required: false
+ id:
+ type: string
+ description: The Control Loop id this applies to.
+ required: false
+ onap.policies.controlloop.guard.common.MinMax:
+ derived_from: onap.policies.controlloop.guard.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ description: Supports Min/Max number of entity for scaling operations
+ properties:
+ min:
+ type: integer
+ required: true
+ description: The minimum instances of this entity
+ max:
+ type: integer
+ required: false
+ description: The maximum instances of this entity \ No newline at end of file
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.MinMax/versions/1.0.0&#63;connectionTimeToLive=5000/.header b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.MinMax/versions/2.0.0&#63;connectionTimeToLive=5000/.header
index 6a280d972..6a280d972 100644
--- a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.MinMax/versions/1.0.0&#63;connectionTimeToLive=5000/.header
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.guard.common.MinMax/versions/2.0.0&#63;connectionTimeToLive=5000/.header
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Apex/versions/1.0.0&#63;connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Apex/versions/1.0.0&#63;connectionTimeToLive=5000/.file
new file mode 100644
index 000000000..44f55879e
--- /dev/null
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Apex/versions/1.0.0&#63;connectionTimeToLive=5000/.file
@@ -0,0 +1,158 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.operational.common.Apex:
+ derived_from: onap.policies.controlloop.operational.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ description: Operational policies for Apex PDP
+ properties:
+ engineServiceParameters:
+ type: string
+ description: The engine parameters like name, instanceCount, policy implementation, parameters etc.
+ required: true
+ eventInputParameters:
+ type: string
+ description: The event input parameters.
+ required: true
+ eventOutputParameters:
+ type: string
+ description: The event output parameters.
+ required: true
+ javaProperties:
+ type: string
+ description: Name/value pairs of properties to be set for APEX if needed.
+ required: false
+ onap.policies.controlloop.operational.Common:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ description: |
+ Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant
+ Policy Types. This does NOT support the legacy Policy YAML policy type.
+ properties:
+ id:
+ type: string
+ description: The unique control loop id.
+ required: true
+ timeout:
+ type: integer
+ description: |
+ Overall timeout for executing all the operations. This timeout should equal or exceed the total
+ timeout for each operation listed.
+ required: true
+ abatement:
+ type: boolean
+ description: Whether an abatement event message will be expected for the control loop from DCAE.
+ required: true
+ default: false
+ trigger:
+ type: string
+ description: Initial operation to execute upon receiving an Onset event message for the Control Loop.
+ required: true
+ operations:
+ type: list
+ description: List of operations to be performed when Control Loop is triggered.
+ required: true
+ entry_schema:
+ type: onap.datatype.controlloop.Operation
+data_types:
+ onap.datatype.controlloop.Target:
+ derived_from: tosca.datatypes.Root
+ description: Definition for a entity in A&AI to perform a control loop operation on
+ properties:
+ targetType:
+ type: string
+ description: Category for the target type
+ required: true
+ constraints:
+ - valid_values: [VNF, VM, VFMODULE, PNF]
+ entityIds:
+ type: map
+ description: |
+ Map of values that identify the resource. If none are provided, it is assumed that the
+ entity that generated the ONSET event will be the target.
+ required: false
+ entry_schema:
+ type: string
+
+ onap.datatype.controlloop.Actor:
+ derived_from: tosca.datatypes.Root
+ description: An actor/operation/target definition
+ properties:
+ actor:
+ type: string
+ description: The actor performing the operation.
+ required: true
+ operation:
+ type: string
+ description: The operation the actor is performing.
+ required: true
+ target:
+ type: onap.datatype.controlloop.Target
+ description: The resource the operation should be performed on.
+ required: true
+ metadata:
+ clamp_possible_values: <string:see clamp project for syntax>
+ payload:
+ type: map
+ description: Name/value pairs of payload information passed by Policy to the actor
+ required: false
+ entry_schema:
+ type: string
+
+ onap.datatype.controlloop.Operation:
+ derived_from: tosca.datatypes.Root
+ description: An operation supported by an actor
+ properties:
+ id:
+ type: string
+ description: Unique identifier for the operation
+ required: true
+ description:
+ type: string
+ description: A user-friendly description of the intent for the operation
+ required: false
+ operation:
+ type: onap.datatype.controlloop.Actor
+ description: The definition of the operation to be performed.
+ required: true
+ metadata:
+ clamp_possible_values: <string:see clamp project for syntax>
+ timeout:
+ type: integer
+ description: The amount of time for the actor to perform the operation.
+ required: true
+ retries:
+ type: integer
+ description: The number of retries the actor should attempt to perform the operation.
+ required: true
+ default: 0
+ success:
+ type: string
+ description: Points to the operation to invoke on success. A value of "final_success" indicates and end to the operation.
+ required: false
+ default: final_success
+ failure:
+ type: string
+ description: Points to the operation to invoke on Actor operation failure.
+ required: false
+ default: final_failure
+ failure_timeout:
+ type: string
+ description: Points to the operation to invoke when the time out for the operation occurs.
+ required: false
+ default: final_failure_timeout
+ failure_retries:
+ type: string
+ description: Points to the operation to invoke when the current operation has exceeded its max retries.
+ required: false
+ default: final_failure_retries
+ failure_exception:
+ type: string
+ description: Points to the operation to invoke when the current operation causes an exception.
+ required: false
+ default: final_failure_exception
+ failure_guard:
+ type: string
+ description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.
+ required: false
+ default: final_failure_guard \ No newline at end of file
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Apex/versions/1.0.0&#63;connectionTimeToLive=5000/.header b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Apex/versions/1.0.0&#63;connectionTimeToLive=5000/.header
new file mode 100644
index 000000000..6a280d972
--- /dev/null
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Apex/versions/1.0.0&#63;connectionTimeToLive=5000/.header
@@ -0,0 +1 @@
+{"Transfer-Encoding": "chunked", "Set-Cookie": "JSESSIONID=158qxkdtdobkd1umr3ikkgrmlx;Path=/", "Expires": "Thu, 01 Jan 1970 00:00:00 GMT", "Server": "Jetty(9.3.21.v20170918)", "Content-Type": "application/json", "X-ECOMP-RequestID": "e2ddb3c8-994f-47df-b4dc-097d4fb55c08"} \ No newline at end of file
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0&#63;connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0&#63;connectionTimeToLive=5000/.file
new file mode 100644
index 000000000..72897be07
--- /dev/null
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0&#63;connectionTimeToLive=5000/.file
@@ -0,0 +1,146 @@
+tosca_definitions_version: tosca_simple_yaml_1_1_0
+policy_types:
+ onap.policies.controlloop.operational.common.Drools:
+ derived_from: onap.policies.controlloop.operational.Common
+ type_version: 1.0.0
+ version: 1.0.0
+ description: Operational policies for Drools PDP
+ properties:
+ controllerName:
+ type: string
+ description: Drools controller properties
+ required: false
+ onap.policies.controlloop.operational.Common:
+ derived_from: tosca.policies.Root
+ version: 1.0.0
+ description: |
+ Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant
+ Policy Types. This does NOT support the legacy Policy YAML policy type.
+ properties:
+ id:
+ type: string
+ description: The unique control loop id.
+ required: true
+ timeout:
+ type: integer
+ description: |
+ Overall timeout for executing all the operations. This timeout should equal or exceed the total
+ timeout for each operation listed.
+ required: true
+ abatement:
+ type: boolean
+ description: Whether an abatement event message will be expected for the control loop from DCAE.
+ required: true
+ default: false
+ trigger:
+ type: string
+ description: Initial operation to execute upon receiving an Onset event message for the Control Loop.
+ required: true
+ operations:
+ type: list
+ description: List of operations to be performed when Control Loop is triggered.
+ required: true
+ entry_schema:
+ type: onap.datatype.controlloop.Operation
+data_types:
+ onap.datatype.controlloop.Target:
+ derived_from: tosca.datatypes.Root
+ description: Definition for a entity in A&AI to perform a control loop operation on
+ properties:
+ targetType:
+ type: string
+ description: Category for the target type
+ required: true
+ constraints:
+ - valid_values: [VNF, VM, VFMODULE, PNF]
+ entityIds:
+ type: map
+ description: |
+ Map of values that identify the resource. If none are provided, it is assumed that the
+ entity that generated the ONSET event will be the target.
+ required: false
+ entry_schema:
+ type: string
+
+ onap.datatype.controlloop.Actor:
+ derived_from: tosca.datatypes.Root
+ description: An actor/operation/target definition
+ properties:
+ actor:
+ type: string
+ description: The actor performing the operation.
+ required: true
+ operation:
+ type: string
+ description: The operation the actor is performing.
+ required: true
+ target:
+ type: onap.datatype.controlloop.Target
+ description: The resource the operation should be performed on.
+ required: true
+ metadata:
+ clamp_possible_values: <string:see clamp project for syntax>
+ payload:
+ type: map
+ description: Name/value pairs of payload information passed by Policy to the actor
+ required: false
+ entry_schema:
+ type: string
+
+ onap.datatype.controlloop.Operation:
+ derived_from: tosca.datatypes.Root
+ description: An operation supported by an actor
+ properties:
+ id:
+ type: string
+ description: Unique identifier for the operation
+ required: true
+ description:
+ type: string
+ description: A user-friendly description of the intent for the operation
+ required: false
+ operation:
+ type: onap.datatype.controlloop.Actor
+ description: The definition of the operation to be performed.
+ required: true
+ metadata:
+ clamp_possible_values: <string:see clamp project for syntax>
+ timeout:
+ type: integer
+ description: The amount of time for the actor to perform the operation.
+ required: true
+ retries:
+ type: integer
+ description: The number of retries the actor should attempt to perform the operation.
+ required: true
+ default: 0
+ success:
+ type: string
+ description: Points to the operation to invoke on success. A value of "final_success" indicates and end to the operation.
+ required: false
+ default: final_success
+ failure:
+ type: string
+ description: Points to the operation to invoke on Actor operation failure.
+ required: false
+ default: final_failure
+ failure_timeout:
+ type: string
+ description: Points to the operation to invoke when the time out for the operation occurs.
+ required: false
+ default: final_failure_timeout
+ failure_retries:
+ type: string
+ description: Points to the operation to invoke when the current operation has exceeded its max retries.
+ required: false
+ default: final_failure_retries
+ failure_exception:
+ type: string
+ description: Points to the operation to invoke when the current operation causes an exception.
+ required: false
+ default: final_failure_exception
+ failure_guard:
+ type: string
+ description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.
+ required: false
+ default: final_failure_guard \ No newline at end of file
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0&#63;connectionTimeToLive=5000/.header b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0&#63;connectionTimeToLive=5000/.header
new file mode 100644
index 000000000..6a280d972
--- /dev/null
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0&#63;connectionTimeToLive=5000/.header
@@ -0,0 +1 @@
+{"Transfer-Encoding": "chunked", "Set-Cookie": "JSESSIONID=158qxkdtdobkd1umr3ikkgrmlx;Path=/", "Expires": "Thu, 01 Jan 1970 00:00:00 GMT", "Server": "Jetty(9.3.21.v20170918)", "Content-Type": "application/json", "X-ECOMP-RequestID": "e2ddb3c8-994f-47df-b4dc-097d4fb55c08"} \ No newline at end of file
diff --git a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0&#63;connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0&#63;connectionTimeToLive=5000/.file
index 5fa4308db..3c17c9004 100644
--- a/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0&#63;connectionTimeToLive=5000/.file
+++ b/src/test/resources/http-cache/example/policy/api/v1/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0&#63;connectionTimeToLive=5000/.file
@@ -1,4 +1,4 @@
-tosca_definitions_version: tosca_simple_yaml_1_0_0
+tosca_definitions_version: tosca_simple_yaml_1_1_0
policy_types:
onap.policies.Monitoring:
derived_from: tosca.policies.Root
@@ -9,10 +9,9 @@ policy_types:
version: 1.0.0
properties:
tca_policy:
- type: map
+ type: onap.datatypes.monitoring.tca_policy
description: TCA Policy JSON
- entry_schema:
- type: onap.datatypes.monitoring.tca_policy
+ required: true
data_types:
onap.datatypes.monitoring.metricsPerEventName:
derived_from: tosca.datatypes.Root
diff --git a/src/test/resources/http-cache/example/policy/pap/v1/pdps&#63;connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/pap/v1/pdps&#63;connectionTimeToLive=5000/.file
index 6b6b372cf..f16f4e899 100644
--- a/src/test/resources/http-cache/example/policy/pap/v1/pdps&#63;connectionTimeToLive=5000/.file
+++ b/src/test/resources/http-cache/example/policy/pap/v1/pdps&#63;connectionTimeToLive=5000/.file
@@ -28,6 +28,10 @@
"properties": {},
"supportedPolicyTypes": [
{
+ "name": "onap.policies.controlloop.operational.common.*",
+ "version": "1.0.0"
+ },
+ {
"name": "onap.policies.controlloop.Operational",
"version": "1.0.0"
}
@@ -42,7 +46,7 @@
"properties": {},
"supportedPolicyTypes": [
{
- "name": "onap.policies.controlloop.Guard",
+ "name": "onap.policies.controlloop.guard.common.*",
"version": "1.0.0"
}
]
diff --git a/src/test/resources/tosca/new-converter/tca-schema.json b/src/test/resources/tosca/new-converter/tca-schema.json
new file mode 100644
index 000000000..3f444aa9e
--- /dev/null
+++ b/src/test/resources/tosca/new-converter/tca-schema.json
@@ -0,0 +1,175 @@
+{
+ "title": "onap.policies.monitoring.cdap.tca.hi.lo.app",
+ "type": "object",
+ "required": [],
+ "properties": {
+ "tca_policy": {
+ "title": "onap.datatypes.monitoring.tca_policy",
+ "type": "object",
+ "required": [
+ "domain",
+ "metricsPerEventName"
+ ],
+ "properties": {
+ "domain": {
+ "type": "string",
+ "description": "Domain name to which TCA needs to be applied",
+ "default": "measurementsForVfScaling",
+ "const": "measurementsForVfScaling"
+ },
+ "metricsPerEventName": {
+ "type": "array",
+ "description": "Contains eventName and threshold details that need to be applied to given eventName",
+ "items": {
+ "title": "onap.datatypes.monitoring.metricsPerEventName",
+ "type": "object",
+ "required": [
+ "controlLoopSchemaType",
+ "eventName",
+ "policyName",
+ "policyScope",
+ "policyVersion",
+ "thresholds"
+ ],
+ "properties": {
+ "controlLoopSchemaType": {
+ "type": "string",
+ "description": "Specifies Control Loop Schema Type for the event Name e.g. VNF, VM",
+ "enum": [
+ "VM",
+ "VNF"
+ ]
+ },
+ "eventName": {
+ "type": "string",
+ "description": "Event name to which thresholds need to be applied"
+ },
+ "policyName": {
+ "type": "string",
+ "description": "TCA Policy Scope Name"
+ },
+ "policyScope": {
+ "type": "string",
+ "description": "TCA Policy Scope"
+ },
+ "policyVersion": {
+ "type": "string",
+ "description": "TCA Policy Scope Version"
+ },
+ "thresholds": {
+ "type": "array",
+ "description": "Thresholds associated with eventName",
+ "items": {
+ "title": "onap.datatypes.monitoring.thresholds",
+ "type": "object",
+ "required": [
+ "closedLoopControlName",
+ "closedLoopEventStatus",
+ "direction",
+ "fieldPath",
+ "severity",
+ "thresholdValue",
+ "version"
+ ],
+ "properties": {
+ "closedLoopControlName": {
+ "type": "string",
+ "description": "Closed Loop Control Name associated with the threshold"
+ },
+ "closedLoopEventStatus": {
+ "type": "string",
+ "description": "Closed Loop Event Status of the threshold",
+ "enum": [
+ "ONSET",
+ "ABATED"
+ ]
+ },
+ "direction": {
+ "type": "string",
+ "description": "Direction of the threshold",
+ "enum": [
+ "LESS",
+ "LESS_OR_EQUAL",
+ "GREATER",
+ "GREATER_OR_EQUAL",
+ "EQUAL"
+ ]
+ },
+ "fieldPath": {
+ "type": "string",
+ "description": "Json field Path as per CEF message which needs to be analyzed for TCA",
+ "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"
+ ]
+ },
+ "severity": {
+ "type": "string",
+ "description": "Threshold Event Severity",
+ "enum": [
+ "CRITICAL",
+ "MAJOR",
+ "MINOR",
+ "WARNING",
+ "NORMAL"
+ ]
+ },
+ "thresholdValue": {
+ "type": "integer",
+ "description": "Threshold value for the field Path inside CEF message"
+ },
+ "version": {
+ "type": "string",
+ "description": "Version number associated with the threshold"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/src/test/resources/tosca/templates.properties b/src/test/resources/tosca/templates.properties
deleted file mode 100644
index 792238bd3..000000000
--- a/src/test/resources/tosca/templates.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-Integer=type,description,required
-Boolean=description,required
-String=type,description,required,metadata,constraints
-Number=description,required
-Map=type,description,required,entry_schema
-List=type,required,entry_schema
-onap.datatype.controlloop.Actor=type,description,required,metadata \ No newline at end of file