From 8fdf84c7f2bd03332e69d13e35414020053c2977 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Fri, 15 Mar 2019 12:36:38 +0000 Subject: [PATCH] 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 --- .../models/provider/PolicyModelsProvider.java | 85 ++++++++++- .../provider/PolicyModelsProviderFactory.java | 4 +- ....java => DatabasePolicyModelsProviderImpl.java} | 60 +++++++- .../impl/DummyPolicyModelsProviderImpl.java | 168 +++++++++++++++++++++ .../dummyimpl/DummyToscaPolicyDeleteResponse.json | 48 ++++++ .../dummyimpl/DummyToscaPolicyGetResponse.json | 48 ++++++ .../DummyToscaPolicyTypeDeleteResponse.json | 48 ++++++ .../dummyimpl/DummyToscaPolicyTypeGetResponse.json | 48 ++++++ .../impl/DummyPolicyModelsProviderTest.java | 49 ++++++ .../tosca/concepts/ToscaTopologyTemplate.java | 10 +- .../legacy/LegacyGuardMessageBodyHandler.java | 56 +++++++ .../serialization/legacy/LegacyGuardPolicy.java | 30 ++++ .../LegacyOperationalMessageBodyHandler.java | 56 +++++++ .../legacy/LegacyOperationalPolicy.java | 30 ++++ .../simple/ToscaPoliciesJsonAdapter.java | 72 +++++++++ .../simple/ToscaPolicyJsonAdapter.java | 85 +++++++++++ .../simple/ToscaServiceTemplateJsonAdapter.java | 75 +++++++++ .../ToscaServiceTemplateMessageBodyHandler.java | 64 ++++++++ .../simple/ToscaTopologyTemplateJsonAdapter.java | 72 +++++++++ .../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 +++++++++++++++++++ pom.xml | 6 + 54 files changed, 2199 insertions(+), 23 deletions(-) rename models-provider/src/main/java/org/onap/policy/models/provider/impl/{PolicyModelsProviderImpl.java => DatabasePolicyModelsProviderImpl.java} (58%) create mode 100644 models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java create mode 100644 models-provider/src/main/resources/dummyimpl/DummyToscaPolicyDeleteResponse.json create mode 100644 models-provider/src/main/resources/dummyimpl/DummyToscaPolicyGetResponse.json create mode 100644 models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeDeleteResponse.json create mode 100644 models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeGetResponse.json create mode 100644 models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardMessageBodyHandler.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicy.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalMessageBodyHandler.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicy.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPoliciesJsonAdapter.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPolicyJsonAdapter.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateJsonAdapter.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateMessageBodyHandler.java create mode 100644 models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaTopologyTemplateJsonAdapter.java 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 diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java index 0144f8c68..fbdf092c2 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java @@ -24,8 +24,9 @@ import lombok.NonNull; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.serialization.legacy.LegacyGuardPolicy; +import org.onap.policy.models.tosca.serialization.legacy.LegacyOperationalPolicy; /** * This interface describes the operations that are provided to users and components for reading @@ -86,7 +87,7 @@ public interface PolicyModelsProvider { * @return the policies found * @throws PfModelException on errors getting policies */ - public ToscaServiceTemplate getPolicies(@NonNull final PfReferenceKey policyKey) throws PfModelException; + public ToscaServiceTemplate getPolicies(@NonNull final PfConceptKey policyKey) throws PfModelException; /** * Create policies. @@ -118,7 +119,83 @@ public interface PolicyModelsProvider { * @return the TOSCA service template containing the policy types that were deleted * @throws PfModelException on errors deleting policies */ - public ToscaServiceTemplate deletePolicies(@NonNull final PfReferenceKey policyKey) throws PfModelException; + public ToscaServiceTemplate deletePolicies(@NonNull final PfConceptKey policyKey) throws PfModelException; + + /** + * Get legacy operational policy. + * + * @param policyId ID of the policy. + * @return the policies found + * @throws PfModelException on errors getting policies + */ + public LegacyOperationalPolicy getOperationalPolicy(@NonNull final String policyId) throws PfModelException; + + /** + * Create legacy operational policy. + * + * @param legacyOperationalPolicy the definition of the policy to be created. + * @return the created policy + * @throws PfModelException on errors creating policies + */ + public LegacyOperationalPolicy createOperationalPolicy( + @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException; + + /** + * Update legacy operational policy. + * + * @param legacyOperationalPolicy the definition of the policy to be updated + * @return the updated policy + * @throws PfModelException on errors updating policies + */ + public LegacyOperationalPolicy updateOperationalPolicy( + @NonNull final LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException; + + /** + * Delete legacy operational policy. + * + * @param policyId ID of the policy. + * @return the deleted policy + * @throws PfModelException on errors deleting policies + */ + public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull final String policyId) throws PfModelException; + + /** + * Get legacy guard policy. + * + * @param policyId ID of the policy. + * @return the policies found + * @throws PfModelException on errors getting policies + */ + public LegacyGuardPolicy getGuardPolicy(@NonNull final String policyId) throws PfModelException; + + /** + * Create legacy guard policy. + * + * @param legacyGuardPolicy the definition of the policy to be created. + * @return the created policy + * @throws PfModelException on errors creating policies + */ + public LegacyGuardPolicy createGuardPolicy(@NonNull final LegacyGuardPolicy legacyGuardPolicy) + throws PfModelException; + + /** + * Update legacy guard policy. + * + * @param legacyGuardPolicy the definition of the policy to be updated + * @return the updated policy + * @throws PfModelException on errors updating policies + */ + public LegacyGuardPolicy updateGuardPolicy(@NonNull final LegacyGuardPolicy legacyGuardPolicy) + throws PfModelException; + + /** + * Delete legacy guard policy. + * + * @param policyId ID of the policy. + * @return the deleted policy + * @throws PfModelException on errors deleting policies + */ + public LegacyGuardPolicy deleteGuardPolicy(@NonNull final String policyId) throws PfModelException; /** * Get PDP groups. @@ -152,5 +229,5 @@ public interface PolicyModelsProvider { * @param somePdpGroupFilter a filter for the get * @throws PfModelException on errors deleting PDP groups */ - public void deletePdpGroups(@NonNull final Object somePdpGroupFilter) throws PfModelException; + public Object deletePdpGroups(@NonNull final Object somePdpGroupFilter) throws PfModelException; } diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderFactory.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderFactory.java index 5c4342800..b4b5f1ddc 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderFactory.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderFactory.java @@ -20,7 +20,7 @@ package org.onap.policy.models.provider; -import org.onap.policy.models.provider.impl.PolicyModelsProviderImpl; +import org.onap.policy.models.provider.impl.DummyPolicyModelsProviderImpl; /** * A factory for creating PolicyModelsProvider objects using the default Policy Framework implementation. @@ -33,6 +33,6 @@ public class PolicyModelsProviderFactory { * Creates a new PolicyModelsProvider object from its implementation. */ public PolicyModelsProvider createPolicyModelsProvider() { - return new PolicyModelsProviderImpl(); + return new DummyPolicyModelsProviderImpl(); } } diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/PolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java similarity index 58% rename from models-provider/src/main/java/org/onap/policy/models/provider/impl/PolicyModelsProviderImpl.java rename to models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java index 12d7686b3..3f41dac7c 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/PolicyModelsProviderImpl.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java @@ -24,16 +24,18 @@ import lombok.NonNull; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.provider.PolicyModelsProvider; import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.serialization.legacy.LegacyGuardPolicy; +import org.onap.policy.models.tosca.serialization.legacy.LegacyOperationalPolicy; /** - * This class provides the implementaiton of the defalut Policy Models Provider for the ONAP Policy Framework. + * This class provides an implementation of the Policy Models Provider for the ONAP Policy Framework + * that works towards a relational database. * * @author Liam Fallon (liam.fallon@est.tech) */ -public class PolicyModelsProviderImpl implements PolicyModelsProvider { +public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider { @Override public ToscaServiceTemplate getPolicyTypes(@NonNull PfConceptKey policyTypeKey) throws PfModelException { @@ -46,13 +48,19 @@ public class PolicyModelsProviderImpl implements PolicyModelsProvider { return null; } + @Override + public ToscaServiceTemplate updatePolicyTypes(@NonNull ToscaServiceTemplate serviceTemplate) + throws PfModelException { + return null; + } + @Override public ToscaServiceTemplate deletePolicyTypes(@NonNull PfConceptKey policyTypeKey) throws PfModelException { return null; } @Override - public ToscaServiceTemplate getPolicies(@NonNull PfReferenceKey policyKey) throws PfModelException { + public ToscaServiceTemplate getPolicies(@NonNull PfConceptKey policyKey) throws PfModelException { return null; } @@ -67,16 +75,52 @@ public class PolicyModelsProviderImpl implements PolicyModelsProvider { } @Override - public ToscaServiceTemplate deletePolicies(@NonNull PfReferenceKey policyKey) throws PfModelException { + public ToscaServiceTemplate deletePolicies(@NonNull PfConceptKey policyKey) throws PfModelException { return null; } @Override - public ToscaServiceTemplate updatePolicyTypes(@NonNull ToscaServiceTemplate serviceTemplate) + public LegacyOperationalPolicy getOperationalPolicy(@NonNull String policyId) throws PfModelException { + return null; + } + + @Override + public LegacyOperationalPolicy createOperationalPolicy(@NonNull LegacyOperationalPolicy legacyOperationalPolicy) throws PfModelException { return null; } + @Override + public LegacyOperationalPolicy updateOperationalPolicy(@NonNull LegacyOperationalPolicy legacyOperationalPolicy) + throws PfModelException { + return null; + } + + @Override + public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull String policyId) throws PfModelException { + return null; + } + + @Override + public LegacyGuardPolicy getGuardPolicy(@NonNull String policyId) throws PfModelException { + return null; + } + + @Override + public LegacyGuardPolicy createGuardPolicy(@NonNull LegacyGuardPolicy legacyGuardPolicy) throws PfModelException { + return null; + } + + @Override + public LegacyGuardPolicy updateGuardPolicy(@NonNull LegacyGuardPolicy legacyGuardPolicy) throws PfModelException { + return null; + } + + @Override + public LegacyGuardPolicy deleteGuardPolicy(@NonNull String policyId) throws PfModelException { + return null; + } + @Override public Object getPdpGroups(@NonNull Object somePdpGroupFilter) throws PfModelException { return null; @@ -93,6 +137,8 @@ public class PolicyModelsProviderImpl implements PolicyModelsProvider { } @Override - public void deletePdpGroups(@NonNull Object somePdpGroupFilter) throws PfModelException { + public Object deletePdpGroups(@NonNull Object somePdpGroupFilter) throws PfModelException { + return null; } + } diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java new file mode 100644 index 000000000..9b92ea3ee --- /dev/null +++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java @@ -0,0 +1,168 @@ +/*- + * ============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.provider.impl; + +import com.google.gson.Gson; + +import javax.ws.rs.core.Response; + +import lombok.NonNull; + +import org.onap.policy.common.utils.resources.TextFileUtils; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.base.PfModelRuntimeException; +import org.onap.policy.models.provider.PolicyModelsProvider; +import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.serialization.legacy.LegacyGuardPolicy; +import org.onap.policy.models.tosca.serialization.legacy.LegacyOperationalPolicy; +import org.onap.policy.models.tosca.serialization.simple.ToscaServiceTemplateMessageBodyHandler; + +/** + * This class provides a dummy implementation of the Policy Models Provider for the ONAP Policy + * Framework. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { + @Override + public ToscaServiceTemplate getPolicyTypes(@NonNull PfConceptKey policyTypeKey) throws PfModelException { + return getDummyResponse("src/main/resources/dummyimpl/DummyToscaPolicyTypeGetResponse.json"); + } + + @Override + public ToscaServiceTemplate createPolicyTypes(@NonNull ToscaServiceTemplate serviceTemplate) + throws PfModelException { + return serviceTemplate; + } + + @Override + public ToscaServiceTemplate updatePolicyTypes(@NonNull ToscaServiceTemplate serviceTemplate) + throws PfModelException { + return serviceTemplate; + } + + @Override + public ToscaServiceTemplate deletePolicyTypes(@NonNull PfConceptKey policyTypeKey) throws PfModelException { + return getDummyResponse("src/main/resources/dummyimpl/DummyToscaPolicyTypeDeleteResponse.json"); + } + + @Override + public ToscaServiceTemplate getPolicies(@NonNull PfConceptKey policyKey) throws PfModelException { + return getDummyResponse("src/main/resources/dummyimpl/DummyToscaPolicyGetResponse.json"); + } + + @Override + public ToscaServiceTemplate createPolicies(@NonNull ToscaServiceTemplate serviceTemplate) throws PfModelException { + return serviceTemplate; + } + + @Override + public ToscaServiceTemplate updatePolicies(@NonNull ToscaServiceTemplate serviceTemplate) throws PfModelException { + return serviceTemplate; + } + + @Override + public ToscaServiceTemplate deletePolicies(@NonNull PfConceptKey policyKey) throws PfModelException { + return getDummyResponse("src/main/resources/dummyimpl/DummyToscaPolicyDeleteResponse.json"); + } + + @Override + public LegacyOperationalPolicy getOperationalPolicy(@NonNull String policyId) throws PfModelException { + return new LegacyOperationalPolicy(); + } + + @Override + public LegacyOperationalPolicy createOperationalPolicy(@NonNull LegacyOperationalPolicy legacyOperationalPolicy) + throws PfModelException { + return legacyOperationalPolicy; + } + + @Override + public LegacyOperationalPolicy updateOperationalPolicy(@NonNull LegacyOperationalPolicy legacyOperationalPolicy) + throws PfModelException { + return legacyOperationalPolicy; + } + + @Override + public LegacyOperationalPolicy deleteOperationalPolicy(@NonNull String policyId) throws PfModelException { + return new LegacyOperationalPolicy(); + } + + @Override + public LegacyGuardPolicy getGuardPolicy(@NonNull String policyId) throws PfModelException { + return new LegacyGuardPolicy(); + } + + @Override + public LegacyGuardPolicy createGuardPolicy(@NonNull LegacyGuardPolicy legacyGuardPolicy) throws PfModelException { + return legacyGuardPolicy; + } + + @Override + public LegacyGuardPolicy updateGuardPolicy(@NonNull LegacyGuardPolicy legacyGuardPolicy) throws PfModelException { + return legacyGuardPolicy; + } + + @Override + public LegacyGuardPolicy deleteGuardPolicy(@NonNull String policyId) throws PfModelException { + return new LegacyGuardPolicy(); + } + + @Override + public Object getPdpGroups(@NonNull Object somePdpGroupFilter) throws PfModelException { + return null; + } + + @Override + public Object createPdpGroups(@NonNull Object somePdpGroupSpecification) throws PfModelException { + return null; + } + + @Override + public Object updatePdpGroups(@NonNull Object somePdpGroupSpecification) throws PfModelException { + return null; + } + + @Override + public Object deletePdpGroups(@NonNull Object somePdpGroupFilter) throws PfModelException { + return null; + } + + /** + * Return a ToscaServicetemplate dummy response. + * + * @param fileName the file name containing the dummy response + * @return the ToscaServiceTemplate with the dummy response + */ + private ToscaServiceTemplate getDummyResponse(@NonNull final String fileName) { + Gson gson = new ToscaServiceTemplateMessageBodyHandler().getGson(); + ToscaServiceTemplate serviceTemplate; + + try { + serviceTemplate = gson.fromJson(TextFileUtils.getTextFileAsString(fileName), ToscaServiceTemplate.class); + } catch (Exception exc) { + throw new PfModelRuntimeException(Response.Status.INTERNAL_SERVER_ERROR, "error serializing object", exc); + } + + return serviceTemplate; + } +} diff --git a/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyDeleteResponse.json b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyDeleteResponse.json new file mode 100644 index 000000000..27de380c2 --- /dev/null +++ b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyDeleteResponse.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-provider/src/main/resources/dummyimpl/DummyToscaPolicyGetResponse.json b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyGetResponse.json new file mode 100644 index 000000000..27de380c2 --- /dev/null +++ b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyGetResponse.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-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeDeleteResponse.json b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeDeleteResponse.json new file mode 100644 index 000000000..27de380c2 --- /dev/null +++ b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeDeleteResponse.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-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeGetResponse.json b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeGetResponse.json new file mode 100644 index 000000000..27de380c2 --- /dev/null +++ b/models-provider/src/main/resources/dummyimpl/DummyToscaPolicyTypeGetResponse.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-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java new file mode 100644 index 000000000..d4808ee70 --- /dev/null +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java @@ -0,0 +1,49 @@ +/*- + * ============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.provider.impl; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfModelException; +import org.onap.policy.models.provider.PolicyModelsProvider; +import org.onap.policy.models.provider.PolicyModelsProviderFactory; +import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate; + +/** + * Test the dummy moldes provider implementation. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +public class DummyPolicyModelsProviderTest { + + @Test + public void test() throws PfModelException { + PolicyModelsProvider dummyProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(); + + ToscaServiceTemplate serviceTemplate = dummyProvider.getPolicies(new PfConceptKey()); + assertNotNull(serviceTemplate); + assertEquals("onap.vcpe.tca:1.0.0", + serviceTemplate.getTopologyTemplate().getPolicies().get("onap.vcpe.tca").getId()); + } +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplate.java index e8541f514..aed181f94 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplate.java @@ -38,8 +38,8 @@ import lombok.NonNull; import org.apache.commons.lang3.ObjectUtils; import org.onap.policy.common.utils.validation.Assertions; import org.onap.policy.models.base.PfConcept; -import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfKey; +import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationMessage; import org.onap.policy.models.base.PfValidationResult; import org.onap.policy.models.base.PfValidationResult.ValidationResult; @@ -59,7 +59,7 @@ public class ToscaTopologyTemplate extends PfConcept { private static final long serialVersionUID = 8969698734673232603L; @EmbeddedId - private PfConceptKey key; + private PfReferenceKey key; @Column(name = "description") private String description; @@ -71,7 +71,7 @@ public class ToscaTopologyTemplate extends PfConcept { * The Default Constructor creates a {@link ToscaTopologyTemplate} object with a null key. */ public ToscaTopologyTemplate() { - this(new PfConceptKey()); + this(new PfReferenceKey()); } /** @@ -80,7 +80,7 @@ public class ToscaTopologyTemplate extends PfConcept { * * @param key the key */ - public ToscaTopologyTemplate(@NonNull final PfConceptKey key) { + public ToscaTopologyTemplate(@NonNull final PfReferenceKey key) { this.key = key; } @@ -169,7 +169,7 @@ public class ToscaTopologyTemplate extends PfConcept { Assertions.instanceOf(copyObject, PfConcept.class); final ToscaTopologyTemplate copy = ((ToscaTopologyTemplate) copyObject); - copy.setKey(new PfConceptKey(key)); + copy.setKey(new PfReferenceKey(key)); copy.setDescription(description); copy.setPolicies(policies != null ? new ToscaPolicies(policies) : null); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardMessageBodyHandler.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardMessageBodyHandler.java new file mode 100644 index 000000000..b343c9e66 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardMessageBodyHandler.java @@ -0,0 +1,56 @@ +/*- + * ============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. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.serialization.legacy; + +import com.google.gson.GsonBuilder; + +import org.onap.policy.common.gson.GsonMessageBodyHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Provider used to serialize and deserialize TOSCA objects using GSON. + */ +public class LegacyGuardMessageBodyHandler extends GsonMessageBodyHandler { + + public static final Logger logger = LoggerFactory.getLogger(LegacyGuardMessageBodyHandler.class); + + /** + * Constructs the object. + */ + public LegacyGuardMessageBodyHandler() { + this(new GsonBuilder()); + + logger.info("Using GSON with TOSCA for REST calls"); + } + + /** + * Constructs the object. + * + * @param builder builder to use to create the gson object + */ + public LegacyGuardMessageBodyHandler(final GsonBuilder builder) { + // @formatter:off + super(builder + .create() + ); + // @formatter:on + } + +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicy.java new file mode 100644 index 000000000..a365696c3 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicy.java @@ -0,0 +1,30 @@ +/*- + * ============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.legacy; + +/** + * Definition of a legacy guard policy stored as a TOSCA policy. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +public class LegacyGuardPolicy { + +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalMessageBodyHandler.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalMessageBodyHandler.java new file mode 100644 index 000000000..f51a427f0 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalMessageBodyHandler.java @@ -0,0 +1,56 @@ +/*- + * ============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. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.serialization.legacy; + +import com.google.gson.GsonBuilder; + +import org.onap.policy.common.gson.GsonMessageBodyHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Provider used to serialize and deserialize TOSCA objects using GSON. + */ +public class LegacyOperationalMessageBodyHandler extends GsonMessageBodyHandler { + + public static final Logger logger = LoggerFactory.getLogger(LegacyOperationalMessageBodyHandler.class); + + /** + * Constructs the object. + */ + public LegacyOperationalMessageBodyHandler() { + this(new GsonBuilder()); + + logger.info("Using GSON with TOSCA for REST calls"); + } + + /** + * Constructs the object. + * + * @param builder builder to use to create the gson object + */ + public LegacyOperationalMessageBodyHandler(final GsonBuilder builder) { + // @formatter:off + super(builder + .create() + ); + // @formatter:on + } + +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicy.java new file mode 100644 index 000000000..0b63f2d68 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicy.java @@ -0,0 +1,30 @@ +/*- + * ============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.legacy; + +/** + * Definition of a legacy operational policy stored as a TOSCA policy. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +public class LegacyOperationalPolicy { + +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPoliciesJsonAdapter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPoliciesJsonAdapter.java new file mode 100644 index 000000000..a12ba8be9 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPoliciesJsonAdapter.java @@ -0,0 +1,72 @@ +/*- + * ============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.simple; + +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import java.lang.reflect.Type; +import java.util.Iterator; + +import lombok.NonNull; + +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.concepts.ToscaPolicies; +import org.onap.policy.models.tosca.concepts.ToscaPolicy; + +/** + * GSON type adapter for TOSCA policies. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +public class ToscaPoliciesJsonAdapter implements JsonSerializer, JsonDeserializer { + @Override + public ToscaPolicies deserialize(@NonNull final JsonElement policiesElement, @NonNull final Type type, + @NonNull final JsonDeserializationContext context) { + // The incoming JSON + final JsonArray policiesJsonArray = policiesElement.getAsJsonArray(); + + // The outgoing object + final PfConceptKey policiesKey = new PfConceptKey("IncomingPolicies", "0.0.1"); + final ToscaPolicies policies = new ToscaPolicies(policiesKey); + + // Get the policies + for (Iterator policiesIterator = policiesJsonArray.iterator(); policiesIterator.hasNext(); ) { + ToscaPolicy policy = new ToscaPolicyJsonAdapter() + .deserialize(policiesIterator.next(), ToscaPolicy.class, context); + + policies.getConceptMap().put(policy.getKey(), policy); + } + + return policies; + } + + @Override + public JsonElement serialize(@NonNull final ToscaPolicies policy, @NonNull final Type type, + @NonNull final JsonSerializationContext context) { + + return null; + } +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPolicyJsonAdapter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPolicyJsonAdapter.java new file mode 100644 index 000000000..ae5e596ba --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPolicyJsonAdapter.java @@ -0,0 +1,85 @@ +/*- + * ============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.simple; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import java.lang.reflect.Type; + +import javax.ws.rs.core.Response; + +import lombok.NonNull; + +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfModelRuntimeException; +import org.onap.policy.models.tosca.concepts.ToscaPolicy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * GSON type adapter for TOSCA policies. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +public class ToscaPolicyJsonAdapter implements JsonSerializer, JsonDeserializer { + // Logger for this class + private static final Logger LOGGER = LoggerFactory.getLogger(ToscaPolicyJsonAdapter.class); + + @Override + public ToscaPolicy deserialize(@NonNull final JsonElement policyElement, @NonNull final Type type, + @NonNull final JsonDeserializationContext context) { + + // The incoming JSON + final JsonObject policyJsonMapObject = policyElement.getAsJsonObject(); + + // We should only have a single entry for the policy + if (policyJsonMapObject.entrySet().size() != 1) { + String errorMessage = "a policy list entry may only contain one and only one policy"; + LOGGER.debug(errorMessage); + throw new PfModelRuntimeException(Response.Status.NOT_ACCEPTABLE, errorMessage); + } + + String policyName = policyJsonMapObject.entrySet().iterator().next().getKey(); + JsonObject policyJsonObject = policyJsonMapObject.entrySet().iterator().next().getValue().getAsJsonObject(); + + PfConceptKey policyKey = new PfConceptKey(policyName, policyJsonObject.get("version").getAsString()); + PfConceptKey policyTypeKey = new PfConceptKey( + policyJsonObject.get("type").getAsString(), + policyJsonObject.get("version").getAsString()); + ToscaPolicy policy = new ToscaPolicy(policyKey, policyTypeKey); + + // TODO: Rest of parsing + + return policy; + } + + @Override + public JsonElement serialize(@NonNull final ToscaPolicy policy, @NonNull final Type type, + @NonNull final JsonSerializationContext context) { + + return null; + } +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateJsonAdapter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateJsonAdapter.java new file mode 100644 index 000000000..b08a33d64 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateJsonAdapter.java @@ -0,0 +1,75 @@ +/*- + * ============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.simple; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import java.lang.reflect.Type; + +import lombok.NonNull; + +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.concepts.ToscaTopologyTemplate; + +/** + * GSON type adapter for TOSCA policies. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +public class ToscaServiceTemplateJsonAdapter + implements JsonSerializer, JsonDeserializer { + @Override + public ToscaServiceTemplate deserialize(@NonNull final JsonElement serviceTemplateElement, @NonNull final Type type, + @NonNull final JsonDeserializationContext context) { + + // The incoming JSON + final JsonObject serviceTemplateJsonObject = serviceTemplateElement.getAsJsonObject(); + + // The outgoing object + final PfConceptKey serviceTemplateKey = new PfConceptKey("IncomingServiceTemplate", "0.0.1"); + final ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate(serviceTemplateKey); + serviceTemplate + .setToscaDefinitionsVersion(serviceTemplateJsonObject.get("tosca_definitions_version").getAsString()); + + if (serviceTemplateJsonObject.has("topology_template")) { + serviceTemplate.setTopologyTemplate(new ToscaTopologyTemplateJsonAdapter().deserialize( + serviceTemplateJsonObject.get("topology_template"), ToscaTopologyTemplate.class, context)); + } + + // Set the parent key of the topology template to be this service template + serviceTemplate.getTopologyTemplate().getKey().setParentConceptKey(serviceTemplateKey); + + return serviceTemplate; + } + + @Override + public JsonElement serialize(@NonNull final ToscaServiceTemplate serviceTemplate, @NonNull final Type type, + @NonNull final JsonSerializationContext context) { + + return null; + } +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateMessageBodyHandler.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateMessageBodyHandler.java new file mode 100644 index 000000000..9abbf1c72 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateMessageBodyHandler.java @@ -0,0 +1,64 @@ +/*- + * ============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. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.serialization.simple; + +import com.google.gson.GsonBuilder; + +import org.onap.policy.common.gson.GsonMessageBodyHandler; +import org.onap.policy.models.tosca.concepts.ToscaPolicies; +import org.onap.policy.models.tosca.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.concepts.ToscaTopologyTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Provider used to serialize and deserialize TOSCA objects using GSON. + */ +public class ToscaServiceTemplateMessageBodyHandler extends GsonMessageBodyHandler { + + public static final Logger logger = LoggerFactory.getLogger(ToscaServiceTemplateMessageBodyHandler.class); + + /** + * Constructs the object. + */ + public ToscaServiceTemplateMessageBodyHandler() { + this(new GsonBuilder()); + + logger.info("Using GSON with TOSCA for REST calls"); + } + + /** + * Constructs the object. + * + * @param builder builder to use to create the gson object + */ + public ToscaServiceTemplateMessageBodyHandler(final GsonBuilder builder) { + // @formatter:off + super(builder + .registerTypeAdapter(ToscaServiceTemplate.class, new ToscaServiceTemplateJsonAdapter()) + .registerTypeAdapter(ToscaTopologyTemplate.class, new ToscaTopologyTemplateJsonAdapter()) + .registerTypeAdapter(ToscaPolicies.class, new ToscaPoliciesJsonAdapter()) + .registerTypeAdapter(ToscaPolicy.class, new ToscaPolicyJsonAdapter()) + .create() + ); + // @formatter:on + } + +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaTopologyTemplateJsonAdapter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaTopologyTemplateJsonAdapter.java new file mode 100644 index 000000000..4f2f590b7 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaTopologyTemplateJsonAdapter.java @@ -0,0 +1,72 @@ +/*- + * ============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.simple; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; + +import java.lang.reflect.Type; + +import lombok.NonNull; + +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfReferenceKey; +import org.onap.policy.models.tosca.concepts.ToscaPolicies; +import org.onap.policy.models.tosca.concepts.ToscaTopologyTemplate; + +/** + * GSON type adapter for TOSCA policies. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +public class ToscaTopologyTemplateJsonAdapter + implements JsonSerializer, JsonDeserializer { + + @Override + public ToscaTopologyTemplate deserialize(@NonNull final JsonElement toplogyTemplateElement, + @NonNull final Type type, @NonNull final JsonDeserializationContext context) { + + // The incoming JSON + final JsonObject topologyTemplateJsonObject = toplogyTemplateElement.getAsJsonObject(); + + // The outgoing object + final PfReferenceKey topologyTemplateKey = new PfReferenceKey(new PfConceptKey(), "IncomingTopologyTemplate"); + final ToscaTopologyTemplate topologyTemplate = new ToscaTopologyTemplate(topologyTemplateKey); + + if (topologyTemplateJsonObject.has("policies")) { + topologyTemplate.setPolicies(new ToscaPoliciesJsonAdapter() + .deserialize(topologyTemplateJsonObject.get("policies"), ToscaPolicies.class, context)); + } + + return topologyTemplate; + } + + @Override + public JsonElement serialize(@NonNull final ToscaTopologyTemplate topologyTemplate, @NonNull final Type type, + @NonNull final JsonSerializationContext context) { + + return null; + } +} 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 diff --git a/pom.xml b/pom.xml index ee5092eae..245dfc9fc 100644 --- a/pom.xml +++ b/pom.xml @@ -87,6 +87,12 @@ gson + + org.yaml + snakeyaml + 1.21 + + javax.ws.rs javax.ws.rs-api -- 2.16.6