From 8fdf84c7f2bd03332e69d13e35414020053c2977 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 15 Mar 2019 12:36:38 +0000 Subject: Add serialization for Tosca Model Added tests for Yaml policy monitoring Added provider interface calls in provider and structure for handling legacy APIs. Issue-ID: POLICY-1195 Change-Id: I4825272e0713b9e6a4b89753828de8905bcffbd1 Signed-off-by: liamfallon --- .../tosca/concepts/ToscaServiceTemplateTest.java | 3 +- .../tosca/concepts/ToscaTopologyTemplateTest.java | 9 +- .../MonitoringPolicySerializationTest.java | 94 ++++++++++++ models-tosca/src/test/resources/logback-test.xml | 50 +++++++ .../src/test/resources/policies/README.txt | 25 ++++ .../vCPE.policy.monitoring.input.tosca.json | 48 +++++++ .../vCPE.policy.monitoring.input.tosca.yaml | 35 +++++ .../vCPE.policy.monitoring.output.tosca.yaml | 36 +++++ .../policies/vCPE.policy.operational.input.json | 4 + .../vCPE.policy.operational.input.tosca.yaml | 33 +++++ .../policies/vCPE.policy.operational.output.json | 5 + .../vCPE.policy.operational.output.tosca.json | 46 ++++++ .../vCPE.policy.operational.output.tosca.yaml | 34 +++++ .../vDNS.policy.guard.frequency.input.json | 14 ++ .../vDNS.policy.guard.frequency.output.json | 23 +++ .../policies/vDNS.policy.guard.minmax.input.json | 14 ++ .../policies/vDNS.policy.guard.minmax.output.json | 10 ++ .../vDNS.policy.monitoring.input.tosca.json | 46 ++++++ .../vDNS.policy.monitoring.input.tosca.yaml | 35 +++++ .../vDNS.policy.monitoring.output.tosca.yaml | 36 +++++ .../policies/vDNS.policy.operational.input.json | 4 + .../vDNS.policy.operational.input.tosca.yaml | 35 +++++ .../policies/vDNS.policy.operational.output.json | 5 + .../vDNS.policy.operational.output.tosca.json | 49 +++++++ .../vDNS.policy.operational.output.tosca.yaml | 36 +++++ .../vFirewall.policy.monitoring.input.tosca.json | 43 ++++++ .../vFirewall.policy.monitoring.input.tosca.yaml | 35 +++++ .../vFirewall.policy.operational.input.json | 4 + .../vFirewall.policy.operational.input.tosca.json | 46 ++++++ .../vFirewall.policy.operational.input.tosca.yaml | 35 +++++ .../vFirewall.policy.operational.output.json | 5 + .../vFirewall.policy.operational.output.tosca.yaml | 36 +++++ ...n2.collectors.datafile.datafile-app-server.yaml | 17 +++ .../onap.policy.monitoring.cdap.tca.hi.lo.app.yaml | 158 +++++++++++++++++++++ 34 files changed, 1103 insertions(+), 5 deletions(-) create mode 100644 models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/MonitoringPolicySerializationTest.java create mode 100644 models-tosca/src/test/resources/logback-test.xml create mode 100644 models-tosca/src/test/resources/policies/README.txt create mode 100644 models-tosca/src/test/resources/policies/vCPE.policy.monitoring.input.tosca.json create mode 100644 models-tosca/src/test/resources/policies/vCPE.policy.monitoring.input.tosca.yaml create mode 100644 models-tosca/src/test/resources/policies/vCPE.policy.monitoring.output.tosca.yaml create mode 100644 models-tosca/src/test/resources/policies/vCPE.policy.operational.input.json create mode 100644 models-tosca/src/test/resources/policies/vCPE.policy.operational.input.tosca.yaml create mode 100644 models-tosca/src/test/resources/policies/vCPE.policy.operational.output.json create mode 100644 models-tosca/src/test/resources/policies/vCPE.policy.operational.output.tosca.json create mode 100644 models-tosca/src/test/resources/policies/vCPE.policy.operational.output.tosca.yaml create mode 100644 models-tosca/src/test/resources/policies/vDNS.policy.guard.frequency.input.json create mode 100644 models-tosca/src/test/resources/policies/vDNS.policy.guard.frequency.output.json create mode 100644 models-tosca/src/test/resources/policies/vDNS.policy.guard.minmax.input.json create mode 100644 models-tosca/src/test/resources/policies/vDNS.policy.guard.minmax.output.json create mode 100644 models-tosca/src/test/resources/policies/vDNS.policy.monitoring.input.tosca.json create mode 100644 models-tosca/src/test/resources/policies/vDNS.policy.monitoring.input.tosca.yaml create mode 100644 models-tosca/src/test/resources/policies/vDNS.policy.monitoring.output.tosca.yaml create mode 100644 models-tosca/src/test/resources/policies/vDNS.policy.operational.input.json create mode 100644 models-tosca/src/test/resources/policies/vDNS.policy.operational.input.tosca.yaml create mode 100644 models-tosca/src/test/resources/policies/vDNS.policy.operational.output.json create mode 100644 models-tosca/src/test/resources/policies/vDNS.policy.operational.output.tosca.json create mode 100644 models-tosca/src/test/resources/policies/vDNS.policy.operational.output.tosca.yaml create mode 100644 models-tosca/src/test/resources/policies/vFirewall.policy.monitoring.input.tosca.json create mode 100644 models-tosca/src/test/resources/policies/vFirewall.policy.monitoring.input.tosca.yaml create mode 100644 models-tosca/src/test/resources/policies/vFirewall.policy.operational.input.json create mode 100644 models-tosca/src/test/resources/policies/vFirewall.policy.operational.input.tosca.json create mode 100644 models-tosca/src/test/resources/policies/vFirewall.policy.operational.input.tosca.yaml create mode 100644 models-tosca/src/test/resources/policies/vFirewall.policy.operational.output.json create mode 100644 models-tosca/src/test/resources/policies/vFirewall.policy.operational.output.tosca.yaml create mode 100644 models-tosca/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml create mode 100644 models-tosca/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml (limited to 'models-tosca/src/test') diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplateTest.java index 0fc7a0bf3..5d8615814 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplateTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplateTest.java @@ -31,6 +31,7 @@ import java.util.TreeMap; import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; /** @@ -103,7 +104,7 @@ public class ToscaServiceTemplateTest { tst.setPolicyTypes(policyTypes); assertEquals(policyTypes, tst.getPolicyTypes()); - PfConceptKey tttKey = new PfConceptKey("TopologyTemplate", "0.0.1"); + PfReferenceKey tttKey = new PfReferenceKey(tstKey, "TopologyTemplate"); ToscaTopologyTemplate ttt = new ToscaTopologyTemplate(tttKey); tst.setTopologyTemplate(ttt); assertEquals(ttt, tst.getTopologyTemplate()); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplateTest.java index 4a288f183..97bbdbe71 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplateTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplateTest.java @@ -31,6 +31,7 @@ import java.util.TreeMap; import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; /** @@ -43,11 +44,11 @@ public class ToscaTopologyTemplateTest { @Test public void testTopologyTemplatePojo() { assertNotNull(new ToscaTopologyTemplate()); - assertNotNull(new ToscaTopologyTemplate(new PfConceptKey())); + assertNotNull(new ToscaTopologyTemplate(new PfReferenceKey())); assertNotNull(new ToscaTopologyTemplate(new ToscaTopologyTemplate())); try { - new ToscaTopologyTemplate((PfConceptKey) null); + new ToscaTopologyTemplate((PfReferenceKey) null); fail("test should throw an exception"); } catch (Exception exc) { assertEquals("key is marked @NonNull but is null", exc.getMessage()); @@ -60,7 +61,7 @@ public class ToscaTopologyTemplateTest { assertEquals("copyConcept is marked @NonNull but is null", exc.getMessage()); } - PfConceptKey tttKey = new PfConceptKey("ttt", "0.0.1"); + PfReferenceKey tttKey = new PfReferenceKey("tst", "0.0.1", "ttt"); ToscaTopologyTemplate ttt = new ToscaTopologyTemplate(tttKey); ttt.setDescription("A Description"); @@ -89,7 +90,7 @@ public class ToscaTopologyTemplateTest { assertEquals(0, ttt.compareTo(ttt)); assertFalse(ttt.compareTo(ttt.getKey()) == 0); - PfConceptKey otherDtKey = new PfConceptKey("otherDt", "0.0.1"); + PfReferenceKey otherDtKey = new PfReferenceKey("otherSt", "0.0.1", "otherDt"); ToscaTopologyTemplate otherDt = new ToscaTopologyTemplate(otherDtKey); assertFalse(ttt.compareTo(otherDt) == 0); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/MonitoringPolicySerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/MonitoringPolicySerializationTest.java new file mode 100644 index 000000000..07f5bca7d --- /dev/null +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/MonitoringPolicySerializationTest.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.serialization; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import com.google.gson.Gson; +import com.google.gson.JsonSyntaxException; + +import java.io.IOException; + +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.common.utils.resources.TextFileUtils; +import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.serialization.simple.ToscaServiceTemplateMessageBodyHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yaml.snakeyaml.Yaml; + +/** + * Test serialization of monitoring policies. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +public class MonitoringPolicySerializationTest { + // Logger for this class + private static final Logger LOGGER = LoggerFactory.getLogger(MonitoringPolicySerializationTest.class); + + private Gson gson; + + @Before + public void setUp() { + gson = new ToscaServiceTemplateMessageBodyHandler().getGson(); + } + + @Test + public void testJsonDeserialization() throws JsonSyntaxException, IOException { + ToscaServiceTemplate serviceTemplate = gson.fromJson( + TextFileUtils + .getTextFileAsString("src/test/resources/policies/vCPE.policy.monitoring.input.tosca.json"), + ToscaServiceTemplate.class); + + assertNotNull(serviceTemplate); + LOGGER.info(serviceTemplate.validate(new PfValidationResult()).toString()); + assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid()); + + assertEquals("onap.vcpe.tca:1.0.0", + serviceTemplate.getTopologyTemplate().getPolicies().get("onap.vcpe.tca").getId()); + assertEquals("onap.vcpe.tca:1.0.0", + serviceTemplate.getTopologyTemplate().getPolicies().get("onap.vcpe.tca").getId()); + } + + @Test + public void testYamlDeserialization() throws JsonSyntaxException, IOException { + Yaml yaml = new Yaml(); + Object yamlObject = yaml.load(TextFileUtils + .getTextFileAsString("src/test/resources/policies/vCPE.policy.monitoring.input.tosca.yaml")); + + String yamlAsJsonString = new Gson().toJson(yamlObject); + + ToscaServiceTemplate serviceTemplate = gson.fromJson(yamlAsJsonString, ToscaServiceTemplate.class); + + assertNotNull(serviceTemplate); + LOGGER.info(serviceTemplate.validate(new PfValidationResult()).toString()); + assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid()); + + assertEquals("onap.vcpe.tca:1.0.0", + serviceTemplate.getTopologyTemplate().getPolicies().get("onap.vcpe.tca").getId()); + assertEquals("onap.vcpe.tca:1.0.0", + serviceTemplate.getTopologyTemplate().getPolicies().get("onap.vcpe.tca").getId()); + } +} diff --git a/models-tosca/src/test/resources/logback-test.xml b/models-tosca/src/test/resources/logback-test.xml new file mode 100644 index 000000000..6e2737da6 --- /dev/null +++ b/models-tosca/src/test/resources/logback-test.xml @@ -0,0 +1,50 @@ + + + + + + Apex + + + + + + + %d %contextName [%t] %level %logger{36} - %msg%n + + + + + + + + + ${LOG_DIR}/apex.log + + %d %-5relative [procId=${processId}] [%thread] %-5level + %logger{26} - %msg %n %ex{full} + + + + + + + diff --git a/models-tosca/src/test/resources/policies/README.txt b/models-tosca/src/test/resources/policies/README.txt new file mode 100644 index 000000000..942913d5c --- /dev/null +++ b/models-tosca/src/test/resources/policies/README.txt @@ -0,0 +1,25 @@ +The "input" prefix indicates that this is what the payload looks like on the POST. While the "output" prefix +indicates that this is what the payload looks like when the response goes back to the caller. + +For each of the use cases, there is at least one configuration policy for DCAE Microservice. + +*.monitoring.input.[json|yaml] <-- POST request + +*.monitoring.output.[json|yaml] --> POST response + +The Operational Policies: + +*.operational.input.yaml --> Can Pam change this to JSON?? + +*.operational.output.json --> POST response + +The Guard Policies: + +*.guard.[frequency|minmax].json <-- POST request + +*.guard.[frequency|minmax].json --> POST response + +For DBAO, the following are internal TOSCA Representations for the Operational and Guard policies, with the +contents of the yaml or JSON URL Encoded: + +*.output.tosca.yaml diff --git a/models-tosca/src/test/resources/policies/vCPE.policy.monitoring.input.tosca.json b/models-tosca/src/test/resources/policies/vCPE.policy.monitoring.input.tosca.json new file mode 100644 index 000000000..27de380c2 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vCPE.policy.monitoring.input.tosca.json @@ -0,0 +1,48 @@ +{ + "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "topology_template": { + "policies": [ + { + "onap.vcpe.tca": { + "type": "onap.policies.monitoring.cdap.tca.hi.lo.app", + "version": "1.0.0", + "metadata": { + "policy-id": "onap.vcpe.tca" + }, + "properties": { + "domain": "measurementsForVfScaling", + "metricsPerEventName": [ + { + "eventName": "Measurement_vGMUX", + "controlLoopSchemaType": "VNF", + "policyScope": "DCAE", + "policyName": "DCAE.Config_tca-hi-lo", + "policyVersion": "v0.0.1", + "thresholds": [ + { + "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", + "version": "1.0.2", + "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value", + "thresholdValue": 0, + "direction": "EQUAL", + "severity": "MAJOR", + "closedLoopEventStatus": "ABATED" + }, + { + "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", + "version": "1.0.2", + "fieldPath": "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value", + "thresholdValue": 0, + "direction": "GREATER", + "severity": "CRITICAL", + "closedLoopEventStatus": "ONSET" + } + ] + } + ] + } + } + } + ] + } +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vCPE.policy.monitoring.input.tosca.yaml b/models-tosca/src/test/resources/policies/vCPE.policy.monitoring.input.tosca.yaml new file mode 100644 index 000000000..a193cba41 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vCPE.policy.monitoring.input.tosca.yaml @@ -0,0 +1,35 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +topology_template: + policies: + - + onap.vcpe.tca: + type: onap.policies.monitoring.cdap.tca.hi.lo.app + version: 1.0.0 + metadata: + policy-id: onap.vcpe.tca + properties: + domain: measurementsForVfScaling + metricsPerEventName: + - + eventName: Measurement_vGMUX + controlLoopSchemaType: VNF + policyScope: DCAE + policyName: "DCAE.Config_tca-hi-lo" + policyVersion: "v0.0.1" + thresholds: + - + closedLoopControlName: "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e" + version: "1.0.2" + fieldPath: "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value" + thresholdValue: 0 + direction: EQUAL + severity: MAJOR + closedLoopEventStatus: ABATED + - + closedLoopControlName: "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e" + version: "1.0.2" + fieldPath: "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value" + thresholdValue: 0 + direction: GREATER + severity: CRITICAL + closedLoopEventStatus: ONSET \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vCPE.policy.monitoring.output.tosca.yaml b/models-tosca/src/test/resources/policies/vCPE.policy.monitoring.output.tosca.yaml new file mode 100644 index 000000000..53ac55d28 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vCPE.policy.monitoring.output.tosca.yaml @@ -0,0 +1,36 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +topology_template: + policies: + - + onap.vcpe.tca: + type: onap.policies.monitoring.cdap.tca.hi.lo.app + version: 1.0.0 + metadata: + policy-id: onap.vcpe.tca + policy-version: 1 + properties: + domain: measurementsForVfScaling + metricsPerEventName: + - + eventName: Measurement_vGMUX + controlLoopSchemaType: VNF + policyScope: DCAE + policyName: "DCAE.Config_tca-hi-lo" + policyVersion: "v0.0.1" + thresholds: + - + closedLoopControlName: "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e" + version: "1.0.2" + fieldPath: "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value" + thresholdValue: 0 + direction: EQUAL + severity: MAJOR + closedLoopEventStatus: ABATED + - + closedLoopControlName: "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e" + version: "1.0.2" + fieldPath: "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value" + thresholdValue: 0 + direction: GREATER + severity: CRITICAL + closedLoopEventStatus: ONSET \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vCPE.policy.operational.input.json b/models-tosca/src/test/resources/policies/vCPE.policy.operational.input.json new file mode 100644 index 000000000..393cb0282 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vCPE.policy.operational.input.json @@ -0,0 +1,4 @@ +{ + "policy-id" : "operational.restart", + "content" : "controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20controlLoopName%3A%20ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0A%20%20trigger_policy%3A%20unique-policy-id-1-restart%0A%20%20timeout%3A%203600%0A%20%20abatement%3A%20true%0A%20%0Apolicies%3A%0A%20%20-%20id%3A%20unique-policy-id-1-restart%0A%20%20%20%20name%3A%20Restart%20the%20VM%0A%20%20%20%20description%3A%0A%20%20%20%20actor%3A%20APPC%0A%20%20%20%20recipe%3A%20Restart%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20type%3A%20VM%0A%20%20%20%20retry%3A%203%0A%20%20%20%20timeout%3A%201200%0A%20%20%20%20success%3A%20final_success%0A%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20failure_guard%3A%20final_failure_guard" +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vCPE.policy.operational.input.tosca.yaml b/models-tosca/src/test/resources/policies/vCPE.policy.operational.input.tosca.yaml new file mode 100644 index 000000000..dda0169f1 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vCPE.policy.operational.input.tosca.yaml @@ -0,0 +1,33 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +topology_template: + policies: + - + operational.restart: + type: onap.policies.controlloop.Operational + version: 1.0.0 + metadata: + policy-id: operational.restart + properties: + controlLoop: + version: 2.0.0 + controlLoopName: ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e + trigger_policy: unique-policy-id-1-restart + timeout: 3600 + abatement: true + + policies: + - id: unique-policy-id-1-restart + name: Restart the VM + description: + actor: APPC + recipe: Restart + target: + type: VM + retry: 3 + timeout: 1200 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + failure_guard: final_failure_guard \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vCPE.policy.operational.output.json b/models-tosca/src/test/resources/policies/vCPE.policy.operational.output.json new file mode 100644 index 000000000..7d26e8e67 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vCPE.policy.operational.output.json @@ -0,0 +1,5 @@ +{ + "policy-id" : "operational.restart", + "policy-version" : "1", + "content" : "controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20controlLoopName%3A%20ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0A%20%20trigger_policy%3A%20unique-policy-id-1-restart%0A%20%20timeout%3A%203600%0A%20%20abatement%3A%20true%0A%20%0Apolicies%3A%0A%20%20-%20id%3A%20unique-policy-id-1-restart%0A%20%20%20%20name%3A%20Restart%20the%20VM%0A%20%20%20%20description%3A%0A%20%20%20%20actor%3A%20APPC%0A%20%20%20%20recipe%3A%20Restart%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20type%3A%20VM%0A%20%20%20%20retry%3A%203%0A%20%20%20%20timeout%3A%201200%0A%20%20%20%20success%3A%20final_success%0A%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20failure_guard%3A%20final_failure_guard" +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vCPE.policy.operational.output.tosca.json b/models-tosca/src/test/resources/policies/vCPE.policy.operational.output.tosca.json new file mode 100644 index 000000000..d73853735 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vCPE.policy.operational.output.tosca.json @@ -0,0 +1,46 @@ +{ + "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "topology_template": { + "policies": [ + { + "operational.restart": { + "type": "onap.policies.controlloop.Operational", + "version": "1.0.0", + "metadata": { + "policy-id": "operational.restart", + "policy-version": 1 + }, + "properties": { + "controlLoop": { + "version": "2.0.0", + "controlLoopName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", + "trigger_policy": "unique-policy-id-1-restart", + "timeout": 3600, + "abatement": true + }, + "policies": [ + { + "id": "unique-policy-id-1-restart", + "name": "Restart the VM", + "description": null, + "actor": "APPC", + "recipe": "Restart", + "target": { + "type": "VM" + }, + "retry": 3, + "timeout": 1200, + "success": "final_success", + "failure": "final_failure", + "failure_timeout": "final_failure_timeout", + "failure_retries": "final_failure_retries", + "failure_exception": "final_failure_exception", + "failure_guard": "final_failure_guard" + } + ] + } + } + } + ] + } +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vCPE.policy.operational.output.tosca.yaml b/models-tosca/src/test/resources/policies/vCPE.policy.operational.output.tosca.yaml new file mode 100644 index 000000000..e4a06947f --- /dev/null +++ b/models-tosca/src/test/resources/policies/vCPE.policy.operational.output.tosca.yaml @@ -0,0 +1,34 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +topology_template: + policies: + - + operational.restart: + type: onap.policies.controlloop.Operational + version: 1.0.0 + metadata: + policy-id: operational.restart + policy-version: 1 + properties: + controlLoop: + version: 2.0.0 + controlLoopName: ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e + trigger_policy: unique-policy-id-1-restart + timeout: 3600 + abatement: true + + policies: + - id: unique-policy-id-1-restart + name: Restart the VM + description: + actor: APPC + recipe: Restart + target: + type: VM + retry: 3 + timeout: 1200 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + failure_guard: final_failure_guard \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vDNS.policy.guard.frequency.input.json b/models-tosca/src/test/resources/policies/vDNS.policy.guard.frequency.input.json new file mode 100644 index 000000000..442f3ec40 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vDNS.policy.guard.frequency.input.json @@ -0,0 +1,14 @@ +{ + "policy-id" : "guard.frequency.scaleout", + "content" : { + "actor": "SO", + "recipe": "scaleOut", + "targets": ".*", + "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3", + "limit": "1", + "timeWindow": "10", + "timeUnits": "minute", + "guardActiveStart": "00:00:01-05:00", + "guardActiveEnd": "23:59:59-05:00" + } +} diff --git a/models-tosca/src/test/resources/policies/vDNS.policy.guard.frequency.output.json b/models-tosca/src/test/resources/policies/vDNS.policy.guard.frequency.output.json new file mode 100644 index 000000000..48c92c3ba --- /dev/null +++ b/models-tosca/src/test/resources/policies/vDNS.policy.guard.frequency.output.json @@ -0,0 +1,23 @@ +{ + "guard.frequency.scaleout": { + "type": "onap.policies.controlloop.guard.FrequencyLimiter", + "version": "1.0.0", + "metadata": { + "policy-id": "guard.frequency.scaleout", + "policy-version": 1 + }, + "properties": { + "content": { + "actor": "SO", + "recipe": "scaleOut", + "targets": ".*", + "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3", + "limit": "1", + "timeWindow": "10", + "timeUnits": "minute", + "guardActiveStart": "00:00:01-05:00", + "guardActiveEnd": "23:59:59-05:00" + } + } + } +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vDNS.policy.guard.minmax.input.json b/models-tosca/src/test/resources/policies/vDNS.policy.guard.minmax.input.json new file mode 100644 index 000000000..c62a229a6 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vDNS.policy.guard.minmax.input.json @@ -0,0 +1,14 @@ +{ +{ + "policy-id" : "guard.minmax.scaleout", + "contents" : { + "actor": "SO", + "recipe": "scaleOut", + "targets": ".*", + "clname": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3", + "min": "1", + "max": "5", + "guardActiveStart": "00:00:01-05:00", + "guardActiveEnd": "23:59:59-05:00" + } +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vDNS.policy.guard.minmax.output.json b/models-tosca/src/test/resources/policies/vDNS.policy.guard.minmax.output.json new file mode 100644 index 000000000..83d2f272f --- /dev/null +++ b/models-tosca/src/test/resources/policies/vDNS.policy.guard.minmax.output.json @@ -0,0 +1,10 @@ +{ + "guard.minmax.scaleout": { + "type": "onap.policies.controlloop.guard.MinMax", + "version": "1.0.0", + "metadata": { + "policy-id": "guard.minmax.scaleout", + "policy-version": 1 + } + } +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vDNS.policy.monitoring.input.tosca.json b/models-tosca/src/test/resources/policies/vDNS.policy.monitoring.input.tosca.json new file mode 100644 index 000000000..69b52129b --- /dev/null +++ b/models-tosca/src/test/resources/policies/vDNS.policy.monitoring.input.tosca.json @@ -0,0 +1,46 @@ +{ + "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "policies": [ + { + "onap.scaleout.tca": { + "type": "onap.policies.monitoring.cdap.tca.hi.lo.app", + "version": "1.0.0", + "metadata": { + "policy-id": "onap.scaleout.tca" + }, + "properties": { + "domain": "measurementsForVfScaling", + "metricsPerEventName": [ + { + "eventName": "vLoadBalancer", + "controlLoopSchemaType": "VNF", + "policyScope": "type=configuration", + "policyName": "onap.scaleout.tca", + "policyVersion": "v0.0.1", + "thresholds": [ + { + "closedLoopControlName": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3", + "closedLoopEventStatus": "ONSET", + "version": "1.0.2", + "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated", + "thresholdValue": 500, + "direction": "LESS_OR_EQUAL", + "severity": "MAJOR" + }, + { + "closedLoopControlName": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3", + "closedLoopEventStatus": "ONSET", + "version": "1.0.2", + "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated", + "thresholdValue": 5000, + "direction": "GREATER_OR_EQUAL", + "severity": "CRITICAL" + } + ] + } + ] + } + } + } + ] +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vDNS.policy.monitoring.input.tosca.yaml b/models-tosca/src/test/resources/policies/vDNS.policy.monitoring.input.tosca.yaml new file mode 100644 index 000000000..054b994bb --- /dev/null +++ b/models-tosca/src/test/resources/policies/vDNS.policy.monitoring.input.tosca.yaml @@ -0,0 +1,35 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +topology_template: + policies: + - + onap.scaleout.tca: + type: onap.policies.monitoring.cdap.tca.hi.lo.app + version: 1.0.0 + metadata: + policy-id: onap.scaleout.tca + properties: + domain: measurementsForVfScaling + metricsPerEventName: + - + eventName: vLoadBalancer + controlLoopSchemaType: VNF + policyScope: "type=configuration" + policyName: "onap.scaleout.tca" + policyVersion: "v0.0.1" + thresholds: + - + closedLoopControlName: "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3" + closedLoopEventStatus: ONSET + version: "1.0.2" + fieldPath: "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated" + thresholdValue: 500 + direction: LESS_OR_EQUAL + severity: MAJOR + - + closedLoopControlName: "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3" + closedLoopEventStatus: ONSET + version: "1.0.2" + fieldPath: "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated" + thresholdValue: 5000 + direction: GREATER_OR_EQUAL + severity: CRITICAL diff --git a/models-tosca/src/test/resources/policies/vDNS.policy.monitoring.output.tosca.yaml b/models-tosca/src/test/resources/policies/vDNS.policy.monitoring.output.tosca.yaml new file mode 100644 index 000000000..5a2fac7b0 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vDNS.policy.monitoring.output.tosca.yaml @@ -0,0 +1,36 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +topology_template: + policies: + - + onap.scaleout.tca: + type: onap.policies.monitoring.cdap.tca.hi.lo.app + version: 1.0.0 + metadata: + policy-id: onap.scaleout.tca + policy-version: 1 + properties: + domain: measurementsForVfScaling + metricsPerEventName: + - + eventName: vLoadBalancer + controlLoopSchemaType: VNF + policyScope: "type=configuration" + policyName: "onap.scaleout.tca" + policyVersion: "v0.0.1" + thresholds: + - + closedLoopControlName: "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3" + closedLoopEventStatus: ONSET + version: "1.0.2" + fieldPath: "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated" + thresholdValue: 500 + direction: LESS_OR_EQUAL + severity: MAJOR + - + closedLoopControlName: "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3" + closedLoopEventStatus: ONSET + version: "1.0.2" + fieldPath: "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated" + thresholdValue: 5000 + direction: GREATER_OR_EQUAL + severity: CRITICAL diff --git a/models-tosca/src/test/resources/policies/vDNS.policy.operational.input.json b/models-tosca/src/test/resources/policies/vDNS.policy.operational.input.json new file mode 100644 index 000000000..dabde0114 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vDNS.policy.operational.input.json @@ -0,0 +1,4 @@ +{ + "policy-id" : "operational.scaleout", + "content" : "controlLoop%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20version%3A%202.0.0%0A%20%20%20%20%20%20%20%20%20%20%20%20%20controlLoopName%3A%20ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3%0A%20%20%20%20%20%20%20%20%20%20%20%20%20trigger_policy%3A%20unique-policy-id-1-scale-up%0A%20%20%20%20%20%20%20%20%20%20%20%20%20timeout%3A%201200%0A%20%20%20%20%20%20%20%20%20%20%20%20%20abatement%3A%20false%0A%20%20%20%20%20%20%20%20%20%20%20policies%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20-%20id%3A%20unique-policy-id-1-scale-up%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%3A%20Create%20a%20new%20VF%20Module%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20description%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20actor%3A%20SO%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20recipe%3A%20VF%20Module%20Create%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20target%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20type%3A%20VNF%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20payload%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20requestParameters%3A%20'%7B%22usePreload%22%3Atrue%2C%22userParams%22%3A%5B%5D%7D'%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20configurationParameters%3A%20'%5B%7B%22ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B9%5D%22%2C%22oam-ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B16%5D%22%2C%22enabled%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B23%5D%22%7D%5D'%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20retry%3A%200%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20timeout%3A%201200%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20success%3A%20final_success%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_guard%3A%20final_failure_guard" +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vDNS.policy.operational.input.tosca.yaml b/models-tosca/src/test/resources/policies/vDNS.policy.operational.input.tosca.yaml new file mode 100644 index 000000000..0f5498804 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vDNS.policy.operational.input.tosca.yaml @@ -0,0 +1,35 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +topology_template: + policies: + - + operational.scaleout: + type: onap.policies.controlloop.Operational + version: 1.0.0 + metadata: + policy-id: operational.scaleout + properties: + controlLoop: + version: 2.0.0 + controlLoopName: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 + trigger_policy: unique-policy-id-1-scale-up + timeout: 1200 + abatement: false + policies: + - id: unique-policy-id-1-scale-up + name: Create a new VF Module + description: + actor: SO + recipe: VF Module Create + target: + type: VNF + payload: + requestParameters: '{"usePreload":true,"userParams":[]}' + configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[9]","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[16]","enabled":"$.vf-module-topology.vf-module-parameters.param[23]"}]' + retry: 0 + timeout: 1200 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + failure_guard: final_failure_guard \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vDNS.policy.operational.output.json b/models-tosca/src/test/resources/policies/vDNS.policy.operational.output.json new file mode 100644 index 000000000..5ce44e0ba --- /dev/null +++ b/models-tosca/src/test/resources/policies/vDNS.policy.operational.output.json @@ -0,0 +1,5 @@ +{ + "policy-id" : "operational.scaleout", + "policy-version" : "1", + "content" : "controlLoop%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20version%3A%202.0.0%0A%20%20%20%20%20%20%20%20%20%20%20%20%20controlLoopName%3A%20ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3%0A%20%20%20%20%20%20%20%20%20%20%20%20%20trigger_policy%3A%20unique-policy-id-1-scale-up%0A%20%20%20%20%20%20%20%20%20%20%20%20%20timeout%3A%201200%0A%20%20%20%20%20%20%20%20%20%20%20%20%20abatement%3A%20false%0A%20%20%20%20%20%20%20%20%20%20%20policies%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20-%20id%3A%20unique-policy-id-1-scale-up%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%3A%20Create%20a%20new%20VF%20Module%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20description%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20actor%3A%20SO%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20recipe%3A%20VF%20Module%20Create%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20target%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20type%3A%20VNF%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20payload%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20requestParameters%3A%20'%7B%22usePreload%22%3Atrue%2C%22userParams%22%3A%5B%5D%7D'%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20configurationParameters%3A%20'%5B%7B%22ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B9%5D%22%2C%22oam-ip-addr%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B16%5D%22%2C%22enabled%22%3A%22%24.vf-module-topology.vf-module-parameters.param%5B23%5D%22%7D%5D'%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20retry%3A%200%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20timeout%3A%201200%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20success%3A%20final_success%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_guard%3A%20final_failure_guard" +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vDNS.policy.operational.output.tosca.json b/models-tosca/src/test/resources/policies/vDNS.policy.operational.output.tosca.json new file mode 100644 index 000000000..2478ff07a --- /dev/null +++ b/models-tosca/src/test/resources/policies/vDNS.policy.operational.output.tosca.json @@ -0,0 +1,49 @@ +{ + "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "topology_template": { + "policies": [ + { + "operational.scaleout": { + "type": "onap.policies.controlloop.Operational", + "version": "1.0.0", + "metadata": { + "policy-id": "operational.scaleout", + "policy-version": 1 + }, + "properties": null, + "controlLoop": { + "version": "2.0.0", + "controlLoopName": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3", + "trigger_policy": "unique-policy-id-1-scale-up", + "timeout": 1200, + "abatement": false + }, + "policies": [ + { + "id": "unique-policy-id-1-scale-up", + "name": "Create a new VF Module", + "description": null, + "actor": "SO", + "recipe": "VF Module Create", + "target": { + "type": "VNF" + }, + "payload": { + "requestParameters": "{\"usePreload\":true,\"userParams\":[]}", + "configurationParameters": "[{\"ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[9]\",\"oam-ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[16]\",\"enabled\":\"$.vf-module-topology.vf-module-parameters.param[23]\"}]" + }, + "retry": 0, + "timeout": 1200, + "success": "final_success", + "failure": "final_failure", + "failure_timeout": "final_failure_timeout", + "failure_retries": "final_failure_retries", + "failure_exception": "final_failure_exception", + "failure_guard": "final_failure_guard" + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vDNS.policy.operational.output.tosca.yaml b/models-tosca/src/test/resources/policies/vDNS.policy.operational.output.tosca.yaml new file mode 100644 index 000000000..a09a235a4 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vDNS.policy.operational.output.tosca.yaml @@ -0,0 +1,36 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +topology_template: + policies: + - + operational.scaleout: + type: onap.policies.controlloop.Operational + version: 1.0.0 + metadata: + policy-id: operational.scaleout + policy-version: 1 + properties: + controlLoop: + version: 2.0.0 + controlLoopName: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 + trigger_policy: unique-policy-id-1-scale-up + timeout: 1200 + abatement: false + policies: + - id: unique-policy-id-1-scale-up + name: Create a new VF Module + description: + actor: SO + recipe: VF Module Create + target: + type: VNF + payload: + requestParameters: '{"usePreload":true,"userParams":[]}' + configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[9]","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[16]","enabled":"$.vf-module-topology.vf-module-parameters.param[23]"}]' + retry: 0 + timeout: 1200 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + failure_guard: final_failure_guard \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vFirewall.policy.monitoring.input.tosca.json b/models-tosca/src/test/resources/policies/vFirewall.policy.monitoring.input.tosca.json new file mode 100644 index 000000000..1593d2033 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vFirewall.policy.monitoring.input.tosca.json @@ -0,0 +1,43 @@ +{ + "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "policies": [ + { + "onap.vfirewall.tca": { + "type": "onap.policy.monitoring.cdap.tca.hi.lo.app", + "version": "1.0.0", + "properties": { + "domain": "measurementsForVfScaling", + "metricsPerEventName": [ + { + "eventName": "vLoadBalancer", + "controlLoopSchemaType": "VNF", + "policyScope": "resource=vLoadBalancer;type=configuration", + "policyName": "onap.vfirewall.tca", + "policyVersion": "v0.0.1", + "thresholds": [ + { + "closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", + "closedLoopEventStatus": "ONSET", + "version": "1.0.2", + "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated", + "thresholdValue": 500, + "direction": "LESS_OR_EQUAL", + "severity": "MAJOR" + }, + { + "closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", + "closedLoopEventStatus": "ONSET", + "version": "1.0.2", + "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated", + "thresholdValue": 5000, + "direction": "GREATER_OR_EQUAL", + "severity": "CRITICAL" + } + ] + } + ] + } + } + } + ] +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vFirewall.policy.monitoring.input.tosca.yaml b/models-tosca/src/test/resources/policies/vFirewall.policy.monitoring.input.tosca.yaml new file mode 100644 index 000000000..c59b89060 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vFirewall.policy.monitoring.input.tosca.yaml @@ -0,0 +1,35 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +topology_template: + policies: + - + onap.vfirewall.tca: + type: onap.policy.monitoring.cdap.tca.hi.lo.app + version: 1.0.0 + metadata: + policy-id: onap.vfirewall.tca + properties: + domain: measurementsForVfScaling + metricsPerEventName: + - + eventName: vLoadBalancer + controlLoopSchemaType: VNF + policyScope: "resource=vLoadBalancer;type=configuration" + policyName: "onap.vfirewall.tca" + policyVersion: "v0.0.1" + thresholds: + - + closedLoopControlName: "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a" + closedLoopEventStatus: ONSET + version: "1.0.2" + fieldPath: "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated" + thresholdValue: 500 + direction: LESS_OR_EQUAL + severity: MAJOR + - + closedLoopControlName: "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a" + closedLoopEventStatus: ONSET + version: "1.0.2" + fieldPath: "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated" + thresholdValue: 5000 + direction: GREATER_OR_EQUAL + severity: CRITICAL \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vFirewall.policy.operational.input.json b/models-tosca/src/test/resources/policies/vFirewall.policy.operational.input.json new file mode 100644 index 000000000..623a68992 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vFirewall.policy.operational.input.json @@ -0,0 +1,4 @@ +{ + "policy-id" : "operational.modifyconfig", + "content" : "controlLoop%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20version%3A%202.0.0%0A%20%20%20%20%20%20%20%20%20%20%20%20%20controlLoopName%3A%20ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a%0A%20%20%20%20%20%20%20%20%20%20%20%20%20trigger_policy%3A%20unique-policy-id-1-modifyConfig%0A%20%20%20%20%20%20%20%20%20%20%20%20%20timeout%3A%201200%0A%20%20%20%20%20%20%20%20%20%20%20%20%20abatement%3A%20false%0A%20%0A%20%20%20%20%20%20%20%20%20%20%20policies%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20-%20id%3A%20unique-policy-id-1-modifyConfig%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%3A%20modify%20packet%20gen%20config%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20description%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20actor%3A%20APPC%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20recipe%3A%20ModifyConfig%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20target%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20TBD%20-%20Cannot%20be%20known%20until%20instantiation%20is%20done%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20resourceID%3A%20Eace933104d443b496b8.nodes.heat.vpg%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20type%3A%20VNF%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20retry%3A%200%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20timeout%3A%20300%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20success%3A%20final_success%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_guard%3A%20final_failure_guard" +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vFirewall.policy.operational.input.tosca.json b/models-tosca/src/test/resources/policies/vFirewall.policy.operational.input.tosca.json new file mode 100644 index 000000000..63c0d8b85 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vFirewall.policy.operational.input.tosca.json @@ -0,0 +1,46 @@ +{ + "tosca_definitions_version": "tosca_simple_yaml_1_0_0", + "topology_template": { + "policies": [ + { + "operational.modifyconfig": { + "type": "onap.policies.controlloop.Operational", + "version": "1.0.0", + "metadata": { + "policy-id": "operational.modifyconfig" + }, + "properties": { + "controlLoop": { + "version": "2.0.0", + "controlLoopName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", + "trigger_policy": "unique-policy-id-1-modifyConfig", + "timeout": 1200, + "abatement": false + }, + "policies": [ + { + "id": "unique-policy-id-1-modifyConfig", + "name": "modify packet gen config", + "description": null, + "actor": "APPC", + "recipe": "ModifyConfig", + "target": { + "resourceID": "Eace933104d443b496b8.nodes.heat.vpg", + "type": "VNF" + }, + "retry": 0, + "timeout": 300, + "success": "final_success", + "failure": "final_failure", + "failure_timeout": "final_failure_timeout", + "failure_retries": "final_failure_retries", + "failure_exception": "final_failure_exception", + "failure_guard": "final_failure_guard" + } + ] + } + } + } + ] + } +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vFirewall.policy.operational.input.tosca.yaml b/models-tosca/src/test/resources/policies/vFirewall.policy.operational.input.tosca.yaml new file mode 100644 index 000000000..ca36d5309 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vFirewall.policy.operational.input.tosca.yaml @@ -0,0 +1,35 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +topology_template: + policies: + - + operational.modifyconfig: + type: onap.policies.controlloop.Operational + version: 1.0.0 + metadata: + policy-id: operational.modifyconfig + properties: + controlLoop: + version: 2.0.0 + controlLoopName: ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a + trigger_policy: unique-policy-id-1-modifyConfig + timeout: 1200 + abatement: false + + policies: + - id: unique-policy-id-1-modifyConfig + name: modify packet gen config + description: + actor: APPC + recipe: ModifyConfig + target: + # TBD - Cannot be known until instantiation is done + resourceID: Eace933104d443b496b8.nodes.heat.vpg + type: VNF + retry: 0 + timeout: 300 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + failure_guard: final_failure_guard \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vFirewall.policy.operational.output.json b/models-tosca/src/test/resources/policies/vFirewall.policy.operational.output.json new file mode 100644 index 000000000..bb8b907f8 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vFirewall.policy.operational.output.json @@ -0,0 +1,5 @@ +{ + "policy-id" : "operational.modifyconfig", + "policy-version" : "1", + "content" : "controlLoop%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20version%3A%202.0.0%0A%20%20%20%20%20%20%20%20%20%20%20%20%20controlLoopName%3A%20ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a%0A%20%20%20%20%20%20%20%20%20%20%20%20%20trigger_policy%3A%20unique-policy-id-1-modifyConfig%0A%20%20%20%20%20%20%20%20%20%20%20%20%20timeout%3A%201200%0A%20%20%20%20%20%20%20%20%20%20%20%20%20abatement%3A%20false%0A%20%0A%20%20%20%20%20%20%20%20%20%20%20policies%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20-%20id%3A%20unique-policy-id-1-modifyConfig%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20name%3A%20modify%20packet%20gen%20config%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20description%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20actor%3A%20APPC%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20recipe%3A%20ModifyConfig%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20target%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20TBD%20-%20Cannot%20be%20known%20until%20instantiation%20is%20done%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20resourceID%3A%20Eace933104d443b496b8.nodes.heat.vpg%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20type%3A%20VNF%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20retry%3A%200%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20timeout%3A%20300%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20success%3A%20final_success%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20failure_guard%3A%20final_failure_guard" +} \ No newline at end of file diff --git a/models-tosca/src/test/resources/policies/vFirewall.policy.operational.output.tosca.yaml b/models-tosca/src/test/resources/policies/vFirewall.policy.operational.output.tosca.yaml new file mode 100644 index 000000000..42ea511d9 --- /dev/null +++ b/models-tosca/src/test/resources/policies/vFirewall.policy.operational.output.tosca.yaml @@ -0,0 +1,36 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +topology_template: + policies: + - + operational.modifyconfig: + type: onap.policies.controlloop.Operational + version: 1.0.0 + metadata: + policy-id: operational.modifyconfig + policy-version: 1 + properties: + controlLoop: + version: 2.0.0 + controlLoopName: ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a + trigger_policy: unique-policy-id-1-modifyConfig + timeout: 1200 + abatement: false + + policies: + - id: unique-policy-id-1-modifyConfig + name: modify packet gen config + description: + actor: APPC + recipe: ModifyConfig + target: + # TBD - Cannot be known until instantiation is done + resourceID: Eace933104d443b496b8.nodes.heat.vpg + type: VNF + retry: 0 + timeout: 300 + success: final_success + failure: final_failure + failure_timeout: final_failure_timeout + failure_retries: final_failure_retries + failure_exception: final_failure_exception + failure_guard: final_failure_guard \ No newline at end of file diff --git a/models-tosca/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml b/models-tosca/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml new file mode 100644 index 000000000..5a093ddbf --- /dev/null +++ b/models-tosca/src/test/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml @@ -0,0 +1,17 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + version: 1.0.0 + onap.policies.Monitoring: + derived_from: tosca.policies.Root + description: a base policy type for all policies that govern monitoring provision + version: 1.0.0 + onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server: + derived_from: policy.nodes.Root + version: 1.0.0 + properties: + buscontroller_feed_publishing_endpoint: + type: string + description: DMAAP Bus Controller feed endpoint + datafile.policy: + type: string + description: datafile Policy JSON as string diff --git a/models-tosca/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml b/models-tosca/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml new file mode 100644 index 000000000..699cffd7e --- /dev/null +++ b/models-tosca/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.yaml @@ -0,0 +1,158 @@ +tosca_definitions_version: tosca_simple_yaml_1_0_0 +policy_types: + onap.policies.Monitoring: + derived_from: tosca.policies.Root + description: a base policy type for all policies that governs monitoring provisioning + onap.policy.monitoring.cdap.tca.hi.lo.app: + derived_from: onap.policies.Monitoring + version: 1.0.0 + properties: + tca_policy: + type: map + description: TCA Policy JSON + entry_schema: + type: onap.datatypes.monitoring.tca_policy +data_types: + onap.datatypes.monitoring.metricsPerEventName: + derived_from: tosca.datatypes.Root + properties: + controlLoopSchemaType: + type: string + required: true + description: Specifies Control Loop Schema Type for the event Name e.g. VNF, VM + constraints: + - valid_values: + - VM + - VNF + eventName: + type: string + required: true + description: Event name to which thresholds need to be applied + policyName: + type: string + required: true + description: TCA Policy Scope Name + policyScope: + type: string + required: true + description: TCA Policy Scope + policyVersion: + type: string + required: true + description: TCA Policy Scope Version + thresholds: + type: list + required: true + description: Thresholds associated with eventName + entry_schema: + type: onap.datatypes.monitoring.thresholds + onap.datatypes.monitoring.tca_policy: + derived_from: tosca.datatypes.Root + properties: + domain: + type: string + required: true + description: Domain name to which TCA needs to be applied + default: measurementsForVfScaling + constraints: + - equal: measurementsForVfScaling + metricsPerEventName: + type: list + required: true + description: Contains eventName and threshold details that need to be applied to given eventName + entry_schema: + type: onap.datatypes.monitoring.metricsPerEventName + onap.datatypes.monitoring.thresholds: + derived_from: tosca.datatypes.Root + properties: + closedLoopControlName: + type: string + required: true + description: Closed Loop Control Name associated with the threshold + closedLoopEventStatus: + type: string + required: true + description: Closed Loop Event Status of the threshold + constraints: + - valid_values: + - ONSET + - ABATED + direction: + type: string + required: true + description: Direction of the threshold + constraints: + - valid_values: + - LESS + - LESS_OR_EQUAL + - GREATER + - GREATER_OR_EQUAL + - EQUAL + fieldPath: + type: string + required: true + description: Json field Path as per CEF message which needs to be analyzed for TCA + constraints: + - valid_values: + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsDelta + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsAccumulated + - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsAccumulated + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuIdle + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageInterrupt + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageNice + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSoftIrq + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSteal + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSystem + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuWait + - $.event.measurementsForVfScalingFields.cpuUsageArray[*].percentUsage + - $.event.measurementsForVfScalingFields.meanRequestLatency + - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryBuffered + - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryCached + - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryConfigured + - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryFree + - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryUsed + - $.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value + severity: + type: string + required: true + description: Threshold Event Severity + constraints: + - valid_values: + - CRITICAL + - MAJOR + - MINOR + - WARNING + - NORMAL + thresholdValue: + type: integer + required: true + description: Threshold value for the field Path inside CEF message + version: + type: string + required: true + description: Version number associated with the threshold -- cgit 1.2.3-korg