From 268ef0de1095a30c74a0ff8144cb49b157253658 Mon Sep 17 00:00:00 2001 From: Peyton Puckett Date: Wed, 11 Mar 2020 11:09:56 -0500 Subject: Delete template.demo submodule, amsterdam controller Issue-ID: POLICY-2421 Change-Id: I0e61e7b3272f5c7babceb41e4e249716af4529cf Signed-off-by: Peyton Puckett --- .gitignore | 1 - README.md | 8 +- .../common/feature-controlloop-amsterdam/pom.xml | 100 -- .../src/assembly/assemble_zip.xml | 75 - .../feature/config/amsterdam-controller.properties | 76 - .../feature/config/logback-include-amsterdam.xml | 56 - .../feature/amsterdam/AmsterdamFeature.java | 48 - ...p.policy.drools.features.PolicyEngineFeatureApi | 1 - .../feature/amsterdam/AmsterdamFeatureTest.java | 31 - .../src/main/feature/bin/create-cl-amsterdam | 231 --- controlloop/common/pom.xml | 1 - controlloop/packages/apps-controlloop/pom.xml | 6 - .../docker-controlloop/src/main/docker/Dockerfile | 6 +- controlloop/pom.xml | 1 - .../templates/archetype-cl-amsterdam/pom.xml | 55 - .../META-INF/maven/archetype-metadata.xml | 79 - .../src/main/resources/archetype-resources/pom.xml | 154 -- .../archetype-resources/src/main/config/CCVPN.yaml | 36 - .../src/main/config/CCVPNBW.yaml | 36 - .../archetype-resources/src/main/config/VoLTE.yaml | 37 - .../config/__artifactId__-controller.properties | 92 - .../config/__artifactId__-controller.rest.json | 52 - .../src/main/config/appc.lcm.success.json | 22 - .../src/main/config/appc.legacy.success.json | 18 - .../src/main/config/dcae.ccvpn.bw.onset.json | 25 - .../src/main/config/dcae.ccvpn.onset.json | 21 - .../src/main/config/dcae.vcpe.abatement.json | 17 - .../src/main/config/dcae.vcpe.onset.json | 16 - .../src/main/config/dcae.vdns.onset.json | 16 - .../src/main/config/dcae.vfw.onset.json | 16 - .../src/main/config/dcae.volte.onset.json | 19 - .../src/main/config/so.success.json | 15 - .../archetype-resources/src/main/config/vCPE.yaml | 36 - .../archetype-resources/src/main/config/vDNS.yaml | 39 - .../archetype-resources/src/main/config/vFW.yaml | 39 - .../src/main/config/vPCI.pcims.onset.json | 18 - .../src/main/config/vPCI.sdnr.success.json | 23 - .../archetype-resources/src/main/config/vPCI.yaml | 38 - .../src/main/config/vSONH.anr.onset | 18 - .../src/main/config/vSONH.anr.sdnr.success | 23 - .../archetype-resources/src/main/config/vSONH.yml | 38 - .../src/main/resources/META-INF/kmodule.xml | 29 - .../main/resources/__closedLoopControlName__.drl | 1833 -------------------- .../resources/projects/basic/archetype.properties | 43 - controlloop/templates/pom.xml | 39 - controlloop/templates/template.demo/README.md | 6 - controlloop/templates/template.demo/pom.xml | 239 --- .../src/main/resources/blacklist_template.xml | 117 -- .../main/resources/frequency_limiter_template.xml | 127 -- .../resources/frequency_limiter_template_old.xml | 101 -- .../template/demo/CcvpnBwControlLoopTest.java | 234 --- .../policy/template/demo/CcvpnControlLoopTest.java | 231 --- .../onap/policy/template/demo/ControlLoopBase.java | 236 --- .../template/demo/ControlLoopEventCleanupTest.java | 377 ---- .../template/demo/ControlLoopFailureTest.java | 279 --- .../demo/ControlLoopParamsCleanupTest.java | 257 --- .../org/onap/policy/template/demo/SupportUtil.java | 460 ----- .../policy/template/demo/VcpeControlLoopTest.java | 287 --- .../template/demo/VdnsControlLoopCqTest.java | 258 --- .../policy/template/demo/VdnsControlLoopTest.java | 290 ---- .../policy/template/demo/VfcControlLoopTest.java | 247 --- .../template/demo/VfwControlLoopCdsTest.java | 273 --- .../policy/template/demo/VfwControlLoopTest.java | 317 ---- .../policy/template/demo/VpciControlLoopTest.java | 284 --- .../policy/template/demo/VsonhControlLoopTest.java | 291 ---- .../src/test/resources/META-INF/persistence.xml | 43 - .../test/resources/xacml/xacml_guard.properties | 72 - .../resources/yaml/policy_ControlLoop_CCVPN.yaml | 37 - .../yaml/policy_ControlLoop_CCVPN_BW.yaml | 37 - .../policy_ControlLoop_EventCleanup-test-B.yaml | 41 - .../yaml/policy_ControlLoop_EventCleanup-test.yaml | 41 - .../policy_ControlLoop_EventCleanup-test2.yaml | 45 - .../policy_ControlLoop_ParamsCleanup-test-B.yaml | 35 - .../policy_ControlLoop_ParamsCleanup-test.yaml | 35 - .../policy_ControlLoop_ParamsCleanup-test2.yaml | 39 - .../resources/yaml/policy_ControlLoop_SO-test.yaml | 47 - .../yaml/policy_ControlLoop_SO_Cq-test.yaml | 47 - .../yaml/policy_ControlLoop_Service123.yaml | 75 - .../resources/yaml/policy_ControlLoop_VFC.yaml | 37 - .../resources/yaml/policy_ControlLoop_vCPE.yaml | 36 - .../resources/yaml/policy_ControlLoop_vFW.yaml | 41 - .../resources/yaml/policy_ControlLoop_vFW_CDS.yaml | 46 - .../resources/yaml/policy_ControlLoop_vPCI.yaml | 38 - .../resources/yaml/policy_ControlLoop_vSONH.yaml | 38 - .../resources/yaml/policy_guard_appc_migrate.yaml | 39 - .../yaml/policy_guard_appc_modifyconfig.yaml | 39 - .../resources/yaml/policy_guard_appc_rebuild.yaml | 39 - .../yaml/policy_guard_appc_rebuild_1.yaml | 39 - .../resources/yaml/policy_guard_appc_restart.yaml | 40 - .../yaml/policy_guard_appc_restart_blacklist.yaml | 40 - 90 files changed, 6 insertions(+), 9554 deletions(-) delete mode 100644 controlloop/common/feature-controlloop-amsterdam/pom.xml delete mode 100644 controlloop/common/feature-controlloop-amsterdam/src/assembly/assemble_zip.xml delete mode 100644 controlloop/common/feature-controlloop-amsterdam/src/main/feature/config/amsterdam-controller.properties delete mode 100644 controlloop/common/feature-controlloop-amsterdam/src/main/feature/config/logback-include-amsterdam.xml delete mode 100644 controlloop/common/feature-controlloop-amsterdam/src/main/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeature.java delete mode 100644 controlloop/common/feature-controlloop-amsterdam/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi delete mode 100644 controlloop/common/feature-controlloop-amsterdam/src/test/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeatureTest.java delete mode 100644 controlloop/common/feature-controlloop-management/src/main/feature/bin/create-cl-amsterdam delete mode 100644 controlloop/templates/archetype-cl-amsterdam/pom.xml delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/META-INF/maven/archetype-metadata.xml delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/pom.xml delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/CCVPN.yaml delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/CCVPNBW.yaml delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/VoLTE.yaml delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.lcm.success.json delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.legacy.success.json delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.ccvpn.bw.onset.json delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.ccvpn.onset.json delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vcpe.abatement.json delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vcpe.onset.json delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vdns.onset.json delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vfw.onset.json delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.volte.onset.json delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/so.success.json delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vCPE.yaml delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vDNS.yaml delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vFW.yaml delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vPCI.pcims.onset.json delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vPCI.sdnr.success.json delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vPCI.yaml delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vSONH.anr.onset delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vSONH.anr.sdnr.success delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vSONH.yml delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/META-INF/kmodule.xml delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl delete mode 100644 controlloop/templates/archetype-cl-amsterdam/src/test/resources/projects/basic/archetype.properties delete mode 100644 controlloop/templates/pom.xml delete mode 100644 controlloop/templates/template.demo/README.md delete mode 100644 controlloop/templates/template.demo/pom.xml delete mode 100644 controlloop/templates/template.demo/src/main/resources/blacklist_template.xml delete mode 100644 controlloop/templates/template.demo/src/main/resources/frequency_limiter_template.xml delete mode 100644 controlloop/templates/template.demo/src/main/resources/frequency_limiter_template_old.xml delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnBwControlLoopTest.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnControlLoopTest.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopBase.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopEventCleanupTest.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopParamsCleanupTest.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/SupportUtil.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VcpeControlLoopTest.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopCqTest.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopTest.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopCdsTest.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopTest.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VpciControlLoopTest.java delete mode 100644 controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VsonhControlLoopTest.java delete mode 100644 controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml delete mode 100644 controlloop/templates/template.demo/src/test/resources/xacml/xacml_guard.properties delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_CCVPN.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_CCVPN_BW.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test-B.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test2.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test-B.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test2.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_SO-test.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_SO_Cq-test.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_Service123.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_VFC.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vCPE.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vFW.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vFW_CDS.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vPCI.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vSONH.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_migrate.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_modifyconfig.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_rebuild.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_rebuild_1.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_restart.yaml delete mode 100644 controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_restart_blacklist.yaml diff --git a/.gitignore b/.gitignore index bc7d482b2..c2ef2d71b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ target .classpath .metadata/ /bin/ -controlloop/templates/template.demo/src/test/resources/xacml/autogenerated_*.xml # IntelliJ file .idea diff --git a/README.md b/README.md index c030fe9be..4eabcb660 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Copyright 2018 AT&T Intellectual Property. All rights reserved. +Copyright 2018-2020 AT&T Intellectual Property. All rights reserved. This file is licensed under the CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE Full license text at https://creativecommons.org/licenses/by/4.0/legalcode @@ -6,9 +6,5 @@ This source repository contains ONAP Policy application code. To build it: 1. using Maven 3 2. git clone http://gerrit.onap.org/r/oparent and copy oparent/settings.xml to ~/.m2 -3. mvn clean install - -The Demo template rule is located in template.demo sub-project. Use that project to protoype and test the .drl demo rule. When finished update the archetype-closedloop-demo-rules project with the .drl. Be sure to remove the Setup rule and comment out any simulation/test code. - -The other projects are supporting code used by the template.demo project. +3. mvn -Pdocker clean install diff --git a/controlloop/common/feature-controlloop-amsterdam/pom.xml b/controlloop/common/feature-controlloop-amsterdam/pom.xml deleted file mode 100644 index 8d7b3ec1c..000000000 --- a/controlloop/common/feature-controlloop-amsterdam/pom.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - 4.0.0 - - - org.onap.policy.drools-applications.controlloop.common - drools-applications-common - 1.6.0-SNAPSHOT - - - feature-controlloop-amsterdam - - - Load Amsterdam Control Loop Use Cases Controller as a feature. - - - - 1.8 - 1.8 - - - - - - maven-assembly-plugin - - - zipfile - - single - - package - - true - ${project.artifactId}-${project.version} - - src/assembly/assemble_zip.xml - - false - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - ${project.build.directory}/assembly/lib - false - true - true - false - false - false - runtime - false - - - - - - - - - - org.onap.policy.drools-pdp - policy-management - ${version.policy.drools-pdp} - provided - - - diff --git a/controlloop/common/feature-controlloop-amsterdam/src/assembly/assemble_zip.xml b/controlloop/common/feature-controlloop-amsterdam/src/assembly/assemble_zip.xml deleted file mode 100644 index 7d9d32ff9..000000000 --- a/controlloop/common/feature-controlloop-amsterdam/src/assembly/assemble_zip.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - feature-controlloop-amsterdam-package - - zip - - - false - - - - target - lib/feature - - feature-controlloop-amsterdam-${project.version}.jar - - - - target/assembly/lib - lib/dependencies - - *.jar - - - - src/main/feature/config - config - 0644 - - - - src/main/feature/bin - bin - 0744 - - - - src/main/feature/db - db - 0744 - - - - src/main/feature/install - install - 0744 - - - - - diff --git a/controlloop/common/feature-controlloop-amsterdam/src/main/feature/config/amsterdam-controller.properties b/controlloop/common/feature-controlloop-amsterdam/src/main/feature/config/amsterdam-controller.properties deleted file mode 100644 index 1feb7ce60..000000000 --- a/controlloop/common/feature-controlloop-amsterdam/src/main/feature/config/amsterdam-controller.properties +++ /dev/null @@ -1,76 +0,0 @@ -### -# ============LICENSE_START======================================================= -# ONAP -# ================================================================================ -# Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - -controller.name=amsterdam - -dmaap.source.topics=DCAE_TOPIC,APPC-CL,APPC-LCM-WRITE,SDNR-CL-RSP - -dmaap.source.topics.DCAE_TOPIC.effectiveTopic=${env:DCAE_TOPIC} -dmaap.source.topics.DCAE_TOPIC.servers=${env:DMAAP_SERVERS} -dmaap.source.topics.DCAE_TOPIC.consumerGroup=${env:DCAE_CONSUMER_GROUP} -dmaap.source.topics.DCAE_TOPIC.events=org.onap.policy.controlloop.VirtualControlLoopEvent -dmaap.source.topics.DCAE_TOPIC.events.org.onap.policy.controlloop.VirtualControlLoopEvent.filter=[?($.closedLoopEventStatus)] -dmaap.source.topics.DCAE_TOPIC.events.custom.gson=org.onap.policy.controlloop.util.Serialization,gson -dmaap.source.topics.DCAE_TOPIC.https=true - -dmaap.source.topics.APPC-CL.servers=${env:DMAAP_SERVERS} -dmaap.source.topics.APPC-CL.events=org.onap.policy.appc.Response -dmaap.source.topics.APPC-CL.events.org.onap.policy.appc.Response.filter=[?($.CommonHeader && $.Status)] -dmaap.source.topics.APPC-CL.events.custom.gson=org.onap.policy.appc.util.Serialization,gsonPretty -dmaap.source.topics.APPC-CL.servers.https=true - -dmaap.source.topics.APPC-LCM-WRITE.servers=${env:DMAAP_SERVERS} -dmaap.source.topics.APPC-LCM-WRITE.events=org.onap.policy.appclcm.AppcLcmDmaapWrapper -dmaap.source.topics.APPC-LCM-WRITE.events.org.onap.policy.appclcm.AppcLcmDmaapWrapper.filter=[?($.type == 'response')] -dmaap.source.topics.APPC-LCM-WRITE.events.custom.gson=org.onap.policy.appclcm.util.Serialization,gson -dmaap.source.topics.APPC-LCM-WRITE.https=true - -dmaap.source.topics.SDNR-CL-RSP.servers=${env:DMAAP_SERVERS} -dmaap.source.topics.SDNR-CL-RSP.events=org.onap.policy.sdnr.PciResponseWrapper -dmaap.source.topics.SDNR-CL-RSP.events.org.onap.policy.sdnr.PciResponseWrapper.filter=[?($.type == 'response')] -dmaap.source.topics.SDNR-CL-RSP.events.custom.gson=org.onap.policy.sdnr.util.Serialization,gson -dmaap.source.topics.SDNR-CL-RSP.https=true - -dmaap.sink.topics=APPC-CL,APPC-LCM-READ,POLICY-CL-MGT,SDNR-CL - -dmaap.sink.topics.APPC-CL.servers=${env:DMAAP_SERVERS} -dmaap.sink.topics.APPC-CL.events=org.onap.policy.appc.Request -dmaap.sink.topics.APPC-CL.events.custom.gson=org.onap.policy.appc.util.Serialization,gsonPretty -dmaap.sink.topics.APPC-CL.https=true - -dmaap.sink.topics.APPC-LCM-READ.servers=${env:DMAAP_SERVERS} -dmaap.sink.topics.APPC-LCM-READ.events=org.onap.policy.appclcm.AppcLcmDmaapWrapper -dmaap.sink.topics.APPC-LCM-READ.events.custom.gson=org.onap.policy.appclcm.util.Serialization,gson -dmaap.sink.topics.APPC-LCM-READ.https=true - -dmaap.sink.topics.POLICY-CL-MGT.servers=${env:DMAAP_SERVERS} -dmaap.sink.topics.POLICY-CL-MGT.events=org.onap.policy.controlloop.VirtualControlLoopNotification -dmaap.sink.topics.POLICY-CL-MGT.events.custom.gson=org.onap.policy.controlloop.util.Serialization,gsonPretty -dmaap.sink.topics.POLICY-CL-MGT.https=true - -dmaap.sink.topics.SDNR-CL.servers=${env:DMAAP_SERVERS} -dmaap.sink.topics.SDNR-CL.events=org.onap.policy.sdnr.PciRequestWrapper -dmaap.sink.topics.SDNR-CL.events.custom.gson=org.onap.policy.sdnr.util.Serialization,gson -dmaap.sink.topics.SDNR-CL.https=true - -rules.groupId= -rules.artifactId= -rules.version= - diff --git a/controlloop/common/feature-controlloop-amsterdam/src/main/feature/config/logback-include-amsterdam.xml b/controlloop/common/feature-controlloop-amsterdam/src/main/feature/config/logback-include-amsterdam.xml deleted file mode 100644 index 780fbdb3a..000000000 --- a/controlloop/common/feature-controlloop-amsterdam/src/main/feature/config/logback-include-amsterdam.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - ${logDir}/${amsterdamLog}.log - - ${logDir}/${amsterdamLog}.%d{yyyy-MM-dd}.%i.log.zip - 50MB - 30 - 10GB - - - ${networkPattern} - - - - - - - - - - - - \ No newline at end of file diff --git a/controlloop/common/feature-controlloop-amsterdam/src/main/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeature.java b/controlloop/common/feature-controlloop-amsterdam/src/main/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeature.java deleted file mode 100644 index 72b34d010..000000000 --- a/controlloop/common/feature-controlloop-amsterdam/src/main/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeature.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - * ================================================================================ - * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.drools.apps.controlloop.feature.amsterdam; - -import org.onap.policy.drools.features.PolicyEngineFeatureApi; - -/** - * Amsterdam installation as a feature saves time - * loading the Amsterdam controller at runtime over the - * usual installation from nexus. It also reduces - * potential for errors in the pom.xml generated in - * the brmsgw side. - * - *

There is no impact on other components as the brmsgw - * etc .. they will continue operating as usual. - * - *

This class will be expanded in the future for additional - * functionality - * - */ -public class AmsterdamFeature implements PolicyEngineFeatureApi { - - public static final int SEQNO = 1000; - - @Override - public int getSequenceNumber() { - return SEQNO; - } - -} diff --git a/controlloop/common/feature-controlloop-amsterdam/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi b/controlloop/common/feature-controlloop-amsterdam/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi deleted file mode 100644 index b9caa4e1c..000000000 --- a/controlloop/common/feature-controlloop-amsterdam/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi +++ /dev/null @@ -1 +0,0 @@ -org.onap.policy.drools.apps.controlloop.feature.amsterdam.AmsterdamFeature diff --git a/controlloop/common/feature-controlloop-amsterdam/src/test/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeatureTest.java b/controlloop/common/feature-controlloop-amsterdam/src/test/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeatureTest.java deleted file mode 100644 index 0deeff5f6..000000000 --- a/controlloop/common/feature-controlloop-amsterdam/src/test/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeatureTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.drools.apps.controlloop.feature.amsterdam; - -import static org.junit.Assert.assertTrue; - -public class AmsterdamFeatureTest { - - @org.junit.Test - public void getSequenceNumber() { - assertTrue(new AmsterdamFeature().getSequenceNumber() == AmsterdamFeature.SEQNO); - } -} \ No newline at end of file diff --git a/controlloop/common/feature-controlloop-management/src/main/feature/bin/create-cl-amsterdam b/controlloop/common/feature-controlloop-management/src/main/feature/bin/create-cl-amsterdam deleted file mode 100644 index b26c04c76..000000000 --- a/controlloop/common/feature-controlloop-management/src/main/feature/bin/create-cl-amsterdam +++ /dev/null @@ -1,231 +0,0 @@ -#! /bin/bash - -### -# ============LICENSE_START======================================================= -# ONAP -# ================================================================================ -# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - -# Interactive script to generate and install in a pdp-d control loops demo rules -# for a standalone PDP-D usage - -source "${POLICY_HOME}"/etc/build.info - -echo "Control Loop CLI Generator for R1 Amsterdam Release" -echo "---------------------------------------------------" -echo - -GROUP_ID="org.onap.policy.rules.amsterdam" -ARTIFACT_ID="amsterdam" -VERSION="${version:-1.3.4}" -PACKAGE="org.onap.policy.rules.amsterdam" -CONTROL_LOOP_NAME="ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e" -POLICY_SCOPE="amsterdam" -POLICY_NAME="vcpe" -POLICY_VERSION="v0.0.1" -CONTROL_LOOP_YAML="controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0D%0A++trigger_policy%3A+unique-policy-id-1-restart%0D%0A++timeout%3A+3600%0D%0A++abatement%3A+true%0D%0A+%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-restart%0D%0A++++name%3A+Restart+the+VM%0D%0A++++description%3A%0D%0A++++actor%3A+APPC%0D%0A++++recipe%3A+Restart%0D%0A++++target%3A%0D%0A++++++type%3A+VM%0D%0A++++retry%3A+3%0D%0A++++timeout%3A+1200%0D%0A++++success%3A+final_success%0D%0A++++failure%3A+final_failure%0D%0A++++failure_timeout%3A+final_failure_timeout%0D%0A++++failure_retries%3A+final_failure_retries%0D%0A++++failure_exception%3A+final_failure_exception%0D%0A++++failure_guard%3A+final_failure_guard" -DMAAP_SERVERS="vm1.mr.simpledemo.openecomp.org" -DCAE_TOPIC="unauthenticated.DCAE_CL_OUTPUT" -DCAE_SERVERS="vm1.mr.simpledemo.openecomp.org" - -read -e -i "${GROUP_ID}" -p "Target Rules Group Id> " GROUP_ID -read -e -i "${ARTIFACT_ID}" -p "Target Rules Artifact Id> " ARTIFACT_ID -read -e -i "${VERSION}" -p "Target Rules Version> " VERSION -read -e -i "${PACKAGE}" -p "Target Rules Java Package> " PACKAGE - -read -e -i "${CONTROL_LOOP_NAME}" -p "Template Control Loop Name> " CONTROL_LOOP_NAME -read -e -i "${POLICY_SCOPE}" -p "Template Policy Scope> " POLICY_SCOPE -read -e -i "${POLICY_NAME}" -p "Template Policy Name> " POLICY_NAME -read -e -i "${POLICY_VERSION}" -p "Template Policy Version> " POLICY_VERSION - -read -e -i "${CONTROL_LOOP_YAML}" -p "Control Loop Yaml> " CONTROL_LOOP_YAML - -read -e -i "${DCAE_SERVERS}" -p "Configuration DCAE DMaaP Servers> " DCAE_SERVERS -read -e -i "${DMAAP_SERVERS}" -p "Configuration Open DMaaP Servers> " DMAAP_SERVERS -read -e -i "${DCAE_TOPIC}" -p "Template DCAE Topic> " DCAE_TOPIC - -echo -echo - -if [ -z "${GROUP_ID}" ]; then echo "Aborting: Rules Maven Group Id not provided"; exit 1; fi -if [ -z "${ARTIFACT_ID}" ]; then echo "Aborting: Rules Maven Coordinates Artifact Id not provided"; exit 1; fi -if [ -z "${VERSION}" ]; then echo "Aborting: Rules Maven Coordinates Version not provided"; exit 1; fi -if [ -z "${PACKAGE}" ]; then echo "Aborting: Rules Package not provided"; exit 1; fi -if [ -z "${CONTROL_LOOP_NAME}" ]; then echo "Aborting: Template Control Loop Name not provided"; exit 1; fi -if [ -z "${POLICY_SCOPE}" ]; then echo "Aborting: Template Policy Scope not provided"; exit 1; fi -if [ -z "${POLICY_NAME}" ]; then echo "Aborting: Template Policy Name not provided"; exit 1; fi -if [ -z "${POLICY_VERSION}" ]; then echo "Aborting: Template Policy Version not provided"; exit 1; fi -if [ -z "${CONTROL_LOOP_YAML}" ]; then echo "Aborting: Control Loop Yaml not provided"; exit 1; fi - -if [ -z "${DCAE_TOPIC}" ]; then echo "Aborting: Configuration DCAE DMaaP Topic not provided"; exit 1; fi -if [ -z "${DMAAP_SERVERS}" ]; then echo "Aborting: Configuration Open DMaaP Servers not provided"; exit 1; fi -if [ -z "${DCAE_SERVERS}" ]; then echo "Aborting: Configuration DCAE DMaaP Servers not provided"; exit 1; fi - -DEPENDENCIES_VERSION="${version}" - -read -e -i "${DEPENDENCIES_VERSION}" -p "Control Loop Jar Dependencies Version (ie: 1.1.1-SNAPSHOT, or 1.1.1) > " DEPENDENCIES_VERSION -if [ -z "${DEPENDENCIES_VERSION}" ]; then echo "Aborting: Control Loop Jar Dependencies Version not provided"; exit 1; fi - -echo "---------------------------------------------------------------------------------------" -echo "Please review the Control Loop Rules, Template, and Configuration Parameters:" -echo -echo "The generated rules jar will be installed in a local Maven Repository" -echo -echo "Rules Maven Artifact Generation: Group Id: ${GROUP_ID}" -echo "Rules Maven Artifact Generation: Artifact Id: ${ARTIFACT_ID}" -echo "Rules Maven Artifact Generation: Version: ${VERSION}" -echo "Rules Maven Artifact Generation: Java Package: ${PACKAGE}" -echo "Rules Maven Artifact Generation: pom: Java Libraries Dependencies Version: ${DEPENDENCIES_VERSION}" -echo -echo "Template Drools DRL Expansion: Control Loop Control Name: ${CONTROL_LOOP_NAME}" -echo "Template Drools DRL Expansion: Control Loop Policy Scope: ${POLICY_SCOPE}" -echo "Template Drools DRL Expansion: Control Loop Policy Name: ${POLICY_NAME}" -echo "Template Drools DRL Expansion: Control Loop Policy Version: ${POLICY_VERSION}" -echo "Template Drools DRL Expansion: Control Loop Yaml: ${CONTROL_LOOP_YAML}" -echo -echo "Configuration Policy Controller: Rules: Group Id: ${GROUP_ID}" -echo "Configuration Policy Controller: Rules: Artifact Id: ${ARTIFACT_ID}" -echo "Configuration Policy Controller: Rules: Version: ${VERSION}" -echo -echo "Configuration Policy Controller: DCAE DMaaP Topic: ${DCAE_TOPIC}" -echo "Configuration Policy Controller: DCAE DMaaP Servers: ${DCAE_SERVERS}" -echo -echo "Configuration Policy Controller: Open DMaaP Servers: ${DMAAP_SERVERS}" -echo "---------------------------------------------------------------------------------------" -echo - -HAPPY="Y" -read -e -i "${HAPPY}" -p "Are the previous parameters correct (Y/N)? " HAPPY -if [[ ${HAPPY} != "Y" ]]; then - exit 1 -fi - -echo -DIR_TMP="/tmp" -echo "The Control Loop Rules Maven Project Source Rules will be installed at ${DIR_TMP}" -read -e -i "${DIR_TMP}" -p "Do you want to change the Rules Source Project install directory? " DIR_TMP - -if [ ! -w "${DIR_TMP}" ]; then - echo "Aborting. ${DIR_TMP} is not writable" - exit 1 -fi - -ARCHETYPE_GROUP_ID="org.onap.policy.drools-applications.controlloop.templates" -ARCHETYPE_ARTIFACT_ID="archetype-cl-amsterdam" -ARCHETYPE_VERSION="${VERSION}" - -if [ -d "${DIR_TMP}/${ARTIFACT_ID}/" ]; then - if [ "$(ls -A "${DIR_TMP}/${ARTIFACT_ID}"/)" ]; then - echo "${DIR_TMP} already contains a ${ARTIFACT_ID}/ directory, saving it to ${DIR_TMP}/${ARTIFACT_ID}.arch.bak/" - if [ -d "${DIR_TMP}/${ARTIFACT_ID}.arch.bak"/ ]; then - ( - echo "${DIR_TMP}/${ARTIFACT_ID}.arch.bak/ also exists, deleting it .." - cd "${DIR_TMP}"/ - rm -fr "${ARTIFACT_ID}.arch.bak" - ) - fi - /bin/mv --force "${DIR_TMP}/${ARTIFACT_ID}/" "${DIR_TMP}/${ARTIFACT_ID}.arch.bak" - if [ "${?}" -ne 0 ]; then - echo - echo - echo "Aborting: ${DIR_TMP}/${ARTIFACT_ID}/ cannot be moved" - exit 1 - fi - else - ( cd "${DIR_TMP}/" ; rmdir "${DIR_TMP}/${ARTIFACT_ID}/" ) - fi -fi - -CREATEARTIFACT="Y" -read -e -i "${CREATEARTIFACT}" -p "Create Maven Artifact (Y/N)? " CREATEARTIFACT -if [[ ${CREATEARTIFACT} != "Y" ]]; then - exit 1 -fi - -( -cd "${DIR_TMP}" - -mvn archetype:generate \ - -B \ - -DarchetypeCatalog=local \ - -DarchetypeGroupId="${ARCHETYPE_GROUP_ID}" \ - -DarchetypeArtifactId="${ARCHETYPE_ARTIFACT_ID}" \ - -DarchetypeVersion="${ARCHETYPE_VERSION}" \ - -Dpackage="${PACKAGE}" \ - -DgroupId="${GROUP_ID}" \ - -DartifactId="${ARTIFACT_ID}" \ - -Dversion="${VERSION}" \ - -DclosedLoopControlName="${CONTROL_LOOP_NAME}" \ - -DcontrolLoopYaml="${CONTROL_LOOP_YAML}" \ - -DpolicyScope="${POLICY_SCOPE}" \ - -DpolicyName="${POLICY_NAME}" \ - -DpolicyVersion="${POLICY_VERSION}" \ - -DdmaapServers="${DMAAP_SERVERS}" \ - -DdcaeTopic="${DCAE_TOPIC}" \ - -DdcaeServers="${DCAE_SERVERS}" \ - -DdependenciesVersion="${DEPENDENCIES_VERSION}" - -if [ "${?}" -ne 0 ]; then - echo - echo - echo "Aborting: ${ARTIFACT_ID} has not been successfully generated" - exit 1 -fi - -echo - -cd "${DIR_TMP}/${ARTIFACT_ID}"/ - -mv src/main/config/* . - -echo -echo "Control Loop Rules from templates have been successfully created under ${DIR_TMP}/${ARTIFACT_ID}/" -echo "You have to option to further tweak this project or deploy it as is to the local maven repository." -echo "If you decide to customize the source rules project, please enter 'N' below," -echo "and when finished type 'mvn install' at ${DIR_TMP}/${ARTIFACT_ID}/ to install the Control Loop." - -INSTALLREPO="Y" -read -e -i "${INSTALLREPO}" -p "Do you want to deploy ${ARTIFACT_ID} rules into maven repository (Y/N)? " INSTALLREPO -if [[ ${INSTALLREPO} != "Y" ]]; then - exit 1 -fi - -echo -echo "installing the rules ${ARTIFACT_ID} maven artifact .." - -mvn install - -if [ "${?}" -ne 0 ]; then - echo - echo - echo "Aborting: ${ARTIFACT_ID} deployable jar cannot be installed" - echo "Fix the source rules project issues, and issue 'mvn install'" - echo "at ${DIR_TMP}/${ARTIFACT_ID}/ when done to install it." - exit 1 -fi - - -echo -echo "${ARTIFACT_ID} has been successfully installed in user's (${USER}) local repository" -echo "Find configuration files at ${DIR_TMP}/${ARTIFACT_ID}/" -echo -echo "To deploy this Control Loop into the PDP-D, follow one of these methods: " -echo "1. copy ${DIR_TMP}/${ARTIFACT_ID}/${ARTIFACT_ID}-controller.properties under '${POLICY_HOME}/config'" -echo " and restart the pdp-d (policy stop; policy start)" -echo "2. cd ${DIR_TMP}/${ARTIFACT_ID}/; rest-add-controller ${ARTIFACT_ID}" -echo -) diff --git a/controlloop/common/pom.xml b/controlloop/common/pom.xml index 934dbcd03..431ab94e6 100644 --- a/controlloop/common/pom.xml +++ b/controlloop/common/pom.xml @@ -42,7 +42,6 @@ feature-controlloop-utils feature-controlloop-trans feature-controlloop-management - feature-controlloop-amsterdam feature-controlloop-frankfurt feature-controlloop-usecases diff --git a/controlloop/packages/apps-controlloop/pom.xml b/controlloop/packages/apps-controlloop/pom.xml index 0a78585df..895e66e10 100644 --- a/controlloop/packages/apps-controlloop/pom.xml +++ b/controlloop/packages/apps-controlloop/pom.xml @@ -89,12 +89,6 @@ ${project.version} zip - - org.onap.policy.drools-applications.controlloop.common - feature-controlloop-amsterdam - ${project.version} - zip - org.onap.policy.drools-applications.controlloop.common feature-controlloop-usecases diff --git a/controlloop/packages/docker-controlloop/src/main/docker/Dockerfile b/controlloop/packages/docker-controlloop/src/main/docker/Dockerfile index 464720360..6c7c11433 100644 --- a/controlloop/packages/docker-controlloop/src/main/docker/Dockerfile +++ b/controlloop/packages/docker-controlloop/src/main/docker/Dockerfile @@ -12,14 +12,16 @@ RUN unzip apps-controlloop.zip && \ chmod 600 $POLICY_HOME/config/* && \ . $POLICY_HOME/etc/profile.d/env.sh && \ $POLICY_HOME/bin/features install controlloop-utils controlloop-trans controlloop-management && \ - $POLICY_HOME/bin/features install controlloop-amsterdam controlloop-usecases && \ + $POLICY_HOME/bin/features install controlloop-frankfurt controlloop-usecases && \ $POLICY_HOME/bin/features enable healthcheck distributed-locking lifecycle && \ $POLICY_HOME/bin/features enable controlloop-trans controlloop-management && \ - $POLICY_HOME/bin/features enable controlloop-amsterdam controlloop-usecases && \ + $POLICY_HOME/bin/features enable controlloop-frankfurt controlloop-usecases && \ $POLICY_HOME/bin/deploy-artifact -l -d -s $POLICY_HOME/etc/m2/standalone-settings.xml \ -a $POLICY_HOME/features/controlloop-management/lib/feature/feature-controlloop-management-$BUILD_VERSION_APP_CL.jar && \ $POLICY_HOME/bin/deploy-artifact -l -d -s $POLICY_HOME/etc/m2/standalone-settings.xml \ -a $POLICY_HOME/features/controlloop-usecases/artifacts/controller-usecases-$BUILD_VERSION_APP_CL.jar && \ + $POLICY_HOME/bin/deploy-artifact -l -d -s $POLICY_HOME/etc/m2/standalone-settings.xml \ + -a $POLICY_HOME/features/controlloop-frankfurt/artifacts/controller-frankfurt-$BUILD_VERSION_APP_CL.jar && \ find $HOME/.m2/ -name _maven.repositories -exec rm -v {} \; && \ find $HOME/.m2/ -name _remote.repositories -exec rm -v {} \; && \ rm $POLICY_INSTALL/apps-controlloop.zip $POLICY_INSTALL/basex-controlloop-$BUILD_VERSION_APP_CL.tar.gz 2> /dev/null diff --git a/controlloop/pom.xml b/controlloop/pom.xml index e99845eee..2a23ac23d 100644 --- a/controlloop/pom.xml +++ b/controlloop/pom.xml @@ -36,7 +36,6 @@ common - templates m2 packages diff --git a/controlloop/templates/archetype-cl-amsterdam/pom.xml b/controlloop/templates/archetype-cl-amsterdam/pom.xml deleted file mode 100644 index 2539ef1c0..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/pom.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - 4.0.0 - maven-archetype - - - org.onap.policy.drools-applications.controlloop.templates - templates - 1.6.0-SNAPSHOT - - - archetype-cl-amsterdam - - ${project.artifactId} - Archetype to generate a yaml based control loop for ONAP Amsterdam release - - - - - org.apache.maven.archetype - archetype-packaging - 3.0.1 - - - - - - - maven-archetype-plugin - 3.0.1 - - - - - diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/META-INF/maven/archetype-metadata.xml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/META-INF/maven/archetype-metadata.xml deleted file mode 100644 index 2c4b2cee2..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/META-INF/maven/archetype-metadata.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e - - - controlLoop%3A%0A++version%3A+2.0.0%0A++controlLoopName%3A+ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0A++trigger_policy%3A+unique-policy-id-1-restart%0A++timeout%3A+3600%0A+%0Apolicies%3A%0A+%0A++-+id%3A+unique-policy-id-1-restart%0A++++name%3A+Restart+the+VM%0A++++description%3A%0A++++actor%3A+APPC%0A++++recipe%3A+Restart%0A++++target%3A%0A++++++type%3A+VM%0A++++retry%3A+3%0A++++timeout%3A+1200%0A++++success%3A+final_success%0A++++failure%3A+final_failure%0A++++failure_timeout%3A+final_failure_timeout%0A++++failure_retries%3A+final_failure_retries%0A++++failure_exception%3A+final_failure_exception%0A++++failure_guard%3A - - - DCAE.Config_tca-hi-lo - - - DCAE - - - 1.1.1 - - - vm1.mr.simpledemo.onap.org - - - unauthenticated.DCAE_CL_OUTPUT - - - vm1.mr.simpledemo.onap.org - - - 2.0.0-SNAPSHOT - - - - - - src/main/resources - - **/*.xml - - - - src/main/resources - - **/*.drl - - - - src/main/config - - **/*.properties - **/*.json - - - - diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/pom.xml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/pom.xml deleted file mode 100644 index eb648348c..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/pom.xml +++ /dev/null @@ -1,154 +0,0 @@ - - - - - 4.0.0 - - ${groupId} - ${artifactId} - ${version} - kjar - - ${artifactId} - Control Loop Amsterdam Release Rules - - - 1.8 - 1.8 - - - - - - org.kie - kie-maven-plugin - true - - - - - - - org.onap.policy.models.policy-models-interactions.model-impl - events - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-impl - appc - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-impl - appclcm - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-impl - vfc - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-impl - so - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-impl - sdnc - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-impl - aai - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-impl - sdc - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-impl - sdnr - ${dependenciesVersion} - - - org.onap.policy.drools-applications.controlloop.common - eventmanager - ${dependenciesVersion} - - - org.onap.policy.drools-applications.controlloop.common - guard - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-actors - actorServiceProvider - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-actors - actor.appc - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-actors - actor.appclcm - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-actors - actor.so - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-actors - actor.sdnr - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-actors - actor.vfc - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions.model-actors - actor.sdnc - ${dependenciesVersion} - - - org.onap.policy.models.policy-models-interactions - policy-yaml - ${dependenciesVersion} - - - org.onap.policy.drools-pdp - policy-management - ${dependenciesVersion} - provided - true - - - diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/CCVPN.yaml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/CCVPN.yaml deleted file mode 100644 index b5b37b0eb..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/CCVPN.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2018 Huawei. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ${ccvpnClosedLoopControlName} - trigger_policy: unique-policy-id-16-Reroute - timeout: 3600 - abatement: false - -policies: - - id: unique-policy-id-16-Reroute - name: Connectivity Reroute - description: - actor: SDNC - recipe: Reroute - 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 diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/CCVPNBW.yaml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/CCVPNBW.yaml deleted file mode 100644 index 7b296ce26..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/CCVPNBW.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ${ccvpnBwClosedLoopControlName} - trigger_policy: unique-policy-id-16-Reroute - timeout: 3600 - abatement: false - -policies: - - id: unique-policy-id-16-BandwidthOnDemand - name: CCVPNBandwidthOnDemand - description: - actor: SDNC - recipe: BandwidthOnDemand - 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 diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/VoLTE.yaml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/VoLTE.yaml deleted file mode 100644 index e2cd61795..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/VoLTE.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ${closedLoopControlName} - trigger_policy: unique-policy-id-1-restart - timeout: 3600 - abatement: false - -policies: - - id: unique-policy-id-1-restart - name: Restart the VM - description: - actor: VFC - 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 - diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties deleted file mode 100644 index b43c3b244..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.properties +++ /dev/null @@ -1,92 +0,0 @@ -### -# ============LICENSE_START======================================================= -# archetype-closed-loop-demo-rules -# ================================================================================ -# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - -controller.name=${artifactId} - -dmaap.source.topics=${dcaeTopic},APPC-CL,APPC-LCM-WRITE,SDNR-CL-RSP - -dmaap.source.topics.${dcaeTopic}.servers=${dcaeServers} -dmaap.source.topics.${dcaeTopic}.apiKey= -dmaap.source.topics.${dcaeTopic}.apiSecret= -dmaap.source.topics.${dcaeTopic}.events=org.onap.policy.controlloop.VirtualControlLoopEvent -dmaap.source.topics.${dcaeTopic}.events.org.onap.policy.controlloop.VirtualControlLoopEvent.filter=[?($.closedLoopEventStatus)] -dmaap.source.topics.${dcaeTopic}.events.custom.gson=org.onap.policy.controlloop.util.Serialization,gson -dmaap.source.topics.${dcaeTopic}.https=true - -dmaap.source.topics.APPC-CL.servers=${dmaapServers} -dmaap.source.topics.APPC-CL.apiKey= -dmaap.source.topics.APPC-CL.apiSecret= -dmaap.source.topics.APPC-CL.events=org.onap.policy.appc.Response -dmaap.source.topics.APPC-CL.events.org.onap.policy.appc.Response.filter=[?($.CommonHeader && $.Status)] -dmaap.source.topics.APPC-CL.events.custom.gson=org.onap.policy.appc.util.Serialization,gsonPretty -dmaap.source.topics.APPC-CL.https=true - -dmaap.source.topics.APPC-LCM-WRITE.servers=${dmaapServers} -dmaap.source.topics.APPC-LCM-WRITE.apiKey= -dmaap.source.topics.APPC-LCM-WRITE.apiSecret= -dmaap.source.topics.APPC-LCM-WRITE.events=org.onap.policy.appclcm.AppcLcmDmaapWrapper -dmaap.source.topics.APPC-LCM-WRITE.events.org.onap.policy.appclcm.AppcLcmDmaapWrapper.filter=[?($.type == 'response')] -dmaap.source.topics.APPC-LCM-WRITE.events.custom.gson=org.onap.policy.appclcm.util.Serialization,gson -dmaap.source.topics.APPC-LCM-WRITE.https=true - -dmaap.source.topics.SDNR-CL-RSP.servers=${dmaapServers} -dmaap.source.topics.SDNR-CL-RSP.apiKey= -dmaap.source.topics.SDNR-CL-RSP.apiSecret= -dmaap.source.topics.SDNR-CL-RSP.events=org.onap.policy.sdnr.PciResponseWrapper -dmaap.source.topics.SDNR-CL-RSP.events.org.onap.policy.sdnr.PciResponseWrapper.filter=[?($.type == 'response')] -dmaap.source.topics.SDNR-CL-RSP.events.custom.gson=org.onap.policy.sdnr.util.Serialization,gson -dmaap.source.topics.SDNR-CL-RSP.https=true - -noop.sink.topics=APPC-CL,APPC-LCM-READ,POLICY-CL-MGT,SDNR-CL,DCAE_CL_RSP - -noop.sink.topics.APPC-CL.servers=${dmaapServers} -noop.sink.topics.APPC-CL.apiKey= -noop.sink.topics.APPC-CL.apiSecret= -noop.sink.topics.APPC-CL.events=org.onap.policy.appc.Request -noop.sink.topics.APPC-CL.events.custom.gson=org.onap.policy.appc.util.Serialization,gsonPretty - -noop.sink.topics.APPC-LCM-READ.servers=${dmaapServers} -noop.sink.topics.APPC-LCM-READ.apiKey= -noop.sink.topics.APPC-LCM-READ.apiSecret= -noop.sink.topics.APPC-LCM-READ.events=org.onap.policy.appclcm.AppcLcmDmaapWrapper -noop.sink.topics.APPC-LCM-READ.events.custom.gson=org.onap.policy.appclcm.util.Serialization,gson - -noop.sink.topics.POLICY-CL-MGT.servers=${dmaapServers} -noop.sink.topics.POLICY-CL-MGT.apiKey= -noop.sink.topics.POLICY-CL-MGT.apiSecret= -noop.sink.topics.POLICY-CL-MGT.events=org.onap.policy.controlloop.VirtualControlLoopNotification -noop.sink.topics.POLICY-CL-MGT.events.custom.gson=org.onap.policy.controlloop.util.Serialization,gsonPretty - -noop.sink.topics.SDNR-CL.servers=${dmaapServers} -noop.sink.topics.SDNR-CL.apiKey= -noop.sink.topics.SDNR-CL.apiSecret= -noop.sink.topics.SDNR-CL.events=org.onap.policy.sdnr.PciRequestWrapper -noop.sink.topics.SDNR-CL.events.custom.gson=org.onap.policy.sdnr.util.Serialization,gson - -noop.sink.topics.DCAE_CL_RSP.servers=${dmaapServers} -noop.sink.topics.DCAE_CL_RSP.apiKey= -noop.sink.topics.DCAE_CL_RSP.apiSecret= -noop.sink.topics.DCAE_CL_RSP.events=org.onap.policy.controlloop.ControlLoopResponse -noop.sink.topics.DCAE_CL_RSP.events.custom.gson=org.onap.policy.controlloop.util.Serialization,gsonPretty - -rules.groupId=${groupId} -rules.artifactId=${artifactId} -rules.version=${version} - diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json deleted file mode 100644 index 53843b1db..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/__artifactId__-controller.rest.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "controller.name": "${artifactId}", - - "ueb.source.topics": "${dcaeTopic},APPC-CL,APPC-LCM-WRITE,SDNR-CL-RSP", - - "ueb.source.topics.${dcaeTopic}.servers": "${dcaeServers}", - "ueb.source.topics.${dcaeTopic}.events": "org.onap.policy.controlloop.VirtualControlLoopEvent", - "ueb.source.topics.${dcaeTopic}.events.org.onap.policy.controlloop.VirtualControlLoopEvent.filter": "[?($.closedLoopEventStatus =~ /.*/)]", - "ueb.source.topics.${dcaeTopic}.events.custom.gson": "org.onap.policy.controlloop.util.Serialization,gson", - - "ueb.source.topics.APPC-CL.servers": "${dmaapServers}", - "ueb.source.topics.APPC-CL.events": "org.onap.policy.appc.Response", - "ueb.source.topics.APPC-CL.events.org.onap.policy.appc.Response.filter": "[?($.CommonHeader =~ /.*/ && $.Status =~ /.*/)]", - "ueb.source.topics.APPC-CL.events.custom.gson": "org.onap.policy.appc.util.Serialization,gsonPretty", - - "ueb.source.topics.APPC-LCM-WRITE.servers": "${dmaapServers}", - "ueb.source.topics.APPC-LCM-WRITE.events": "org.onap.policy.appclcm.AppcLcmDmaapWrapper", - "ueb.source.topics.APPC-LCM-WRITE.events.org.onap.policy.appclcm.AppcLcmDmaapWrapper.filter": "[?($.type == 'response')]", - "ueb.source.topics.APPC-LCM-WRITE.events.custom.gson": "org.onap.policy.appclcm.util.Serialization,gson", - - "ueb.source.topics.SDNR-CL-RSP.servers": "${dmaapServers}", - "ueb.source.topics.SDNR-CL-RSP.events": "org.onap.policy.sdnr.PciResponseWrapper", - "ueb.source.topics.SDNR-CL-RSP.events.org.onap.policy.sdnr.PciResponseWrapper.filter": "[?($.type == 'response')]", - "ueb.source.topics.SDNR-CL-RSP.events.custom.gson": "org.onap.policy.sdnr.util.Serialization,gson", - - "noop.sink.topics": "APPC-CL,APPC-LCM-READ,POLICY-CL-MGT,SDNR-CL,DCAE_CL_RSP", - - "noop.sink.topics.APPC-CL.servers": "${dmaapServers}", - "noop.sink.topics.APPC-CL.events": "org.onap.policy.appc.Request", - "noop.sink.topics.APPC-CL.events.custom.gson": "org.onap.policy.appc.util.Serialization,gsonPretty", - - "noop.sink.topics.APPC-LCM-READ.servers": "${dmaapServers}", - "noop.sink.topics.APPC-LCM-READ.events": "org.onap.policy.appclcm.AppcLcmDmaapWrapper", - "noop.sink.topics.APPC-LCM-READ.events.custom.gson": "org.onap.policy.appclcm.util.Serialization,gson", - - "noop.sink.topics.POLICY-CL-MGT.servers": "${dmaapServers}", - "noop.sink.topics.POLICY-CL-MGT.events": "org.onap.policy.controlloop.VirtualControlLoopNotification", - "noop.sink.topics.POLICY-CL-MGT.events.custom.gson": "org.onap.policy.controlloop.util.Serialization,gson", - - "noop.sink.topics.SDNR-CL.servers": "${dmaapServers}", - "noop.sink.topics.SDNR-CL.events": "org.onap.policy.sdnr.PciRequestWrapper", - "noop.sink.topics.SDNR-CL.events.custom.gson": "org.onap.policy.sdnr.util.Serialization,gson", - - "noop.sink.topics.DCAE_CL_RSP.servers": "${dmaapServers}", - "noop.sink.topics.DCAE_CL_RSP.events": "org.onap.policy.controlloop.ControlLoopResponse", - "noop.sink.topics.DCAE_CL_RSP.events.custom.gson": "org.onap.policy.controlloop.util.Serialization,gson", - - "rules.groupId": "${groupId}", - "rules.artifactId": "${artifactId}", - "rules.version": "${version}" - -} diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.lcm.success.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.lcm.success.json deleted file mode 100644 index 985685000..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.lcm.success.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "body": { - "output": { - "common-header": { - "timestamp": "2017-08-25T21:06:23.037Z", - "api-ver": "5.00", - "originator-id": "664be3d2-6c12-4f4b-a3e7-c349acced200", - "request-id": "664be3d2-6c12-4f4b-a3e7-c349acced200", - "sub-request-id": "1", - "flags": {} - }, - "status": { - "code": 400, - "message": "Restart Successful" - } - } - }, - "version": "2.0", - "rpc-name": "restart", - "correlation-id": "664be3d2-6c12-4f4b-a3e7-c349acced200-1", - "type": "response" -} \ No newline at end of file diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.legacy.success.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.legacy.success.json deleted file mode 100644 index 4f956885e..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/appc.legacy.success.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "CommonHeader": { - "TimeStamp": 1506051879001, - "APIver": "1.01", - "RequestID": "c7c6a4aa-bb61-4a15-b831-ba1472dd4a65", - "SubRequestID": "1", - "RequestTrack": [], - "Flags": [] - }, - "Status": { - "Code": 400, - "Value": "SUCCESS" - }, - "Payload": { - "generic-vnf.vnf-id": "jimmy-test-vnf2" - } - } -} \ No newline at end of file diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.ccvpn.bw.onset.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.ccvpn.bw.onset.json deleted file mode 100644 index b2dbb7ba3..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.ccvpn.bw.onset.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "closedLoopEventClient": "DCAE.HolmesInstance", - "policyVersion": "2.0.0", - "policyName": "CCVPNBandwidthOnDemand", - "policyScope": "service=SITEService,type=SampleType,closedLoopControlName=CL-CCVPN-d925ed73-8231-4d02-9545-db4e101f88f8", - "target_type": "VM", - "AAI": { - "vserver.vserver-name" : "TBD", - "globalSubscriberId" : "e151059a-d924-4629-845f-264db19e50b4", - "serviceType" : "service-ccvpn", - "service-instance.service-instance-id" : "298dad9933BBBasa", - "vserver.is-closed-loop-disabled" : "false", - "vserver.prov-status":"ACTIVE", - "bandwidth" : "500", - "bandwidth-change-time":"20190321-10:59:32:321", - "vnfId": "2fbf0f93-c46e-42ed-9a9b-68aaa09ea11d" - }, - "closedLoopAlarmStart": "1484677482204798", - "closedLoopEventStatus": "ONSET", - "closedLoopControlName": "${ccvpnBwClosedLoopControlName}", - "version": "1.0.2", - "target": "vserver.vserver-name", - "requestID": "97964e10-686e-4790-8c45-bdfa61df880f", - "from": "DCAE" -} \ No newline at end of file diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.ccvpn.onset.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.ccvpn.onset.json deleted file mode 100644 index 474911e74..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.ccvpn.onset.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "closedLoopEventClient": "DCAE.HolmesInstance", - "policyVersion": "1.0.0.5", - "policyName": "CCVPN", - "policyScope": "service=SOTNService,type=SampleType,closedLoopControlName=CL-CCVPN-d925ed73-8231-4d02-9545-db4e101f88f8", - "target_type": "VM", - "AAI": { - "vserver.vserver-name" : "TBD", - "globalSubscriberId" : "e151059a-d924-4629-845f-264db19e50b4", - "serviceType" : "SOTN", - "service-information.service-instance-id" : "service-instance-id-example-1", - "network-information. network-id " : "id" - }, - "closedLoopAlarmStart": 1484677482204798, - "closedLoopEventStatus": "ONSET", - "closedLoopControlName": "${ccvpnClosedLoopControlName}", - "version": "1.0.2", - "target": "vserver.vserver-name", - "requestID": "97964e10-686e-4790-8c45-bdfa61df770f", - "from": "DCAE" -} diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vcpe.abatement.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vcpe.abatement.json deleted file mode 100644 index 006e1a52c..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vcpe.abatement.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "closedLoopControlName": "${closedLoopControlName}", - "closedLoopAlarmStart": 1463679805324, - "closedLoopAlarmEnd": 1463699805324, - "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", - "closedLoopEventStatus": "ABATED", - "requestID": "664be3d2-6c12-4f4b-a3e7-c349acced200", - "target_type": "VNF", - "target": "generic-vnf.vnf-id", - "AAI": { - "vserver.is-closed-loop-disabled": "false", - "vserver.prov-status": "ACTIVE", - "generic-vnf.vnf-id": "vCPE_Infrastructure_vGMUX_demo_app" - }, - "from": "DCAE", - "version": "1.0.2" -} diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vcpe.onset.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vcpe.onset.json deleted file mode 100644 index d1d7c05bc..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vcpe.onset.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "closedLoopControlName": "${closedLoopControlName}", - "closedLoopAlarmStart": 1463679805324, - "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", - "closedLoopEventStatus": "ONSET", - "requestID": "664be3d2-6c12-4f4b-a3e7-c349acced200", - "target_type": "VNF", - "target": "generic-vnf.vnf-id", - "AAI": { - "vserver.is-closed-loop-disabled": "false", - "vserver.prov-status": "ACTIVE", - "generic-vnf.vnf-id": "vCPE_Infrastructure_vGMUX_demo_app" - }, - "from": "DCAE", - "version": "1.0.2" -} diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vdns.onset.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vdns.onset.json deleted file mode 100644 index 4c4b53c8c..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vdns.onset.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "closedLoopControlName": "${closedLoopControlName}", - "closedLoopAlarmStart": 1484677482204798, - "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", - "closedLoopEventStatus": "ONSET", - "requestID": "e4f95e0c-a013-4530-8e59-c5c5f9e539b6", - "target_type": "VNF", - "target": "vserver.vserver-name", - "AAI": { - "vserver.is-closed-loop-disabled": "false", - "vserver.prov-status": "ACTIVE", - "vserver.vserver-name": "dfw1lb01lb01" - }, - "from": "DCAE", - "version": "1.0.2" -} \ No newline at end of file diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vfw.onset.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vfw.onset.json deleted file mode 100644 index cd3c243a8..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.vfw.onset.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "closedLoopControlName": "${closedLoopControlName}", - "closedLoopAlarmStart": 1463679805324, - "closedLoopEventClient": "microservice.stringmatcher", - "closedLoopEventStatus": "ONSET", - "requestID": "c7c6a4aa-bb61-4a15-b831-ba1472dd4a65", - "target_type": "VNF", - "target": "generic-vnf.vnf-id", - "AAI": { - "vserver.is-closed-loop-disabled": "false", - "vserver.prov-status": "ACTIVE", - "generic-vnf.vnf-id": "fw0002vm002fw002" - }, - "from": "DCAE", - "version": "1.0.2" -} diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.volte.onset.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.volte.onset.json deleted file mode 100644 index b5bb6e792..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/dcae.volte.onset.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "closedLoopControlName": "${closedLoopControlName}", - "closedLoopAlarmStart": 1484677482204798, - "closedLoopEventClient": "DCAE.HolmesInstance", - "closedLoopEventStatus": "ONSET", - "requestID": "97964e10-686e-4790-8c45-bdfa61df770f", - "target_type": "VM", - "target": "vserver.vserver-name", - "AAI": { - "vserver.is-closed-loop-disabled": "false", - "vserver.prov-status": "ACTIVE", - "vserver.vserver-name": "dfw1lb01lb01", - "service-instance.service-instance-id" : "vserver-name-16102016-aai3255-data-11-1", - "generic-vnf.vnf-id" : "vnf-id-16102016-aai3255-data-11-1", - "generic-vnf.vnf-name" : "vnf-name-16102016-aai3255-data-11-1" - }, - "from": "DCAE", - "version": "1.0.2" -} \ No newline at end of file diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/so.success.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/so.success.json deleted file mode 100644 index 6d617b4bf..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/so.success.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "requestReferences": { - "instanceId": "ff305d54-75b4-ff1b-bdb2-eb6b9e5460ff", - "requestId": "e4f95e0c-a013-4530-8e59-c5c5f9e539b6" - }, - "request": { - "requestId": "e4f95e0c-a013-4530-8e59-c5c5f9e539b6", - "requestStatus": { - "percentProgress": 100, - "requestState": "COMPLETE", - "wasRolledBack": false - } - }, - "httpResponseCode": 200 -} diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vCPE.yaml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vCPE.yaml deleted file mode 100644 index 19b755c96..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vCPE.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ${closedLoopControlName} - 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/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vDNS.yaml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vDNS.yaml deleted file mode 100644 index 71ee386ef..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vDNS.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ${closedLoopControlName} - 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":[{"name":"gtp_bind_addr","value":"vmme_private_ip_0"},{"name":"mmc","value":"001"},{"name":"mme_addr","value":"vmme_private_ip_0"},{"name":"mnc","value":"01"},{"name":"n_prob","value":"50"},{"name":"vnfHostIpAddress","value":"veb_private_ip_0"}]}' - configurationParameters: '[{"availability-zone":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]","xtz-123":"$.vnf-topology.vnf-resource-assignments.availability-zones.availability-zone[0]"}]' - 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 diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vFW.yaml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vFW.yaml deleted file mode 100644 index b517e76b3..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vFW.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2018-2019 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ${closedLoopControlName} - trigger_policy: unique-policy-id-1-modifyConfig - timeout: 3600 - abatement: false - -policies: - - id: unique-policy-id-1-modifyConfig - name: modify packet gen config - description: - actor: APPC - recipe: ModifyConfig - target: - resourceID: Eace933104d443b496b8.nodes.heat.vpg - type: VNF - payload: - streams: '{"active-streams":5}' - retry: 2 - 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 diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vPCI.pcims.onset.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vPCI.pcims.onset.json deleted file mode 100644 index 0e67d3251..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vPCI.pcims.onset.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "closedLoopControlName": "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459", - "closedLoopAlarmStart": 1510187409180, - "closedLoopEventClient": "microservice.PCI", - "closedLoopEventStatus": "ONSET", - "requestID": "9d2d790e-a5f0-11e8-98d0-529269fb1459", - "target_type": "VNF", - "target": "generic-vnf.vnf-id", - "AAI": { - "generic-vnf.is-closed-loop-disabled": "false", - "generic-vnf.prov-status": "ACTIVE", - "generic-vnf.vnf-id": "notused" - }, - "from": "PCIMS", - "version": "1.0.2", - "Action": "ModifyConfig", - "payload": "{ \"Configurations\":[ { \"data\":{ \"FAPService\":{ \"alias\":\"Cell1\", \"X0005b9Lte\" : { \"PhyCellIdInUse\" : \"35\", \"PnfName\" : \"cu1\" }, \"CellConfig\":{ \"LTE\":{ \"RAN\":{ \"Common\":{ \"CellIdentity\":\"1\" } } } } } } } ] }" -} diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vPCI.sdnr.success.json b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vPCI.sdnr.success.json deleted file mode 100644 index 74d7f60bb..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vPCI.sdnr.success.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "body": { - "output": { - "CommonHeader": { - "TimeStamp": "2018-09-10T07:10:05.614Z", - "APIver": "1.0", - "RequestID": "9d2d790e-a5f0-11e8-98d0-529269fb1459", - "SubRequestID": "1", - "RequestTrack": [], - "Flags": [] - }, - "Status": { - "Code": 200, - "Value": "SUCCESS" - }, - "Payload": "{ \"Configurations\":[ { \"Status\": { \"Code\": 200, \"Value\": \"SUCCESS\" }, \"data\":{ \"FAPService\":{ \"alias\":\"Network1\", \"X0005b9Lte\" : { \"PnfName\" : \"cu1\" }, \"CellConfig\":{ \"LTE\":{ \"RAN\":{ \"Common\":{ \"CellIdentity\":\"1\" } } } } } } } ] }" - } - }, - "version": "1.0", - "rpc-name": "ModifyConfig", - "correlation-id": "9d2d790e-a5f0-11e8-98d0-529269fb1459-1", - "type": "response" -} diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vPCI.yaml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vPCI.yaml deleted file mode 100644 index 0fe44e3d0..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vPCI.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2018 Wipro Limited Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 3.0.0 - controlLoopName: ${closedLoopControlName} - trigger_policy: unique-policy-id-123-modifyconfig - timeout: 1200 - abatement: false - -policies: - - id: unique-policy-id-123-modifyconfig - name: modify PCI config - description: - actor: SDNR - recipe: ModifyConfig - target: - # These fields are not used - 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 diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vSONH.anr.onset b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vSONH.anr.onset deleted file mode 100644 index 7636c2ade..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vSONH.anr.onset +++ /dev/null @@ -1,18 +0,0 @@ -{ - "closedLoopControlName": "ControlLoop-vSONH-7d4baf04-8875-4d1f-946d-06b874048b61", - "closedLoopAlarmStart": 1510187409180, - "closedLoopEventClient": "microservice.SONH", - "closedLoopEventStatus": "ONSET", - "requestID": "722ee65a-8afd-48df-bf57-c152ae45bacc", - "target_type": "VNF", - "target": "generic-vnf.vnf-id", - "AAI": { - "generic-vnf.is-closed-loop-disabled": "false", - "generic-vnf.prov-status": "ACTIVE", - "generic-vnf.vnf-id": "notused" - }, - "from": "SONHMS", - "version": "1.0.2", - "Action": "ModifyConfigANR", - "payload": "{ \"Configurations\":[ { \"data\":{ \"FAPService\":{ \"alias\":\"Cell1\", \"CellConfig\":{ \"LTE\":{ \"RAN\":{ \"Common\":{ \"CellIdentity\":\"1\" }, \"NeighborListInUse\" : { \"LTECellNumberOfEntries\" : \"1\" , \"LTECell\" : [{ \"PLMNID\" :\"plmnid1\", \"CID\":\"Chn0001\", \"PhyCellID\":\"3\", \"PNFName\":\"ncserver01\", \"Blacklisted\":\"false\"}] } } } } } } } ] }" -} diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vSONH.anr.sdnr.success b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vSONH.anr.sdnr.success deleted file mode 100644 index c814a7459..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vSONH.anr.sdnr.success +++ /dev/null @@ -1,23 +0,0 @@ -{ - "body": { - "output": { - "CommonHeader": { - "TimeStamp": "2018-09-10T07:10:05.614Z", - "APIver": "1.0", - "RequestID": "722ee65a-8afd-48df-bf57-c152ae45bacc", - "SubRequestID": "1", - "RequestTrack": [], - "Flags": [] - }, - "Status": { - "Code": 200, - "Value": "SUCCESS" - }, - "Payload": "{ \"Configurations\":[ { \"Status\": { \"Code\": 200, \"Value\": \"SUCCESS\" }, \"data\":{ \"FAPService\":{ \"alias\":\"Cell1\", \"CellConfig\":{ \"LTE\":{ \"RAN\":{ \"Common\":{ \"CellIdentity\":\"1\" }, \"NeighborListInUse\" : { \"LTECellNumberOfEntries\" : \"1\" , \"LTECell\" : [{ \"PLMNID\" :\"plmnid1\", \"CID\":\"Chn0001\", \"PhyCellID\":\"3\", \"PNFName\":\"ncserver01\", \"Blacklisted\":\"false\"}] } } } } } } } ] }" - } - }, - "version": "1.0", - "rpc-name": "ModifyConfigANR", - "correlation-id": "722ee65a-8afd-48df-bf57-c152ae45bacc-1", - "type": "response" -} diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vSONH.yml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vSONH.yml deleted file mode 100644 index 07790226a..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/config/vSONH.yml +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2019 Wipro Limited Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 3.0.0 - controlLoopName: ${closedLoopControlName} - trigger_policy: unique-policy-id-123-modifyconfig - timeout: 1200 - abatement: false - -policies: - - id: unique-policy-id-456-modifyconfig - name: modify ANR config - description: - actor: SDNR - recipe: ModifyConfigANR - target: - # These fields are not used - 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 diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/META-INF/kmodule.xml b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/META-INF/kmodule.xml deleted file mode 100644 index 9ec524b0e..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/META-INF/kmodule.xml +++ /dev/null @@ -1,29 +0,0 @@ -#set( $symbol_pound = '#' ) -#set( $symbol_dollar = '$' ) -#set( $symbol_escape = '\' ) - - - - - - - - diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl deleted file mode 100644 index 88bf6141f..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl +++ /dev/null @@ -1,1833 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Bell Canada. - * ================================================================================ - * 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.controlloop; - -import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; - -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.VirtualControlLoopNotification; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopException; -import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.policy.PolicyResult; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.controlloop.policy.Policy; -import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager; -import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager.NewEventStatus; -import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager; -import org.onap.policy.controlloop.eventmanager.LockCallbackWorkingMemory; -import org.onap.policy.controlloop.actor.so.SoActorServiceProvider; -import org.onap.policy.controlloop.actor.cds.CdsActorServiceProvider; -import org.onap.policy.controlloop.actor.cds.CdsActorServiceProvider.CdsActorServiceManager; -import org.onap.policy.controlloop.actor.cds.constants.CdsActorConstants; -import org.onap.policy.aai.AaiCqResponse; -import org.onap.policy.appc.Request; -import org.onap.policy.appc.Response; -import org.onap.policy.appc.CommonHeader; -import org.onap.policy.appclcm.AppcLcmDmaapWrapper; -import org.onap.policy.cds.CdsResponse; -import org.onap.policy.cds.client.CdsProcessorGrpcClient; -import org.onap.policy.cds.properties.CdsServerProperties; -import org.onap.policy.drools.utils.Pair; -import org.onap.policy.sdnr.PciRequestWrapper; -import org.onap.policy.sdnr.PciResponseWrapper; -import org.onap.policy.sdnr.PciRequest; -import org.onap.policy.sdnr.PciResponse; -import org.onap.policy.vfc.VfcRequest; -import org.onap.policy.vfc.VfcResponse; -import org.onap.policy.vfc.VfcManager; -import org.onap.policy.so.SoManager; -import org.onap.policy.so.SoRequest; -import org.onap.policy.so.SoResponseWrapper; -import org.onap.policy.sdnc.SdncRequest; -import org.onap.policy.sdnc.SdncManager; -import org.onap.policy.sdnc.SdncResponse; -import org.onap.policy.drools.core.lock.Lock; -import org.onap.policy.guard.PolicyGuardRequest; -import org.onap.policy.guard.PolicyGuardResponse; -import org.onap.policy.guard.PolicyGuardXacmlRequestAttributes; -import org.onap.policy.guard.PolicyGuardXacmlHelper; - -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; - -import org.slf4j.LoggerFactory; -import org.slf4j.Logger; - -import java.time.Instant; -import java.util.LinkedList; -import java.util.Iterator; - -import org.onap.policy.drools.system.PolicyEngineConstants; - -/* - * This structure mimics the Params structure. - * Its only purpose is to allow management of - * rules by the PAP component.. - * It has no use at runtime since the rules go by - * Params for matching purposes. - */ -declare PapParams - closedLoopControlName : String - controlLoopYaml : String -end - -/* - * Control Loop Identity - */ -declare Params - closedLoopControlName : String - controlLoopYaml : String -end - -/* - * Used to trigger clean up Params that no longer have associated rules. - */ -declare ParamsInitCleaner - closedLoopControlName : String // only used when logging -end - -/* - * Used to clean up Params that no longer have associated rules. - */ -declare ParamsCleaner - closedLoopControlName : String - controlLoopYaml : String -end - -/* - * This object is to provide support for timeouts - * due to a bug in drools' built-in timers - */ -declare ControlLoopTimer - closedLoopControlName : String - requestId : String - delay : String - expired : boolean - //timerType is the type of timer: either "ClosedLoop" or "Operation" - timerType : String -end - -/* -* -* Called to insert the parameters into working memory for this Closed Loop policy. This is called -* once each time a closed loop is added or its YAML is updated. -* This has a higher salience so we can ensure that the Params is created before we have a chance to -* discard any events. -* -*/ -rule "${policyName}.SETUP" - salience 1 - when - not( Params( getClosedLoopControlName() == "${closedLoopControlName}", - getControlLoopYaml() == "${controlLoopYaml}" ) ) - then - - Params params = new Params(); - params.setClosedLoopControlName("${closedLoopControlName}"); - params.setControlLoopYaml("${controlLoopYaml}"); - insert(params); - - ParamsInitCleaner initCleaner = new ParamsInitCleaner(); - initCleaner.setClosedLoopControlName("${closedLoopControlName}"); - insert(initCleaner); - - // Note: globals have bad behavior when persistence is used, - // hence explicitly getting the logger vs using a global - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {} : YAML=[{}]", params.getClosedLoopControlName(), drools.getRule().getName(), - params.getControlLoopYaml()); -end - -/* -* -* This rule responds to DCAE Events where there is no manager yet. Either it is -* the first ONSET, or a subsequent badly formed Event (i.e. Syntax error, or is-closed-loop-disabled) -* -*/ -rule "${policyName}.EVENT" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() ) - not ( ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); - - try { - - // - // Check the event, because we need it to not be null when - // we create the ControlLoopEventManager. The ControlLoopEventManager - // will do extra syntax checking as well check if the closed loop is disabled. - // - if ($event.getRequestId() == null) { - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setNotification(ControlLoopNotificationType.REJECTED); - notification.setFrom("policy"); - notification.setMessage("Missing requestId"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - - // - // Let interested parties know - // - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - - // - // Retract it from memory - // - retract($event); - } else if ($event.getClosedLoopEventStatus() != ControlLoopEventStatus.ONSET) { - throw new ControlLoopException($event.getClosedLoopEventStatus() + " received with no prior onset"); - } else { - // - // Create an EventManager - // - ControlLoopEventManager manager = new ControlLoopEventManager($params.getClosedLoopControlName(), - $event.getRequestId()); - // - // Determine if EventManager can actively process the event - // (i.e. syntax, is_closed_loop_disabled checks etc.) - // - VirtualControlLoopNotification notification = manager.activate($params.getControlLoopYaml(), $event); - notification.setFrom("pdp-0001-controller=controlloop"); // Engine.getInstanceName() - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - // - // Are we actively pursuing this event? - // - if (notification.getNotification() == ControlLoopNotificationType.ACTIVE) { - // - // Insert Event Manager into memory, this will now kick off processing. - // - insert(manager); - // - // Let interested parties know - // - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - // - // Setup the Overall Control Loop timer - // - ControlLoopTimer clTimer = new ControlLoopTimer(); - clTimer.setTimerType("ClosedLoop"); - clTimer.setClosedLoopControlName($event.getClosedLoopControlName()); - clTimer.setRequestId($event.getRequestId().toString()); - clTimer.setDelay(manager.getControlLoopTimeout(1500) + "s"); - // - // Insert it - // - insert(clTimer); - } else { - // - // Let interested parties know - // - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - // - // Retract it from memory - // - retract($event); - } - - // - // Now that the manager is inserted into Drools working memory, we'll wait for - // another rule to fire in order to continue processing. This way we can also - // then screen for additional ONSET and ABATED events for this RequestId. - // - } - } catch (Exception e) { - logger.warn("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName(), e); - - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setNotification(ControlLoopNotificationType.REJECTED); - notification.setMessage("Exception occurred: " + e.getMessage()); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - // - // - // - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - // - // Retract the event - // - retract($event); - } -end - -/* -* -* This rule happens when we got a valid ONSET, closed loop is enabled and an Event Manager -* is now created. We can start processing the yaml specification via the Event Manager. -* -*/ -rule "${policyName}.EVENT.MANAGER" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $clTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId().toString(), timerType == "ClosedLoop", !expired ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}: event={} manager={} clTimer={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event, $manager, $clTimer); - - try { - // - // Check which event this is. - // - ControlLoopEventManager.NewEventStatus eventStatus = $manager.onNewEvent($event); - // - // Check what kind of event this is - // - if (eventStatus == NewEventStatus.SUBSEQUENT_ONSET) { - // - // We don't care about subsequent onsets - // - logger.info("{}: {}: subsequent onset", - $params.getClosedLoopControlName(), drools.getRule().getName()); - retract($event); - return; - } - if (eventStatus == NewEventStatus.SYNTAX_ERROR) { - // - // Ignore any bad syntax events - // - logger.warn("{}: {}: syntax error", - $params.getClosedLoopControlName(), drools.getRule().getName()); - retract($event); - return; - } - // - // We only want the initial ONSET event in memory, - // all the other events need to be retracted to support - // cleanup and avoid the other rules being fired for this event. - // - if (eventStatus != NewEventStatus.FIRST_ONSET) { - logger.warn("{}: {}: not first onset", - $params.getClosedLoopControlName(), drools.getRule().getName()); - retract($event); - } - - logger.debug("{}: {}: target={}", $params.getClosedLoopControlName(), - drools.getRule().getName(), $event.getTarget()); - // - // Now start seeing if we need to process this event - // - - // - // Check if this is a Final Event - // - VirtualControlLoopNotification notification = $manager.isControlLoopFinal(); - - - if (notification != null) { - // - // Its final, but are we waiting for abatement? - // - if ($manager.getNumAbatements() > 0) { - logger.info("{}: {}: abatement received for {}. Closing the control loop", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event.getRequestId()); - - /// DB Write---end event processing for this RequestId() - $manager.commitAbatement("Event Abated","Closed"); - - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - // - // In this case, we are done - // - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - // - // Unlock the target - // - Lock lock = $manager.unlockCurrentOperation(); - if(lock != null) { - logger.debug("{}: {}: retracting lock={}", $params.getClosedLoopControlName(), - drools.getRule().getName(), lock); - retract(lock); - } - // - // Retract everything from memory - // - logger.info("{}: {}: retracting onset, manager, and timer", - $params.getClosedLoopControlName(), drools.getRule().getName()); - - retract($manager.getOnsetEvent()); - - // don't retract manager, etc. - a clean-up rule will do that - - // - // TODO - what if we get subsequent Events for this RequestId? - // By default, it will all start over again. May be confusing for Ruby. - // Or, we could track this and then subsequently ignore the events - // - } else { - // - // Check whether we need to wait for abatement - // - if ($manager.getProcessor().getControlLoop().getAbatement() == true && notification.getNotification() == ControlLoopNotificationType.FINAL_SUCCESS) { - logger.info("{}: {}: waiting for abatement ..", - $params.getClosedLoopControlName(), drools.getRule().getName()); - } else { - logger.info("{}: {}: no abatement expect for {}. Closing the control loop", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event.getRequestId()); - - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - - // - // In this case, we are done - // - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - // - // Unlock the target - // - Lock lock = $manager.unlockCurrentOperation(); - if(lock != null) { - logger.debug("{}: {}: retracting lock={}", $params.getClosedLoopControlName(), - drools.getRule().getName(), lock); - retract(lock); - } - // - // Retract everything from memory - // - logger.info("{}: {}: retracting onset, manager, and timer", - $params.getClosedLoopControlName(), drools.getRule().getName()); - - retract($manager.getOnsetEvent()); - - // don't retract manager, etc. - a clean-up rule will do that - } - } - } else { - // - // NOT final, so let's ask for the next operation - // - ControlLoopOperationManager operation = $manager.processControlLoop(); - if (operation != null) { - // - // Let's ask for a lock right away - // - logger.info("{}: {}: requesting lock for operation={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - operation); - - Pair oldNew = $manager.lockCurrentOperation( - new LockCallbackWorkingMemory($params.getClosedLoopControlName(), drools.getWorkingMemory())); - if(oldNew.first() != null) { - logger.debug("{}: {}: retracting lock={}", $params.getClosedLoopControlName(), - drools.getRule().getName(), oldNew.first()); - retract(oldNew.first()); - } - if(oldNew.second() != null) { - logger.debug("{}: {}: inserting lock={}", $params.getClosedLoopControlName(), - drools.getRule().getName(), oldNew.second()); - insert(oldNew.second()); - } - - // - // insert the operation into memory - // - insert(operation); - // - // insert operation timeout object - // - ControlLoopTimer opTimer = new ControlLoopTimer(); - opTimer.setTimerType("Operation"); - opTimer.setClosedLoopControlName($event.getClosedLoopControlName()); - opTimer.setRequestId($event.getRequestId().toString()); - Integer timeout = operation.getOperationTimeout(); - opTimer.setDelay(timeout > 0 ? timeout.toString() + "s" : $clTimer.getDelay()); - insert(opTimer); - - } else { - // - // Probably waiting for abatement - // - logger.info("{}: {}: no operation, probably waiting for abatement", - $params.getClosedLoopControlName(), drools.getRule().getName()); - } - } - } catch (Exception e) { - logger.warn("{}: {}: unexpected", - $params.getClosedLoopControlName(), - drools.getRule().getName(), e); - - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE); - notification.setMessage(e.getMessage()); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - - retract($event); - - // don't retract manager, etc. - a clean-up rule will do that - } - -end - -/* -* -* Lock denied -* -*/ -rule "${policyName}.EVENT.MANAGER.OPERATION.LOCK.DENIED" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), - onset.getRequestId() == $event.getRequestId(), "None".equalsIgnoreCase(getGuardApprovalStatus()) ) - $lock : Lock (ownerKey == $event.getRequestId().toString(), isUnavailable()) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}: event={} manager={} operation={} lock={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event, $manager, $operation, $lock); - - logger.debug("The target resource {} is already processing", - $event.getAai().get($event.getTarget())); - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setNotification(ControlLoopNotificationType.REJECTED); - notification.setMessage("The target " + $event.getAai().get($event.getTarget()) - + " is already locked"); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - - retract($event); - - // don't retract manager, etc. - a clean-up rule will do that -end - -/* -* -* Guard Permitted, let's send request to the actor. -* -*/ -rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), - onset.getRequestId() == $event.getRequestId(), "Permit".equalsIgnoreCase(getGuardApprovalStatus()) ) - $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId().toString(), timerType == "Operation", !expired ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}: event={} manager={} operation={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event, $manager, $operation); - - Object request = null; - boolean caughtException = false; - - try { - request = $operation.startOperation($event); - - if (request != null) { - logger.debug("{}: {}: starting operation ..", - $params.getClosedLoopControlName(), drools.getRule().getName()); - // - // Tell interested parties we are performing this Operation - // - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setNotification(ControlLoopNotificationType.OPERATION); - notification.setMessage($operation.getOperationMessage()); - notification.setHistory($operation.getHistory()); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - - switch ($operation.policy.getActor()){ - - case "APPC": - if (request instanceof Request) { - PolicyEngineConstants.getManager().deliver("APPC-CL", request); - } - else if (request instanceof AppcLcmDmaapWrapper) { - PolicyEngineConstants.getManager().deliver("APPC-LCM-READ", request); - } - break; - case "SO": - // at this point the AAI named query request should have already been made, - // the response recieved and used - // in the construction of the SO Request which is stored in operationRequest - - if(request instanceof SoRequest) { - // Call SO. The response will be inserted into memory once it's received - class mySoCallback implements SoManager.SoCallback { - public void onSoResponseWrapper(SoResponseWrapper wrapper) { - drools.getWorkingMemory().insert(wrapper); - } - } - SoActorServiceProvider.sendRequest($event.getRequestId().toString(), - new mySoCallback(), - request, - PolicyEngineConstants.getManager().getEnvironmentProperty("so.url"), - PolicyEngineConstants.getManager().getEnvironmentProperty("so.username"), - PolicyEngineConstants.getManager().getEnvironmentProperty("so.password")); - } - break; - case "VFC": - if (request instanceof VfcRequest) { - // Start VFC thread - class myVfcCallback implements VfcManager.VfcCallback { - - public void onResponse(VfcResponse responseError) { - drools.getWorkingMemory().insert(responseError); - } - }; - // Start VFC thread - Thread t = new Thread(new VfcManager(new myVfcCallback(), - (VfcRequest)request, - PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.url"), - PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.username"), - PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.password"))); - t.start(); - } - break; - - case "SDNC": - if (request instanceof SdncRequest) { - // Start SDNC thread - class mySdncCallback implements SdncManager.SdncCallback { - public void onCallback(SdncResponse response) { - drools.getWorkingMemory().insert(response); - } - } - // Start SDNC thread - Thread t = new Thread(new SdncManager(new mySdncCallback(), - (SdncRequest)request, - PolicyEngineConstants.getManager().getEnvironmentProperty("sdnc.url"), - PolicyEngineConstants.getManager().getEnvironmentProperty("sdnc.username"), - PolicyEngineConstants.getManager().getEnvironmentProperty("sdnc.password"))); - t.start(); - } - break; - case "SDNR": - if (request instanceof PciRequestWrapper) { - PolicyEngineConstants.getManager().deliver("SDNR-CL", request); - } - break; - - case "CDS": - - if(request instanceof ExecutionServiceInput) { - - // Instantiate cds actor, service manager and grpc properties - - CdsActorServiceProvider cdsActor = new CdsActorServiceProvider(); - CdsActorServiceProvider.CdsActorServiceManager cdsActorServiceManager = cdsActor.new CdsActorServiceManager(); - - CdsServerProperties props = new CdsServerProperties(); - props.setHost(PolicyEngineConstants.getManager().getEnvironmentProperty("cds.grpcHost")); - props.setPort(Integer.parseInt(PolicyEngineConstants.getManager().getEnvironmentProperty("cds.grpcPort"))); - props.setUsername(PolicyEngineConstants.getManager().getEnvironmentProperty("cds.grpcUsername")); - props.setPassword(PolicyEngineConstants.getManager().getEnvironmentProperty("cds.grpcPassword")); - props.setTimeout(Integer.parseInt(PolicyEngineConstants.getManager().getEnvironmentProperty("cds.grpcTimeout"))); - - // Send cds grpc request - try (CdsProcessorGrpcClient client = new CdsProcessorGrpcClient(cdsActorServiceManager, props)) { - CdsResponse response = - cdsActorServiceManager.sendRequestToCds(client, props, (ExecutionServiceInput) request); - logger.info("CDS response: {}", response); - insert(response); - } - - } - break; - - } - } else { - // - // What happens if its null? - // - logger.warn("{}: {}: unexpected null operation request", - $params.getClosedLoopControlName(), - drools.getRule().getName()); - if ("SO".equals($operation.policy.getActor())) { - retract($opTimer); - retract($operation); - modify($manager) {finishOperation($operation)}; - } - else if ("vfc".equalsIgnoreCase($operation.policy.getActor())) { - retract($opTimer); - retract($operation); - modify($manager) {finishOperation($operation)}; - } - else if ("sdnc".equalsIgnoreCase($operation.policy.getActor())) { - retract($opTimer); - retract($operation); - modify($manager) {finishOperation($operation)}; - } - } - - } catch (Exception e) { - String msg = e.getMessage(); - logger.warn("{}: {}: operation={}: AAI failure: {}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $operation, msg, e); - $operation.setOperationHasException(msg); - - if(request != null) { - // - // Create a notification for it ("DB Write - end operation") - // - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE); - notification.setMessage($operation.getOperationHistory()); - notification.setHistory($operation.getHistory()); - - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - } - - retract($opTimer); - retract($operation); - caughtException = true; - } - - // Having the modify statement in the catch clause doesn't work for whatever reason - if (caughtException) { - modify($manager) {finishOperation($operation)}; - } -end - - -/* -* -* We were able to acquire a lock so now let's ask Xacml Guard whether -* we are allowed to proceed with the request to the actor. -* -*/ -rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), - onset.getRequestId() == $event.getRequestId(), "None".equalsIgnoreCase(getGuardApprovalStatus()) ) - $lock : Lock (ownerKey == $event.getRequestId().toString(), isActive()) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}: event={} manager={} operation={} lock={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event, $manager, $operation, $lock); - - // - // Sending notification that we are about to query Guard ("DB write - start operation") - // - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setNotification(ControlLoopNotificationType.OPERATION); - notification.setMessage("Sending guard query for " + $operation.policy.getActor() + " " - + $operation.policy.getRecipe()); - notification.setHistory($operation.getHistory()); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - - // - // Now send Guard Request to XACML Guard. In order to bypass the call to Guard, - // just change guardEnabled to false. - // - // In order to use REST XACML, provide a URL instead of "" as a second argument - // to the CallGuardTask() and set the first argument to null - // (instead of XacmlPdpEngine). - // - - // NOTE: The environment properties uses "guard.disabled" but the boolean is guardEnabled - boolean guardEnabled = "false".equalsIgnoreCase(PolicyEngineConstants.getManager().getEnvironmentProperty("guard.disabled")); - - if(guardEnabled){ - - Thread t = new Thread(new org.onap.policy.guard.CallGuardTask( - drools.getWorkingMemory(), - $event.getClosedLoopControlName(), - $operation.policy.getActor().toString(), - $operation.policy.getRecipe(), - $operation.getTargetEntity(), - $event.getRequestId().toString(), - () -> { - try { - AaiCqResponse resp_cq = $manager.getCqResponse($event); - if (resp_cq == null){ - return null; - } else { - String custId = $operation.policy.getTarget().getModelCustomizationId(); - String invId = $operation.policy.getTarget().getModelInvariantId(); - String verId = $operation.policy.getTarget().getModelVersionId(); - return resp_cq.getVfModuleCount(custId, invId, verId); - } - } catch (Exception e){ - logger.warn("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName(), e); - } - return null; - })); - t.start(); - } - else{ - insert(new PolicyGuardResponse("Permit", $event.getRequestId(), $operation.policy.getRecipe())); - } - -end - -// -// This rule will be triggered when a thread talking to the XACML Guard inserts a -// guardResponse object into the working memory -// -rule "${policyName}.GUARD.RESPONSE" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), - closedLoopEventStatus == ControlLoopEventStatus.ONSET ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), - onset.getRequestId() == $event.getRequestId() ) - $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId().toString(), timerType == "Operation", !expired ) - $guardResponse : PolicyGuardResponse(requestId == $event.getRequestId(), $operation.policy.recipe == operation) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}: event={} manager={} operation={} opTimer={} guardResponse={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event, $manager, $operation, $opTimer, $guardResponse); - - - //we will permit the operation if there was no Guard for it - if("Indeterminate".equalsIgnoreCase($guardResponse.getResult())){ - $guardResponse.setResult("Permit"); - } - - // - // This notification has Guard result in "message". ("DB write - end operation in case of Guard Deny") - // - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setNotification(ControlLoopNotificationType.OPERATION); - notification.setMessage("Guard result for " + $operation.policy.getActor() + " " + $operation.policy.getRecipe() - + " is " + $guardResponse.getResult()); - notification.setHistory($operation.getHistory()); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - - if("Permit".equalsIgnoreCase($guardResponse.getResult())){ - - modify($operation){setGuardApprovalStatus($guardResponse.getResult())}; - } - else { - //This is the Deny case - $operation.startOperation($event); - $operation.setOperationHasGuardDeny(); - retract($opTimer); - retract($operation); - modify($manager) {finishOperation($operation)}; - } - - retract($guardResponse); - -end - -/* -* -* This rule responds to APPC Response Events -* -* I would have like to be consistent and write the Response like this: -* $response : Response( CommonHeader.RequestId == $onset.getRequestId() ) -* -* However, no compile error was given. But a runtime error was given. I think -* because drools is confused between the classname CommonHeader vs the property CommonHeader. -* -*/ -rule "${policyName}.APPC.RESPONSE" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), - closedLoopEventStatus == ControlLoopEventStatus.ONSET ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), - onset.getRequestId() == $event.getRequestId() ) - $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId().toString(), timerType == "Operation", !expired ) - $response : Response( getCommonHeader().RequestId == $event.getRequestId() ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); - logger.debug("{}: {}: event={} manager={} operation={} opTimer={} response={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event, $manager, $operation, $opTimer, $response); - // - // Get the result of the operation - // - PolicyResult policyResult = $operation.onResponse($response); - if (policyResult != null) { - logger.debug("{}: {}: operation finished - result={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - policyResult); - // - // This Operation has completed, construct a notification showing our results. (DB write - end operation) - // - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - notification.setMessage($operation.getOperationHistory()); - notification.setHistory($operation.getHistory()); - if (policyResult.equals(PolicyResult.SUCCESS)) { - notification.setNotification(ControlLoopNotificationType.OPERATION_SUCCESS); - // - // Let interested parties know - // - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - } else { - notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE); - // - // Let interested parties know - // - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - } - // - // Ensure the operation is complete - // - if ($operation.isOperationComplete() == true) { - // - // It is complete, remove it from memory - // - retract($operation); - // - // We must also retract the timer object - // NOTE: We could write a Rule to do this - // - retract($opTimer); - // - // Complete the operation - // - modify($manager) {finishOperation($operation)}; - } else { - // - // Just doing this will kick off the LOCKED rule again - // - modify($operation) {}; - } - } else { - // - // Its not finished yet (i.e. expecting more Response objects) - // - // Or possibly it is a leftover response that we timed the request out previously - // - } - // - // We are going to retract these objects from memory - // - retract($response); -end - -/* -* -* The problem with Responses is that they don't have a controlLoopControlName -* field in them, so the only way to attach them is via RequestId. If we have multiple -* control loop .drl's loaded in the same container, we need to be sure the cleanup -* rules don't remove Responses for other control loops. -* -*/ -rule "${policyName}.APPC.RESPONSE.CLEANUP" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $response : Response($id : getCommonHeader().RequestId ) - not ( VirtualControlLoopEvent( requestId == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); - logger.debug("{}: {}: orphan appc response={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), $id); - - // - // Retract it - // - retract($response); -end - -/* -* -* This rule responds to APPC Response Events using the new LCM interface provided by appc -* -*/ -rule "${policyName}.APPC.LCM.RESPONSE" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), - closedLoopEventStatus == ControlLoopEventStatus.ONSET ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), - onset.getRequestId() == $event.getRequestId() ) - $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId().toString(), timerType == "Operation", !expired ) - $response : AppcLcmDmaapWrapper( getBody().getOutput().getCommonHeader().getRequestId() == $event.getRequestId() ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); - logger.debug("{}: {}: event={} manager={} operation={} opTimer={} response={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event, $manager, $operation, $operation, $opTimer, $response); - - // - // Get the result of the operation - // - PolicyResult policyResult = $operation.onResponse($response); - if (policyResult != null) { - logger.debug("{}: {}: operation finished - result={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - policyResult); - - // - // This Operation has completed, construct a notification showing our results. (DB write - end operation) - // - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - notification.setMessage($operation.getOperationHistory()); - notification.setHistory($operation.getHistory()); - if (policyResult.equals(PolicyResult.SUCCESS)) { - notification.setNotification(ControlLoopNotificationType.OPERATION_SUCCESS); - } else { - notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE); - } - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - // - // Ensure the operation is complete - // - if ($operation.isOperationComplete() == true) { - // - // It is complete, remove it from memory - // - retract($operation); - // - // We must also retract the timer object - // NOTE: We could write a Rule to do this - // - retract($opTimer); - // - // Complete the operation - // - modify($manager) {finishOperation($operation)}; - } else { - // - // Just doing this will kick off the LOCKED rule again - // - modify($operation) {}; - } - } else { - // - // Its not finished yet (i.e. expecting more Response objects) - // - // Or possibly it is a leftover response that we timed the request out previously - // - } - // - // We are going to retract these objects from memory - // - retract($response); -end - -/* -* -* Clean Up any lingering LCM reponses -* -*/ -rule "${policyName}.APPC.LCM.RESPONSE.CLEANUP" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $response : AppcLcmDmaapWrapper($id : getBody().getOutput().getCommonHeader().getRequestId() ) - not ( VirtualControlLoopEvent( requestId == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); - logger.debug("{}: {}: orphan appc response={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), $id); - // - // Retract it - // - retract($response); -end - -/* -* -* This rule responds to SDNR Response Events using the new interface provided by SDNR -* -*/ -rule "${policyName}.SDNR.RESPONSE" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), - closedLoopEventStatus == ControlLoopEventStatus.ONSET ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), - onset.getRequestId() == $event.getRequestId() ) - $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId().toString(), timerType == "Operation", !expired ) - $response : PciResponseWrapper( getBody().getCommonHeader().getRequestId() == $event.getRequestId() ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); - logger.debug("{}: {}: event={} manager={} operation={} opTimer={} response={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event, $manager, $operation, $operation, $opTimer, $response); - - // - // Get the result of the operation - // - PolicyResult policyResult = $operation.onResponse($response); - if (policyResult != null) { - logger.debug("{}: {}: operation finished - result={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - policyResult); - - // - // This Operation has completed, construct a notification showing our results. (DB write - end operation) - // - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - notification.setMessage($operation.getOperationHistory()); - notification.setHistory($operation.getHistory()); - if (policyResult.equals(PolicyResult.SUCCESS)) { - notification.setNotification(ControlLoopNotificationType.OPERATION_SUCCESS); - } else { - notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE); - } - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - // - // Ensure the operation is complete - // - if ($operation.isOperationComplete()) { - // - // It is complete, remove it from memory - // - retract($operation); - // - // We must also retract the timer object - // NOTE: We could write a Rule to do this - // - retract($opTimer); - // - // Complete the operation - // - modify($manager) {finishOperation($operation)}; - } else { - // - // Just doing this will kick off the LOCKED rule again - // - modify($operation) {}; - } - } else { - // - // Its not finished yet (i.e. expecting more Response objects) - // - // Or possibly it is a leftover response that we timed the request out previously - // - } - // - // We are going to retract these objects from memory - // - retract($response); -end - -/* -* -* Clean Up any lingering SDNR reponses -* -*/ -rule "${policyName}.SDNR.RESPONSE.CLEANUP" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $response : PciResponseWrapper($id : getBody().getCommonHeader().getRequestId ) - not ( VirtualControlLoopEvent( requestId == $id, closedLoopEventStatus == ControlLoopEventStatus.ONSET ) ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); - logger.debug("{}: {}: orphan SDNR response={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), $id); - // - // Retract it - // - retract($response); -end - -/* -* -* This rule responds to SO Response Events -* -*/ -rule "${policyName}.SO.RESPONSE" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), - closedLoopEventStatus == ControlLoopEventStatus.ONSET ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), - onset.getRequestId() == $event.getRequestId() ) - $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId().toString(), timerType == "Operation", !expired ) - $response : SoResponseWrapper(requestId.toString() == $event.getRequestId().toString() ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); - logger.debug("{}: {}: event={} manager={} operation={} opTimer={} response={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event, $manager, $operation, $operation, $opTimer, $response); - - // Get the result of the operation - // - PolicyResult policyResult = $operation.onResponse($response); - if (policyResult != null) { - logger.debug("{}: {}: operation finished - result={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - policyResult); - - // - // This Operation has completed, construct a notification showing our results - // - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - notification.setMessage($operation.getOperationHistory()); - notification.setHistory($operation.getHistory()); - if (policyResult.equals(PolicyResult.SUCCESS)) { - notification.setNotification(ControlLoopNotificationType.OPERATION_SUCCESS); - } else { - notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE); - - } - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - // - // Ensure the operation is complete - // - if ($operation.isOperationComplete() == true) { - // - // It is complete, remove it from memory - // - retract($operation); - // - // We must also retract the timer object - // NOTE: We could write a Rule to do this - // - retract($opTimer); - // - // Complete the operation - // - modify($manager) {finishOperation($operation)}; - } else { - // - // Just doing this will kick off the LOCKED rule again - // - modify($operation) {}; - } - } else { - // - // Its not finished yet (i.e. expecting more Response objects) - // - // Or possibly it is a leftover response that we timed the request out previously - // - } - // - // We are going to retract these objects from memory - // - retract($response); - -end - -/* -* -* This rule responds to VFC Response Events -* -*/ -rule "${policyName}.VFC.RESPONSE" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), - closedLoopEventStatus == ControlLoopEventStatus.ONSET ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), - onset.getRequestId() == $event.getRequestId() ) - $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId().toString(), timerType == "Operation", !expired ) - $response : VfcResponse( requestId.toString() == $event.getRequestId().toString() ) - then - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); - logger.debug("{}: {}: event={} manager={} operation={} opTimer={} response={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event, $manager, $operation, $operation, $opTimer, $response); - - // Get the result of the operation - // - PolicyResult policyResult = $operation.onResponse($response); - if (policyResult != null) { - // - // This Operation has completed, construct a notification showing our results - // - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - notification.setMessage($operation.getOperationHistory()); - notification.setHistory($operation.getHistory()); - // - // Ensure the operation is complete - // - if ($operation.isOperationComplete() == true) { - // - // It is complete, remove it from memory - // - retract($operation); - // - // We must also retract the timer object - // NOTE: We could write a Rule to do this - // - retract($opTimer); - // - // Complete the operation - // - modify($manager) {finishOperation($operation)}; - } else { - // - // Just doing this will kick off the LOCKED rule again - // - modify($operation) {}; - } - } else { - // - // Its not finished yet (i.e. expecting more Response objects) - // - // Or possibly it is a leftover response that we timed the request out previously - // - } - // - // We are going to retract these objects from memory - // - retract($response); - -end - -/* -* -* This rule responds to SDNC Response Events -* -*/ - -rule "${policyName}.SDNC.RESPONSE" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), - closedLoopEventStatus == ControlLoopEventStatus.ONSET ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), - onset.getRequestId() == $event.getRequestId() ) - $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId().toString(), timerType == "Operation", !expired ) - $response : SdncResponse( requestId.toString() == $event.getRequestId().toString() ) - then - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); - logger.debug("{}: {}: event={} manager={} operation={} opTimer={} response={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event, $manager, $operation, $operation, $opTimer, $response); - - // Get the result of the operation - // - PolicyResult policyResult = $operation.onResponse($response); - if (policyResult != null) { - // - // This Operation has completed, construct a notification showing our results - // - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - notification.setMessage($operation.getOperationHistory()); - notification.setHistory($operation.getHistory()); - // - // Ensure the operation is complete - // - if ($operation.isOperationComplete()) { - // - // It is complete, remove it from memory - // - retract($operation); - // - // We must also retract the timer object - // NOTE: We could write a Rule to do this - // - retract($opTimer); - // - // Complete the operation - // - modify($manager) {finishOperation($operation)}; - } else { - // - // Just doing this will kick off the LOCKED rule again - // - modify($operation) {}; - } - } else { - // - // Its not finished yet (i.e. expecting more Response objects) - // - // Or possibly it is a leftover response that we timed the request out previously - // - } - // - // We are going to retract these objects from memory - // - retract($response); - -end - - -/** - * This rule responds to CDS Response Events - */ -rule "${policyName}.CDS.RESPONSE" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), - closedLoopEventStatus == ControlLoopEventStatus.ONSET ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), - onset.getRequestId() == $event.getRequestId() ) - $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId().toString(), timerType == "Operation", !expired ) - $response : CdsResponse( requestId == $event.getRequestId().toString() ) - - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); - logger.debug("{}: {}: event={} manager={} operation={} opTimer={} response={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event, $manager, $operation, $operation, $opTimer, $response); - - // Get the result of the operation - PolicyResult policyResult = $operation.onResponse($response); - - if (policyResult != null) { - logger.debug("{}: {}: operation finished - result={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - policyResult); - - // The operation has completed, construct a notification showing our results - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - notification.setMessage($operation.getOperationHistory()); - notification.setHistory($operation.getHistory()); - notification.setNotification( - ($response != null && CdsActorConstants.SUCCESS.equals($response.getStatus())) - ? ControlLoopNotificationType.OPERATION_SUCCESS : ControlLoopNotificationType.OPERATION_FAILURE); - - // Send the notification - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - - // Ensure the operation is complete - if ($operation.isOperationComplete()) { - - // It is complete, remove it from memory - retract($operation); - - // We must also retract the timer object - // NOTE: We could write a Rule to do this - retract($opTimer); - - // Complete the operation - modify($manager) {finishOperation($operation)}; - - } else { - // Just doing this will kick off the LOCKED rule again - modify($operation) {}; - } - } else { - // Its not finished yet (i.e. expecting more Response objects) - // Or possibly it is a leftover response that we timed the request out previously - logger.info( - "policyResult is null" - + "\nIt's not finished yet (i.e. expecting more Response objects)" - + "\nOr possibly it is a leftover response that we timed the request out previously"); - } - - // We are going to retract these objects from memory - retract($response); - -end - -/* -* -* This manages a single timer. -* Due to a bug in the drools code, the drools timer needed to be split from most of the objects in the when clause -* -*/ -rule "${policyName}.TIMER.FIRED" - timer (expr: $timeout) - when - $timer : ControlLoopTimer($timeout : delay, !expired) - then - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("This is ${policyName}.TIMER.FIRED"); - modify($timer){setExpired(true)}; - end - -/* -* -* This is the timer that manages the timeout for an individual operation. -* -*/ -rule "${policyName}.EVENT.MANAGER.OPERATION.TIMEOUT" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), - onset.getRequestId() == $event.getRequestId() ) - $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId().toString(), expired, timerType == "Operation" ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); - logger.debug("{}: {}: event={} manager={} operation={} opTimer={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event, $manager, $operation, $operation, $opTimer); - - // - // Tell it it has timed out - // - $operation.setOperationHasTimedOut(); - // - // Create a notification for it ("DB Write - end operation") - // - VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event); - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE); - notification.setMessage($operation.getOperationHistory()); - notification.setHistory($operation.getHistory()); - // - // Let interested parties know - // - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - // - // Get rid of the timer - // - retract($opTimer); - // - // Ensure the operation is complete - // - if ($operation.isOperationComplete() == true) { - // - // It is complete, remove it from memory - // - retract($operation); - // - // Complete the operation - // - modify($manager) {finishOperation($operation)}; - } else { - // - // Just doing this will kick off the LOCKED rule again - // - modify($operation) {}; - } -end - -/* -* -* This is the timer that manages the overall control loop timeout. -* -*/ -rule "${policyName}.EVENT.MANAGER.TIMEOUT" - when - $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" ) - $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() ) - $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId() ) - $clTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), - requestId == $event.getRequestId().toString(), expired, timerType == "ClosedLoop" ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName()); - - logger.debug("{}: {}: event={}", - $params.getClosedLoopControlName(), drools.getRule().getName(), - $event); - // - // Tell the Event Manager it has timed out - // - VirtualControlLoopNotification notification = $manager.setControlLoopTimedOut(); - if (notification != null) { - notification.setFrom("policy"); - notification.setPolicyName(drools.getRule().getName()); - notification.setPolicyScope("${policyScope}"); - notification.setPolicyVersion("${policyVersion}"); - // - // Let interested parties know - // - PolicyEngineConstants.getManager().deliver("POLICY-CL-MGT", notification); - } - // - // Retract the event - // - retract($event); -end - -/* -* -* This rule cleans up the manager and other objects after an event has -* been retracted. -* -*/ -rule "${policyName}.EVENT.MANAGER.CLEANUP" - when - $manager : ControlLoopEventManager( $clName : getClosedLoopControlName(), $requestId : getRequestId() ) - $operations : LinkedList() - from collect( ControlLoopOperationManager( onset.closedLoopControlName == $clName, - onset.getRequestId() == $requestId ) ) - $timers : LinkedList() - from collect( ControlLoopTimer( closedLoopControlName == $clName, - requestId == $requestId.toString() ) ) - not( VirtualControlLoopEvent( closedLoopControlName == $clName, requestId == $requestId ) ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $clName, drools.getRule().getName()); - - logger.debug("{}: {}: manager={} timers={} operations={}", - $clName, drools.getRule().getName(), - $manager, $timers.size(), $operations.size()); - - // - // Retract lock by invoking unlock() - // - Lock lock = $manager.unlockCurrentOperation(); - if(lock != null) { - retract(lock); - } - - // - // Retract EVERYTHING - // - - retract($manager); - - for(Object manager: $operations) { - retract((ControlLoopOperationManager) manager); - } - for(Object timer: $timers) { - retract((ControlLoopTimer) timer); - } -end - -/* -* -* This rule will clean up any rogue onsets where there is no -* ControlLoopParams object corresponding to the onset event. -* -*/ -rule "${policyName}.EVENT.CLEANUP" - when - $event : VirtualControlLoopEvent( $clName: closedLoopControlName ) - not ( Params( getClosedLoopControlName() == $clName) ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $clName, drools.getRule().getName()); - logger.debug("{}: {}: orphan onset event={}", - $clName, drools.getRule().getName(), $event); - - retract($event); -end - -/* -* Creates a cleaner for every Params object. -* This has a higher salience so that it is fired before PARAMS.FINISHED in ANY policy. -*/ -rule "${policyName}.PARAMS.CLEANING" - salience 2 - when - $params: Params( ) - ParamsInitCleaner( ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {} : YAML=[{}]", $params.getClosedLoopControlName(), drools.getRule().getName(), - $params.getControlLoopYaml()); - - ParamsCleaner cleaner = new ParamsCleaner(); - cleaner.setClosedLoopControlName($params.getClosedLoopControlName()); - cleaner.setControlLoopYaml($params.getControlLoopYaml()); - insert(cleaner); -end - -/* -* Finished creating cleaner objects, so remove the trigger. -* This has a higher salience so that it is fired before processing any events. -*/ -rule "${policyName}.PARAMS.FINISHED" - salience 1 - when - $initCleaner: ParamsInitCleaner( ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {}", $initCleaner.getClosedLoopControlName(), drools.getRule().getName()); - - retract($initCleaner); -end - -/* -* Identifies Params objects that are still active, removing their associated cleaners. -* This should only leave one active Params object for each policy. -* This has a higher salience so that it is fired before PARAMS.DELETE in ANY policy. -*/ -rule "${policyName}.PARAMS.ACTIVE" - salience 3 - when - $params: Params( getClosedLoopControlName() == "${closedLoopControlName}", - getControlLoopYaml() == "${controlLoopYaml}" ) - $cleaner: ParamsCleaner( getClosedLoopControlName() == "${closedLoopControlName}", - getControlLoopYaml() == "${controlLoopYaml}" ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {} : YAML=[{}]", $params.getClosedLoopControlName(), drools.getRule().getName(), - $params.getControlLoopYaml()); - - retract($cleaner); -end - -/* -* Delete Params objects that are not active (i.e., those that still have an associated -* cleaner object). -* This has a higher salience so that it is fired before PARAMS.CLEANED in ANY policy. -*/ -rule "${policyName}.PARAMS.DELETE" - salience 2 - when - $params: Params( ) - $cleaner: ParamsCleaner( getClosedLoopControlName() == $params.getClosedLoopControlName(), - getControlLoopYaml() == $params.getControlLoopYaml() ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {} : YAML=[{}]", $params.getClosedLoopControlName(), drools.getRule().getName(), - $params.getControlLoopYaml()); - - retract($params); -end - -/* -* Finished clean-up, so delete the cleaner objects. -* This has a higher salience so that it is fired before processing any events. -*/ -rule "${policyName}.PARAMS.CLEANED" - salience 1 - when - $cleaner: ParamsCleaner( ) - then - - Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage()); - logger.info("{}: {} : YAML=[{}]", $cleaner.getClosedLoopControlName(), drools.getRule().getName(), - $cleaner.getControlLoopYaml()); - - retract($cleaner); -end diff --git a/controlloop/templates/archetype-cl-amsterdam/src/test/resources/projects/basic/archetype.properties b/controlloop/templates/archetype-cl-amsterdam/src/test/resources/projects/basic/archetype.properties deleted file mode 100644 index 8cc10c97c..000000000 --- a/controlloop/templates/archetype-cl-amsterdam/src/test/resources/projects/basic/archetype.properties +++ /dev/null @@ -1,43 +0,0 @@ -### -# ============LICENSE_START======================================================= -# archetype-closed-loop-demo-rules -# ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - -groupId=org.onap.policy.demo.drools -artifactId=amsterdam -version=1.1.0-SNAPSHOT -package=org.onap.policy.demo.drools -closedLoopControlName=ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e -controlLoopYaml=controlLoop%3A%0A++version%3A+2.0.0%0A++controlLoopName%3A+ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0A++trigger_policy%3A+unique-policy-id-1-restart%0A++timeout%3A+3600%0A++abatement%3A+true%0A+%0Apolicies%3A%0A++-+id%3A+unique-policy-id-1-restart%0A++++name%3A+Restart+the+VM%0A++++description%3A%0A++++actor%3A+APPC%0A++++recipe%3A+Restart%0A++++target%3A%0A++++++type%3A+VM%0A++++retry%3A+3%0A++++timeout%3A+1200%0A++++success%3A+final_success%0A++++failure%3A+final_failure%0A++++failure_timeout%3A+final_failure_timeout%0A++++failure_retries%3A+final_failure_retries%0A++++failure_exception%3A+final_failure_exception%0A++++failure_guard%3A+final_failure_guard%0A -policyScope=service=test;resource=FRWL;type=configuration -policyName=FirewallDemo -policyVersion=v1.0 -dmaapServers=server1,server2,server3 -appcTopic=APPC-CL -notificationTopic=POLICY-CL-MGT -dcaeTopic=DCAE-CL-EVENT -dcaeServers=server1,server2,server3 -dependenciesVersion=1.0.0-SNAPSHOT -aaiURL=http://localhost:8080/TestREST/Test -aaiUsername=policy -aaiPassword=policy -aaiNamedQueryUUID=d925ed73-8231-4d02-9545-db4e101fffff -aaiPatternMatch=false -soURL=http://localhost:8080/TestREST/Test -soUsername=policy -soPassword=policy diff --git a/controlloop/templates/pom.xml b/controlloop/templates/pom.xml deleted file mode 100644 index eaffc0af7..000000000 --- a/controlloop/templates/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - 4.0.0 - pom - - - org.onap.policy.drools-applications.controlloop - controlloop - 1.6.0-SNAPSHOT - - - org.onap.policy.drools-applications.controlloop.templates - templates - - - template.demo - archetype-cl-amsterdam - - - diff --git a/controlloop/templates/template.demo/README.md b/controlloop/templates/template.demo/README.md deleted file mode 100644 index a996a2291..000000000 --- a/controlloop/templates/template.demo/README.md +++ /dev/null @@ -1,6 +0,0 @@ -Copyright 2018 AT&T Intellectual Property. All rights reserved. -This file is licensed under the CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE -Full license text at https://creativecommons.org/licenses/by/4.0/legalcode - -This is the ongoing implementation of template to support vFW/vDNS with integration with AAI. - diff --git a/controlloop/templates/template.demo/pom.xml b/controlloop/templates/template.demo/pom.xml deleted file mode 100644 index b2d6aff19..000000000 --- a/controlloop/templates/template.demo/pom.xml +++ /dev/null @@ -1,239 +0,0 @@ - - - - 4.0.0 - - - org.onap.policy.drools-applications.controlloop.templates - templates - 1.6.0-SNAPSHOT - - - template.demo - - - 3.6.1 - 1.17.1 - - - - - org.eclipse.persistence - org.eclipse.persistence.jpa - provided - - - commons-io - commons-io - 2.5 - provided - - - org.drools - drools-core - test - - - org.drools - drools-compiler - test - - - com.google.code.gson - gson - test - - - org.onap.policy.models.policy-models-interactions.model-impl - appc - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-impl - sdnr - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-impl - appclcm - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-impl - so - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-impl - vfc - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-impl - sdnc - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-impl - events - ${policy.models.version} - provided - - - org.onap.policy.drools-applications.controlloop.common - database - ${project.version} - provided - - - org.onap.policy.drools-applications.controlloop.common - guard - ${project.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-impl - aai - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-impl - sdc - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions - model-yaml - ${policy.models.version} - provided - - - org.onap.policy.drools-applications.controlloop.common - eventmanager - ${project.version} - provided - - - org.eclipse.persistence - javax.persistence - provided - - - org.onap.policy.models.policy-models-interactions.model-actors - actorServiceProvider - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-actors - actor.appc - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-actors - actor.sdnr - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-actors - actor.appclcm - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-actors - actor.so - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-actors - actor.vfc - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-actors - actor.sdnc - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-actors - actor.cds - ${policy.models.version} - provided - - - org.onap.policy.models.policy-models-interactions.model-impl - cds - ${policy.models.version} - provided - - - com.google.protobuf - protobuf-java - ${protobuf.version} - provided - - - com.h2database - h2 - test - - - org.onap.policy.common - policy-endpoints - ${version.policy.common} - provided - - - org.onap.policy.models.policy-models-interactions - simulators - ${policy.models.version} - test - - - io.grpc - grpc-testing - ${grpc.version} - test - - - org.onap.policy.drools-pdp - policy-management - ${version.policy.drools-pdp} - provided - - - diff --git a/controlloop/templates/template.demo/src/main/resources/blacklist_template.xml b/controlloop/templates/template.demo/src/main/resources/blacklist_template.xml deleted file mode 100644 index 1563e4a7d..000000000 --- a/controlloop/templates/template.demo/src/main/resources/blacklist_template.xml +++ /dev/null @@ -1,117 +0,0 @@ - - - - Policy for frequency limiter. - - - - - - ${clname} - - - - - - ${actor} - - - - ${recipe} - - - - - - - DENY - only if target is in black list and guard is - active. - - - - - - - - - - - - - - - ${blackListElement} - - - - - - - - - - ${guardActiveStart} - ${guardActiveEnd} - - - diff --git a/controlloop/templates/template.demo/src/main/resources/frequency_limiter_template.xml b/controlloop/templates/template.demo/src/main/resources/frequency_limiter_template.xml deleted file mode 100644 index d26432f86..000000000 --- a/controlloop/templates/template.demo/src/main/resources/frequency_limiter_template.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - - Policy for frequency limiter. - - - - - - - ${clname} - - - - - - ${actor} - - - - ${recipe} - - - - - ${targets} - - - - - - - - DENY - only if number of operations performed in - the past is larger than the limit and the Guard is active. - - - - - - - - - - - - - ${guardActiveStart} - ${guardActiveEnd} - - - - - - - - ${limit} - - - diff --git a/controlloop/templates/template.demo/src/main/resources/frequency_limiter_template_old.xml b/controlloop/templates/template.demo/src/main/resources/frequency_limiter_template_old.xml deleted file mode 100644 index e1e3451f3..000000000 --- a/controlloop/templates/template.demo/src/main/resources/frequency_limiter_template_old.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - Policy for frequency limiter. - - - - - ${actor} - - - - ${recipe} - - - - - - - DENY - only if number of operations performed in - the past is larger than the limit and the Guard is active. - - - - - - - - - - - - - ${guardActiveStart} - ${guardActiveEnd} - - - - - - - - ${limit} - - - diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnBwControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnBwControlLoopTest.java deleted file mode 100644 index ab0070724..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnBwControlLoopTest.java +++ /dev/null @@ -1,234 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved. - * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. - * ================================================================================ - * 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.template.demo; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.time.Instant; -import java.util.HashMap; -import java.util.UUID; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.VirtualControlLoopNotification; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.sdnc.SdncRequest; - -public class CcvpnBwControlLoopTest extends ControlLoopBase implements TopicListener { - - /** - * Setup the simulator. - */ - @BeforeClass - public static void setUpBeforeClass() { - ControlLoopBase.setUpBeforeClass( - "../archetype-cl-amsterdam/src/main/resources/archetype-resources/" - + "src/main/resources/__closedLoopControlName__.drl", - "src/test/resources/yaml/policy_ControlLoop_CCVPN_BW.yaml", - "type=operational", - "BandwidthOnDemand", "2.0.0"); - } - - @Test - public void testSuccess() throws IOException { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - @Test - public void testNullRequest() throws IOException { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(pair.first.getControlLoop().getControlLoopName()); - event.setRequestId(UUID.randomUUID()); - event.setClosedLoopEventClient("DCAE.HolmesInstance"); - event.setTargetType(ControlLoopTargetType.VM); - event.setTarget("vserver.vserver-name"); - event.setFrom("DCAE"); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap()); - event.getAai().put("vserver.vserver-name", "nullRequest"); - event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); - kieSession.insert(event); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - /* - * (non-Javadoc) - * - * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String) - */ - @Override - public void onTopicEvent(CommInfrastructure commType, String topic, String event) { - /* - * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation - * of type active - */ - Object obj = null; - if ("POLICY-CL-MGT".equals(topic)) { - obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, - VirtualControlLoopNotification.class); - } - assertNotNull(obj); - if (obj instanceof VirtualControlLoopNotification) { - VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj; - String policyName = notification.getPolicyName(); - if (policyName.endsWith("EVENT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification())); - } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("Sending guard query")); - } else if (policyName.endsWith("GUARD.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().toLowerCase().endsWith("permit")); - } else if (policyName.endsWith("GUARD_PERMITTED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=SDNC")); - } else if (policyName.endsWith("OPERATION.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The operation timed out"); - fail("Operation Timed Out"); - } else if (policyName.endsWith("SDNC.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=SDNC")); - } else if (policyName.endsWith("EVENT.MANAGER")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - if ("nullRequest".equals(notification.getAai().get("vserver.vserver-name"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification()); - } else { - assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.getNotification()); - } - kieSession.halt(); - } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The control loop timed out"); - fail("Control Loop Timed Out"); - } - } else if (obj instanceof SdncRequest) { - logger.debug("\n============ SDNC received the request!!! ===========\n"); - } - } - - /** - * This method is used to simulate event messages from DCAE that start the control loop (onset - * message) or end the control loop (abatement message). - * - * @param policy the controlLoopName comes from the policy - */ - protected void sendEvent(ControlLoopPolicy policy) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(UUID.randomUUID()); - event.setClosedLoopEventClient("DCAE.HolmesInstance"); - event.setTargetType(ControlLoopTargetType.VM); - event.setTarget("vserver.vserver-name"); - event.setFrom("DCAE"); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap()); - event.getAai().put("vserver.vserver-name", "TBD"); - event.getAai().put("globalSubscriberId", "e151059a-d924-4629-845f-264db19e50b4"); - event.getAai().put("serviceType", "siteService"); - event.getAai().put("service-instance.service-instance-id", "service-instance-id-example-1"); - event.getAai().put("vserver.is-closed-loop-disabled", "false"); - event.getAai().put("vserver.prov-status", "ACTIVE"); - event.getAai().put("bandwidth", "500"); - event.getAai().put("bandwidth-change-time", "20190326-05:20:38:668"); - event.getAai().put("vnfId", "vnf-id"); - event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); - kieSession.insert(event); - } -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnControlLoopTest.java deleted file mode 100644 index 3599d47d0..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnControlLoopTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Huawei. All rights reserved. - * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. - * ================================================================================ - * 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.template.demo; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.time.Instant; -import java.util.HashMap; -import java.util.UUID; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.VirtualControlLoopNotification; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.sdnc.SdncRequest; - -public class CcvpnControlLoopTest extends ControlLoopBase implements TopicListener { - - /** - * Setup the simulator. - */ - @BeforeClass - public static void setUpBeforeClass() { - ControlLoopBase.setUpBeforeClass( - "../archetype-cl-amsterdam/src/main/resources/archetype-resources/" - + "src/main/resources/__closedLoopControlName__.drl", - "src/test/resources/yaml/policy_ControlLoop_CCVPN.yaml", - "type=operational", - "Connectivity Reroute", - "2.0.0"); - } - - @Test - public void testSuccess() throws IOException { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - @Test - public void testNullRequest() throws IOException { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(pair.first.getControlLoop().getControlLoopName()); - event.setRequestId(UUID.randomUUID()); - event.setClosedLoopEventClient("DCAE.HolmesInstance"); - event.setTargetType(ControlLoopTargetType.VM); - event.setTarget("vserver.vserver-name"); - event.setFrom("DCAE"); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap()); - event.getAai().put("vserver.vserver-name", "nullRequest"); - event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); - kieSession.insert(event); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - /* - * (non-Javadoc) - * - * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String) - */ - @Override - public void onTopicEvent(CommInfrastructure commType, String topic, String event) { - /* - * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation - * of type active - */ - Object obj = null; - if ("POLICY-CL-MGT".equals(topic)) { - obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, - VirtualControlLoopNotification.class); - } - assertNotNull(obj); - if (obj instanceof VirtualControlLoopNotification) { - VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj; - String policyName = notification.getPolicyName(); - if (policyName.endsWith("EVENT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification())); - } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("Sending guard query")); - } else if (policyName.endsWith("GUARD.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().toLowerCase().endsWith("permit")); - } else if (policyName.endsWith("GUARD_PERMITTED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=SDNC")); - } else if (policyName.endsWith("OPERATION.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The operation timed out"); - fail("Operation Timed Out"); - } else if (policyName.endsWith("SDNC.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=SDNC")); - } else if (policyName.endsWith("EVENT.MANAGER")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - if ("nullRequest".equals(notification.getAai().get("vserver.vserver-name"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification()); - } else { - assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.getNotification()); - } - kieSession.halt(); - } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The control loop timed out"); - fail("Control Loop Timed Out"); - } - } else if (obj instanceof SdncRequest) { - logger.debug("\n============ SDNC received the request!!! ===========\n"); - } - } - - /** - * This method is used to simulate event messages from DCAE that start the control loop (onset - * message) or end the control loop (abatement message). - * - * @param policy the controlLoopName comes from the policy - */ - protected void sendEvent(ControlLoopPolicy policy) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(UUID.randomUUID()); - event.setClosedLoopEventClient("DCAE.HolmesInstance"); - event.setTargetType(ControlLoopTargetType.VM); - event.setTarget("vserver.vserver-name"); - event.setFrom("DCAE"); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap()); - event.getAai().put("vserver.vserver-name", "TBD"); - event.getAai().put("globalSubscriberId", "e151059a-d924-4629-845f-264db19e50b4"); - event.getAai().put("serviceType", "SOTN"); - event.getAai().put("service-instance.service-instance-id", "service-instance-id-example-1"); - event.getAai().put("network-information.network-id", "id"); - event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); - kieSession.insert(event); - } -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopBase.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopBase.java deleted file mode 100644 index a311ba0b0..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopBase.java +++ /dev/null @@ -1,236 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * demo - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Bell Canada. - * ================================================================================ - * 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.template.demo; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.net.URLEncoder; -import java.util.List; -import java.util.Properties; -import java.util.UUID; -import org.junit.AfterClass; -import org.kie.api.runtime.KieSession; -import org.kie.api.runtime.rule.FactHandle; -import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; -import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.drools.protocol.coders.EventProtocolCoderConstants; -import org.onap.policy.drools.protocol.coders.EventProtocolParams; -import org.onap.policy.drools.protocol.coders.JsonProtocolFilter; -import org.onap.policy.drools.system.PolicyControllerConstants; -import org.onap.policy.drools.system.PolicyEngineConstants; -import org.onap.policy.drools.utils.logging.LoggerUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Common super class used by various Control Loop test classes. It manages the simulators - * and the kie session. - */ -public class ControlLoopBase { - - private static final String JUNIT_ARTIFACT_ID = "junit.artifactId"; - - private static final String JUNIT_GROUP_ID = "junit.groupId"; - - protected static final Logger logger = LoggerFactory.getLogger(ControlLoopBase.class); - - protected static List noopTopics; - - protected static KieSession kieSession; - protected static SupportUtil.Pair pair; - - protected UUID requestId; - - /** - * Starts the simulator and the kie session. - * - * @param droolsTemplate the DRL rules file - * @param yamlFile the yaml file containing the policies - * @param policyScope scope for policy - * @param policyName name of the policy - * @param policyVersion version of the policy - */ - public static void setUpBeforeClass(String droolsTemplate, String yamlFile, String policyScope, - String policyName, String policyVersion) { - - SupportUtil.setCustomQuery("false"); - - /* Set environment properties */ - SupportUtil.setAaiProps(); - SupportUtil.setGuardProps(); - SupportUtil.setSdncProps(); - SupportUtil.setSoProps(); - SupportUtil.setVfcProps(); - SupportUtil.setPuProp(); - SupportUtil.setCdsProps(); - - LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO"); - - PolicyEngineConstants.getManager().configure(new Properties()); - assertTrue(PolicyEngineConstants.getManager().start()); - Properties noopSinkProperties = new Properties(); - noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, - "APPC-LCM-READ,APPC-CL,SDNR-CL,POLICY-CL-MGT"); - noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events", "org.onap.policy.appclcm.AppcLcmDmaapWrapper"); - noopSinkProperties.put("noop.sink.topics.APPC-LCM-READ.events.custom.gson", - "org.onap.policy.appclcm.util.Serialization,gson"); - noopSinkProperties.put("noop.sink.topics.APPC-CL.events", "org.onap.policy.appc.Response"); - noopSinkProperties.put("noop.sink.topics.APPC-CL.events.custom.gson", - "org.onap.policy.appc.util.Serialization,gsonPretty"); - noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events", - "org.onap.policy.controlloop.VirtualControlLoopNotification"); - noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", - "org.onap.policy.controlloop.util.Serialization,gsonPretty"); - noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties); - - EventProtocolCoderConstants.getManager().addEncoder(EventProtocolParams.builder() - .groupId(JUNIT_GROUP_ID) - .artifactId(JUNIT_ARTIFACT_ID) - .topic("POLICY-CL-MGT") - .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification") - .protocolFilter(new JsonProtocolFilter()) - .modelClassLoaderHash(1111)); - EventProtocolCoderConstants.getManager().addEncoder(EventProtocolParams.builder() - .groupId(JUNIT_GROUP_ID) - .artifactId(JUNIT_ARTIFACT_ID) - .topic("APPC-LCM-READ") - .eventClass("org.onap.policy.appclcm.AppcLcmDmaapWrapper") - .protocolFilter(new JsonProtocolFilter()) - .modelClassLoaderHash(1111)); - EventProtocolCoderConstants.getManager().addEncoder(EventProtocolParams.builder() - .groupId(JUNIT_GROUP_ID) - .artifactId(JUNIT_ARTIFACT_ID) - .topic("APPC-CL") - .eventClass("org.onap.policy.appc.Request") - .protocolFilter(new JsonProtocolFilter()) - .modelClassLoaderHash(1111)); - EventProtocolCoderConstants.getManager().addEncoder(EventProtocolParams.builder() - .groupId(JUNIT_GROUP_ID) - .artifactId(JUNIT_ARTIFACT_ID) - .topic("SDNR-CL") - .eventClass("org.onap.policy.sdnr.PciRequestWrapper") - .protocolFilter(new JsonProtocolFilter()) - .modelClassLoaderHash(1111)); - try { - SupportUtil.buildAaiSim(); - SupportUtil.buildSdncSim(); - SupportUtil.buildSoSim(); - SupportUtil.buildVfcSim(); - SupportUtil.buildGuardSim(); - } catch (Exception e) { - fail(e.getMessage()); - } - - - /* - * Start the kie session - */ - try { - kieSession = startSession(droolsTemplate, yamlFile, policyScope, - policyName, policyVersion); - } catch (IOException e) { - e.printStackTrace(); - logger.debug("Could not create kieSession"); - fail("Could not create kieSession"); - } - } - - /** - * Stops the simulators and the kie session. - */ - @AfterClass - public static void tearDownAfterClass() { - - SupportUtil.setCustomQuery("false"); - - /* - * Gracefully shut down the kie session - */ - kieSession.dispose(); - - PolicyEngineConstants.getManager().stop(); - HttpServletServerFactoryInstance.getServerFactory().destroy(); - PolicyControllerConstants.getFactory().shutdown(); - TopicEndpointManager.getManager().shutdown(); - } - - /** - * This method will start a kie session and instantiate the Policy Engine. - * - * @param droolsTemplate the DRL rules file - * @param yamlFile the yaml file containing the policies - * @param policyScope scope for policy - * @param policyName name of the policy - * @param policyVersion version of the policy - * @return the kieSession to be used to insert facts - * @throws IOException IO exception - */ - private static KieSession startSession(String droolsTemplate, String yamlFile, String policyScope, - String policyName, String policyVersion) throws IOException { - - /* - * Load policies from yaml - */ - pair = SupportUtil.loadYaml(yamlFile); - assertNotNull(pair); - assertNotNull(pair.first); - assertNotNull(pair.first.getControlLoop()); - assertNotNull(pair.first.getControlLoop().getControlLoopName()); - assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0); - - /* - * Construct a kie session - */ - final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate, - pair.first.getControlLoop().getControlLoopName(), - policyScope, policyName, policyVersion, URLEncoder.encode(pair.second, "UTF-8")); - - /* - * Retrieve the Policy Engine - */ - - logger.debug("============"); - logger.debug(URLEncoder.encode(pair.second, "UTF-8")); - logger.debug("============"); - - return kieSession; - } - - /** - * This method will dump all the facts in the working memory. - * - * @param kieSession the session containing the facts - */ - public void dumpFacts(KieSession kieSession) { - logger.debug("Fact Count: {}", kieSession.getFactCount()); - for (FactHandle handle : kieSession.getFactHandles()) { - logger.debug("FACT: {}", handle); - } - } - -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopEventCleanupTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopEventCleanupTest.java deleted file mode 100644 index 151819c4d..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopEventCleanupTest.java +++ /dev/null @@ -1,377 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * demo - * ================================================================================ - * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.template.demo; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.time.Instant; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; -import java.util.UUID; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.kie.api.runtime.KieSession; -import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; -import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.drools.protocol.coders.EventProtocolCoderConstants; -import org.onap.policy.drools.protocol.coders.EventProtocolParams; -import org.onap.policy.drools.protocol.coders.JsonProtocolFilter; -import org.onap.policy.drools.system.PolicyControllerConstants; -import org.onap.policy.drools.system.PolicyEngineConstants; -import org.onap.policy.drools.utils.logging.LoggerUtil; -import org.onap.policy.template.demo.SupportUtil.Pair; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Verifies that event objects are cleaned up when rules are updated. This loads - * two copies of the rule set into a single policy to ensure that the two copies - * interact appropriately with each other's event objects. - */ -public class ControlLoopEventCleanupTest { - private static final Logger logger = LoggerFactory.getLogger(ControlLoopEventCleanupTest.class); - - /** - * Number of objects per control loop, including the Params object. - */ - private static int CL_OBJECTS = 7; - - private static final String YAML = "src/test/resources/yaml/policy_ControlLoop_EventCleanup-test.yaml"; - - /** - * YAML to be used when the first rule set is updated. - */ - private static final String YAML2 = "src/test/resources/yaml/policy_ControlLoop_EventCleanup-test2.yaml"; - - private static final String POLICY_VERSION = "v2.0"; - - private static final String POLICY_NAME = "CL_CleanupTest"; - - private static final String POLICY_SCOPE = "type=operational"; - - private static final String CONTROL_LOOP_NAME = "ControlLoop-Event-Cleanup-Test"; - - private static final String DROOLS_TEMPLATE = "../archetype-cl-amsterdam/src/main/resources/archetype-resources/" - + "src/main/resources/__closedLoopControlName__.drl"; - - // values specific to the second copy of the rules - - private static final String YAML_B = "src/test/resources/yaml/policy_ControlLoop_EventCleanup-test-B.yaml"; - private static final String POLICY_NAME_B = "CL_CleanupTest_B"; - private static final String CONTROL_LOOP_NAME_B = "ControlLoop-Event-Cleanup-Test-B"; - - private static final String GUARD_DISABLED = "guard.disabled"; - - private static String saveGuardFlag; - - private static KieSession kieSession; - private static SupportUtil.RuleSpec[] specifications; - - /** - * Setup the simulator. - */ - @BeforeClass - public static void setUpSimulator() { - LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO"); - - saveGuardFlag = PolicyEngineConstants.getManager().getEnvironmentProperty(GUARD_DISABLED); - PolicyEngineConstants.getManager().getEnvironment().setProperty(GUARD_DISABLED, "true"); - - SupportUtil.setAaiProps(); - - PolicyEngineConstants.getManager().configure(new Properties()); - assertTrue(PolicyEngineConstants.getManager().start()); - Properties noopSinkProperties = new Properties(); - noopSinkProperties.put(PolicyEndPointProperties.PROPERTY_NOOP_SINK_TOPICS, "APPC-CL,POLICY-CL-MGT"); - noopSinkProperties.put("noop.sink.topics.APPC-CL.events", "org.onap.policy.appc.Response"); - noopSinkProperties.put("noop.sink.topics.APPC-CL.events.custom.gson", - "org.onap.policy.appc.util.Serialization,gsonPretty"); - noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events", - "org.onap.policy.controlloop.VirtualControlLoopNotification"); - noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", - "org.onap.policy.controlloop.util.Serialization,gsonPretty"); - final List noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties); - - EventProtocolCoderConstants.getManager().addEncoder(EventProtocolParams.builder() - .groupId("junit.groupId") - .artifactId("junit.artifactId") - .topic("POLICY-CL-MGT") - .eventClass("org.onap.policy.controlloop.VirtualControlLoopNotification") - .protocolFilter(new JsonProtocolFilter()) - .modelClassLoaderHash(1111)); - EventProtocolCoderConstants.getManager().addEncoder(EventProtocolParams.builder() - .groupId("junit.groupId") - .artifactId("junit.artifactId") - .topic("APPC-CL") - .eventClass("org.onap.policy.appc.Request") - .protocolFilter(new JsonProtocolFilter()) - .modelClassLoaderHash(1111)); - - try { - SupportUtil.buildAaiSim(); - - } catch (Exception e) { - logger.error("Could not create simulator", e); - fail("Could not create simulator"); - } - - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - } - - try { - specifications = new SupportUtil.RuleSpec[2]; - - specifications[0] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME, POLICY_SCOPE, POLICY_NAME, - POLICY_VERSION, loadYaml(YAML)); - - specifications[1] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME_B, POLICY_SCOPE, - POLICY_NAME_B, POLICY_VERSION, loadYaml(YAML_B)); - - kieSession = SupportUtil.buildContainer(POLICY_VERSION, specifications); - - } catch (IOException e) { - logger.error("Could not create kieSession", e); - fail("Could not create kieSession"); - } - } - - /** - * Tear down. - */ - @AfterClass - public static void tearDown() { - kieSession.dispose(); - - PolicyEngineConstants.getManager().stop(); - HttpServletServerFactoryInstance.getServerFactory().destroy(); - PolicyControllerConstants.getFactory().shutdown(); - TopicEndpointManager.getManager().shutdown(); - - if (saveGuardFlag == null) { - PolicyEngineConstants.getManager().getEnvironment().remove(GUARD_DISABLED); - - } else { - PolicyEngineConstants.getManager().getEnvironment().setProperty(GUARD_DISABLED, saveGuardFlag); - } - } - - @Ignore - @Test - public void test() throws IOException { - - /* - * Let rules create Params objects. - */ - kieSession.fireAllRules(); - - injectEvent(CONTROL_LOOP_NAME); - injectEvent(CONTROL_LOOP_NAME_B); - - kieSession.fireAllRules(); - List facts = getSessionObjects(); - - // should have events for both control loops - assertEquals(2 * CL_OBJECTS, facts.size()); - assertTrue(hasEvent(facts, CONTROL_LOOP_NAME)); - assertTrue(hasEvent(facts, CONTROL_LOOP_NAME_B)); - - logger.info("UPDATING VERSION TO v3.0"); - updatePolicy(YAML2, "v3.0"); - - /* - * Let rules update Params objects. The Params for the first set of rules should - * now be deleted and replaced with a new one, while the Params for the second set - * should be unchanged. - */ - kieSession.fireAllRules(); - facts = getSessionObjects(); - - // should only have event for second control loop + 1 Params for first control loop - assertEquals(CL_OBJECTS + 1, facts.size()); - assertTrue(hasEvent(facts, CONTROL_LOOP_NAME_B)); - - // add event for first control loop again - injectEvent(CONTROL_LOOP_NAME); - kieSession.fireAllRules(); - - logger.info("UPDATING VERSION TO v4.0"); - updatePolicy(YAML, "v4.0"); - - /* - * Let rules update Params objects. The Params for the first set of rules should - * now be deleted and replaced with a new one, while the Params for the second set - * should be unchanged. - */ - kieSession.fireAllRules(); - facts = getSessionObjects(); - - // should only have event for second control loop + 1 Params for first control loop - assertEquals(CL_OBJECTS + 1, facts.size()); - assertTrue(hasEvent(facts, CONTROL_LOOP_NAME_B)); - - // add event for first control loop again - injectEvent(CONTROL_LOOP_NAME); - kieSession.fireAllRules(); - - logger.info("UPDATING VERSION TO v4.0 (i.e., unchanged)"); - updatePolicy(YAML, "v4.0"); - - /* - * Let rules update Params objects. As the version (and YAML) are unchanged for - * either rule set, both Params objects should be unchanged. - */ - kieSession.fireAllRules(); - facts = getSessionObjects(); - - // should have events for both control loops - assertEquals(2 * CL_OBJECTS, facts.size()); - assertTrue(hasEvent(facts, CONTROL_LOOP_NAME)); - assertTrue(hasEvent(facts, CONTROL_LOOP_NAME_B)); - - /* - * Now we'll delete the first rule set. That won't actually have any immediate - * effect, so then we'll update the second rule set, which should trigger a - * clean-up of both. - */ - SupportUtil.RuleSpec[] specs = new SupportUtil.RuleSpec[1]; - specs[0] = specifications[1]; - - logger.info("UPDATING VERSION TO v5.0 - DELETED RULE SET"); - SupportUtil.updateContainer("v5.0", specs); - - specs[0] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME_B, POLICY_SCOPE, POLICY_NAME_B, - POLICY_VERSION, loadYaml(YAML)); - - logger.info("UPDATING VERSION TO v6.0 - UPDATED SECOND RULE SET"); - SupportUtil.updateContainer("v6.0", specs); - - kieSession.fireAllRules(); - facts = getSessionObjects(); - - // only 1 Params should remain, for second rule set, but events should be gone - assertEquals(1, facts.size()); - assertTrue(facts.stream().anyMatch(obj -> obj.toString().startsWith("Params( "))); - } - - /** - * Updates the policy, changing the YAML associated with the first rule set. - * - * @param yamlFile name of the YAML file - * @param policyVersion policy version - * @throws IOException if an error occurs - */ - private static void updatePolicy(String yamlFile, String policyVersion) throws IOException { - - specifications[0] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME, POLICY_SCOPE, POLICY_NAME, - policyVersion, loadYaml(yamlFile)); - - /* - * Update the policy within the container. - */ - SupportUtil.updateContainer(policyVersion, specifications); - } - - /** - * Loads a YAML file and URL-encodes it. - * - * @param yamlFile name of the YAML file - * @return the contents of the specified file, URL-encoded - * @throws UnsupportedEncodingException if an error occurs - */ - private static String loadYaml(String yamlFile) throws UnsupportedEncodingException { - Pair pair = SupportUtil.loadYaml(yamlFile); - assertNotNull(pair); - assertNotNull(pair.first); - assertNotNull(pair.first.getControlLoop()); - assertNotNull(pair.first.getControlLoop().getControlLoopName()); - assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0); - - return URLEncoder.encode(pair.second, "UTF-8"); - } - - /** - * Gets the session objects. - * - * @return the session objects - */ - private static List getSessionObjects() { - // sort the objects so we know the order - LinkedList lst = new LinkedList<>(kieSession.getObjects()); - lst.sort((left, right) -> left.toString().compareTo(right.toString())); - - lst.forEach(obj -> logger.info("obj={}", obj)); - - return lst; - } - - /** - * Injects an ONSET event into the rule engine. - * - * @param controlLoopName the control loop name - */ - private void injectEvent(String controlLoopName) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - - event.setClosedLoopControlName(controlLoopName); - - UUID reqid = UUID.randomUUID(); - event.setRequestId(reqid); - - event.setTarget("generic-vnf.vnf-id"); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap<>()); - event.getAai().put("generic-vnf.vnf-id", "vnf-" + reqid.toString()); - event.getAai().put(ControlLoopEventManager.GENERIC_VNF_IS_CLOSED_LOOP_DISABLED, "false"); - event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); - - kieSession.insert(event); - } - - /** - * Determines if the facts contain an event for the given control loop. - * - * @param facts session facts to be checked - * @param controlLoopName name of the control loop of interest - * @return {@code true} if the facts contain an event for the given control loop, - * {@code false} otherwise - */ - private boolean hasEvent(List facts, String controlLoopName) { - return (facts.stream().anyMatch(obj -> obj instanceof VirtualControlLoopEvent - && controlLoopName.equals(((VirtualControlLoopEvent) obj).getClosedLoopControlName()))); - } -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java deleted file mode 100644 index e3409146f..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java +++ /dev/null @@ -1,279 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * demo - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.template.demo; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.time.Instant; -import java.util.HashMap; -import java.util.UUID; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.appclcm.AppcLcmBody; -import org.onap.policy.appclcm.AppcLcmDmaapWrapper; -import org.onap.policy.appclcm.AppcLcmInput; -import org.onap.policy.appclcm.AppcLcmOutput; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.VirtualControlLoopNotification; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; - -public class ControlLoopFailureTest extends ControlLoopBase implements TopicListener { - - private UUID requestId2; - private UUID requestId3; - private int eventCount; - private int nsuccess = 0; - private int nreject = 0; - - /** - * Setup simulator. - */ - @BeforeClass - public static void setUpBeforeClass() { - ControlLoopBase.setUpBeforeClass( - "../archetype-cl-amsterdam/src/main/resources/archetype-resources" - + "/src/main/resources/__closedLoopControlName__.drl", - "src/test/resources/yaml/policy_ControlLoop_vCPE.yaml", - "service=ServiceDemo;resource=Res1Demo;type=operational", - "CL_vCPE", - "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0"); - } - - /** - * This test case tests the scenario where 3 events occur and 2 of the requests refer to the - * same target entity while the 3rd is for another entity. The expected result is that the event - * with the duplicate target entity will have a final success result for one of the events, and - * a rejected message for the one that was unable to obtain the lock. The event that is - * referring to a different target entity should be able to obtain a lock since it is a - * different target. After processing of all events there should only be the params object left - * in memory. - */ - @Test - public void targetLockedTest() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * This will be a unique request for another target entity - */ - requestId2 = UUID.randomUUID(); - - /* - * This will be a request duplicating the target entity of the first request - */ - requestId3 = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, "vnf01"); - - /* - * Send a second event for a different target to ensure there are no problems with obtaining - * a lock - */ - sendEvent(pair.first, requestId2, ControlLoopEventStatus.ONSET, "vnf02"); - - /* - * Send a third event requesting an action for a duplicate target entity - */ - sendEvent(pair.first, requestId3, ControlLoopEventStatus.ONSET, "vnf01"); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - // should be one success and one failure for vnf01 - assertEquals(1, nsuccess); - assertEquals(1, nreject); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - /* - * (non-Javadoc) - * - * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String) - */ - @Override - public synchronized void onTopicEvent(CommInfrastructure commType, String topic, String event) { - /* - * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation - * of type active - */ - Object obj = null; - if ("POLICY-CL-MGT".equals(topic)) { - obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, - org.onap.policy.controlloop.VirtualControlLoopNotification.class); - } else if ("APPC-LCM-READ".equals(topic)) { - obj = org.onap.policy.appclcm.util.Serialization.gsonJunit.fromJson(event, - org.onap.policy.appclcm.AppcLcmDmaapWrapper.class); - } - assertNotNull(obj); - if (obj instanceof VirtualControlLoopNotification) { - VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj; - String policyName = notification.getPolicyName(); - if (policyName.endsWith("EVENT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification())); - } else if (policyName.endsWith("DENIED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.REJECTED.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().contains("is already locked")); - if (requestId.equals(notification.getRequestId()) || requestId3.equals(notification.getRequestId())) { - ++nreject; - } - if (++eventCount == 3) { - kieSession.halt(); - } - } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("Sending guard query")); - } else if (policyName.endsWith("GUARD.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().toLowerCase().endsWith("permit")); - } else if (policyName.endsWith("GUARD_PERMITTED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=APPC")); - } else if (policyName.endsWith("OPERATION.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The operation timed out"); - fail("Operation Timed Out"); - } else if (policyName.endsWith("APPC.LCM.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=APPC")); - if (requestId.equals(notification.getRequestId()) || requestId3.equals(notification.getRequestId())) { - sendEvent(pair.first, notification.getRequestId(), ControlLoopEventStatus.ABATED, "vnf01"); - } else if (requestId2.equals(notification.getRequestId())) { - sendEvent(pair.first, requestId2, ControlLoopEventStatus.ABATED, "vnf02"); - } - } else if (policyName.endsWith("EVENT.MANAGER")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - if (requestId.equals(notification.getRequestId()) || requestId3.equals(notification.getRequestId())) { - assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.getNotification())); - ++nsuccess; - } else { - assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.getNotification())); - } - if (++eventCount == 3) { - kieSession.halt(); - } - } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The control loop timed out"); - fail("Control Loop Timed Out"); - } - } else if (obj instanceof AppcLcmDmaapWrapper) { - /* - * The request should be of type LCMRequestWrapper and the subrequestid should be 1 - */ - AppcLcmDmaapWrapper dmaapRequest = (AppcLcmDmaapWrapper) obj; - AppcLcmInput appcRequest = dmaapRequest.getBody().getInput(); - assertTrue(appcRequest.getCommonHeader().getSubRequestId().equals("1")); - - logger.debug("\n============ APPC received the request!!! ===========\n"); - - /* - * Simulate a success response from APPC and insert the response into the working memory - */ - AppcLcmDmaapWrapper dmaapResponse = new AppcLcmDmaapWrapper(); - AppcLcmOutput appcResponse = new AppcLcmOutput(appcRequest); - appcResponse.getStatus().setCode(400); - appcResponse.getStatus().setMessage("AppC success"); - dmaapResponse.setBody(new AppcLcmBody()); - dmaapResponse.getBody().setOutput(appcResponse); - - /* - * Interrupting with a different request for the same target entity to check if lock - * will be denied - */ - if (requestId.equals(appcResponse.getCommonHeader().getRequestId())) { - sendEvent(pair.first, requestId3, ControlLoopEventStatus.ONSET, "vnf01"); - } - kieSession.insert(dmaapResponse); - } - } - - /** - * This method is used to simulate event messages from DCAE that start the control loop (onset - * message) or end the control loop (abatement message). - * - * @param policy the controlLoopName comes from the policy - * @param requestId the requestId for this event - * @param status could be onset or abated - * @param target the target entity to take an action on - */ - protected void sendEvent(ControlLoopPolicy policy, UUID requestId, ControlLoopEventStatus status, String target) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(requestId); - event.setTarget("generic-vnf.vnf-id"); - event.setTargetType(ControlLoopTargetType.VNF); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap<>()); - event.getAai().put("generic-vnf.vnf-id", target); - event.getAai().put("vserver.vserver-name", "OzVServer"); - event.setClosedLoopEventStatus(status); - kieSession.insert(event); - } -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopParamsCleanupTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopParamsCleanupTest.java deleted file mode 100644 index ae12d0469..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopParamsCleanupTest.java +++ /dev/null @@ -1,257 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - * ================================================================================ - * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.template.demo; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.kie.api.runtime.KieSession; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.drools.utils.logging.LoggerUtil; -import org.onap.policy.template.demo.SupportUtil.Pair; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Verifies that Params objects are cleaned up when rules are updated. This loads - * two copies of the rule set into a single policy to ensure that the two copies - * interact appropriately with each other's Params objects. - */ -public class ControlLoopParamsCleanupTest { - private static final Logger logger = LoggerFactory.getLogger(ControlLoopParamsCleanupTest.class); - - private static final String YAML = "src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test.yaml"; - - /** - * YAML to be used when the first rule set is updated. - */ - private static final String YAML2 = "src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test2.yaml"; - - private static final String POLICY_VERSION = "v2.0"; - - private static final String POLICY_NAME = "CL_CleanupTest"; - - private static final String POLICY_SCOPE = "type=operational"; - - private static final String CONTROL_LOOP_NAME = "ControlLoop-Params-Cleanup-Test"; - - private static final String DROOLS_TEMPLATE = "../archetype-cl-amsterdam/src/main/resources/archetype-resources/" - + "src/main/resources/__closedLoopControlName__.drl"; - - // values specific to the second copy of the rules - - private static final String YAML_B = "src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test-B.yaml"; - private static final String POLICY_NAME_B = "CL_CleanupTest_B"; - private static final String CONTROL_LOOP_NAME_B = "ControlLoop-Params-Cleanup-Test-B"; - - private static KieSession kieSession; - private static SupportUtil.RuleSpec[] specifications; - - /** - * Setup the simulator. - */ - @BeforeClass - public static void setUpSimulator() { - LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, "INFO"); - - try { - specifications = new SupportUtil.RuleSpec[2]; - - specifications[0] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME, POLICY_SCOPE, POLICY_NAME, - POLICY_VERSION, loadYaml(YAML)); - - specifications[1] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME_B, POLICY_SCOPE, - POLICY_NAME_B, POLICY_VERSION, loadYaml(YAML_B)); - - kieSession = SupportUtil.buildContainer(POLICY_VERSION, specifications); - - } catch (IOException e) { - logger.error("Could not create kieSession", e); - fail("Could not create kieSession"); - } - } - - /** - * Tear down. - */ - @AfterClass - public static void tearDown() { - kieSession.dispose(); - } - - @Ignore - @Test - public void test() throws IOException { - - /* - * Let rules create Params objects. There should be one object for each set of - * rules. - */ - kieSession.fireAllRules(); - List facts = getSessionObjects(); - assertEquals(specifications.length, facts.size()); - Iterator iter = facts.iterator(); - - final Object fact1 = iter.next(); - assertTrue(fact1.toString().contains(loadYaml(YAML))); - - final Object fact1b = iter.next(); - assertTrue(fact1b.toString().contains(loadYaml(YAML_B))); - - logger.info("UPDATING VERSION TO v3.0"); - updatePolicy(YAML2, "v3.0"); - - /* - * Let rules update Params objects. The Params for the first set of rules should - * now be deleted and replaced with a new one, while the Params for the second set - * should be unchanged. - */ - kieSession.fireAllRules(); - facts = getSessionObjects(); - assertEquals(specifications.length, facts.size()); - iter = facts.iterator(); - - final Object fact2 = iter.next(); - assertTrue(fact2 != fact1); - assertTrue(fact2 != fact1b); - assertTrue(fact2.toString().contains(loadYaml(YAML2))); - - assertTrue(iter.next() == fact1b); - - logger.info("UPDATING VERSION TO v4.0"); - updatePolicy(YAML, "v4.0"); - - /* - * Let rules update Params objects. The Params for the first set of rules should - * now be deleted and replaced with a new one, while the Params for the second set - * should be unchanged. - */ - kieSession.fireAllRules(); - facts = getSessionObjects(); - assertEquals(specifications.length, facts.size()); - iter = facts.iterator(); - - final Object fact3 = iter.next(); - assertTrue(fact3.toString().contains(loadYaml(YAML))); - assertTrue(fact3 != fact2); - assertTrue(fact3 != fact1b); - - assertTrue(iter.next() == fact1b); - - logger.info("UPDATING VERSION TO v4.0 (i.e., unchanged)"); - updatePolicy(YAML, "v4.0"); - - /* - * Let rules update Params objects. As the version (and YAML) are unchanged for - * either rule set, both Params objects should be unchanged. - */ - kieSession.fireAllRules(); - facts = getSessionObjects(); - assertEquals(specifications.length, facts.size()); - iter = facts.iterator(); - assertTrue(iter.next() == fact3); - assertTrue(iter.next() == fact1b); - - /* - * Now we'll delete the first rule set. That won't actually have any immediate - * effect, so then we'll update the second rule set, which should trigger a - * clean-up of both. - */ - SupportUtil.RuleSpec[] specs = new SupportUtil.RuleSpec[1]; - specs[0] = specifications[1]; - - logger.info("UPDATING VERSION TO v5.0 - DELETED RULE SET"); - SupportUtil.updateContainer("v5.0", specs); - - specs[0] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME_B, POLICY_SCOPE, POLICY_NAME_B, - POLICY_VERSION, loadYaml(YAML)); - - logger.info("UPDATING VERSION TO v6.0 - UPDATED SECOND RULE SET"); - SupportUtil.updateContainer("v6.0", specs); - - kieSession.fireAllRules(); - facts = getSessionObjects(); - assertEquals(specs.length, facts.size()); - iter = facts.iterator(); - assertTrue(iter.next().toString().contains(CONTROL_LOOP_NAME_B)); - } - - /** - * Updates the policy, changing the YAML associated with the first rule set. - * - * @param yamlFile name of the YAML file - * @param policyVersion policy version - * @throws IOException if an error occurs - */ - private static void updatePolicy(String yamlFile, String policyVersion) throws IOException { - - specifications[0] = new SupportUtil.RuleSpec(DROOLS_TEMPLATE, CONTROL_LOOP_NAME, POLICY_SCOPE, POLICY_NAME, - policyVersion, loadYaml(yamlFile)); - - /* - * Update the policy within the container. - */ - SupportUtil.updateContainer(policyVersion, specifications); - } - - /** - * Loads a YAML file and URL-encodes it. - * - * @param yamlFile name of the YAML file - * @return the contents of the specified file, URL-encoded - * @throws UnsupportedEncodingException if an error occurs - */ - private static String loadYaml(String yamlFile) throws UnsupportedEncodingException { - Pair pair = SupportUtil.loadYaml(yamlFile); - assertNotNull(pair); - assertNotNull(pair.first); - assertNotNull(pair.first.getControlLoop()); - assertNotNull(pair.first.getControlLoop().getControlLoopName()); - assertTrue(pair.first.getControlLoop().getControlLoopName().length() > 0); - - return URLEncoder.encode(pair.second, "UTF-8"); - } - - /** - * Gets the session objects. - * - * @return the session objects - */ - private static List getSessionObjects() { - // sort the objects so we know the order - LinkedList lst = new LinkedList<>(kieSession.getObjects()); - lst.sort((left, right) -> left.toString().compareTo(right.toString())); - - return lst; - } -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/SupportUtil.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/SupportUtil.java deleted file mode 100644 index 878f94be1..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/SupportUtil.java +++ /dev/null @@ -1,460 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * demo - * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Bell Canada. - * ================================================================================ - * 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.template.demo; - -import static org.junit.Assert.fail; - -import com.att.research.xacml.util.XACMLProperties; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.apache.commons.io.IOUtils; -import org.kie.api.KieServices; -import org.kie.api.builder.KieBuilder; -import org.kie.api.builder.KieFileSystem; -import org.kie.api.builder.Message; -import org.kie.api.builder.ReleaseId; -import org.kie.api.builder.Results; -import org.kie.api.runtime.KieContainer; -import org.kie.api.runtime.KieSession; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; -import org.onap.policy.common.utils.network.NetworkUtil; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.controlloop.policy.guard.ControlLoopGuard; -import org.onap.policy.drools.system.PolicyEngineConstants; -import org.onap.policy.guard.PolicyGuardYamlToXacml; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; - -public final class SupportUtil { - - private static final String OPSHISTPUPROP = "OperationsHistoryPU"; - private static final Logger logger = LoggerFactory.getLogger(SupportUtil.class); - - static final int GRPC_SERVER_PORT; - - static { - try { - GRPC_SERVER_PORT = NetworkUtil.allocPort(); - } catch (IOException e) { - throw new RuntimeException("Socket cannot be created for grpc server port", e); - } - } - - public static class Pair { - public final A first; - public final B second; - - public Pair(A first, B second) { - this.first = first; - this.second = second; - } - } - - // values from the last call to buildContainer() - - private static KieServices kieServices; - private static KieContainer keyContainer; - - /** - * Load YAML. - * - * @param testFile test file to load - * @return the Pair of a policy and the yaml contents - */ - public static Pair loadYaml(String testFile) { - try (InputStream is = new FileInputStream(new File(testFile))) { - String contents = IOUtils.toString(is, StandardCharsets.UTF_8); - // - // Read the yaml into our Java Object - // - Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class)); - Object obj = yaml.load(contents); - - logger.debug(contents); - - return new Pair((ControlLoopPolicy) obj, contents); - } catch (FileNotFoundException e) { - fail(e.getLocalizedMessage()); - } catch (IOException e) { - fail(e.getLocalizedMessage()); - } - return null; - } - - /** - * Load the YAML guard policy. - * - * @param testFile the test file to load - * @return return the guard object - */ - public static ControlLoopGuard loadYamlGuard(String testFile) { - try (InputStream is = new FileInputStream(new File(testFile))) { - String contents = IOUtils.toString(is, StandardCharsets.UTF_8); - // - // Read the yaml into our Java Object - // - Yaml yaml = new Yaml(new Constructor(ControlLoopGuard.class)); - Object obj = yaml.load(contents); - return (ControlLoopGuard) obj; - } catch (FileNotFoundException e) { - fail(e.getLocalizedMessage()); - } catch (IOException e) { - fail(e.getLocalizedMessage()); - } - return null; - } - - public static HttpServletServer buildAaiSim() throws InterruptedException, IOException { - return org.onap.policy.simulators.Util.buildAaiSim(); - } - - public static HttpServletServer buildSoSim() throws InterruptedException, IOException { - return org.onap.policy.simulators.Util.buildSoSim(); - } - - public static HttpServletServer buildVfcSim() throws InterruptedException, IOException { - return org.onap.policy.simulators.Util.buildVfcSim(); - } - - public static HttpServletServer buildGuardSim() throws InterruptedException, IOException { - return org.onap.policy.simulators.Util.buildGuardSim(); - } - - public static HttpServletServer buildSdncSim() throws InterruptedException, IOException { - return org.onap.policy.simulators.Util.buildSdncSim(); - } - - /** - * Build a container containing a single set of rules. - * - * @param droolsTemplate template - * @param closedLoopControlName control loop id - * @param policyScope policy scope - * @param policyName policy name - * @param policyVersion policy version - * @param yamlSpecification incoming yaml specification - * @return the Kie session - * @throws IOException if the container cannot be built - */ - public static KieSession buildContainer(String droolsTemplate, String closedLoopControlName, - String policyScope, String policyName, String policyVersion, String yamlSpecification) - throws IOException { - - RuleSpec spec = new RuleSpec(droolsTemplate, closedLoopControlName, policyScope, policyName, - policyVersion, yamlSpecification); - - return buildContainer(policyVersion, new RuleSpec[] {spec}); - } - - /** - * Build a container containing all of the specified rules. - * - * @param policyVersion policy version - * @param specifications rule specifications - * @return the Kie session - * @throws IOException if the container cannot be built - */ - public static KieSession buildContainer(String policyVersion, RuleSpec[] specifications) - throws IOException { - // - // Get our Drools Kie factory - // - kieServices = KieServices.Factory.get(); - - ReleaseId releaseId = buildPolicy(policyVersion, specifications); - logger.debug(releaseId.toString()); - - // - // Create our kie Session and container - // - keyContainer = kieServices.newKieContainer(releaseId); - - return setupSession(keyContainer.newKieSession()); - } - - /** - * Update the container with new rules. - * - * @param policyVersion new policy version - * @param specifications new rule specifications - * @throws IOException if the container cannot be built - */ - public static void updateContainer(String policyVersion, RuleSpec[] specifications) - throws IOException { - ReleaseId releaseId = buildPolicy(policyVersion, specifications); - logger.debug(releaseId.toString()); - - keyContainer.updateToVersion(releaseId); - } - - /** - * Build the Policy so it can be loaded into a KIE container. - * - * @param policyVersion policy version - * @param specifications rule specifications - * @return the release - * @throws IOException if the container cannot be built - */ - private static ReleaseId buildPolicy(String policyVersion, RuleSpec[] specifications) - throws IOException { - // - // Generate our drools rule from our template - // - KieFileSystem kfs = kieServices.newKieFileSystem(); - ReleaseId releaseId = kieServices.getRepository().getDefaultReleaseId(); - releaseId = kieServices.newReleaseId(releaseId.getGroupId(), releaseId.getArtifactId(), - policyVersion); - - kfs.generateAndWritePomXML(releaseId); - - for (RuleSpec spec : specifications) { - String drlContents = spec.generateRules(); - kfs.write("src/main/resources/" + spec.policyName + ".drl", - kieServices.getResources().newByteArrayResource(drlContents.getBytes())); - } - - // - // Compile the rule - // - KieBuilder builder = kieServices.newKieBuilder(kfs).buildAll(); - Results results = builder.getResults(); - if (results.hasMessages(Message.Level.ERROR)) { - for (Message msg : results.getMessages()) { - logger.error(msg.toString()); - } - throw new RuntimeException("Drools Rule has Errors"); - } - for (Message msg : results.getMessages()) { - logger.debug(msg.toString()); - } - - return releaseId; - } - - private static KieSession setupSession(KieSession kieSession) { - - // - // Create XACML Guard policy from YAML - // We prepare 4 Guards. Notice that Rebuilds recipe has two Guards (for checking policy - // combining algorithm) - // - PolicyGuardYamlToXacml.fromYamlToXacml( - "src/test/resources/yaml/policy_guard_appc_restart.yaml", - "src/main/resources/frequency_limiter_template.xml", - "src/test/resources/xacml/autogenerated_frequency_limiter_restart.xml"); - - PolicyGuardYamlToXacml.fromYamlToXacml( - "src/test/resources/yaml/policy_guard_appc_rebuild.yaml", - "src/main/resources/frequency_limiter_template.xml", - "src/test/resources/xacml/autogenerated_frequency_limiter_rebuild.xml"); - - PolicyGuardYamlToXacml.fromYamlToXacml( - "src/test/resources/yaml/policy_guard_appc_rebuild_1.yaml", - "src/main/resources/frequency_limiter_template.xml", - "src/test/resources/xacml/autogenerated_frequency_limiter_rebuild_1.xml"); - - PolicyGuardYamlToXacml.fromYamlToXacml( - "src/test/resources/yaml/policy_guard_appc_migrate.yaml", - "src/main/resources/frequency_limiter_template.xml", - "src/test/resources/xacml/autogenerated_frequency_limiter_migrate.xml"); - - PolicyGuardYamlToXacml.fromYamlToXacml( - "src/test/resources/yaml/policy_guard_appc_modifyconfig.yaml", - "src/main/resources/frequency_limiter_template.xml", - "src/test/resources/xacml/autogenerated_frequency_limiter_modifyconfig.xml"); - - PolicyGuardYamlToXacml.fromYamlToXacmlBlacklist( - "src/test/resources/yaml/policy_guard_appc_restart_blacklist.yaml", - "src/main/resources/blacklist_template.xml", - "src/test/resources/xacml/autogenerated_blacklist.xml"); - - // - // Creating an embedded XACML PDP - // - System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, - "src/test/resources/xacml/xacml_guard.properties"); - - return kieSession; - } - - /** - * Set the A&AI properties. - */ - public static void setAaiProps() { - PolicyEngineConstants.getManager().setEnvironmentProperty("aai.url", - "http://localhost:6666"); - PolicyEngineConstants.getManager().setEnvironmentProperty("aai.username", "AAI"); - PolicyEngineConstants.getManager().setEnvironmentProperty("aai.password", "AAI"); - } - - /** - * Set the SO properties. - */ - public static void setSoProps() { - PolicyEngineConstants.getManager().setEnvironmentProperty("so.url", - "http://localhost:6667"); - PolicyEngineConstants.getManager().setEnvironmentProperty("so.username", "SO"); - PolicyEngineConstants.getManager().setEnvironmentProperty("so.password", "SO"); - } - - /** - * Set the SDNC properties. - */ - public static void setSdncProps() { - PolicyEngineConstants.getManager().setEnvironmentProperty("sdnc.url", - "http://localhost:6670/restconf/operations"); - PolicyEngineConstants.getManager().setEnvironmentProperty("sdnc.username", "sdnc"); - PolicyEngineConstants.getManager().setEnvironmentProperty("sdnc.password", "sdnc"); - } - - /** - * Set the Guard properties. - */ - public static void setGuardProps() { - /* - * Guard PDP-x connection Properties - */ - PolicyEngineConstants.getManager().setEnvironmentProperty( - org.onap.policy.guard.Util.PROP_GUARD_URL, - "http://localhost:6669/policy/pdpx/v1/decision"); - PolicyEngineConstants.getManager() - .setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_USER, "python"); - PolicyEngineConstants.getManager() - .setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_PASS, "test"); - PolicyEngineConstants.getManager() - .setEnvironmentProperty(org.onap.policy.guard.Util.PROP_GUARD_DISABLED, "false"); - } - - /** - * Sets the value of customQuery Environment property. - * - * @param value of the custom query boolean. - */ - public static void setCustomQuery(String value) { - PolicyEngineConstants.getManager().setEnvironmentProperty("aai.customQuery", value); - } - - /** - * Set the VFC properties. - */ - public static void setVfcProps() { - PolicyEngineConstants.getManager().setEnvironmentProperty("vfc.url", - "http://localhost:6668/api/nslcm/v1"); - PolicyEngineConstants.getManager().setEnvironmentProperty("vfc.username", "VFC"); - PolicyEngineConstants.getManager().setEnvironmentProperty("vfc.password", "VFC"); - } - - /** - * Set the operation history properties. - */ - public static void setPuProp() { - System.setProperty(OPSHISTPUPROP, "OperationsHistoryPUTest"); - } - - /** - * Set cds properties. - */ - public static void setCdsProps() { - PolicyEngineConstants.getManager().setEnvironmentProperty("cds.grpcHost", "localhost"); - PolicyEngineConstants.getManager().setEnvironmentProperty("cds.grpcPort", Integer.toString(GRPC_SERVER_PORT)); - PolicyEngineConstants.getManager().setEnvironmentProperty("cds.grpcUsername", "grpc-username"); - PolicyEngineConstants.getManager().setEnvironmentProperty("cds.grpcPassword", "grpc-password"); - PolicyEngineConstants.getManager().setEnvironmentProperty("cds.grpcTimeout", "5"); - } - - /** - * Rule specification. - */ - public static class RuleSpec { - private String droolsTemplate; - private String closedLoopControlName; - private String policyScope; - private String policyName; - private String policyVersion; - private String yamlSpecification; - - /** - * Constructs the object. - * - * @param droolsTemplate template - * @param closedLoopControlName control loop id - * @param policyScope policy scope - * @param policyName policy name - * @param policyVersion policy version - * @param yamlSpecification incoming yaml specification - */ - public RuleSpec(String droolsTemplate, String closedLoopControlName, String policyScope, - String policyName, String policyVersion, String yamlSpecification) { - - this.droolsTemplate = droolsTemplate; - this.closedLoopControlName = closedLoopControlName; - this.policyScope = policyScope; - this.policyName = policyName; - this.policyVersion = policyVersion; - this.yamlSpecification = yamlSpecification; - } - - /** - * Generates the rules by reading the template and making variable substitutions. - * - * @return the rules - * @throws IOException if an error occurs - */ - private String generateRules() throws IOException { - Path rule = Paths.get(droolsTemplate); - String ruleTemplate = new String(Files.readAllBytes(rule)); - - Pattern pattern = Pattern.compile("\\$\\{closedLoopControlName\\}"); - Matcher matcher = pattern.matcher(ruleTemplate); - ruleTemplate = matcher.replaceAll(closedLoopControlName); - - pattern = Pattern.compile("\\$\\{policyScope\\}"); - matcher = pattern.matcher(ruleTemplate); - ruleTemplate = matcher.replaceAll(policyScope); - - pattern = Pattern.compile("\\$\\{policyName\\}"); - matcher = pattern.matcher(ruleTemplate); - ruleTemplate = matcher.replaceAll(policyName); - - pattern = Pattern.compile("\\$\\{policyVersion\\}"); - matcher = pattern.matcher(ruleTemplate); - ruleTemplate = matcher.replaceAll(policyVersion); - - pattern = Pattern.compile("\\$\\{controlLoopYaml\\}"); - matcher = pattern.matcher(ruleTemplate); - ruleTemplate = matcher.replaceAll(yamlSpecification); - - return ruleTemplate; - } - } -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VcpeControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VcpeControlLoopTest.java deleted file mode 100644 index e0cb0ef1f..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VcpeControlLoopTest.java +++ /dev/null @@ -1,287 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * demo - * ================================================================================ - * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.template.demo; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.time.Instant; -import java.util.HashMap; -import java.util.UUID; -import org.junit.BeforeClass; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; -import org.onap.policy.appclcm.AppcLcmBody; -import org.onap.policy.appclcm.AppcLcmDmaapWrapper; -import org.onap.policy.appclcm.AppcLcmInput; -import org.onap.policy.appclcm.AppcLcmOutput; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.VirtualControlLoopNotification; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class VcpeControlLoopTest extends ControlLoopBase implements TopicListener { - - /** - * Setup the simulator. - */ - @BeforeClass - public static void setUpBeforeClass() { - ControlLoopBase.setUpBeforeClass( - "../archetype-cl-amsterdam/src/main/resources/archetype-resources" - + "/src/main/resources/__closedLoopControlName__.drl", - "src/test/resources/yaml/policy_ControlLoop_vCPE.yaml", - "service=ServiceDemo;resource=Res1Demo;type=operational", "CL_vCPE", - "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0"); - } - - @Test - public void testASuccess() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, "OzVServer", true); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - @Test - public void testBAaiGetFail() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, "getFail", false); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - /* - * (non-Javadoc) - * - * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String) - */ - @Override - public void onTopicEvent(CommInfrastructure commType, String topic, String event) { - /* - * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation - * of type active - */ - Object obj = null; - if ("POLICY-CL-MGT".equals(topic)) { - obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, - org.onap.policy.controlloop.VirtualControlLoopNotification.class); - } else if ("APPC-LCM-READ".equals(topic)) { - obj = org.onap.policy.appclcm.util.Serialization.gsonJunit.fromJson(event, - org.onap.policy.appclcm.AppcLcmDmaapWrapper.class); - } - assertNotNull(obj); - if (obj instanceof VirtualControlLoopNotification) { - VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj; - String policyName = notification.getPolicyName(); - if (policyName.endsWith("EVENT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue( - ControlLoopNotificationType.ACTIVE.equals(notification.getNotification())); - } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue( - ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("Sending guard query")); - } else if (policyName.endsWith("GUARD.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue( - ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().toLowerCase().endsWith("permit")); - } else if (policyName.endsWith("GUARD_PERMITTED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue( - ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=APPC")); - } else if (policyName.endsWith("OPERATION.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The operation timed out"); - fail("Operation Timed Out"); - } else if (policyName.endsWith("APPC.LCM.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS - .equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=APPC")); - sendEvent(pair.first, requestId, ControlLoopEventStatus.ABATED); - } else if (policyName.endsWith("EVENT.MANAGER")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - if ("getFail".equals(notification.getAai().get("generic-vnf.vnf-name"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, - notification.getNotification()); - kieSession.halt(); - } else { - assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, - notification.getNotification()); - kieSession.halt(); - } - } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The control loop timed out"); - fail("Control Loop Timed Out"); - } - } else if (obj instanceof AppcLcmDmaapWrapper) { - /* - * The request should be of type LcmRequestWrapper and the subrequestid should be 1 - */ - AppcLcmDmaapWrapper dmaapRequest = (AppcLcmDmaapWrapper) obj; - AppcLcmInput appcRequest = dmaapRequest.getBody().getInput(); - assertTrue(appcRequest.getCommonHeader().getSubRequestId().equals("1")); - assertNotNull(appcRequest.getActionIdentifiers().get("vnf-id")); - - logger.debug("\n============ APPC received the request!!! ===========\n"); - - /* - * Simulate a success response from APPC and insert the response into the working memory - */ - AppcLcmDmaapWrapper dmaapResponse = new AppcLcmDmaapWrapper(); - AppcLcmOutput appcResponse = new AppcLcmOutput(appcRequest); - appcResponse.getStatus().setCode(400); - appcResponse.getStatus().setMessage("AppC success"); - dmaapResponse.setBody(new AppcLcmBody()); - dmaapResponse.getBody().setOutput(appcResponse); - - kieSession.insert(dmaapResponse); - } - } - - /** - * This method is used to simulate event messages from DCAE that start the control loop (onset - * message) or end the control loop (abatement message). - * - * @param policy the controlLoopName comes from the policy - * @param requestId the requestId for this event - * @param status could be onset or abated - */ - protected void sendEvent(ControlLoopPolicy policy, UUID requestId, - ControlLoopEventStatus status) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(requestId); - event.setTarget("generic-vnf.vnf-name"); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap<>()); - event.getAai().put("generic-vnf.vnf-name", "testGenericVnfName"); - event.setClosedLoopEventStatus(status); - kieSession.insert(event); - } - - protected void sendEvent(ControlLoopPolicy policy, UUID requestId, - ControlLoopEventStatus status, String vnfName, boolean isEnriched) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(requestId); - event.setTarget("generic-vnf.vnf-name"); - event.setTargetType(ControlLoopTargetType.VNF); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap<>()); - event.getAai().put("generic-vnf.vnf-name", vnfName); - event.getAai().put("vserver.vserver-name", vnfName); - if (isEnriched) { - event.getAai().put("generic-vnf.in-maint", "false"); - event.getAai().put("generic-vnf.is-closed-loop-disabled", "false"); - event.getAai().put("generic-vnf.orchestration-status", "Created"); - event.getAai().put("generic-vnf.prov-status", "ACTIVE"); - event.getAai().put("generic-vnf.resource-version", "1"); - event.getAai().put("generic-vnf.service-id", "e8cb8968-5411-478b-906a-f28747de72cd"); - event.getAai().put("generic-vnf.vnf-id", "63b31229-9a3a-444f-9159-04ce2dca3be9"); - event.getAai().put("generic-vnf.vnf-type", "vCPEInfraService10/vCPEInfraService10 0"); - } - event.setClosedLoopEventStatus(status); - kieSession.insert(event); - } -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopCqTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopCqTest.java deleted file mode 100644 index 88c9e6ef7..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopCqTest.java +++ /dev/null @@ -1,258 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * demo - * ================================================================================ - * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.template.demo; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.time.Instant; -import java.util.HashMap; -import java.util.UUID; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.VirtualControlLoopNotification; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.so.SoRequest; - -public class VdnsControlLoopCqTest extends ControlLoopBase implements TopicListener { - - /** - * Setup the simulator. - */ - @BeforeClass - public static void setUpBeforeClass() { - ControlLoopBase.setUpBeforeClass( - "../archetype-cl-amsterdam/src/main/resources/archetype-resources/" - + "src/main/resources/__closedLoopControlName__.drl", - "src/test/resources/yaml/policy_ControlLoop_SO_Cq-test.yaml", "type=operational", - "CL_vDNS", "v2.0"); - SupportUtil.setCustomQuery("true"); - } - - @Test - public void testSuccess() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - @Test - public void testAaiGetFail() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, "getFail"); - - try { - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - } catch (Exception e) { - e.printStackTrace(); - logger.warn(e.toString()); - fail(e.getMessage()); - } - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - /* - * (non-Javadoc) - * - * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String) - */ - @Override - public void onTopicEvent(CommInfrastructure commType, String topic, String event) { - /* - * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation - * of type active - */ - Object obj = null; - if ("POLICY-CL-MGT".equals(topic)) { - obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, - org.onap.policy.controlloop.VirtualControlLoopNotification.class); - } - assertNotNull(obj); - if (obj instanceof VirtualControlLoopNotification) { - VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj; - String policyName = notification.getPolicyName(); - if (policyName.endsWith("EVENT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue( - ControlLoopNotificationType.ACTIVE.equals(notification.getNotification())); - } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue( - ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("Sending guard query")); - } else if (policyName.endsWith("GUARD.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue( - ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().toLowerCase().endsWith("permit")); - } else if (policyName.endsWith("GUARD_PERMITTED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue( - ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=SO")); - } else if (policyName.endsWith("OPERATION.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The operation timed out"); - fail("Operation Timed Out"); - } else if (policyName.endsWith("SO.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS - .equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=SO")); - } else if (policyName.endsWith("EVENT.MANAGER")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - if ("error".equals(notification.getAai().get("vserver.vserver-name"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, - notification.getNotification()); - } else if ("getFail".equals(notification.getAai().get("vserver.vserver-name"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, - notification.getNotification()); - } else { - assertTrue(ControlLoopNotificationType.FINAL_SUCCESS - .equals(notification.getNotification())); - } - kieSession.halt(); - } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The control loop timed out"); - fail("Control Loop Timed Out"); - } - } else if (obj instanceof SoRequest) { - logger.debug("\n============ SO received the request!!! ===========\n"); - } - } - - /** - * This method is used to simulate event messages from DCAE that start the control loop (onset - * message) or end the control loop (abatement message). - * - * @param policy the controlLoopName comes from the policy - * @param requestId the requestId for this event - * @param status could be onset or abated - */ - protected void sendEvent(ControlLoopPolicy policy, UUID requestId, - ControlLoopEventStatus status) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(requestId); - event.setTarget("vserver.vserver-name"); - event.setTargetType(ControlLoopTargetType.VNF); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap<>()); - event.getAai().put("vserver.vserver-name", "OzVServer"); - event.getAai().put("vserver.is-closed-loop-disabled", "false"); - event.getAai().put("vserver.prov-status", "ACTIVE"); - event.setClosedLoopEventStatus(status); - kieSession.insert(event); - } - - protected void sendEvent(ControlLoopPolicy policy, UUID requestId, - ControlLoopEventStatus status, String vserverName) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(requestId); - event.setTarget("vserver.vserver-name"); - event.setTargetType(ControlLoopTargetType.VNF); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap<>()); - event.getAai().put("vserver.vserver-name", vserverName); - event.setClosedLoopEventStatus(status); - kieSession.insert(event); - } -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopTest.java deleted file mode 100644 index b7b034a9c..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopTest.java +++ /dev/null @@ -1,290 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * demo - * ================================================================================ - * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.template.demo; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.time.Instant; -import java.util.HashMap; -import java.util.UUID; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.VirtualControlLoopNotification; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.so.SoRequest; - -public class VdnsControlLoopTest extends ControlLoopBase implements TopicListener { - - /** - * Setup the simulator. - */ - @BeforeClass - public static void setUpBeforeClass() { - ControlLoopBase.setUpBeforeClass( - "../archetype-cl-amsterdam/src/main/resources/archetype-resources/" - + "src/main/resources/__closedLoopControlName__.drl", - "src/test/resources/yaml/policy_ControlLoop_SO-test.yaml", - "type=operational", - "CL_vDNS", - "v2.0"); - } - - @Test - public void testSuccessTest() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - @Test - public void testNamedQueryFail() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, "error"); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - @Test - public void testAaiGetFail() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, "getFail"); - - try { - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - } catch (Exception e) { - e.printStackTrace(); - logger.warn(e.toString()); - fail(e.getMessage()); - } - - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - /* - * (non-Javadoc) - * - * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String) - */ - @Override - public void onTopicEvent(CommInfrastructure commType, String topic, String event) { - /* - * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation - * of type active - */ - Object obj = null; - if ("POLICY-CL-MGT".equals(topic)) { - obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, - org.onap.policy.controlloop.VirtualControlLoopNotification.class); - } - assertNotNull(obj); - if (obj instanceof VirtualControlLoopNotification) { - VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj; - String policyName = notification.getPolicyName(); - if (policyName.endsWith("EVENT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification())); - } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("Sending guard query")); - } else if (policyName.endsWith("GUARD.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().toLowerCase().endsWith("permit")); - } else if (policyName.endsWith("GUARD_PERMITTED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=SO")); - } else if (policyName.endsWith("OPERATION.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The operation timed out"); - fail("Operation Timed Out"); - } else if (policyName.endsWith("SO.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=SO")); - } else if (policyName.endsWith("EVENT.MANAGER")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - if ("error".equals(notification.getAai().get("vserver.vserver-name"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification()); - } else if ("getFail".equals(notification.getAai().get("vserver.vserver-name"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification()); - } else { - assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.getNotification())); - } - kieSession.halt(); - } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The control loop timed out"); - fail("Control Loop Timed Out"); - } - } else if (obj instanceof SoRequest) { - logger.debug("\n============ SO received the request!!! ===========\n"); - } - } - - /** - * This method is used to simulate event messages from DCAE that start the control loop (onset - * message) or end the control loop (abatement message). - * - * @param policy the controlLoopName comes from the policy - * @param requestId the requestId for this event - * @param status could be onset or abated - */ - protected void sendEvent(ControlLoopPolicy policy, UUID requestId, ControlLoopEventStatus status) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(requestId); - event.setTarget("vserver.vserver-name"); - event.setTargetType(ControlLoopTargetType.VNF); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap<>()); - event.getAai().put("vserver.vserver-name", "OzVServer"); - event.getAai().put("vserver.is-closed-loop-disabled", "false"); - event.getAai().put("vserver.prov-status", "ACTIVE"); - event.setClosedLoopEventStatus(status); - kieSession.insert(event); - } - - protected void sendEvent(ControlLoopPolicy policy, UUID requestId, ControlLoopEventStatus status, - String vserverName) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(requestId); - event.setTarget("vserver.vserver-name"); - event.setTargetType(ControlLoopTargetType.VNF); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap<>()); - event.getAai().put("vserver.vserver-name", vserverName); - event.setClosedLoopEventStatus(status); - kieSession.insert(event); - } -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java deleted file mode 100644 index 4f472a07b..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java +++ /dev/null @@ -1,247 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * demo - * ================================================================================ - * Copyright (C) 2017-2018 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.template.demo; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.time.Instant; -import java.util.HashMap; -import java.util.UUID; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.VirtualControlLoopNotification; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.vfc.VfcRequest; - - -public class VfcControlLoopTest extends ControlLoopBase implements TopicListener { - - /** - * Setup the simulator. - */ - @BeforeClass - public static void setUpBeforeClass() { - ControlLoopBase.setUpBeforeClass( - "../archetype-cl-amsterdam/src/main/resources/archetype-resources/" - + "src/main/resources/__closedLoopControlName__.drl", - "src/test/resources/yaml/policy_ControlLoop_VFC.yaml", - "type=operational", - "CL_VoLTE", - "v2.0"); - } - - @Test - public void testSuccess() throws IOException { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - @Test - public void testNullRequest() throws IOException { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(pair.first.getControlLoop().getControlLoopName()); - event.setRequestId(UUID.randomUUID()); - event.setClosedLoopEventClient("tca.instance00009"); - event.setTargetType(ControlLoopTargetType.VM); - event.setTarget("vserver.vserver-name"); - event.setFrom("DCAE"); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap()); - event.getAai().put("vserver.vserver-name", "nullRequest"); - event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); - kieSession.insert(event); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - /* - * (non-Javadoc) - * - * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String) - */ - @Override - public void onTopicEvent(CommInfrastructure commType, String topic, String event) { - /* - * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation - * of type active - */ - Object obj = null; - if ("POLICY-CL-MGT".equals(topic)) { - obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, - org.onap.policy.controlloop.VirtualControlLoopNotification.class); - } - assertNotNull(obj); - if (obj instanceof VirtualControlLoopNotification) { - VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj; - String policyName = notification.getPolicyName(); - if (policyName.endsWith("EVENT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification())); - } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("Sending guard query")); - } else if (policyName.endsWith("GUARD.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().toLowerCase().endsWith("permit")); - } else if (policyName.endsWith("GUARD_PERMITTED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=VFC")); - } else if (policyName.endsWith("OPERATION.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The operation timed out"); - fail("Operation Timed Out"); - } else if (policyName.endsWith("VFC.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=VFC")); - } else if (policyName.endsWith("EVENT.MANAGER")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - if ("nullRequest".equals(notification.getAai().get("vserver.vserver-name"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification()); - } else { - assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.getNotification()); - } - kieSession.halt(); - } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The control loop timed out"); - fail("Control Loop Timed Out"); - } - } else if (obj instanceof VfcRequest) { - logger.debug("\n============ VFC received the request!!! ===========\n"); - } - } - - /** - * This method is used to simulate event messages from DCAE that start the control loop (onset - * message) or end the control loop (abatement message). - * - * @param policy the controlLoopName comes from the policy - * @param requestId the requestId for this event - * @param status could be onset or abated - */ - protected void sendEvent(ControlLoopPolicy policy, UUID requestId, ControlLoopEventStatus status) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(UUID.randomUUID()); - event.setClosedLoopEventClient("tca.instance00009"); - event.setTargetType(ControlLoopTargetType.VM); - event.setTarget("vserver.vserver-name"); - event.setFrom("DCAE"); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap()); - event.getAai().put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1"); - event.getAai().put("vserver.vserver-id", "vserver-id-16102016-aai3255-data-11-1"); - event.getAai().put("generic-vnf.vnf-id", "vnf-id-16102016-aai3255-data-11-1"); - event.getAai().put("service-instance.service-instance-id", "service-instance-id-16102016-aai3255-data-11-1"); - event.getAai().put("vserver.is-closed-loop-disabled", "false"); - event.getAai().put("vserver.prov-status", "ACTIVE"); - event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); - kieSession.insert(event); - } -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopCdsTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopCdsTest.java deleted file mode 100644 index c480db71e..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopCdsTest.java +++ /dev/null @@ -1,273 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Bell Canada. - * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.template.demo; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import io.grpc.Server; -import io.grpc.ServerBuilder; -import io.grpc.stub.StreamObserver; - -import java.io.IOException; -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicReference; - -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; -import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType; -import org.onap.ccsdk.cds.controllerblueprints.common.api.Status; -import org.onap.ccsdk.cds.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc; -import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput; -import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceOutput; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.VirtualControlLoopNotification; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.controlloop.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Test class for vfirewall use case using CDS actor. - */ -public class VfwControlLoopCdsTest extends ControlLoopBase implements TopicListener { - - private static final Logger LOGGER = LoggerFactory.getLogger(VfwControlLoopCdsTest.class); - - private final AtomicReference> responseObserverRef = new AtomicReference<>(); - private Server server; - - /** - * Setup the simulator. - */ - @BeforeClass - public static void setUpBeforeClass() { - ControlLoopBase.setUpBeforeClass("../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/" - + "main/resources/__closedLoopControlName__.drl", - "src/test/resources/yaml/policy_ControlLoop_vFW_CDS.yaml", - "service=ServiceDemo;resource=Res1Demo;type=operational", "CL_vFW", - "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0"); - SupportUtil.setCustomQuery("true"); - } - - @Before - public void setUp() throws IOException { - this.startGrpcServer(); - } - - @After - public void tearDown() { - this.stopGrpcServer(); - } - - private void startGrpcServer() throws IOException { - - BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase cdsBlueprintServerImpl = - - new BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() { - - @Override - public StreamObserver process( - final StreamObserver responseObserver) { - - responseObserverRef.set(responseObserver); - - return new StreamObserver() { - @Override - public void onNext(final ExecutionServiceInput input) { - LOGGER.info("gRPC server onNext() for input: {} ...", input); - ExecutionServiceOutput output = - ExecutionServiceOutput.newBuilder() - .setCommonHeader( - CommonHeader.newBuilder().setRequestId( - input.getCommonHeader().getRequestId()).build()) - .setStatus( - Status.newBuilder().setEventType( - EventType.EVENT_COMPONENT_EXECUTED).build()) - .build(); - responseObserver.onNext(output); - } - - @Override - public void onError(final Throwable throwable) { - LOGGER.error("gRPC server onError() for throwable: {} ...", throwable); - } - - @Override - public void onCompleted() { - LOGGER.info("gRPC server onCompleted() ..."); - responseObserver.onCompleted(); - } - }; - } - }; - - server = ServerBuilder.forPort(SupportUtil.GRPC_SERVER_PORT).addService(cdsBlueprintServerImpl).build().start(); - LOGGER.info("gRPC server is listening for CDS requests on port {}", SupportUtil.GRPC_SERVER_PORT); - - } - - private void stopGrpcServer() { - if (server != null) { - this.server.shutdown(); - LOGGER.info("gRPC server handling CDS requests has been successfully shut down."); - } - } - - @Test - public void testSuccess() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET); - - kieSession.fireUntilHalt(); - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - - /* - * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String) - */ - @Override - public void onTopicEvent(CommInfrastructure commType, String topic, String event) { - /* - * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNotification - * of type active - */ - assertEquals("POLICY-CL-MGT", topic); - VirtualControlLoopNotification notification = - Serialization.gsonJunit.fromJson(event, VirtualControlLoopNotification.class); - assertNotNull(notification); - String policyName = notification.getPolicyName(); - if (policyName.endsWith("EVENT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification()); - } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertEquals(ControlLoopNotificationType.OPERATION, notification.getNotification()); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("Sending guard query")); - } else if (policyName.endsWith("GUARD.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertEquals(ControlLoopNotificationType.OPERATION, notification.getNotification()); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().toLowerCase().endsWith("permit")); - } else if (policyName.endsWith("GUARD_PERMITTED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertEquals(ControlLoopNotificationType.OPERATION, notification.getNotification()); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=CDS")); - } else if (policyName.endsWith("OPERATION.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The operation timed out"); - fail("Operation Timed Out"); - } else if (policyName.endsWith("CDS.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertEquals(ControlLoopNotificationType.OPERATION_SUCCESS, notification.getNotification()); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=CDS")); - sendEvent(pair.first, requestId, ControlLoopEventStatus.ABATED); - } else if (policyName.endsWith("EVENT.MANAGER")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - if ("error".equals(notification.getAai().get("generic-vnf.vnf-name"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification()); - assertEquals("Target vnf-id could not be found", notification.getMessage()); - } else if ("getFail".equals(notification.getAai().get("generic-vnf.vnf-name"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification()); - } else { - assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.getNotification()); - } - kieSession.halt(); - } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The control loop timed out"); - fail("Control Loop Timed Out"); - } - } - - /** - * This method is used to simulate event messages from DCAE that start the control loop (onset - * message) or end the control loop (abatement message). - * - * @param policy the controlLoopName comes from the policy - * @param requestId the requestId for this event - * @param status could be onset or abated - */ - private void sendEvent(ControlLoopPolicy policy, UUID requestId, ControlLoopEventStatus status) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(requestId); - event.setTargetType(ControlLoopTargetType.VNF); - event.setTarget("generic-vnf.vnf-name"); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap<>()); - event.getAai().put("generic-vnf.vnf-name", "testGenericVnfID"); - event.getAai().put("vserver.vserver-name", "OzVServer"); - event.setClosedLoopEventStatus(status); - Map map = new HashMap<>(); - map.put("my-key", "my-value"); - event.setAdditionalEventParams(map); - kieSession.insert(event); - } - -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopTest.java deleted file mode 100644 index 09c5927a8..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopTest.java +++ /dev/null @@ -1,317 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * demo - * ================================================================================ - * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.template.demo; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.time.Instant; -import java.util.HashMap; -import java.util.UUID; -import org.junit.BeforeClass; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; -import org.onap.policy.appc.Request; -import org.onap.policy.appc.Response; -import org.onap.policy.appc.ResponseCode; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.VirtualControlLoopNotification; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class VfwControlLoopTest extends ControlLoopBase implements TopicListener { - - /** - * Setup the simulator. - */ - @BeforeClass - public static void setUpBeforeClass() { - ControlLoopBase.setUpBeforeClass( - "../archetype-cl-amsterdam/src/main/resources/archetype-resources/src/" - + "main/resources/__closedLoopControlName__.drl", - "src/test/resources/yaml/policy_ControlLoop_vFW.yaml", - "service=ServiceDemo;resource=Res1Demo;type=operational", - "CL_vFW", - "org.onap.closed_loop.ServiceDemo:VNFS:1.0.0"); - } - - @Test - public void testASuccess() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET); - - try { - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - } catch (Exception e) { - e.printStackTrace(); - logger.warn(e.toString()); - fail("fail"); - } - - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - @Test - public void testBAaiFail() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an event ready - * to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, "error"); - try { - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - } catch (Exception e) { - e.printStackTrace(); - logger.warn(e.toString()); - fail(e.getMessage()); - } - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off processing - * through the rules - */ - - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, "getFail"); - - try { - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - } catch (Exception e) { - e.printStackTrace(); - logger.warn(e.toString()); - fail(e.getMessage()); - } - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - } - - /* - * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String) - */ - @Override - public void onTopicEvent(CommInfrastructure commType, String topic, String event) { - /* - * Pull the object that was sent out to DMAAP and make sure it is a ControlLoopNoticiation - * of type active - */ - Object obj = null; - if ("POLICY-CL-MGT".equals(topic)) { - obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, - org.onap.policy.controlloop.VirtualControlLoopNotification.class); - } else if ("APPC-CL".equals(topic)) { - obj = org.onap.policy.appc.util.Serialization.gsonPretty.fromJson(event, - org.onap.policy.appc.Request.class); - } - assertNotNull(obj); - if (obj instanceof VirtualControlLoopNotification) { - VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj; - String policyName = notification.getPolicyName(); - if (policyName.endsWith("EVENT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.ACTIVE.equals(notification.getNotification())); - } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("Sending guard query")); - } else if (policyName.endsWith("GUARD.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().toLowerCase().endsWith("permit")); - } else if (policyName.endsWith("GUARD_PERMITTED")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=APPC")); - } else if (policyName.endsWith("OPERATION.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The operation timed out"); - fail("Operation Timed Out"); - } else if (policyName.endsWith("APPC.RESPONSE")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - assertTrue(ControlLoopNotificationType.OPERATION_SUCCESS.equals(notification.getNotification())); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=APPC")); - sendEvent(pair.first, requestId, ControlLoopEventStatus.ABATED); - } else if (policyName.endsWith("EVENT.MANAGER")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - if ("error".equals(notification.getAai().get("generic-vnf.vnf-name"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification()); - assertEquals("Target vnf-id could not be found", notification.getMessage()); - } else if ("getFail".equals(notification.getAai().get("generic-vnf.vnf-name"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification()); - } else { - assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.getNotification())); - } - kieSession.halt(); - } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) { - logger.debug("Rule Fired: " + notification.getPolicyName()); - kieSession.halt(); - logger.debug("The control loop timed out"); - fail("Control Loop Timed Out"); - } - } else if (obj instanceof Request) { - assertTrue(((Request) obj).getCommonHeader().getSubRequestId().equals("1")); - assertNotNull(((Request) obj).getPayload().get("generic-vnf.vnf-id")); - - logger.debug("\n============ APPC received the request!!! ===========\n"); - - /* - * Simulate a success response from APPC and insert the response into the working memory - */ - Response appcResponse = new Response((Request) obj); - appcResponse.getStatus().setCode(ResponseCode.SUCCESS.getValue()); - appcResponse.getStatus().setValue("SUCCESS"); - kieSession.insert(appcResponse); - } - } - - /** - * This method is used to simulate event messages from DCAE that start the control loop (onset - * message) or end the control loop (abatement message). - * - * @param policy the controlLoopName comes from the policy - * @param requestId the requestId for this event - * @param status could be onset or abated - */ - protected void sendEvent(ControlLoopPolicy policy, UUID requestId, ControlLoopEventStatus status) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(requestId); - event.setTarget("generic-vnf.vnf-name"); - event.setTargetType(ControlLoopTargetType.VNF); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap<>()); - event.getAai().put("generic-vnf.vnf-name", "testGenericVnfID"); - event.getAai().put("vserver.vserver-name", "testVserverName"); - event.setClosedLoopEventStatus(status); - kieSession.insert(event); - } - - /** - * This method is used to simulate event messages from DCAE that start the control loop (onset - * message) or end the control loop (abatement message). - * - * @param policy the controlLoopName comes from the policy - * @param requestId the requestId for this event - * @param status could be onset or abated - */ - protected void sendEvent(ControlLoopPolicy policy, UUID requestId, ControlLoopEventStatus status, String vnfId) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(requestId); - event.setTarget("generic-vnf.vnf-name"); - event.setTargetType(ControlLoopTargetType.VNF); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap<>()); - event.getAai().put("generic-vnf.vnf-name", vnfId); - event.getAai().put("vserver.vserver-name", vnfId); - event.setClosedLoopEventStatus(status); - kieSession.insert(event); - } -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VpciControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VpciControlLoopTest.java deleted file mode 100644 index e57af7760..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VpciControlLoopTest.java +++ /dev/null @@ -1,284 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * demo - * ================================================================================ - * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.template.demo; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.time.Instant; -import java.util.HashMap; -import java.util.UUID; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.VirtualControlLoopNotification; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.sdnr.PciRequest; -import org.onap.policy.sdnr.PciRequestWrapper; -import org.onap.policy.sdnr.PciResponse; -import org.onap.policy.sdnr.PciResponseWrapper; - -public class VpciControlLoopTest extends ControlLoopBase implements TopicListener { - - /** - * Setup the simulator. - */ - @BeforeClass - public static void setUpBeforeClass() { - ControlLoopBase.setUpBeforeClass( - "../archetype-cl-amsterdam/src/main/resources/archetype-resources" - + "/src/main/resources/__closedLoopControlName__.drl", - "src/test/resources/yaml/policy_ControlLoop_vPCI.yaml", - "type=operational", - "CL_vPCI", - "v3.0.0"); - } - - @Test - public void testSuccess() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an - * event ready to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off - * processing through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, true); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - - } - - @Test - public void testAaiGetFail() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an - * event ready to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off - * processing through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, false); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - - } - - /* - * (non-Javadoc) - * - * @see - * org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang. - * String) - */ - @Override - public void onTopicEvent(CommInfrastructure commType, String topic, String event) { - logger.debug("\n============ onTopicEvent!!! ===========\n"); - logger.debug("topic: {}, event: {}", topic, event); - /* - * Pull the object that was sent out to DMAAP and make sure it is a - * ControlLoopNoticiation of type active - */ - Object obj = null; - if ("POLICY-CL-MGT".equals(topic)) { - obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, - org.onap.policy.controlloop.VirtualControlLoopNotification.class); - } else if ("SDNR-CL".equals(topic)) { - obj = org.onap.policy.sdnr.util.Serialization.gsonJunit.fromJson(event, - org.onap.policy.sdnr.PciRequestWrapper.class); - } - assertNotNull(obj); - if (obj instanceof VirtualControlLoopNotification) { - VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj; - String policyName = notification.getPolicyName(); - logger.debug("Rule Fired: {}", policyName); - if (policyName.endsWith("EVENT")) { - assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification()); - } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) { - assertEquals(ControlLoopNotificationType.OPERATION, notification.getNotification()); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("Sending guard query")); - } else if (policyName.endsWith("GUARD.RESPONSE")) { - assertEquals(ControlLoopNotificationType.OPERATION, notification.getNotification()); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().toLowerCase().endsWith("permit")); - } else if (policyName.endsWith("GUARD_PERMITTED")) { - assertEquals(ControlLoopNotificationType.OPERATION, notification.getNotification()); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=SDNR")); - } else if (policyName.endsWith("OPERATION.TIMEOUT")) { - kieSession.halt(); - logger.debug("The operation timed out"); - fail("Operation Timed Out"); - } else if (policyName.endsWith("SDNR.RESPONSE")) { - assertEquals(ControlLoopNotificationType.OPERATION_SUCCESS, notification.getNotification()); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=SDNR")); - } else if (policyName.endsWith("EVENT.MANAGER")) { - if ("getFail".equals(notification.getAai().get("generic-vnf.vnf-id"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification()); - kieSession.halt(); - } else { - assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.getNotification()); - kieSession.halt(); - } - } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) { - kieSession.halt(); - logger.debug("The control loop timed out"); - fail("Control Loop Timed Out"); - } - } else if (obj instanceof PciRequestWrapper) { - /* - * The request should be of type PciRequestWrapper and the subrequestid should - * be 1 - */ - PciRequestWrapper dmaapRequest = (PciRequestWrapper) obj; - PciRequest pciRequest = dmaapRequest.getBody(); - assertEquals("1", pciRequest.getCommonHeader().getSubRequestId()); - - logger.debug("\n============ SDNR received the request!!! ===========\n"); - logger.debug("\n============ dmaapRequest ===========\n {} ", dmaapRequest); - logger.debug("\n============ pciRequest ===========\n {}", pciRequest); - - /* - * Simulate a success response from SDNR and insert the response into the - * working memory - */ - PciResponse pciResponse = new PciResponse(pciRequest); - pciResponse.getStatus().setCode(200); - pciResponse.getStatus().setValue("SUCCESS"); - StringBuilder sb = new StringBuilder(); - sb.append("{ \"Configurations\":[ { \"Status\": { \"Code\": 200, \"Value\":" - + " \"SUCCESS\" }, \"data\":{ \"FAPService\":{ \"alias\":" - + "\"Network1\", \"X0005b9Lte\" : { \"PnfName\" : \"cu1\" }, \"CellConfig\":" - + "{ \"LTE\":{ \"RAN\":{ \"Common\":{ \"CellIdentity\":" + "\"1\" } } } } } } } ] }"); - - pciResponse.setPayload(sb.toString()); - PciResponseWrapper dmaapResponse = new PciResponseWrapper(); - dmaapResponse.setBody(pciResponse); - dmaapResponse.setType("response"); - logger.debug("\n============ SDNR sending response!!! ===========\n"); - logger.debug("\n============ dmaapResponse ===========\n {}", dmaapResponse); - logger.debug("\n============ pciResponse ===========\n {}", pciResponse); - kieSession.insert(dmaapResponse); - } - } - - /** - * This method is used to simulate event messages from DCAE that start the - * control loop (onset message). - * - * @param policy - * the controlLoopName comes from the policy - * @param requestId - * the requestId for this event - * @param status - * could be onset - */ - protected void sendEvent(ControlLoopPolicy policy, UUID requestId, ControlLoopEventStatus status, - boolean isEnriched) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(requestId); - event.setTarget("generic-vnf.vnf-id"); - event.setTargetType(ControlLoopTargetType.VNF); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap<>()); - if (isEnriched) { - event.getAai().put("generic-vnf.is-closed-loop-disabled", "false"); - event.getAai().put("generic-vnf.prov-status", "ACTIVE"); - event.getAai().put("generic-vnf.vnf-id", "notused"); - event.getAai().put("vserver.vserver-name", "OzVServer"); - } else { - event.getAai().put("generic-vnf.vnf-id", "getFail"); - } - event.setClosedLoopEventStatus(status); - StringBuilder sb = new StringBuilder(); - sb.append("{ \"Configurations\":[ { \"data\":{ \"FAPService\":" - + " { \"alias\":\"Cell1\", \"X0005b9Lte\" : { \"PhyCellIdInUse\" :" - + " \"35\", \"PnfName\" : \"cu1\" }, \"CellConfig\":{ \"LTE\":{ \"RAN\":" - + "{ \"Common\":{ \"CellIdentity\":\"1\" } } } } } } } ] }"); - - event.setPayload(sb.toString()); - logger.debug("\n============ Policy receiving ONSET event !!! ===========\n"); - logger.debug("\n============ event ===========\n {}", event); - kieSession.insert(event); - } -} diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VsonhControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VsonhControlLoopTest.java deleted file mode 100644 index 5aaab40bb..000000000 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VsonhControlLoopTest.java +++ /dev/null @@ -1,291 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * demo - * ================================================================================ - * Copyright (C) 2019 Wipro Limited Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.template.demo; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.time.Instant; -import java.util.HashMap; -import java.util.UUID; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicListener; -import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.controlloop.ControlLoopEventStatus; -import org.onap.policy.controlloop.ControlLoopNotificationType; -import org.onap.policy.controlloop.ControlLoopTargetType; -import org.onap.policy.controlloop.VirtualControlLoopEvent; -import org.onap.policy.controlloop.VirtualControlLoopNotification; -import org.onap.policy.controlloop.policy.ControlLoopPolicy; -import org.onap.policy.sdnr.PciRequest; -import org.onap.policy.sdnr.PciRequestWrapper; -import org.onap.policy.sdnr.PciResponse; -import org.onap.policy.sdnr.PciResponseWrapper; - -public class VsonhControlLoopTest extends ControlLoopBase implements TopicListener { - - /** - * Setup the simulator. - */ - @BeforeClass - public static void setUpBeforeClass() { - ControlLoopBase.setUpBeforeClass( - "../archetype-cl-amsterdam/src/main/resources/archetype-resources" - + "/src/main/resources/__closedLoopControlName__.drl", - "src/test/resources/yaml/policy_ControlLoop_vSONH.yaml", - "type=operational", - "CL_vSONH", - "v4.0.0"); - } - - @Test - public void testSuccess() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an - * event ready to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off - * processing through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, true); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - - } - - @Test - public void testAaiGetFailTest() { - - /* - * Allows the PolicyEngine to callback to this object to notify that there is an - * event ready to be pulled from the queue - */ - for (TopicSink sink : noopTopics) { - assertTrue(sink.start()); - sink.register(this); - } - - /* - * Create a unique requestId - */ - requestId = UUID.randomUUID(); - - /* - * Simulate an onset event the policy engine will receive from DCAE to kick off - * processing through the rules - */ - sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, false); - - kieSession.fireUntilHalt(); - - // allow object clean-up - kieSession.fireAllRules(); - - /* - * The only fact in memory should be Params - */ - assertEquals(1, kieSession.getFactCount()); - - /* - * Print what's left in memory - */ - dumpFacts(kieSession); - - } - - /* - * (non-Javadoc) - * - * @see - * org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang. - * String) - */ - @Override - public void onTopicEvent(CommInfrastructure commType, String topic, String event) { - logger.debug("\n============ onTopicEvent!!! ===========\n"); - logger.debug("topic: {}, event: {}", topic, event); - /* - * Pull the object that was sent out to DMAAP and make sure it is a - * ControlLoopNoticiation of type active - */ - Object obj = null; - if ("POLICY-CL-MGT".equals(topic)) { - obj = org.onap.policy.controlloop.util.Serialization.gsonJunit.fromJson(event, - org.onap.policy.controlloop.VirtualControlLoopNotification.class); - } else if ("SDNR-CL".equals(topic)) { - obj = org.onap.policy.sdnr.util.Serialization.gsonJunit.fromJson(event, - org.onap.policy.sdnr.PciRequestWrapper.class); - } - assertNotNull(obj); - if (obj instanceof VirtualControlLoopNotification) { - VirtualControlLoopNotification notification = (VirtualControlLoopNotification) obj; - String policyName = notification.getPolicyName(); - logger.debug("Rule Fired: {}", policyName); - if (policyName.endsWith("EVENT")) { - assertEquals(ControlLoopNotificationType.ACTIVE, notification.getNotification()); - } else if (policyName.endsWith("GUARD_NOT_YET_QUERIED")) { - assertEquals(ControlLoopNotificationType.OPERATION, notification.getNotification()); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("Sending guard query")); - } else if (policyName.endsWith("GUARD.RESPONSE")) { - assertEquals(ControlLoopNotificationType.OPERATION, notification.getNotification()); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().toLowerCase().endsWith("permit")); - } else if (policyName.endsWith("GUARD_PERMITTED")) { - assertEquals(ControlLoopNotificationType.OPERATION, notification.getNotification()); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=SDNR")); - } else if (policyName.endsWith("OPERATION.TIMEOUT")) { - kieSession.halt(); - logger.debug("The operation timed out"); - fail("Operation Timed Out"); - } else if (policyName.endsWith("SDNR.RESPONSE")) { - assertEquals(ControlLoopNotificationType.OPERATION_SUCCESS, notification.getNotification()); - assertNotNull(notification.getMessage()); - assertTrue(notification.getMessage().startsWith("actor=SDNR")); - } else if (policyName.endsWith("EVENT.MANAGER")) { - if ("getFail".equals(notification.getAai().get("generic-vnf.vnf-id"))) { - assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.getNotification()); - kieSession.halt(); - } else { - assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.getNotification()); - kieSession.halt(); - } - } else if (policyName.endsWith("EVENT.MANAGER.TIMEOUT")) { - kieSession.halt(); - logger.debug("The control loop timed out"); - fail("Control Loop Timed Out"); - } - } else if (obj instanceof PciRequestWrapper) { - /* - * The request should be of type PciRequestWrapper and the subrequestid should - * be 1 - */ - PciRequestWrapper dmaapRequest = (PciRequestWrapper) obj; - PciRequest pciRequest = dmaapRequest.getBody(); - assertEquals("1", pciRequest.getCommonHeader().getSubRequestId()); - - logger.debug("\n============ SDNR received the request!!! ===========\n"); - logger.debug("\n============ dmaapRequest ===========\n {} ", dmaapRequest); - logger.debug("\n============ pciRequest ===========\n {}", pciRequest); - - /* - * Simulate a success response from SDNR and insert the response into the - * working memory - */ - PciResponse pciResponse = new PciResponse(pciRequest); - pciResponse.getStatus().setCode(200); - pciResponse.getStatus().setValue("SUCCESS"); - StringBuilder sb = new StringBuilder(); - sb.append("{ \"Configurations\":[ { \"Status\": { \"Code\": 200, \"Value\":" - + " \"SUCCESS\" }, \"data\":{ \"FAPService\":{ \"alias\":" - + "\"Network1\", \"CellConfig\":{ \"LTE\":{ \"RAN\":{ \"Common\":" - + "{ \"CellIdentity\":\"1\" }, \"NeighborListInUse\" : " - + "{ \"LTECellNumberOfEntries\" : \"1\" , \"LTECell\" : " - + "[ { \"PLMNID\" :\"plmnid1\", \"CID\":\"Chn0001\", \"PhyCellID\":" - + "\"3\", \"PNFName\":\"ncserver01\", \"Blacklisted\":\"false\" " - + "} ] } } } } } } } ] }"); - - pciResponse.setPayload(sb.toString()); - PciResponseWrapper dmaapResponse = new PciResponseWrapper(); - dmaapResponse.setBody(pciResponse); - dmaapResponse.setType("response"); - logger.debug("\n============ SDNR sending response!!! ===========\n"); - logger.debug("\n============ dmaapResponse ===========\n {}", dmaapResponse); - logger.debug("\n============ pciResponse ===========\n {}", pciResponse); - kieSession.insert(dmaapResponse); - } - } - - /** - * This method is used to simulate event messages from DCAE that start the - * control loop (onset message). - * - * @param policy - * the controlLoopName comes from the policy - * @param requestId - * the requestId for this event - * @param status - * could be onset - */ - protected void sendEvent(ControlLoopPolicy policy, UUID requestId, ControlLoopEventStatus status, - boolean isEnriched) { - VirtualControlLoopEvent event = new VirtualControlLoopEvent(); - event.setClosedLoopControlName(policy.getControlLoop().getControlLoopName()); - event.setRequestId(requestId); - event.setTarget("generic-vnf.vnf-id"); - event.setTargetType(ControlLoopTargetType.VNF); - event.setClosedLoopAlarmStart(Instant.now()); - event.setAai(new HashMap<>()); - if (isEnriched) { - event.getAai().put("generic-vnf.is-closed-loop-disabled", "false"); - event.getAai().put("generic-vnf.prov-status", "ACTIVE"); - event.getAai().put("generic-vnf.vnf-id", "notused"); - event.getAai().put("vserver.vserver-name", "OzVServer"); - } else { - event.getAai().put("generic-vnf.vnf-id", "getFail"); - } - event.setClosedLoopEventStatus(status); - StringBuilder sb = new StringBuilder(); - sb.append("{ \"Configurations\":[ { \"data\":{ \"FAPService\":" - + " { \"alias\":\"Cell1\", \"CellConfig\":{ \"LTE\":{ \"RAN\":{ \"Common\":" - + "{ \"CellIdentity\":\"1\" }, \"NeighborListInUse\" : " - + "{ \"LTECellNumberOfEntries\" : \"1\" , \"LTECell\" : " - + "[ { \"PLMNID\" :\"plmnid1\", \"CID\":\"Chn0001\", \"PhyCellID\":" - + "\"3\", \"PNFName\":\"ncserver01\", \"Blacklisted\":\"false\" " - + "} ] } } } } } } } ] }"); - - event.setPayload(sb.toString()); - logger.debug("\n============ Policy receiving ONSET event !!! ===========\n"); - logger.debug("\n============ event ===========\n {}", event); - kieSession.insert(event); - } -} diff --git a/controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml b/controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml deleted file mode 100644 index b6d80e099..000000000 --- a/controlloop/templates/template.demo/src/test/resources/META-INF/persistence.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - org.eclipse.persistence.jpa.PersistenceProvider - - org.onap.policy.database.operationshistory.Dbao - - - - - - - - - - - - - - - diff --git a/controlloop/templates/template.demo/src/test/resources/xacml/xacml_guard.properties b/controlloop/templates/template.demo/src/test/resources/xacml/xacml_guard.properties deleted file mode 100644 index 175b9d3d2..000000000 --- a/controlloop/templates/template.demo/src/test/resources/xacml/xacml_guard.properties +++ /dev/null @@ -1,72 +0,0 @@ -### -# ============LICENSE_START======================================================= -# ONAP -# ================================================================================ -# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### -# -# -# This files defines PIPs that will be used by XACML Guard Policies. One PIP per time window (5 min, 10min,...,1 month). -# -# -# - -# -# Default XACML Properties File -# Standard API Factories -# -xacml.dataTypeFactory=com.att.research.xacml.std.StdDataTypeFactory -xacml.pdpEngineFactory=com.att.research.xacmlatt.pdp.ATTPDPEngineFactory -xacml.pepEngineFactory=com.att.research.xacml.std.pep.StdEngineFactory -xacml.pipFinderFactory=com.att.research.xacml.std.pip.StdPIPFinderFactory -xacml.traceEngineFactory=com.att.research.xacml.std.trace.LoggingTraceEngineFactory -# -# AT&T PDP Implementation Factories -# -xacml.att.evaluationContextFactory=com.att.research.xacmlatt.pdp.std.StdEvaluationContextFactory -xacml.att.combiningAlgorithmFactory=com.att.research.xacmlatt.pdp.std.StdCombiningAlgorithmFactory -xacml.att.functionDefinitionFactory=com.att.research.xacmlatt.pdp.std.StdFunctionDefinitionFactory -xacml.att.policyFinderFactory=com.att.research.xacmlatt.pdp.std.StdPolicyFinderFactory - - -# -# NOTE: If you are testing against a RESTful PDP, then the PDP must be configured with the -# policies and PIP configuration as defined below. Otherwise, this is the configuration that -# the embedded PDP uses. -# - -# In case we have multiple applicable Guard policies, we will deny if any of them denies. -xacml.att.policyFinderFactory.combineRootPolicies=urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:permit-unless-deny - - -# Policies to load -# -xacml.rootPolicies=p1,p2,p3,p4,p5 -p1.file=src/test/resources/xacml/autogenerated_frequency_limiter_restart.xml -p2.file=src/test/resources/xacml/autogenerated_frequency_limiter_rebuild.xml -p3.file=src/test/resources/xacml/autogenerated_frequency_limiter_migrate.xml -p4.file=src/test/resources/xacml/autogenerated_frequency_limiter_rebuild_1.xml -p5.file=src/test/resources/xacml/autogenerated_blacklist.xml - - -# PIP Engine Definition -# -xacml.pip.engines=count-recent-operations -count-recent-operations.classname=org.onap.policy.pdp.xacml.application.common.operationshistory.CountRecentOperationsPip -count-recent-operations.issuer=urn:org:onap:xacml:guard:count-recent-operations -count-recent-operations.name=CountRecentOperations -count-recent-operations.description=Returns operation counts based on time window -count-recent-operations.persistenceunit=OperationsHistoryPUTest diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_CCVPN.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_CCVPN.yaml deleted file mode 100644 index 176c1dc0e..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_CCVPN.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (C) 2018 Huawei. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-CCVPN-2179b738-fd36-4843-a71a-a8c24c70c66b - trigger_policy: unique-policy-id-16-Reroute - timeout: 3600 - abatement: false - -policies: - - id: unique-policy-id-16-Reroute - name: Connectivity Reroute - description: - actor: SDNC - recipe: Reroute - 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 - diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_CCVPN_BW.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_CCVPN_BW.yaml deleted file mode 100644 index f994d4104..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_CCVPN_BW.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-CCVPN-2179b738-fd36-4843-a71a-a8c24c70c22b - trigger_policy: unique-policy-id-16-BandwidthOnDemand - timeout: 3600 - abatement: false - -policies: - - id: unique-policy-id-16-BandwidthOnDemand - name: CCVPNBandwidthOnDemand - description: - actor: SDNC - recipe: BandwidthOnDemand - 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 - diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test-B.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test-B.yaml deleted file mode 100644 index 498ef766e..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test-B.yaml +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-Event-Cleanup-Test-B - services: - - serviceInvariantUUID: 5cfe6f4a-41bc-4247-8674-ebd4b98e35cc - serviceUUID: 0f40bba5-986e-4b3c-803f-ddd1b7b25f24 - serviceName: 57e66ea7-0ed6-45c7-970f - trigger_policy: unique-policy-id-1-modifyConfig - timeout: 60 - abatement: true - -policies: - - id: unique-policy-id-1-modifyConfig - name: modify packet gen config - description: - actor: APPC - recipe: ModifyConfig - target: - resourceID: Eace933104d443b496b8.nodes.heat.vpg - type: VNF - retry: 0 - timeout: 30 - 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/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test.yaml deleted file mode 100644 index a19b0ef6b..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test.yaml +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-Event-Cleanup-Test - services: - - serviceInvariantUUID: 5cfe6f4a-41bc-4247-8674-ebd4b98e35cc - serviceUUID: 0f40bba5-986e-4b3c-803f-ddd1b7b25f24 - serviceName: 57e66ea7-0ed6-45c7-970f - trigger_policy: unique-policy-id-1-modifyConfig - timeout: 60 - abatement: true - -policies: - - id: unique-policy-id-1-modifyConfig - name: modify packet gen config - description: - actor: APPC - recipe: ModifyConfig - target: - resourceID: Eace933104d443b496b8.nodes.heat.vpg - type: VNF - retry: 0 - timeout: 30 - 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/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test2.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test2.yaml deleted file mode 100644 index 57062a47a..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_EventCleanup-test2.yaml +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# This YAML must be slightly different from test.yaml. -# -controlLoop: - version: 3.0.0 - controlLoopName: ControlLoop-Event-Cleanup-Test - services: - - serviceInvariantUUID: 5cfe6f4a-41bc-4247-8674-ebd4b98e35cc - serviceUUID: 0f40bba5-986e-4b3c-803f-ddd1b7b25f24 - serviceName: 57e66ea7-0ed6-45c7-970f - trigger_policy: unique-policy-id-1-modifyConfig - timeout: 60 - abatement: true - -policies: - - id: unique-policy-id-1-modifyConfig - name: modify packet gen config - description: - actor: APPC - recipe: ModifyConfig - target: - resourceID: Eace933104d443b496b8.nodes.heat.vpg - type: VNF - retry: 0 - timeout: 30 - 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/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test-B.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test-B.yaml deleted file mode 100644 index e19cb498e..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test-B.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-Params-Cleanup-Test-B - trigger_policy: unique-policy-id-1-scale-up - timeout: 60 - -policies: - - id: unique-policy-id-1-scale-up - name: Create a new VF Module - description: - actor: SO - recipe: VF Module Create - target: - type: VNF - retry: 0 - timeout: 30 - 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 diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test.yaml deleted file mode 100644 index 6d89d58c4..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-Params-Cleanup-Test - trigger_policy: unique-policy-id-1-scale-up - timeout: 60 - -policies: - - id: unique-policy-id-1-scale-up - name: Create a new VF Module - description: - actor: SO - recipe: VF Module Create - target: - type: VNF - retry: 0 - timeout: 30 - 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 diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test2.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test2.yaml deleted file mode 100644 index 358bbfbea..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_ParamsCleanup-test2.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# -# This YAML must be slightly different from test.yaml. -# -controlLoop: - version: 3.0.0 - controlLoopName: ControlLoop-Params-Cleanup-Test - trigger_policy: unique-policy-id-1-scale-up - timeout: 60 - -policies: - - id: unique-policy-id-1-scale-up - name: Create a new VF Module - description: - actor: SO - recipe: VF Module Create - target: - type: VNF - retry: 0 - timeout: 30 - 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 diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_SO-test.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_SO-test.yaml deleted file mode 100644 index d32f55b5d..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_SO-test.yaml +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 - services: - - serviceName: d4738992-6497-4dca-9db9 - serviceInvariantUUID: dc112d6e-7e73-4777-9c6f-1a7fb5fd1b6f - serviceUUID: 2eea06c6-e1d3-4c3a-b9c4-478c506eeedf - trigger_policy: unique-policy-id-1-scale-up - timeout: 60 - -policies: - - id: unique-policy-id-1-scale-up - name: Create a new VF Module - description: - actor: SO - recipe: VF Module Create - target: - type: VFMODULE - modelInvariantId: e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e - modelVersionId: 94b18b1d-cc91-4f43-911a-e6348665f292 - modelName: VfwclVfwsnkBbefb8ce2bde..base_vfw..module-0 - modelVersion: 1 - modelCustomizationId: 47958575-138f-452a-8c8d-d89b595f8164 - 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: 30 - 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 diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_SO_Cq-test.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_SO_Cq-test.yaml deleted file mode 100644 index 16c031f33..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_SO_Cq-test.yaml +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2019 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3 - services: - - serviceName: d4738992-6497-4dca-9db9 - serviceInvariantUUID: dc112d6e-7e73-4777-9c6f-1a7fb5fd1b6f - serviceUUID: 2eea06c6-e1d3-4c3a-b9c4-478c506eeedf - trigger_policy: unique-policy-id-1-scale-up - timeout: 60 - -policies: - - id: unique-policy-id-1-scale-up - name: Create a new VF Module - description: - actor: SO - recipe: VF Module Create - target: - type: VFMODULE - modelInvariantId: e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e - modelVersionId: 94b18b1d-cc91-4f43-911a-e6348665f292 - modelName: VfwclVfwsnkBbefb8ce2bde..base_vfw..module-0 - modelVersion: 1 - modelCustomizationId: 47958575-138f-452a-8c8d-d89b595f8164 - 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: 30 - 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 diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_Service123.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_Service123.yaml deleted file mode 100644 index 3892c3bb2..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_Service123.yaml +++ /dev/null @@ -1,75 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-Service123-cbed919f-2212-4ef7-8051-fe6308da1bda - services: - - serviceName: Service123 - resources: - - resourceName: res1 - resourceType: VFC - - resourceName: res2 - resourceType: VFC - trigger_policy: unique-policy-id-1-restart - timeout: 60 - abatement: true - -policies: - - id: unique-policy-id-1-restart - name: Restart Policy - description: - actor: APPC - recipe: Restart - target: - type: VM - retry: 3 - timeout: 20 - success: final_success - failure: unique-policy-id-2-rebuild - failure_timeout: unique-policy-id-2-rebuild - failure_retries: unique-policy-id-2-rebuild - failure_guard: unique-policy-id-2-rebuild - failure_exception: final_failure_exception - - - id: unique-policy-id-2-rebuild - name: Rebuild Policy - description: - actor: APPC - recipe: Rebuild - target: - type: VM - retry: 0 - timeout: 10 - success: final_success - failure: unique-policy-id-3-migrate - failure_timeout: unique-policy-id-3-migrate - failure_retries: unique-policy-id-3-migrate - failure_guard: unique-policy-id-3-migrate - failure_exception: final_failure_exception - - - id: unique-policy-id-3-migrate - name: Migrate Policy - description: - actor: APPC - recipe: Migrate - target: - type: VM - retry: 0 - timeout: 30 - success: final_success - failure: final_failure - failure_timeout: final_failure_timeout - failure_retries: final_failure_retries - failure_guard: final_failure_guard - failure_exception: final_failure_exception diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_VFC.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_VFC.yaml deleted file mode 100644 index ea9c7ded2..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_VFC.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b - - trigger_policy: unique-policy-id-1-restart - timeout: 60 - -policies: - - id: unique-policy-id-1-restart - name: Restart the VM - description: - actor: VFC - recipe: Restart - target: - type: VM - retry: 3 - timeout: 30 - 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 - diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vCPE.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vCPE.yaml deleted file mode 100644 index 26fc5c81b..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vCPE.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e - trigger_policy: unique-policy-id-1-restart - timeout: 60 - abatement: true - -policies: - - id: unique-policy-id-1-restart - name: Restart the VM - description: - actor: APPC - recipe: Restart - target: - type: VNF - retry: 3 - timeout: 30 - 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 diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vFW.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vFW.yaml deleted file mode 100644 index 8c94b1adc..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vFW.yaml +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a - services: - - serviceInvariantUUID: f6937c86-584c-47ae-ad29-8d41d6f0cc7c - serviceUUID: 7be584e2-0bb2-4126-adaf-ced2c77ca0b3 - serviceName: Service_Ete_Name7ba1fbde-6187-464a-a62d-d9dd25bdf4e8 - trigger_policy: unique-policy-id-1-modifyConfig - timeout: 60 - abatement: true - -policies: - - id: unique-policy-id-1-modifyConfig - name: modify packet gen config - description: - actor: APPC - recipe: ModifyConfig - target: - resourceID: bbb3cefd-01c8-413c-9bdd-2b92f9ca3d38 - type: VNF - retry: 0 - timeout: 30 - 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 diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vFW_CDS.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vFW_CDS.yaml deleted file mode 100644 index 511a9694b..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vFW_CDS.yaml +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (C) 2019 Bell Canada. -# -# 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. -controlLoop: - version: 2.0.0 - controlLoopName: ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a - services: - - serviceInvariantUUID: 5cfe6f4a-41bc-4247-8674-ebd4b98e35cc - serviceUUID: 0f40bba5-986e-4b3c-803f-ddd1b7b25f24 - serviceName: 57e66ea7-0ed6-45c7-970f - trigger_policy: unique-policy-id-1-modifyConfig - timeout: 60 - abatement: true - -policies: - - id: unique-policy-id-1-modifyConfig - name: modify packet gen config - description: - actor: CDS - recipe: ModifyConfig - target: - resourceID: bbb3cefd-01c8-413c-9bdd-2b92f9ca3d38 - type: VNF - payload: - artifact_name: vfw-cds - artifact_version: 1.0.0 - mode: async - data: '{"mapInfo":{"key":"val"},"arrayInfo":["one","two"],"paramInfo":"val"}' - retry: 0 - timeout: 30 - 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 diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vPCI.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vPCI.yaml deleted file mode 100644 index 42e2000db..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vPCI.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2018 Wipro Limited Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 3.0.0 - controlLoopName: ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459 - trigger_policy: unique-policy-id-123-modifyconfig - timeout: 1200 - abatement: false - -policies: - - id: unique-policy-id-123-modifyconfig - name: modify PCI config - description: - actor: SDNR - recipe: ModifyConfig - target: - # These fields are not used - resourceID: bbb3cefd-01c8-413c-9bdd-2b92f9ca3d38 - 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 diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vSONH.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vSONH.yaml deleted file mode 100644 index 4cdf8ff40..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_vSONH.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2019 Wipro Limited Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -controlLoop: - version: 3.0.0 - controlLoopName: ControlLoop-vSONH-7d4baf04-8875-4d1f-946d-06b874048b61 - trigger_policy: unique-policy-id-456-modifyconfig - timeout: 1200 - abatement: false - -policies: - - id: unique-policy-id-456-modifyconfig - name: modify ANR config - description: - actor: SDNR - recipe: ModifyConfigANR - target: - # These fields are not used - 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 diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_migrate.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_migrate.yaml deleted file mode 100644 index 1e84f391a..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_migrate.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -guard: - version: 2.0.0 - -guards: - - id: unique_guard_1 - name: APPC 5 Migrate - description: | - We only allow 2 restarts over 10 minute window during the day time hours (avoid midnight to 5am) - match_parameters: - #controlLoopName: ControlLoop-Service123-cbed919f-2212-4ef7-8051-fe6308da1bda - actor: APPC - recipe: Migrate - limit_constraints: - - freq_limit_per_target: 1 - time_window: - value: 10 - units: minute - active_time_range: - start: 00:00:00-05:00 - end: 23:59:59-05:00 - - - - - - \ No newline at end of file diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_modifyconfig.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_modifyconfig.yaml deleted file mode 100644 index 9a1fd884c..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_modifyconfig.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -guard: - version: 2.0.0 - -guards: - - id: unique_guard_6 - name: APPC 6 ModifyConfig - description: | - We only allow 2 ModifyConfig over 10 minute window during the day time hours (avoid midnight to 5am) - match_parameters: - controlLoopName: ControlLoop-Service123-cbed919f-2212-4ef7-8051-fe6308da1bda - actor: APPC - recipe: ModifyConfig - targets: - - s1 - - s2 - - foobartriggersource36 - - s3 - - testGenericVnfName - limit_constraints: - - freq_limit_per_target: 1 - time_window: - value: 10 - units: minute - active_time_range: - start: 00:00:00-05:00 - end: 23:59:59-05:00 \ No newline at end of file diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_rebuild.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_rebuild.yaml deleted file mode 100644 index 1e4988636..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_rebuild.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -guard: - version: 2.0.0 - -guards: - - id: unique_guard_3 - name: APPC 5 Rebuild - description: | - We only allow 2 restarts over 10 minute window during the day time hours (avoid midnight to 5am) - match_parameters: - controlLoopName: ControlLoop-Service123-cbed919f-2212-4ef7-8051-fe6308da1bda - actor: APPC - recipe: Rebuild - limit_constraints: - - freq_limit_per_target: 2 - time_window: - value: 10 - units: minute - active_time_range: - start: 00:00:00-05:00 - end: 23:59:59-05:00 - - - - - - \ No newline at end of file diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_rebuild_1.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_rebuild_1.yaml deleted file mode 100644 index 57205132e..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_rebuild_1.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -guard: - version: 2.0.0 - -guards: - - id: unique_guard_2 - name: APPC 5 Rebuild - description: | - We only allow 2 restarts over 10 minute window during the day time hours (avoid midnight to 5am) - match_parameters: - controlLoopName: ControlLoop-Service123-cbed919f-2212-4ef7-8051-fe6308da1bda - actor: - recipe: Rebuild - limit_constraints: - - freq_limit_per_target: 25 - time_window: - value: 1 - units: week - active_time_range: - start: 00:00:00-05:00 - end: 23:59:59-05:00 - - - - - - \ No newline at end of file diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_restart.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_restart.yaml deleted file mode 100644 index c10050b7f..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_restart.yaml +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -guard: - version: 2.0.0 - -guards: - - id: unique_guard_5 - name: APPC 5 Restart - description: | - We only allow 2 restarts over 10 minute window during the day time hours (avoid midnight to 5am) - match_parameters: - controlLoopName: ControlLoop-Service123-cbed919f-2212-4ef7-8051-fe6308da1bda - actor: APPC - recipe: Restart - targets: - - s1 - - s2 - - foobartriggersource36 - - s3 - - testGenericVnfName - limit_constraints: - - freq_limit_per_target: 1 - time_window: - value: 10 - units: minute - active_time_range: - start: 00:00:00-05:00 - end: 23:59:59-05:00 - diff --git a/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_restart_blacklist.yaml b/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_restart_blacklist.yaml deleted file mode 100644 index d89577182..000000000 --- a/controlloop/templates/template.demo/src/test/resources/yaml/policy_guard_appc_restart_blacklist.yaml +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2018 AT&T Intellectual Property. All rights reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -guard: - version: 2.0.0 - -guards: - - id: unique_guard_4_Blacklist - name: APPC Restart Blacklist - description: | - We deny restart of the blacklisted targets (avoid midnight to 5am) - match_parameters: - actor: APPC - recipe: Restart - limit_constraints: - - blacklist: - - server123 - - server2234 - - vserver.vserver-name22 - - aaabbbccc - - foobartriggersource35 - active_time_range: - start: 00:00:00-05:00 - end: 23:59:59-05:00 - - - - - - \ No newline at end of file -- cgit 1.2.3-korg