diff options
author | Jorge Hernandez <jorge.hernandez-herrero@att.com> | 2020-01-08 16:53:02 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-01-08 16:53:02 +0000 |
commit | 4ad1874d63c56d9b82df6c7f8aff118a3b0da391 (patch) | |
tree | c7bacb5469d1aa758ceb7ba16317efa893d925db /examples | |
parent | 6fae58f0d1c3c2374d39d4f91fcbc0cf95780ee7 (diff) | |
parent | 7a8e49a16020f7d04724803659f365236987c5ed (diff) |
Merge "Update vCPE example to use Avro schemas"
Diffstat (limited to 'examples')
50 files changed, 2689 insertions, 62 deletions
diff --git a/examples/examples-onap-vcpe/pom.xml b/examples/examples-onap-vcpe/pom.xml index 9f6c285c4..e6917ef2f 100644 --- a/examples/examples-onap-vcpe/pom.xml +++ b/examples/examples-onap-vcpe/pom.xml @@ -1,7 +1,7 @@ <!-- ============LICENSE_START======================================================= Copyright (C) 2018 Ericsson. All rights reserved. - Copyright (C) 2019 Nordix Foundation. + Modifications Copyright (C) 2019-2020 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -34,6 +34,8 @@ <properties> <policymodel.name>ONAPvCPEPolicyModel</policymodel.name> <toscapolicy.name>ONAPvCPEToscaPolicy</toscapolicy.name> + <policymodelstandalone.name>ONAPvCPEPolicyModelStandalone</policymodelstandalone.name> + <toscapolicystandalone.name>ONAPvCPEToscaPolicyStandalone</toscapolicystandalone.name> <apex-domains-onap-vcpe-dir>${project.basedir}/src</apex-domains-onap-vcpe-dir> </properties> @@ -134,6 +136,43 @@ </arguments> </configuration> </execution> + <!-- Generate the Standalone APEX Policy JSON from the APEX CLI command --> + <execution> + <id>generate-standalone-policy</id> + <phase>compile</phase> + <goals> + <goal>java</goal> + </goals> + <configuration> + <mainClass>org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain</mainClass> + <classpathScope>compile</classpathScope> + <arguments> + <argument>--command-file=${project.basedir}/src/main/resources/policy/${policymodelstandalone.name}.apex</argument> + <argument>--output-model-file=${project.build.directory}/classes/${policymodelstandalone.name}.json</argument> + <argument>--log-file=${project.build.directory}/${policymodelstandalone.name}_policygeneration.log</argument> + <argument>--working-dir=${project.basedir}</argument> + </arguments> + </configuration> + </execution> + <!-- Generate the standalone APEX ToscaPolicy JSON file--> + <execution> + <id>generate-standalone-tosca-policy</id> + <phase>compile</phase> + <goals> + <goal>java</goal> + </goals> + <configuration> + <mainClass>org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain</mainClass> + <classpathScope>compile</classpathScope> + <arguments> + <argument>--command-file=${project.basedir}/src/main/resources/policy/${policymodelstandalone.name}.apex</argument> + <argument>--output-tosca-file=${project.build.directory}/classes/${toscapolicystandalone.name}.json</argument> + <argument>--log-file=${project.build.directory}/${policymodelstandalone.name}_policygeneration.log</argument> + <argument>--apex-config-file=${project.basedir}/src/main/resources/examples/config/ONAPvCPEStandalone/ApexConfig.json</argument> + <argument>--tosca-template-file=${project.basedir}/src/main/resources/tosca/ToscaTemplate.json</argument> + </arguments> + </configuration> + </execution> </executions> </plugin> </plugins> diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPEStandalone/ApexConfig.json b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPEStandalone/ApexConfig.json new file mode 100644 index 000000000..e82be89a8 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPEStandalone/ApexConfig.json @@ -0,0 +1,168 @@ +{ + "engineServiceParameters": { + "name": "MyApexEngine", + "version": "0.0.1", + "id": 45, + "instanceCount": 4, + "deploymentPort": 12561, + "policyModelFileName": "examples/models/ONAPvCPE/ONAPvCPEPolicyModel.json", + "engineParameters": { + "executorParameters": { + "JAVASCRIPT": { + "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" + } + }, + "contextParameters": { + "parameterClassName": "org.onap.policy.apex.context.parameters.ContextParameters", + "schemaParameters": { + "Avro": { + "parameterClassName": "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters" + }, + "Java": { + "parameterClassName": "org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters", + "jsonAdapters": { + "Instant": { + "adaptedClass": "java.time.Instant", + "adaptorClass": "org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter" + } + } + } + } + } + } + }, + "eventInputParameters": { + "ConfigureBlackWhiteListConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://10.2.0.13:30227/events/BLACK-WHITE-LIST-READ/APEX/1?timeout=60000" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + }, + "AnalyticsConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://10.2.0.13:30227/events/unauthenticated.DCAE_CL_OUTPUT/APEX/1?timeout=60000" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "pojoField": "VirtualControlLoopEvent", + "sourceAlias": "from" + } + }, + "eventName": "VirtualControlLoopEvent" + }, + "ControllerConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://10.2.0.13:30227/events/APPC-LCM-WRITE/APEX/1?timeout=60000" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "pojoField": "ControllerResponse" + } + }, + "eventName": "ControllerResponseEvent" + }, + "ActionInitConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "EVENT_REQUESTOR" + }, + "eventProtocolParameters": { + "eventProtocol": "APEX" + }, + "eventNameFilter": "ActionEvent", + "requestorMode": true, + "requestorPeer": "ActionInitProducer", + "requestorTimeout": 500 + } + }, + "eventOutputParameters": { + "ConfigureBlackWhiteListProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://10.2.0.13:30227/events/BLACK-WHITE-LIST-WRITE" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + }, + "eventNameFilter": "ConfigureBlackWhiteListResultEvent" + }, + "ActionInitProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "EVENT_REQUESTOR" + }, + "eventProtocolParameters": { + "eventProtocol": "APEX" + }, + "eventNameFilter": "ActionEventListEvent", + "requestorMode": true, + "requestorPeer": "ActionInitConsumer", + "requestorTimeout": 500 + }, + "logProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "/tmp/ControlLoopEventsOut.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + }, + "ControllerProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://10.2.0.13:30227/events/APPC-LCM-READ" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "sourceAlias": "from", + "pojoField": "ControllerRequest" + } + }, + "eventNameFilter": "ControllerRequestEvent" + }, + "PolicyLogProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://10.2.0.13:30227/events/POLICY-CL-MGT" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "sourceAlias": "from", + "pojoField": "VirtualControlLoopNotification" + } + }, + "eventNameFilter": "ControlLoopLogEvent" + } + } +} diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPEStandalone/ApexConfig_Sim.json b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPEStandalone/ApexConfig_Sim.json new file mode 100644 index 000000000..081cc999f --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPEStandalone/ApexConfig_Sim.json @@ -0,0 +1,184 @@ +{ + "engineServiceParameters": { + "name": "MyApexEngine", + "version": "0.0.1", + "id": 45, + "instanceCount": 4, + "deploymentPort": 12561, + "policyModelFileName": "examples/models/ONAPvCPE/ONAPvCPEPolicyModel.json", + "engineParameters": { + "executorParameters": { + "JAVASCRIPT": { + "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" + } + }, + "contextParameters": { + "parameterClassName": "org.onap.policy.apex.context.parameters.ContextParameters", + "schemaParameters": { + "Avro": { + "parameterClassName": "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters" + }, + "Java": { + "parameterClassName": "org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters", + "jsonAdapters": { + "Instant": { + "adaptedClass": "java.time.Instant", + "adaptorClass": "org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter" + } + } + } + } + } + } + }, + "eventInputParameters": { + "ConfigureBlackWhiteListConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "examples/events/ONAPvCPEStandalone/ConfigureBlackWhiteLists.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + }, + "AnalyticsPreloadConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "examples/events/ONAPvCPEStandalone/MultiEvents.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "pojoField": "VirtualControlLoopEvent", + "sourceAlias": "from" + } + }, + "eventName": "VirtualControlLoopEvent" + }, + "AnalyticsConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://localhost:54321/OnapVCpeSim/sim/events/unauthenticated.DCAE_CL_OUTPUT/APEX/1?timeout=30000" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "pojoField": "VirtualControlLoopEvent", + "sourceAlias": "from" + } + }, + "eventName": "VirtualControlLoopEvent" + }, + "ControllerConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://localhost:54321/OnapVCpeSim/sim/events/APPC_LCM_WRITE/APEX/1?timeout=60000" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "pojoField": "ControllerResponse" + } + }, + "eventName": "ControllerResponseEvent", + "eventNameFilter": "ControllerResponseEvent" + }, + "ActionInitConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "EVENT_REQUESTOR" + }, + "eventProtocolParameters": { + "eventProtocol": "APEX" + }, + "eventNameFilter": "ActionEvent", + "requestorMode": true, + "requestorPeer": "ActionInitProducer", + "requestorTimeout": 500 + } + }, + "eventOutputParameters": { + "ConfigureBlackWhiteListProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://localhost:54321/OnapVCpeSim/sim/events/BLACK-WHITE-LIST-READ" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + }, + "eventNameFilter": "ConfigureBlackWhiteListResultEvent" + }, + "ActionInitProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "EVENT_REQUESTOR" + }, + "eventProtocolParameters": { + "eventProtocol": "APEX" + }, + "eventNameFilter": "ActionEventListEvent", + "requestorMode": true, + "requestorPeer": "ActionInitConsumer", + "requestorTimeout": 500 + }, + "logProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "/tmp/ControlLoopEventsOut.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + }, + "ControllerProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://localhost:54321/OnapVCpeSim/sim/events/APPC-LCM-READ" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "sourceAlias": "from", + "pojoField": "ControllerRequest" + } + }, + "eventNameFilter": "ControllerRequestEvent" + }, + "PolicyLogProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://localhost:54321/OnapVCpeSim/sim/events/POLICY_CL_MGT" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "sourceAlias": "from", + "pojoField": "VirtualControlLoopNotification" + } + }, + "eventNameFilter": "ControlLoopLogEvent" + } + } +} diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPEStandalone/ApexConfig_Sim_StdIO.json b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPEStandalone/ApexConfig_Sim_StdIO.json new file mode 100644 index 000000000..d6b6555ce --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPEStandalone/ApexConfig_Sim_StdIO.json @@ -0,0 +1,100 @@ +{ + "engineServiceParameters": { + "name": "MyApexEngine", + "version": "0.0.1", + "id": 45, + "instanceCount": 4, + "deploymentPort": 12561, + "policyModelFileName": "examples/models/ONAPvCPE/ONAPvCPEPolicyModel.json", + "engineParameters": { + "executorParameters": { + "JAVASCRIPT": { + "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" + } + }, + "contextParameters": { + "parameterClassName": "org.onap.policy.apex.context.parameters.ContextParameters", + "schemaParameters": { + "Avro": { + "parameterClassName": "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters" + }, + "Java": { + "parameterClassName": "org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters", + "jsonAdapters": { + "Instant": { + "adaptedClass": "java.time.Instant", + "adaptorClass": "org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter" + } + } + } + } + } + } + }, + "eventInputParameters": { + "ConfigureBlackWhiteListConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "examples/events/ONAPvCPEStandalone/ConfigureBlackWhiteLists.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + }, + "AnalyticsConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "standardIo": true + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "pojoField": "VirtualControlLoopEvent", + "sourceAlias": "from" + } + }, + "eventName": "VirtualControlLoopEvent" + }, + "ActionInitConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "EVENT_REQUESTOR" + }, + "eventProtocolParameters": { + "eventProtocol": "APEX" + }, + "eventNameFilter": "ActionEvent", + "requestorMode": true, + "requestorPeer": "ActionInitProducer", + "requestorTimeout": 500 + } + }, + "eventOutputParameters": { + "ActionInitProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "EVENT_REQUESTOR" + }, + "eventProtocolParameters": { + "eventProtocol": "APEX" + }, + "eventNameFilter": "ActionEventListEvent", + "requestorMode": true, + "requestorPeer": "ActionInitConsumer", + "requestorTimeout": 500 + }, + "logProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "standardIo": true + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + } + } +} diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/CLAbatedEvent.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/CLAbatedEvent.json new file mode 100644 index 000000000..bee240319 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/CLAbatedEvent.json @@ -0,0 +1,31 @@ +{ + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", + "closedLoopAlarmStart": 1519638001326, + "closedLoopAlarmEnd": 1519638197324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ABATED", + "requestID": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "version": "1.0.2", + "from": "DCAE", + "policyScope": "ControlLoop", + "policyName": "ONAPvCPEStandalone", + "policyVersion": "1.0.0", + "additionalEventParams": {}, + "payload": "", + "AAI": { + "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db39e1", + "generic-vnf.resource-version": "1", + "generic-vnf.vnf-name": "vCPEInfraVNF13", + "generic-vnf.prov-status": "PREPROV", + "generic-vnf.is-closed-loop-disabled": "false", + "generic-vnf.orchestration-status": "Created", + "generic-vnf.vnf-type": "cCPEInfraService10/vCPEInfraService10 0", + "generic-vnf.in-maint": "false", + "generic-vnf.service-id": "5585fd2c-ad0d-4050-b0cf-dfe4a03bd01f", + "vserver.is-closed-loop-disabled": "false", + "vserver.prov-status": "ACTIVE", + "vserver.vserver-name": "vserverName" + } +} diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/CLOnsetEvent.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/CLOnsetEvent.json new file mode 100644 index 000000000..105120dfe --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/CLOnsetEvent.json @@ -0,0 +1,31 @@ +{ + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", + "closedLoopAlarmStart": 1519638197324, + "closedLoopAlarmEnd": 0, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "version": "1.0.2", + "from": "DCAE", + "policyScope": "ControlLoop", + "policyName": "ONAPvCPEStandalone", + "policyVersion": "1.0.0", + "additionalEventParams": {}, + "payload": "", + "AAI": { + "generic-vnf.resource-version": "1", + "generic-vnf.vnf-name": "vCPEInfraVNF13", + "generic-vnf.prov-status": "PREPROV", + "generic-vnf.is-closed-loop-disabled": "false", + "generic-vnf.orchestration-status": "Created", + "generic-vnf.vnf-type": "vCPEInfraService10/vCPEInfraService10 0", + "generic-vnf.in-maint": "false", + "generic-vnf.service-id": "5585fd2c-ad0d-4050-b0cf-dfe4a03bd01f", + "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db39e1", + "vserver.is-closed-loop-disabled": "false", + "vserver.prov-status": "ACTIVE", + "vserver.vserver-name": "vserverName" + } +} diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/ConfigureBlackWhiteLists.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/ConfigureBlackWhiteLists.json new file mode 100644 index 000000000..d9edab528 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/ConfigureBlackWhiteLists.json @@ -0,0 +1,48 @@ +{ + "nameSpace": "org.onap.policy.apex.onap.vcpe", + "name": "ConfigureBlackWhiteListEvent", + "version": "0.0.1", + "targetType": "VNF", + "target": "b4fe00ac-1da6-4b00-ac0d-8e8300db39e1", + "black": false +} +{ + "nameSpace": "org.onap.policy.apex.onap.vcpe", + "name": "ConfigureBlackWhiteListEvent", + "version": "0.0.1", + "targetType": "VNF", + "target": "b4fe00ac-1da6-4b00-ac0d-8e8300db39e2", + "black": true +} +{ + "nameSpace": "org.onap.policy.apex.onap.vcpe", + "name": "ConfigureBlackWhiteListEvent", + "version": "0.0.1", + "targetType": "Service", + "target": "5585fd2c-ad0d-4050-b0cf-dfe4a03bd01f", + "black": false +} +{ + "nameSpace": "org.onap.policy.apex.onap.vcpe", + "name": "ConfigureBlackWhiteListEvent", + "version": "0.0.1", + "targetType": "Service", + "target": "5585fd2c-ad0d-4050-b0cf-dfe4a03bd020", + "black": true +} +{ + "nameSpace": "org.onap.policy.apex.onap.vcpe", + "name": "ConfigureBlackWhiteListEvent", + "version": "0.0.1", + "targetType": "VServer", + "target": "vserverName", + "black": false +} +{ + "nameSpace": "org.onap.policy.apex.onap.vcpe", + "name": "ConfigureBlackWhiteListEvent", + "version": "0.0.1", + "targetType": "VServer", + "target": "vserverNameBlack", + "black": true +} diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/ControllerActionEvent.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/ControllerActionEvent.json new file mode 100644 index 000000000..6e18a91b0 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/ControllerActionEvent.json @@ -0,0 +1,22 @@ +{ + "rpc-name": "restart", + "version": "2.0", + "correlation-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "type": "request", + "body": { + "input": { + "common-header": { + "timestamp": "2018-02-26T10:23:41.97Z", + "api-ver": "2.15", + "originator-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "request-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "sub-request-id": "1", + "flags": {} + }, + "action": "Restart", + "action-identifiers": { + "vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db39e1" + } + } + } +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/ControllerResponseNOKEvent.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/ControllerResponseNOKEvent.json new file mode 100644 index 000000000..da7d1f52b --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/ControllerResponseNOKEvent.json @@ -0,0 +1,27 @@ +{ + "rpc-name": "restart", + "version": "0.0.1", + "correlation-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "type": "request", + "body": { + "output": { + "common-header": { + "timestamp": 1578052403357, + "api-ver": "2.00", + "originator-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "request-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "sub-request-id": "1", + "flags": { + "mode": "EXCLUSIVE", + "force": "TRUE", + "ttl": "10000" + } + }, + "status": { + "code": 200, + "message": "Restart Failed" + }, + "payload": "" + } + } +} diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/ControllerResponseOKEvent.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/ControllerResponseOKEvent.json new file mode 100644 index 000000000..f2d3abe01 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/ControllerResponseOKEvent.json @@ -0,0 +1,27 @@ +{ + "rpc-name": "restart", + "version": "2.0.0", + "correlation-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "type": "request", + "body": { + "output": { + "common-header": { + "timestamp": 1578052403357, + "api-ver": "2.00", + "originator-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "request-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "sub-request-id": "1", + "flags": { + "mode": "EXCLUSIVE", + "force": "TRUE", + "ttl": "10000" + } + }, + "status": { + "code": 400, + "message": "Restart Successful" + }, + "payload": "" + } + } +} diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/MultiEvents.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/MultiEvents.json new file mode 100644 index 000000000..030cbf789 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPEStandalone/MultiEvents.json @@ -0,0 +1,124 @@ +{ + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", + "closedLoopAlarmStart": 1519638197324, + "closedLoopAlarmEnd": 0, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "4a68f8a5-0db9-4070-a132-adede51e0000", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "version": "1.0.2", + "from": "DCAE", + "policyScope": "ControlLoop", + "policyName": "ONAPvCPEStandalone", + "policyVersion": "1.0.0", + "additionalEventParams": {}, + "payload": "", + "AAI": { + "generic-vnf.resource-version": "1", + "generic-vnf.vnf-name": "vCPEInfraVNF0000", + "generic-vnf.prov-status": "PREPROV", + "generic-vnf.is-closed-loop-disabled": "false", + "generic-vnf.orchestration-status": "Created", + "generic-vnf.vnf-type": "vCPEInfraService10/vCPEInfraService10 0", + "generic-vnf.in-maint": "false", + "generic-vnf.service-id": "5585fd2c-ad0d-4050-b0cf-dfe4a03bd01f", + "generic-vnf.vnf-id": "00000000-0000-0000-0000-000000000000", + "vserver.is-closed-loop-disabled": "false", + "vserver.prov-status": "ACTIVE", + "vserver.vserver-name": "Ete_vCPECLvCPESNK_7ba1fbde_0" + } +} +{ + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", + "closedLoopAlarmStart": 1519638197324, + "closedLoopAlarmEnd": 0, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "4a68f8a5-0db9-4070-a132-adede51e0001", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "version": "1.0.2", + "from": "DCAE", + "policyScope": "ControlLoop", + "policyName": "ONAPvCPEStandalone", + "policyVersion": "1.0.0", + "additionalEventParams": {}, + "payload": "", + "AAI": { + "generic-vnf.resource-version": "1", + "generic-vnf.vnf-name": "vCPEInfraVNF0001", + "generic-vnf.prov-status": "PREPROV", + "generic-vnf.is-closed-loop-disabled": "false", + "generic-vnf.orchestration-status": "Created", + "generic-vnf.vnf-type": "vCPEInfraService10/vCPEInfraService10 0", + "generic-vnf.in-maint": "false", + "generic-vnf.service-id": "5585fd2c-ad0d-4050-b0cf-dfe4a03bd01f", + "generic-vnf.vnf-id": "00000000-0000-0000-0000-000000000001", + "vserver.is-closed-loop-disabled": "false", + "vserver.prov-status": "ACTIVE", + "vserver.vserver-name": "Ete_vCPECLvCPESNK_7ba1fbde_1" + } +} +{ + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", + "closedLoopAlarmStart": 1519638001326, + "closedLoopAlarmEnd": 1519638197324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ABATED", + "requestID": "4a68f8a5-0db9-4070-a132-adede51e0005", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "version": "1.0.2", + "from": "DCAE", + "policyScope": "ControlLoop", + "policyName": "ONAPvCPEStandalone", + "policyVersion": "1.0.0", + "additionalEventParams": {}, + "payload": "", + "AAI": { + "generic-vnf.vnf-id": "00000000-0000-0000-0000-000000000005", + "generic-vnf.resource-version": "1", + "generic-vnf.vnf-name": "vCPEInfraVNF0005", + "generic-vnf.prov-status": "PREPROV", + "generic-vnf.is-closed-loop-disabled": "false", + "generic-vnf.orchestration-status": "Created", + "generic-vnf.vnf-type": "cCPEInfraService10/vCPEInfraService10 0", + "generic-vnf.in-maint": "false", + "generic-vnf.service-id": "5585fd2c-ad0d-4050-b0cf-dfe4a03b0005", + "vserver.is-closed-loop-disabled": "false", + "vserver.prov-status": "ACTIVE", + "vserver.vserver-name": "Ete_vCPECLvCPESNK_7ba1fbde_4" + } +} +{ + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", + "closedLoopAlarmStart": 1519638001326, + "closedLoopAlarmEnd": 1519638197324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ABATED", + "requestID": "4a68f8a5-0db9-4070-a132-adede51e0006", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "version": "1.0.2", + "from": "DCAE", + "policyScope": "ControlLoop", + "policyName": "ONAPvCPEStandalone", + "policyVersion": "1.0.0", + "additionalEventParams": {}, + "payload": "", + "AAI": { + "generic-vnf.vnf-id": "00000000-0000-0000-0000-000000000006", + "generic-vnf.resource-version": "1", + "generic-vnf.vnf-name": "vCPEInfraVNF0006", + "generic-vnf.prov-status": "PREPROV", + "generic-vnf.is-closed-loop-disabled": "false", + "generic-vnf.orchestration-status": "Created", + "generic-vnf.vnf-type": "cCPEInfraService10/vCPEInfraService10 0", + "generic-vnf.in-maint": "false", + "generic-vnf.service-id": "5585fd2c-ad0d-4050-b0cf-dfe4a03b0006", + "vserver.is-closed-loop-disabled": "false", + "vserver.prov-status": "ACTIVE", + "vserver.vserver-name": "Ete_vCPECLvCPESNK_7ba1fbde_5" + } +} diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AAILookupTask.js index fcb39052d..fcb39052d 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AAILookupTask.js diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFRequestTask.js index dd69dcb1d..dd69dcb1d 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFRequestTask.js diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFResponseTask.js index 75ab6a3af..75ab6a3af 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/APPCRestartVNFResponseTask.js diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/AbatedTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AbatedTask.js index f37b6f1b5..f37b6f1b5 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/AbatedTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/AbatedTask.js diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/ControlLoopLogTask.js index aa816ca95..a5a692cbc 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/ControlLoopLogTask.js @@ -1,19 +1,20 @@ /* * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -40,7 +41,7 @@ clNotification.setClosedLoopEventClient(vcpeClosedLoopStatus.get("closedLoopEven clNotification.setVersion(vcpeClosedLoopStatus.get("version")); clNotification.setRequestId(java.util.UUID.fromString(vcpeClosedLoopStatus.get("requestID"))); clNotification.setTargetType(vcpeClosedLoopStatus.get("target_type")); -clNotification.setTarget(org.onap.policy.controlloop.ControlLoopEventStatus.toStatus(vcpeClosedLoopStatus.get("target"))); +clNotification.setTarget(vcpeClosedLoopStatus.get("target")); clNotification.setFrom(vcpeClosedLoopStatus.get("from")); clNotification.setPolicyScope(vcpeClosedLoopStatus.get("policyScope")); clNotification.setPolicyName(vcpeClosedLoopStatus.get("policyName")); @@ -54,16 +55,16 @@ clNotification.setNotificationTime(notificationTime); var aaiInfo = vcpeClosedLoopStatus.get("AAI"); -clNotification.getAai().put("generic-vnf.resource-version", aaiInfo.get("genericVnfResourceVersion")); -clNotification.getAai().put("generic-vnf.vnf-name", aaiInfo.get("genericVnfVnfName")); -clNotification.getAai().put("generic-vnf.prov-status", aaiInfo.get("genericVnfProvStatus")); -clNotification.getAai().put("generic-vnf.is-closed-loop-disabled", aaiInfo.get("genericVnfIsClosedLoopDisabled")); -clNotification.getAai().put("generic-vnf.orchestration-status", aaiInfo.get("genericVnfOrchestrationStatus")); -clNotification.getAai().put("generic-vnf.vnf-type", aaiInfo.get("genericVnfVnfType")); -clNotification.getAai().put("generic-vnf.in-maint", aaiInfo.get("genericVnfInMaint")); -clNotification.getAai().put("generic-vnf.service-id", aaiInfo.get("genericVnfServiceId")); +clNotification.getAai().put("generic-vnf.resource-version", aaiInfo.get("genericVnfResourceVersion")); +clNotification.getAai().put("generic-vnf.vnf-name", aaiInfo.get("genericVnfVnfName")); +clNotification.getAai().put("generic-vnf.prov-status", aaiInfo.get("genericVnfProvStatus")); +clNotification.getAai().put("generic-vnf.is-closed-loop-disabled", aaiInfo.get("genericVnfIsClosedLoopDisabled")); +clNotification.getAai().put("generic-vnf.orchestration-status", aaiInfo.get("genericVnfOrchestrationStatus")); +clNotification.getAai().put("generic-vnf.vnf-type", aaiInfo.get("genericVnfVnfType")); +clNotification.getAai().put("generic-vnf.in-maint", aaiInfo.get("genericVnfInMaint")); +clNotification.getAai().put("generic-vnf.service-id", aaiInfo.get("genericVnfServiceId")); if(vnfID != null) { - clNotification.getAai().put("generic-vnf.vnf-id", aaiInfo.get("genericVnfVnfId")); + clNotification.getAai().put("generic-vnf.vnf-id", aaiInfo.get("genericVnfVnfId")); } executor.outFields.put("VirtualControlLoopNotification", clNotification); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/DeniedTask.js index 353c21ef6..353c21ef6 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/DeniedTask.js diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GetVCPEStateTask.js index f4f6d908d..f4f6d908d 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GetVCPEStateTask.js diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardRequestTask.js index d247f8a65..d247f8a65 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardRequestTask.js diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardResponseTask.js index 2a9100b7f..2a9100b7f 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/GuardResponseTask.js diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/NoAAILookupTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/NoAAILookupTask.js index ebc0e6387..ebc0e6387 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/NoAAILookupTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/NoAAILookupTask.js diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/OnsetOrAbatedStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/OnsetOrAbatedStateTSL.js index c8a3bfba8..c8a3bfba8 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/OnsetOrAbatedStateTSL.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/OnsetOrAbatedStateTSL.js diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/RestartAPPCRequestPolicyPermitOrDenyTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/RestartAPPCRequestPolicyPermitOrDenyTSL.js index a1bac6546..a1bac6546 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/RestartAPPCRequestPolicyPermitOrDenyTSL.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/definitive/RestartAPPCRequestPolicyPermitOrDenyTSL.js diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/CheckServiceIdTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/CheckServiceIdTask.js new file mode 100644 index 000000000..88bf72671 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/CheckServiceIdTask.js @@ -0,0 +1,46 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var vnfId = executor.inFields.get("vnfID").toString(); +var vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum").get(vnfId); +var serviceId = vcpeClosedLoopStatus.get("AAI").get("genericVnfServiceId"); +var blackFlag = executor.getContextAlbum("ServiceIdWhiteBlackListAlbum").get(serviceId.toString()); + +executor.logger.info("vnfId=" + vnfId + ", serviceId=" + serviceId + ", blackFlag=" + blackFlag); + +if (blackFlag != null && blackFlag === true) { + vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis()); + vcpeClosedLoopStatus.put("notification", "BLACKLIST"); + var message = vcpeClosedLoopStatus.get("message"); + + if (message != null) { + vcpeClosedLoopStatus.put("message", message + ":Service ID blacklisted"); + } + else { + vcpeClosedLoopStatus.put("message", "Service ID blacklisted"); + } +} + +executor.logger.info(executor.outFields); + +var returnValue = executor.isTrue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/CheckVNFIdTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/CheckVNFIdTask.js new file mode 100644 index 000000000..d4e3f30dc --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/CheckVNFIdTask.js @@ -0,0 +1,45 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var vnfId = executor.inFields.get("vnfID").toString(); +var blackFlag = executor.getContextAlbum("VnfIdWhiteBlackListAlbum").get(vnfId); + +executor.logger.info("vnfId=" + vnfId + ", blackFlag=" + blackFlag); + +if (blackFlag != null && blackFlag === true) { + var vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum").get(vnfId); + vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis()); + vcpeClosedLoopStatus.put("notification", "BLACKLIST"); + var message = vcpeClosedLoopStatus.get("message"); + + if (message != null) { + vcpeClosedLoopStatus.put("message", message + ":VNF ID blacklisted"); + } + else { + vcpeClosedLoopStatus.put("message", "VNF ID blacklisted"); + } +} + +executor.logger.info(executor.outFields); + +var returnValue = executor.isTrue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/CheckVServerIdTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/CheckVServerIdTask.js new file mode 100644 index 000000000..785d93f25 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/CheckVServerIdTask.js @@ -0,0 +1,46 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var vnfId = executor.inFields.get("vnfID").toString(); +var vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum").get(vnfId); +var vServerId = vcpeClosedLoopStatus.get("AAI").get("vserverName"); +var blackFlag = executor.getContextAlbum("VServerIdWhiteBlackListAlbum").get(vServerId.toString()); + +executor.logger.info("vnfId=" + vnfId + ", vServerId=" + vServerId + ", blackFlag=" + blackFlag); + +if (blackFlag != null && blackFlag === true) { + vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis()); + vcpeClosedLoopStatus.put("notification", "BLACKLIST"); + var message = vcpeClosedLoopStatus.get("message"); + + if (message != null) { + vcpeClosedLoopStatus.put("message", message + ":VServer ID blacklisted"); + } + else { + vcpeClosedLoopStatus.put("message", "VServer ID blacklisted"); + } +} + +executor.logger.info(executor.outFields); + +var returnValue = executor.isTrue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ConfigureBlackWhiteListTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ConfigureBlackWhiteListTask.js new file mode 100644 index 000000000..2d41e5f90 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ConfigureBlackWhiteListTask.js @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +// Pass through to the log state + +executor.logger.info(executor.outFields); + +var targetType = executor.inFields.get("targetType"); +var target = executor.inFields.get("target"); +var black = executor.inFields.get("black"); + +var returnValue = executor.isTrue; + +if (targetType === "VNF") { + executor.getContextAlbum("VnfIdWhiteBlackListAlbum").put(target, black); + executor.logger.info("added VNF ID \"" + target + "\" with black flag \"" + black + "\" to VNF ID list"); +} +else if (targetType === "Service") { + executor.getContextAlbum("ServiceIdWhiteBlackListAlbum").put(target, black); + executor.logger.info("added Service ID \"" + target + "\" with black flag \"" + black + "\" to Service ID list"); +} +else if (targetType === "VServer") { + executor.getContextAlbum("VServerIdWhiteBlackListAlbum").put(target, black); + executor.logger.info("added VServer ID \"" + target + "\" with black flag \"" + black + "\" to VServer ID list"); +} +else { + executor.logger.warn("unknown target type \"" + targetType + "\" specified"); + returnValue = executor.isFalse; +} diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ControlLoopLogTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ControlLoopLogTask.js new file mode 100644 index 000000000..ca2166c75 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ControlLoopLogTask.js @@ -0,0 +1,75 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var vnfID = executor.inFields.get("vnfID"); +if (vnfID == null) { + vnfID = executor.inFields.get("vnfName"); +} +executor.logger.info("vnfID=" + vnfID); + +var controlLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum").get(vnfID.toString()); + +executor.logger.info("Logging context information for VNF \"" + vnfID + "\""); + +var clNotification = executor.subject.getOutFieldSchemaHelper("VirtualControlLoopNotification").createNewInstance(); + +clNotification.put("requestID", executor.inFields.get("requestID").toString()); +clNotification.put("closedLoopControlName", controlLoopStatus.get("closedLoopControlName")); +clNotification.put("closedLoopAlarmStart", controlLoopStatus.get("closedLoopAlarmStart")); +clNotification.put("closedLoopAlarmEnd", controlLoopStatus.get("closedLoopAlarmEnd")); +clNotification.put("closedLoopEventClient", controlLoopStatus.get("closedLoopEventClient")); +clNotification.put("version", controlLoopStatus.get("version")); +clNotification.put("targetType", controlLoopStatus.get("target_type")); +clNotification.put("target", controlLoopStatus.get("target")); +clNotification.put("from", controlLoopStatus.get("from")); +clNotification.put("policyScope", controlLoopStatus.get("policyScope")); +clNotification.put("policyName", controlLoopStatus.get("policyName")); +clNotification.put("policyVersion", controlLoopStatus.get("policyVersion")); +clNotification.put("notification", controlLoopStatus.get("notification")); +clNotification.put("message", controlLoopStatus.get("message")); +clNotification.put("notificationTime", controlLoopStatus.get("notificationTime")); +clNotification.put("opsClTimer", 0); + +var aaiInfo = controlLoopStatus.get("AAI"); + +var aaiInfoOut = new java.util.HashMap(); + +aaiInfoOut.put("generic-vnf.resource-version", aaiInfo.get("genericVnfResourceVersion")); +aaiInfoOut.put("generic-vnf.vnf-name", aaiInfo.get("genericVnfVnfName")); +aaiInfoOut.put("generic-vnf.prov-status", aaiInfo.get("genericVnfProvStatus")); +aaiInfoOut.put("generic-vnf.is-closed-loop-disabled", aaiInfo.get("genericVnfIsClosedLoopDisabled")); +aaiInfoOut.put("generic-vnf.orchestration-status", aaiInfo.get("genericVnfOrchestrationStatus")); +aaiInfoOut.put("generic-vnf.vnf-type", aaiInfo.get("genericVnfVnfType")); +aaiInfoOut.put("generic-vnf.in-maint", aaiInfo.get("genericVnfInMaint")); +aaiInfoOut.put("generic-vnf.service-id", aaiInfo.get("genericVnfServiceId")); +if (vnfID != null) { + aaiInfoOut.put("generic-vnf.vnf-id", aaiInfo.get("genericVnfVnfId")); +} + +clNotification.put("AAI", aaiInfoOut); + +executor.outFields.put("VirtualControlLoopNotification", clNotification); + +executor.logger.info(executor.outFields); + +var returnValue = executor.isTrue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ControllerRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ControllerRequestTask.js new file mode 100644 index 000000000..b6d4cae38 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ControllerRequestTask.js @@ -0,0 +1,71 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var controllerRequest = executor.subject.getOutFieldSchemaHelper("ControllerRequest").createNewInstance(); + +var controllerRequestBody = executor.subject.getOutFieldSchemaHelper("ControllerRequest").createNewSubInstance( + "Controller_Body_Type"); + +var controllerRequestBodyInput = executor.subject.getOutFieldSchemaHelper("ControllerRequest").createNewSubInstance( + "Controller_Body_Type_Input"); + +var controllerRequestBodyInputCommonHeader = executor.subject.getOutFieldSchemaHelper("ControllerRequest") + .createNewSubInstance("Controller_Body_Type_Common_Header"); + +var vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum").get( + executor.inFields.get("vnfID").toString()); + +controllerRequest.put("version", "2.0.0"); +controllerRequest.put("rpc_DasH_name", "restart"); +controllerRequest.put("correlation_DasH_id", executor.inFields.get("requestID").toString()); +controllerRequest.put("type", "request"); + +controllerRequestBodyInput.put("action", "Restart"); +controllerRequestBodyInput.put("action_DasH_identifiers", new java.util.HashMap()); +controllerRequestBodyInput.get("action_DasH_identifiers").put("vnf-id", executor.inFields.get("vnfID").toString()); + +controllerRequestBodyInputCommonHeader.put("timestamp", java.lang.System.currentTimeMillis()); +controllerRequestBodyInputCommonHeader.put("api_DasH_ver", "2.00"); +controllerRequestBodyInputCommonHeader.put("originator_DasH_id", executor.inFields.get("requestID").toString()); +controllerRequestBodyInputCommonHeader.put("request_DasH_id", executor.inFields.get("requestID").toString()); +controllerRequestBodyInputCommonHeader.put("sub_DasH_request_DasH_id", "1"); +controllerRequestBodyInputCommonHeader.put("flags", new java.util.HashMap()); +controllerRequestBodyInputCommonHeader.get("flags").put("ttl", "10000"); +controllerRequestBodyInputCommonHeader.get("flags").put("force", "TRUE"); +controllerRequestBodyInputCommonHeader.get("flags").put("mode", "EXCLUSIVE"); + +controllerRequestBodyInput.put("common_DasH_header", controllerRequestBodyInputCommonHeader); +controllerRequestBody.put("input", controllerRequestBodyInput); +controllerRequest.put("body", controllerRequestBody); + +executor.getContextAlbum("RequestIDVNFIDAlbum").put(executor.inFields.get("requestID").toString(), + executor.inFields.get("vnfID")); + +vcpeClosedLoopStatus.put("notification", "OPERATION"); +vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis()); + +executor.outFields.put("ControllerRequest", controllerRequest); + +executor.logger.info(executor.outFields); + +var returnValue = executor.isTrue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ControllerResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ControllerResponseTask.js new file mode 100644 index 000000000..5a8703780 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ControllerResponseTask.js @@ -0,0 +1,90 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * APPC LCM Response code: 100 ACCEPTED + * 200 ERROR UNEXPECTED ERROR means failure + * 312 REJECTED DUPLICATE REQUEST + * 400 SUCCESS + * + * Note: Sometimes the corelationId has a -1 at the tail, need to get rid of it when present. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var controllerResponse = executor.inFields.get("ControllerResponse"); + +var requestIDString = new java.lang.String(controllerResponse.get("correlation_DasH_id")); +executor.logger.info("requestIDString =\"" + requestIDString + "\""); +var vnfID = executor.getContextAlbum("RequestIDVNFIDAlbum").get(requestIDString); +executor.logger.info("vnfID = " + vnfID); + +var returnValue = executor.isTrue; + +if (vnfID != null) { + var vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum").get(vnfID.toString()); + var requestId = java.util.UUID.fromString(vcpeClosedLoopStatus.get("requestID")); + + vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis()); + + var returnedCode = controllerResponse.get("body").get("output").get("status").get("code"); + var responseStatus = null; + + if (returnedCode == 100) { + responseStatus = "ACCEPTED"; + } else if (returnedCode == 200) { + responseStatus = "ERROR"; + } else if (returnedCode >= 300 && returnedCode <= 316) { + responseStatus = "REJECT"; + } else if (returnedCode == 400) { + responseStatus = "SUCCESS"; + } else if (returnedCode == 450 || (returnedCode >= 401 && returnedCode <= 406)) { + responseStatus = "FAILURE"; + } else if (returnedCode == 500) { + responseStatus = "PARTIAL_SUCCESS"; + } else if (returnedCode >= 501 && returnedCode <= 599) { + responseStatus = "PARTIAL_FAILURE"; + } else { + responseStatus = "SYSTEM_ERROR"; + } + + executor.logger.info("Got from APPC code: " + responseStatus); + + if (responseStatus === "SUCCESS") { + vcpeClosedLoopStatus.put("notification", "OPERATION_SUCCESS"); + vcpeClosedLoopStatus.put("message", "vCPE restarted"); + executor.getContextAlbum("RequestIDVNFIDAlbum").remove(requestIDString); + } else if (responseStatus === "ACCEPTED" || responseStatus === "REJECT") { + executor.logger.info("Got ACCEPTED 100 or REJECT 312, keep the context, wait for next response. Code is: " + + responseStatus); + } else { + executor.getContextAlbum("RequestIDVNFIDAlbum").remove(requestIDString); + vcpeClosedLoopStatus.put("notification", "OPERATION_FAILURE"); + vcpeClosedLoopStatus.put("message", "vCPE restart failed, code is " + responseStatus + ", message is " + + controllerResponse.get("body").get("output").get("status").get("message")); + } + + executor.outFields.put("requestID", requestId); + executor.outFields.put("vnfID", vnfID); +} else { + executor.message = "VNF ID not found in context album for request ID " + requestIDString; + returnValue = executor.isFalse; +} + +executor.logger.info(executor.outFields); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/DoControllerRequestActionTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/DoControllerRequestActionTask.js new file mode 100644 index 000000000..c24e76523 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/DoControllerRequestActionTask.js @@ -0,0 +1,27 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +// Pass through to the log state + +executor.logger.info(executor.outFields); + +var returnValue = executor.isTrue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/DoLogActionTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/DoLogActionTask.js new file mode 100644 index 000000000..003942e22 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/DoLogActionTask.js @@ -0,0 +1,28 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +// Pass through to the log state + +executor.logger.info(executor.outFields); + +var returnValue = executor.isTrue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ExecuteActionsPolicyActionStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ExecuteActionsPolicyActionStateTSL.js new file mode 100644 index 000000000..a8bb40c80 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ExecuteActionsPolicyActionStateTSL.js @@ -0,0 +1,33 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var returnValue = executor.isTrue; +var status = null; + +if (executor.inFields.get("action") === "ControllerRequestAction") { + executor.subject.getTaskKey("DoControllerRequestActionTask").copyTo(executor.selectedTask); +} else { + executor.subject.getTaskKey("DoLogActionTask").copyTo(executor.selectedTask); +} + +executor.logger.info("ReceiveEventPolicyOnsetOrAbatedStateTSL State Selected Task:" + executor.selectedTask); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/GetEntityStateTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/GetEntityStateTask.js new file mode 100644 index 000000000..1567608bb --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/GetEntityStateTask.js @@ -0,0 +1,157 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Note: The incoming closedloop message can be ONSET with both VNF-name and VNF-ID + * or ABATED with only VNF-name. So need to handle differently. For ABATED case, + * since we still keep the RequireIDVNFID context album, we can get it from there. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var utf8Type = Java.type("org.apache.avro.util.Utf8"); +var uuidType = Java.type("java.util.UUID"); + +var clEvent = executor.inFields.get("VirtualControlLoopEvent"); + +executor.logger.info(clEvent.toString()); +executor.logger.info(clEvent.get("closedLoopControlName")); + +var requestID = uuidType.fromString(clEvent.get("requestID")); +executor.logger.info("requestID = " + requestID); +var vnfID = null; +var vcpeClosedLoopStatus = null; + +if (clEvent.get("AAI").get(new utf8Type("generic_DasH_vnf_DoT_vnf_DasH_id")) != null) { + vnfID = uuidType.fromString(clEvent.get("AAI").get(new utf8Type("generic_DasH_vnf_DoT_vnf_DasH_id"))); + executor.logger.info("vnfID = " + vnfID); + vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum").get(vnfID); + + if (vcpeClosedLoopStatus == null) { + executor.logger.info("Creating context information for new vCPE VNF \"" + vnfID.toString() + "\""); + + vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum").getSchemaHelper().createNewInstance(); + + vcpeClosedLoopStatus.put("closedLoopControlName", clEvent.get("closedLoopControlName")); + vcpeClosedLoopStatus.put("closedLoopAlarmStart", clEvent.get("closedLoopAlarmStart")); + vcpeClosedLoopStatus.put("closedLoopEventClient", clEvent.get("closedLoopEventClient")); + vcpeClosedLoopStatus.put("closedLoopEventStatus", clEvent.get("closedLoopEventStatus")); + vcpeClosedLoopStatus.put("version", clEvent.get("version")); + vcpeClosedLoopStatus.put("requestID", clEvent.get("requestID")); + vcpeClosedLoopStatus.put("target_type", clEvent.get("target_type")); + vcpeClosedLoopStatus.put("target", clEvent.get("target")); + vcpeClosedLoopStatus.put("from", clEvent.get("from")); + vcpeClosedLoopStatus.put("policyScope", "vCPE"); + vcpeClosedLoopStatus.put("policyName", "ONAPvCPEPolicyModel"); + vcpeClosedLoopStatus.put("policyVersion", "0.0.1"); + vcpeClosedLoopStatus.put("notification", "ACTIVE"); + vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis()); + vcpeClosedLoopStatus.put("message", ""); + + var aaiInfo = executor.getContextAlbum("ControlLoopStatusAlbum").getSchemaHelper().createNewSubInstance( + "VCPE_AAI_Type"); + + aaiInfo.put("genericVnfResourceVersion", clEvent.get("AAI").get( + new utf8Type("generic_DasH_vnf_DoT_resource_DasH_version"))); + aaiInfo.put("genericVnfVnfName", clEvent.get("AAI").get(new utf8Type("generic_DasH_vnf_DoT_vnf_DasH_name"))); + aaiInfo.put("genericVnfProvStatus", clEvent.get("AAI").get( + new utf8Type("generic_DasH_vnf_DoT_prov_DasH_status"))); + aaiInfo.put("genericVnfIsClosedLoopDisabled", clEvent.get("AAI").get( + new utf8Type("generic_DasH_vnf_DoT_is_DasH_closed_DasH_loop_DasH_disabled"))); + aaiInfo.put("genericVnfOrchestrationStatus", clEvent.get("AAI").get( + new utf8Type("generic_DasH_vnf_DoT_orchestration_DasH_status"))); + aaiInfo.put("genericVnfVnfType", clEvent.get("AAI").get(new utf8Type("generic_DasH_vnf_DoT_vnf_DasH_type"))); + aaiInfo.put("genericVnfInMaint", clEvent.get("AAI").get(new utf8Type("generic_DasH_vnf_DoT_in_DasH_maint"))); + aaiInfo + .put("genericVnfServiceId", clEvent.get("AAI") + .get(new utf8Type("generic_DasH_vnf_DoT_service_DasH_id"))); + aaiInfo.put("genericVnfVnfId", clEvent.get("AAI").get(new utf8Type("generic_DasH_vnf_DoT_vnf_DasH_id"))); + aaiInfo.put("vserverIsClosedLoopDisabled", clEvent.get("AAI").get( + new utf8Type("vserver_DoT_is_DasH_closed_DasH_loop_DasH_disabled"))); + aaiInfo.put("vserverProvStatus", clEvent.get("AAI").get(new utf8Type("vserver_DoT_prov_DasH_status"))); + aaiInfo.put("vserverName", clEvent.get("AAI").get(new utf8Type("vserver_DoT_vserver_DasH_name"))); + + vcpeClosedLoopStatus.put("AAI", aaiInfo); + + if (clEvent.get("closedLoopAlarmEnd") != null) { + vcpeClosedLoopStatus.put("closedLoopAlarmEnd", clEvent.get("closedLoopAlarmEnd")); + } else { + vcpeClosedLoopStatus.put("closedLoopAlarmEnd", java.lang.Long.valueOf(0)); + } + + executor.getContextAlbum("ControlLoopStatusAlbum").put(vnfID.toString(), vcpeClosedLoopStatus); + + executor.logger.info("Created context information for new vCPE VNF \"" + vnfID.toString() + "\""); + } + + executor.outFields.put("requestID", requestID); + executor.outFields.put("vnfID", vnfID); + + executor.logger.info(executor.outFields); +} else { + executor.logger.info("No vnf-id in VirtualControlLoopEvent, status:" + + clEvent.get("closedLoopEventStatus").toString()); + var vnfName = clEvent.get("AAI").get(new utf8Type("generic_DasH_vnf_DoT_vnf_DasH_name")); + executor.logger.info("No vnf-id in VirtualControlLoopEvent for " + vnfName); + + vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum").get(vnfName); + + if (vcpeClosedLoopStatus == null) { + executor.logger.info("Creating context information for new vCPE VNF \"" + vnfName + "\""); + + vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum").getSchemaHelper().createNewInstance(); + + vcpeClosedLoopStatus.put("closedLoopControlName", clEvent.get("closedLoopControlName")); + vcpeClosedLoopStatus.put("closedLoopAlarmStart", clEvent.get("closedLoopAlarmStart")); + vcpeClosedLoopStatus.put("closedLoopEventClient", clEvent.get("closedLoopEventClient")); + vcpeClosedLoopStatus.put("closedLoopEventStatus", clEvent.get("closedLoopEventStatus(")); + vcpeClosedLoopStatus.put("version", clEvent.get("version")); + vcpeClosedLoopStatus.put("requestID", clEvent.get("requestID")); + vcpeClosedLoopStatus.put("target_type", clEvent.get("targetType")); + vcpeClosedLoopStatus.put("target", clEvent.get("target")); + vcpeClosedLoopStatus.put("from", clEvent.get("from")); + vcpeClosedLoopStatus.put("policyScope", "vCPE"); + vcpeClosedLoopStatus.put("policyName", "ONAPvCPEPolicyModel"); + vcpeClosedLoopStatus.put("policyVersion", "0.0.1"); + vcpeClosedLoopStatus.put("notification", "ACTIVE"); + vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis()); + vcpeClosedLoopStatus.put("message", ""); + + var aaiInfo = executor.getContextAlbum("ControlLoopStatusAlbum").getSchemaHelper().createNewSubInstance( + "VCPE_AAI_Type"); + + aaiInfo.put("genericVnfVnfName", clEvent.get("AAI").get(new utf8Type("generic_DasH_vnf_DoT_vnf_DasH_name"))); + vcpeClosedLoopStatus.put("AAI", aaiInfo); + + if (clEvent.get("closedLoopAlarmEnd") != null) { + vcpeClosedLoopStatus.put("closedLoopAlarmEnd", clEvent.get("closedLoopAlarmEnd")); + } else { + vcpeClosedLoopStatus.put("closedLoopAlarmEnd", java.lang.Long.valueOf(0)); + } + + executor.getContextAlbum("ControlLoopStatusAlbum").put(vnfName, vcpeClosedLoopStatus); + + executor.logger.info("Created context information for new vCPE VNF \"" + vnfName + "\""); + } + executor.outFields.put("requestID", requestID); + executor.outFields.put("vnfName", vnfName); + executor.logger.info(executor.outFields); +} + +var returnValue = executor.isTrue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/InitiateActionsTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/InitiateActionsTask.js new file mode 100644 index 000000000..0303bc9a4 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/InitiateActionsTask.js @@ -0,0 +1,54 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum").get( + executor.inFields.get("vnfID").toString()); + +var eventList = executor.subject.getOutFieldSchemaHelper("ActionEventList").createNewInstance(); + +var eventType = Java.type("org.onap.policy.apex.service.engine.event.ApexEvent"); + +var controllerRequestActionEvent = new eventType("ActionEvent", "0.0.1", "org.onap.policy.apex.onap.vcpe", "APEX", + "APEX"); + +controllerRequestActionEvent.put("action", "ControllerRequestAction"); +controllerRequestActionEvent.put("requestID", executor.inFields.get("requestID")); +controllerRequestActionEvent.put("vnfID", executor.inFields.get("vnfID")); +controllerRequestActionEvent.put("vnfName", executor.inFields.get("vnfName")); + +eventList.add(controllerRequestActionEvent); + +var logActionEvent = new eventType("ActionEvent", "0.0.1", "org.onap.policy.apex.onap.vcpe", "APEX", "APEX"); + +logActionEvent.put("action", "LogAction"); +logActionEvent.put("requestID", executor.inFields.get("requestID")); +logActionEvent.put("vnfID", executor.inFields.get("vnfID")); +logActionEvent.put("vnfName", executor.inFields.get("vnfName")); + +eventList.add(logActionEvent); + +executor.outFields.put("ActionEventList", eventList); + +executor.logger.info(executor.outFields); + +var returnValue = executor.isTrue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ReceiveEventPolicyExecuteOrLogStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ReceiveEventPolicyExecuteOrLogStateTSL.js new file mode 100644 index 000000000..46a65add3 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/ReceiveEventPolicyExecuteOrLogStateTSL.js @@ -0,0 +1,55 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var returnValue = executor.isTrue; + +if( executor.inFields.get("vnfID") == null) { + executor.logger.info("ControlLoopStatusAlbum: vnfID is null"); + var vnfName = executor.inFields.get("vnfName"); + var vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum").get( + executor.inFields.get("vnfName")); +} else { + var vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum").get( + executor.inFields.get("vnfID").toString()); +} + +var status = vcpeClosedLoopStatus.get("closedLoopEventStatus").toString(); +var notification = vcpeClosedLoopStatus.get("notification"); + +var returnValue = executor.isTrue; + +if (notification != null && notification === "BLACKLIST") { + executor.subject.getTaskKey("StopAndLogTask").copyTo(executor.selectedTask); +} +else { + if (status === "ONSET") { + executor.subject.getTaskKey("InitiateActionsTask").copyTo(executor.selectedTask); + } else if (status === "ABATED") { + executor.subject.getTaskKey("StopAndLogTask").copyTo(executor.selectedTask); + } else { + executor.message = "closedLoopEventStatus is \"" + status + "\", it must be either \"ONSET\" or \"ABATED\""; + returnValue = executor.isFalse; + } +} + +executor.logger.info("ReceiveEventPolicyOnsetOrAbatedStateTSL State Selected Task:" + executor.selectedTask); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/standalone/StopAndLogTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/StopAndLogTask.js new file mode 100644 index 000000000..af57bf1f7 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/standalone/StopAndLogTask.js @@ -0,0 +1,47 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +executor.logger.info(executor.subject.id); +executor.logger.info(executor.inFields); + +var vcpeClosedLoopStatus = null; +if (executor.inFields.get("vnfID") == null) { + executor.logger.info("AbatedTask: vnfID is null"); + var vnfName = executor.inFields.get("vnfName"); + vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum") + .get(executor.inFields.get("vnfName")); +} else { + vcpeClosedLoopStatus = executor.getContextAlbum("ControlLoopStatusAlbum") + .get(executor.inFields.get("vnfID").toString()); +} + +vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis()); + +var message = vcpeClosedLoopStatus.get("message"); +if (message == null || message === "") { + vcpeClosedLoopStatus.put("message", "situation has been abated"); +} +else { + vcpeClosedLoopStatus.put("notification", "FINAL_FAILURE"); +} + +executor.logger.info(executor.outFields); + +var returnValue = executor.isTrue; diff --git a/examples/examples-onap-vcpe/src/main/resources/policy/ONAPvCPEPolicyModel.apex b/examples/examples-onap-vcpe/src/main/resources/policy/ONAPvCPEPolicyModel.apex index 0748cbed1..241435e67 100644 --- a/examples/examples-onap-vcpe/src/main/resources/policy/ONAPvCPEPolicyModel.apex +++ b/examples/examples-onap-vcpe/src/main/resources/policy/ONAPvCPEPolicyModel.apex @@ -1,6 +1,7 @@ #------------------------------------------------------------------------------- # ============LICENSE_START======================================================= # Copyright (C) 2016-2018 Ericsson. All rights reserved. +# Modifications Copyright (C) 2019-2020 Nordix Foundation. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,11 +33,11 @@ schema create name=APPCLCMRequestType flavour=Java schema=org.onap.policy.appclc schema create name=APPCLCMResponseType flavour=Java schema=org.onap.policy.appclcm.AppcLcmDmaapWrapper schema create name=GuardDecisionAttributesType flavour=Avro schema=LS -#MACROFILE:"src/main/resources/schemas/GuardDecisionAttributesType.avsc" +#MACROFILE:"src/main/resources/schemas/definitive/GuardDecisionAttributesType.avsc" LE schema create name=VCPEClosedLoopStatusType flavour=Avro schema=LS -#MACROFILE:"src/main/resources/schemas/VCPEClosedLoopStatusType.avsc" +#MACROFILE:"src/main/resources/schemas/definitive/VCPEClosedLoopStatusType.avsc" LE album create name=VCPEClosedLoopStatusAlbum scope=policy writable=true schemaName=VCPEClosedLoopStatusType @@ -84,7 +85,7 @@ task contextref create name=GetVCPEStateTask albumName=VCPEClosedLoopStatusAlbum task contextref create name=GetVCPEStateTask albumName=RequestIDVNFIDAlbum task logic create name=GetVCPEStateTask logicFlavour=JAVASCRIPT logic=LS -#MACROFILE:"src/main/resources/logic/GetVCPEStateTask.js" +#MACROFILE:"src/main/resources/logic/definitive/GetVCPEStateTask.js" LE task create name=AbatedTask @@ -100,7 +101,7 @@ task outputfield create name=AbatedTask fieldName=vnfName schemaName=SimpleStr task contextref create name=AbatedTask albumName=VCPEClosedLoopStatusAlbum task logic create name=AbatedTask logicFlavour=JAVASCRIPT logic=LS -#MACROFILE:"src/main/resources/logic/AbatedTask.js" +#MACROFILE:"src/main/resources/logic/definitive/AbatedTask.js" LE task create name=GuardRequestTask @@ -115,7 +116,7 @@ task contextref create name=GuardRequestTask albumName=VCPEClosedLoopStatusAlbum task contextref create name=GuardRequestTask albumName=ControlLoopExecutionIDAlbum task logic create name=GuardRequestTask logicFlavour=JAVASCRIPT logic=LS -#MACROFILE:"src/main/resources/logic/GuardRequestTask.js" +#MACROFILE:"src/main/resources/logic/definitive/GuardRequestTask.js" LE task create name=GuardResponseTask @@ -130,7 +131,7 @@ task contextref create name=GuardResponseTask albumName=VCPEClosedLoopStatusAlbu task contextref create name=GuardResponseTask albumName=ControlLoopExecutionIDAlbum task logic create name=GuardResponseTask logicFlavour=JAVASCRIPT logic=LS -#MACROFILE:"src/main/resources/logic/GuardResponseTask.js" +#MACROFILE:"src/main/resources/logic/definitive/GuardResponseTask.js" LE task create name=DeniedTask @@ -144,7 +145,7 @@ task outputfield create name=DeniedTask fieldName=vnfID schemaName=UUIDType task contextref create name=DeniedTask albumName=VCPEClosedLoopStatusAlbum task logic create name=DeniedTask logicFlavour=JAVASCRIPT logic=LS -#MACROFILE:"src/main/resources/logic/DeniedTask.js" +#MACROFILE:"src/main/resources/logic/definitive/DeniedTask.js" LE task create name=APPCRestartVNFRequestTask @@ -158,7 +159,7 @@ task contextref create name=APPCRestartVNFRequestTask albumName=VCPEClosedLoopSt task contextref create name=APPCRestartVNFRequestTask albumName=RequestIDVNFIDAlbum task logic create name=APPCRestartVNFRequestTask logicFlavour=JAVASCRIPT logic=LS -#MACROFILE:"src/main/resources/logic/APPCRestartVNFRequestTask.js" +#MACROFILE:"src/main/resources/logic/definitive/APPCRestartVNFRequestTask.js" LE task create name=APPCRestartVNFResponseTask @@ -172,7 +173,7 @@ task contextref create name=APPCRestartVNFResponseTask albumName=VCPEClosedLoopS task contextref create name=APPCRestartVNFResponseTask albumName=RequestIDVNFIDAlbum task logic create name=APPCRestartVNFResponseTask logicFlavour=JAVASCRIPT logic=LS -#MACROFILE:"src/main/resources/logic/APPCRestartVNFResponseTask.js" +#MACROFILE:"src/main/resources/logic/definitive/APPCRestartVNFResponseTask.js" LE task create name=ControlLoopLogTask @@ -185,7 +186,7 @@ task outputfield create name=ControlLoopLogTask fieldName=VirtualControlLoopNoti task contextref create name=ControlLoopLogTask albumName=VCPEClosedLoopStatusAlbum task logic create name=ControlLoopLogTask logicFlavour=JAVASCRIPT logic=LS -#MACROFILE:"src/main/resources/logic/ControlLoopLogTask.js" +#MACROFILE:"src/main/resources/logic/definitive/ControlLoopLogTask.js" LE task create name=AAILookupTask @@ -199,7 +200,7 @@ task outputfield create name=AAILookupTask fieldName=vnfID schemaName=UUIDTy task contextref create name=AAILookupTask albumName=VCPEClosedLoopStatusAlbum task logic create name=AAILookupTask logicFlavour=JAVASCRIPT logic=LS -#MACROFILE:"src/main/resources/logic/AAILookupTask.js" +#MACROFILE:"src/main/resources/logic/definitive/AAILookupTask.js" LE task create name=NoAAILookupTask @@ -211,7 +212,7 @@ task outputfield create name=NoAAILookupTask fieldName=requestID schemaName=UUID task outputfield create name=NoAAILookupTask fieldName=vnfID schemaName=UUIDType task logic create name=NoAAILookupTask logicFlavour=JAVASCRIPT logic=LS -#MACROFILE:"src/main/resources/logic/NoAAILookupTask.js" +#MACROFILE:"src/main/resources/logic/definitive/NoAAILookupTask.js" LE # @@ -232,7 +233,7 @@ policy state taskref create name=ReceiveEventPolicy stateName=OnsetOrAbatedState policy state contextref create name=ReceiveEventPolicy stateName=OnsetOrAbatedState albumName=VCPEClosedLoopStatusAlbum policy state selecttasklogic create name=ReceiveEventPolicy stateName=OnsetOrAbatedState logicFlavour=JAVASCRIPT logic=LS -#MACROFILE:"src/main/resources/logic/OnsetOrAbatedStateTSL.js" +#MACROFILE:"src/main/resources/logic/definitive/OnsetOrAbatedStateTSL.js" LE policy state create name=ReceiveEventPolicy stateName=RequestAAIState triggerName=VCPEStateUpdatedEvent defaultTaskName=AAILookupTask @@ -267,7 +268,7 @@ policy state taskref create name=RestartAPPCRequestPolicy stateName=PolicyGuardR policy state contextref create name=RestartAPPCRequestPolicy stateName=PermitOrDenyState albumName=VCPEClosedLoopStatusAlbum policy state selecttasklogic create name=RestartAPPCRequestPolicy stateName=PermitOrDenyState logicFlavour=JAVASCRIPT logic=LS -#MACROFILE:"src/main/resources/logic/RestartAPPCRequestPolicyPermitOrDenyTSL.js" +#MACROFILE:"src/main/resources/logic/definitive/RestartAPPCRequestPolicyPermitOrDenyTSL.js" LE # diff --git a/examples/examples-onap-vcpe/src/main/resources/policy/ONAPvCPEPolicyModelStandalone.apex b/examples/examples-onap-vcpe/src/main/resources/policy/ONAPvCPEPolicyModelStandalone.apex new file mode 100644 index 000000000..b73565a00 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/policy/ONAPvCPEPolicyModelStandalone.apex @@ -0,0 +1,368 @@ +#------------------------------------------------------------------------------- +# ============LICENSE_START======================================================= +# Copyright (C) 2020 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +#------------------------------------------------------------------------------- + +model create name=ONAPvCPEPolicyModelStandalone + +schema create name=SimpleStringType flavour=Java schema=java.lang.String +schema create name=SimpleLongType flavour=Java schema=java.lang.Long +schema create name=SimpleBooleanType flavour=Java schema=java.lang.Boolean +schema create name=UUIDType flavour=Java schema=java.util.UUID + +schema create name=VirtualControlLoopEventType flavour=Avro schema=LS +#MACROFILE:"src/main/resources/schemas/standalone/VirtualControlLoopEventType.avsc" +LE + +schema create name=VirtualControlLoopNotificationType flavour=Avro schema=LS +#MACROFILE:"src/main/resources/schemas/standalone/VirtualControlLoopNotificationType.avsc" +LE + +schema create name=ControllerRequestType flavour=Avro schema=LS +#MACROFILE:"src/main/resources/schemas/standalone/ControllerRequestType.avsc" +LE + +schema create name=ControllerResponseType flavour=Avro schema=LS +#MACROFILE:"src/main/resources/schemas/standalone/ControllerResponseType.avsc" +LE + +schema create name=ControlLoopStatusType flavour=Avro schema=LS +#MACROFILE:"src/main/resources/schemas/standalone/ControlLoopStatusType.avsc" +LE + +schema create name=ActionEventListType flavour=Java schema=org.onap.policy.apex.service.engine.event.ApexEventList + +album create name=ControlLoopStatusAlbum scope=policy writable=true schemaName=ControlLoopStatusType + +album create name=RequestIDVNFIDAlbum scope=policy writable=true schemaName=UUIDType + +album create name=VnfIdWhiteBlackListAlbum scope=policy writable=true schemaName=SimpleBooleanType +album create name=ServiceIdWhiteBlackListAlbum scope=policy writable=true schemaName=SimpleBooleanType +album create name=VServerIdWhiteBlackListAlbum scope=policy writable=true schemaName=SimpleBooleanType + +event create name=VirtualControlLoopEvent version=1.0.2 nameSpace=org.onap.policy.apex.onap.vcpe source=Analytics target=APEX +event parameter create name=VirtualControlLoopEvent parName=VirtualControlLoopEvent schemaName=VirtualControlLoopEventType + +event create name=EntityStateUpdatedEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APEX +event parameter create name=EntityStateUpdatedEvent parName=requestID schemaName=UUIDType +event parameter create name=EntityStateUpdatedEvent parName=vnfID schemaName=UUIDType +event parameter create name=EntityStateUpdatedEvent parName=vnfName schemaName=SimpleStringType optional=true + +event create name=ActionEventListEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APEX +event parameter create name=ActionEventListEvent parName=ActionEventList schemaName=ActionEventListType + +event create name=ActionEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APEX +event parameter create name=ActionEvent parName=action schemaName=SimpleStringType +event parameter create name=ActionEvent parName=requestID schemaName=UUIDType +event parameter create name=ActionEvent parName=vnfID schemaName=UUIDType +event parameter create name=ActionEvent parName=vnfName schemaName=SimpleStringType optional=true + +event create name=ControllerRequestEvent version="2.0.0" nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=Controller +event parameter create name=ControllerRequestEvent parName=ControllerRequest schemaName=ControllerRequestType + +event create name=ControllerResponseEvent version="2.0.0" nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APPC +event parameter create name=ControllerResponseEvent parName=ControllerResponse schemaName=ControllerResponseType + +event create name=ControlLoopLogEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APEX +event parameter create name=ControlLoopLogEvent parName=VirtualControlLoopNotification schemaName=VirtualControlLoopNotificationType + +event create name=ConfigureBlackWhiteListEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APEX +event parameter create name=ConfigureBlackWhiteListEvent parName=targetType schemaName=SimpleStringType +event parameter create name=ConfigureBlackWhiteListEvent parName=target schemaName=SimpleStringType +event parameter create name=ConfigureBlackWhiteListEvent parName=black schemaName=SimpleBooleanType + +event create name=ConfigureBlackWhiteListResultEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APEX +event parameter create name=ConfigureBlackWhiteListResultEvent parName=targetType schemaName=SimpleStringType +event parameter create name=ConfigureBlackWhiteListResultEvent parName=target schemaName=SimpleStringType +event parameter create name=ConfigureBlackWhiteListResultEvent parName=black schemaName=SimpleBooleanType + +task create name=GetEntityStateTask + +task inputfield create name=GetEntityStateTask fieldName=VirtualControlLoopEvent schemaName=VirtualControlLoopEventType + +task outputfield create name=GetEntityStateTask fieldName=requestID schemaName=UUIDType +task outputfield create name=GetEntityStateTask fieldName=vnfID schemaName=UUIDType +task outputfield create name=GetEntityStateTask fieldName=vnfName schemaName=SimpleStringType optional=true + +task contextref create name=GetEntityStateTask albumName=ControlLoopStatusAlbum +task contextref create name=GetEntityStateTask albumName=RequestIDVNFIDAlbum + +task logic create name=GetEntityStateTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/GetEntityStateTask.js" +LE + +task create name=CheckVNFIdTask + +task inputfield create name=CheckVNFIdTask fieldName=requestID schemaName=UUIDType +task inputfield create name=CheckVNFIdTask fieldName=vnfID schemaName=UUIDType +task inputfield create name=CheckVNFIdTask fieldName=vnfName schemaName=SimpleStringType optional=true + +task outputfield create name=CheckVNFIdTask fieldName=requestID schemaName=UUIDType +task outputfield create name=CheckVNFIdTask fieldName=vnfID schemaName=UUIDType +task outputfield create name=CheckVNFIdTask fieldName=vnfName schemaName=SimpleStringType optional=true + +task contextref create name=CheckVNFIdTask albumName=ControlLoopStatusAlbum +task contextref create name=CheckVNFIdTask albumName=VnfIdWhiteBlackListAlbum + +task logic create name=CheckVNFIdTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/CheckVNFIdTask.js" +LE + +task create name=CheckServiceIdTask + +task inputfield create name=CheckServiceIdTask fieldName=requestID schemaName=UUIDType +task inputfield create name=CheckServiceIdTask fieldName=vnfID schemaName=UUIDType +task inputfield create name=CheckServiceIdTask fieldName=vnfName schemaName=SimpleStringType optional=true + +task outputfield create name=CheckServiceIdTask fieldName=requestID schemaName=UUIDType +task outputfield create name=CheckServiceIdTask fieldName=vnfID schemaName=UUIDType +task outputfield create name=CheckServiceIdTask fieldName=vnfName schemaName=SimpleStringType optional=true + +task contextref create name=CheckServiceIdTask albumName=ControlLoopStatusAlbum +task contextref create name=CheckServiceIdTask albumName=ServiceIdWhiteBlackListAlbum + +task logic create name=CheckServiceIdTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/CheckServiceIdTask.js" +LE + +task create name=CheckVServerIdTask + +task inputfield create name=CheckVServerIdTask fieldName=requestID schemaName=UUIDType +task inputfield create name=CheckVServerIdTask fieldName=vnfID schemaName=UUIDType +task inputfield create name=CheckVServerIdTask fieldName=vnfName schemaName=SimpleStringType optional=true + +task outputfield create name=CheckVServerIdTask fieldName=requestID schemaName=UUIDType +task outputfield create name=CheckVServerIdTask fieldName=vnfID schemaName=UUIDType +task outputfield create name=CheckVServerIdTask fieldName=vnfName schemaName=SimpleStringType optional=true + +task contextref create name=CheckVServerIdTask albumName=ControlLoopStatusAlbum +task contextref create name=CheckVServerIdTask albumName=VServerIdWhiteBlackListAlbum + +task logic create name=CheckVServerIdTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/CheckVServerIdTask.js" +LE + +task create name=StopAndLogTask + +task inputfield create name=StopAndLogTask fieldName=requestID schemaName=UUIDType +task inputfield create name=StopAndLogTask fieldName=vnfID schemaName=UUIDType +task inputfield create name=StopAndLogTask fieldName=vnfName schemaName=SimpleStringType optional=true + +task outputfield create name=StopAndLogTask fieldName=requestID schemaName=UUIDType +task outputfield create name=StopAndLogTask fieldName=vnfID schemaName=UUIDType +task outputfield create name=StopAndLogTask fieldName=vnfName schemaName=SimpleStringType optional=true + +task contextref create name=StopAndLogTask albumName=ControlLoopStatusAlbum + +task logic create name=StopAndLogTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/StopAndLogTask.js" +LE + +task create name=InitiateActionsTask + +task inputfield create name=InitiateActionsTask fieldName=requestID schemaName=UUIDType +task inputfield create name=InitiateActionsTask fieldName=vnfID schemaName=UUIDType + +task outputfield create name=InitiateActionsTask fieldName=ActionEventList schemaName=ActionEventListType + +task contextref create name=InitiateActionsTask albumName=ControlLoopStatusAlbum + +task logic create name=InitiateActionsTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/InitiateActionsTask.js" +LE + +task create name=DoControllerRequestActionTask + +task inputfield create name=DoControllerRequestActionTask fieldName=action schemaName=SimpleStringType +task inputfield create name=DoControllerRequestActionTask fieldName=requestID schemaName=UUIDType +task inputfield create name=DoControllerRequestActionTask fieldName=vnfID schemaName=UUIDType +task inputfield create name=DoControllerRequestActionTask fieldName=vnfName schemaName=SimpleStringType optional=true + +task outputfield create name=DoControllerRequestActionTask fieldName=requestID schemaName=UUIDType +task outputfield create name=DoControllerRequestActionTask fieldName=vnfID schemaName=UUIDType + +task contextref create name=DoControllerRequestActionTask albumName=ControlLoopStatusAlbum + +task logic create name=DoControllerRequestActionTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/DoControllerRequestActionTask.js" +LE + +task create name=DoLogActionTask + +task inputfield create name=DoLogActionTask fieldName=action schemaName=SimpleStringType +task inputfield create name=DoLogActionTask fieldName=requestID schemaName=UUIDType +task inputfield create name=DoLogActionTask fieldName=vnfID schemaName=UUIDType +task inputfield create name=DoLogActionTask fieldName=vnfName schemaName=SimpleStringType optional=true + +task outputfield create name=DoLogActionTask fieldName=requestID schemaName=UUIDType +task outputfield create name=DoLogActionTask fieldName=vnfID schemaName=UUIDType + +task contextref create name=DoLogActionTask albumName=ControlLoopStatusAlbum + +task logic create name=DoLogActionTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/DoLogActionTask.js" +LE + +task create name=ControllerRequestTask + +task inputfield create name=ControllerRequestTask fieldName=action schemaName=SimpleStringType +task inputfield create name=ControllerRequestTask fieldName=requestID schemaName=UUIDType +task inputfield create name=ControllerRequestTask fieldName=vnfID schemaName=UUIDType +task inputfield create name=ControllerRequestTask fieldName=vnfName schemaName=SimpleStringType optional=true + +task outputfield create name=ControllerRequestTask fieldName=ControllerRequest schemaName=ControllerRequestType + +task contextref create name=ControllerRequestTask albumName=ControlLoopStatusAlbum +task contextref create name=ControllerRequestTask albumName=RequestIDVNFIDAlbum + +task logic create name=ControllerRequestTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/ControllerRequestTask.js" +LE + +task create name=ControllerResponseTask + +task inputfield create name=ControllerResponseTask fieldName=ControllerResponse schemaName=ControllerResponseType + +task outputfield create name=ControllerResponseTask fieldName=requestID schemaName=UUIDType +task outputfield create name=ControllerResponseTask fieldName=vnfID schemaName=UUIDType + +task contextref create name=ControllerResponseTask albumName=ControlLoopStatusAlbum +task contextref create name=ControllerResponseTask albumName=RequestIDVNFIDAlbum + +task logic create name=ControllerResponseTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/ControllerResponseTask.js" +LE + +task create name=ControlLoopLogTask + +task inputfield create name=ControlLoopLogTask fieldName=requestID schemaName=UUIDType +task inputfield create name=ControlLoopLogTask fieldName=vnfID schemaName=UUIDType + +task outputfield create name=ControlLoopLogTask fieldName=VirtualControlLoopNotification schemaName=VirtualControlLoopNotificationType + +task contextref create name=ControlLoopLogTask albumName=ControlLoopStatusAlbum + +task logic create name=ControlLoopLogTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/ControlLoopLogTask.js" +LE + +task create name=ConfigureBlackWhiteListTask + +task inputfield create name=ConfigureBlackWhiteListTask fieldName=targetType schemaName=SimpleStringType +task inputfield create name=ConfigureBlackWhiteListTask fieldName=black schemaName=SimpleBooleanType +task inputfield create name=ConfigureBlackWhiteListTask fieldName=target schemaName=SimpleStringType + +task outputfield create name=ConfigureBlackWhiteListTask fieldName=targetType schemaName=SimpleStringType +task outputfield create name=ConfigureBlackWhiteListTask fieldName=black schemaName=SimpleBooleanType +task outputfield create name=ConfigureBlackWhiteListTask fieldName=target schemaName=SimpleStringType + +task contextref create name=ConfigureBlackWhiteListTask albumName=VnfIdWhiteBlackListAlbum +task contextref create name=ConfigureBlackWhiteListTask albumName=ServiceIdWhiteBlackListAlbum +task contextref create name=ConfigureBlackWhiteListTask albumName=VServerIdWhiteBlackListAlbum + +task logic create name=ConfigureBlackWhiteListTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/ConfigureBlackWhiteListTask.js" +LE + +# +# ReceiveEventPolicy +# +policy create name=ReceiveEventPolicy template=Freestyle firstState=GetEntityState + +policy state create name=ReceiveEventPolicy stateName=LogAndStopState triggerName=EntityStateUpdatedEvent defaultTaskName=ControlLoopLogTask +policy state output create name=ReceiveEventPolicy stateName=LogAndStopState outputName=AbatedOutput eventName=ControlLoopLogEvent +policy state taskref create name=ReceiveEventPolicy stateName=LogAndStopState taskName=ControlLoopLogTask outputType=DIRECT outputName=AbatedOutput + +policy state create name=ReceiveEventPolicy stateName=ExecuteOrLogState triggerName=EntityStateUpdatedEvent defaultTaskName=StopAndLogTask +policy state output create name=ReceiveEventPolicy stateName=ExecuteOrLogState outputName=ExecuteOutput eventName=ActionEventListEvent +policy state taskref create name=ReceiveEventPolicy stateName=ExecuteOrLogState taskName=InitiateActionsTask outputType=DIRECT outputName=ExecuteOutput +policy state output create name=ReceiveEventPolicy stateName=ExecuteOrLogState outputName=StopAndLogOutput eventName=EntityStateUpdatedEvent nextState=LogAndStopState +policy state taskref create name=ReceiveEventPolicy stateName=ExecuteOrLogState taskName=StopAndLogTask outputType=DIRECT outputName=StopAndLogOutput + +policy state contextref create name=ReceiveEventPolicy stateName=ExecuteOrLogState albumName=ControlLoopStatusAlbum + +policy state selecttasklogic create name=ReceiveEventPolicy stateName=ExecuteOrLogState logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/ReceiveEventPolicyExecuteOrLogStateTSL.js" +LE + +policy state create name=ReceiveEventPolicy stateName=CheckVNFIdState triggerName=EntityStateUpdatedEvent defaultTaskName=CheckVNFIdTask +policy state output create name=ReceiveEventPolicy stateName=CheckVNFIdState outputName=CheckVNFIdOutput eventName=EntityStateUpdatedEvent nextState=ExecuteOrLogState +policy state taskref create name=ReceiveEventPolicy stateName=CheckVNFIdState taskName=CheckVNFIdTask outputType=DIRECT outputName=CheckVNFIdOutput + +policy state create name=ReceiveEventPolicy stateName=CheckVServerIdState triggerName=EntityStateUpdatedEvent defaultTaskName=CheckVServerIdTask +policy state output create name=ReceiveEventPolicy stateName=CheckVServerIdState outputName=CheckVServerIdOutput eventName=EntityStateUpdatedEvent nextState=CheckVNFIdState +policy state taskref create name=ReceiveEventPolicy stateName=CheckVServerIdState taskName=CheckVServerIdTask outputType=DIRECT outputName=CheckVServerIdOutput + +policy state create name=ReceiveEventPolicy stateName=CheckServiceIdState triggerName=EntityStateUpdatedEvent defaultTaskName=CheckServiceIdTask +policy state output create name=ReceiveEventPolicy stateName=CheckServiceIdState outputName=CheckServiceIdOutput eventName=EntityStateUpdatedEvent nextState=CheckVServerIdState +policy state taskref create name=ReceiveEventPolicy stateName=CheckServiceIdState taskName=CheckServiceIdTask outputType=DIRECT outputName=CheckServiceIdOutput + +policy state create name=ReceiveEventPolicy stateName=GetEntityState triggerName=VirtualControlLoopEvent defaultTaskName=GetEntityStateTask +policy state output create name=ReceiveEventPolicy stateName=GetEntityState outputName=GetEntityStateOutput eventName=EntityStateUpdatedEvent nextState=CheckServiceIdState +policy state taskref create name=ReceiveEventPolicy stateName=GetEntityState taskName=GetEntityStateTask outputType=DIRECT outputName=GetEntityStateOutput + +policy state contextref create name=ReceiveEventPolicy stateName=GetEntityState albumName=ControlLoopStatusAlbum + +# +# ExecuteActionsPolicy +# +policy create name=ExecuteActionsPolicy template=Freestyle firstState=ActionState + +policy state create name=ExecuteActionsPolicy stateName=ControllerRequestActionState triggerName=ActionEvent defaultTaskName=ControllerRequestTask +policy state output create name=ExecuteActionsPolicy stateName=ControllerRequestActionState outputName=ControllerRequestOutput eventName=ControllerRequestEvent +policy state taskref create name=ExecuteActionsPolicy stateName=ControllerRequestActionState taskName=ControllerRequestTask outputType=DIRECT outputName=ControllerRequestOutput + +policy state create name=ExecuteActionsPolicy stateName=LogActionState triggerName=EntityStateUpdatedEvent defaultTaskName=ControlLoopLogTask +policy state output create name=ExecuteActionsPolicy stateName=LogActionState outputName=ResponseLogOutput eventName=ControlLoopLogEvent +policy state taskref create name=ExecuteActionsPolicy stateName=LogActionState taskName=ControlLoopLogTask outputType=DIRECT outputName=ResponseLogOutput + +policy state create name=ExecuteActionsPolicy stateName=ActionState triggerName=ActionEvent defaultTaskName=DoLogActionTask +policy state output create name=ExecuteActionsPolicy stateName=ActionState outputName=LogActionOutput eventName=EntityStateUpdatedEvent nextState=LogActionState +policy state taskref create name=ExecuteActionsPolicy stateName=ActionState taskName=DoLogActionTask outputType=DIRECT outputName=LogActionOutput +policy state output create name=ExecuteActionsPolicy stateName=ActionState outputName=ControllerRequestActionOutput eventName=ActionEvent nextState=ControllerRequestActionState +policy state taskref create name=ExecuteActionsPolicy stateName=ActionState taskName=DoControllerRequestActionTask outputType=DIRECT outputName=ControllerRequestActionOutput + +policy state contextref create name=ExecuteActionsPolicy stateName=ActionState albumName=ControlLoopStatusAlbum + +policy state selecttasklogic create name=ExecuteActionsPolicy stateName=ActionState logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/standalone/ExecuteActionsPolicyActionStateTSL.js" +LE + +# +# ControllerResponsePolicy +# +policy create name=ControllerResponsePolicy template=Freestyle firstState=ControllerResponseState + +policy state create name=ControllerResponsePolicy stateName=ResponseLogState triggerName=EntityStateUpdatedEvent defaultTaskName=ControlLoopLogTask +policy state output create name=ControllerResponsePolicy stateName=ResponseLogState outputName=ResponseLogOutput eventName=ControlLoopLogEvent +policy state taskref create name=ControllerResponsePolicy stateName=ResponseLogState taskName=ControlLoopLogTask outputType=DIRECT outputName=ResponseLogOutput + +policy state create name=ControllerResponsePolicy stateName=ControllerResponseState triggerName=ControllerResponseEvent defaultTaskName=ControllerResponseTask +policy state output create name=ControllerResponsePolicy stateName=ControllerResponseState outputName=ControllerResponseOutput eventName=EntityStateUpdatedEvent nextState=ResponseLogState +policy state taskref create name=ControllerResponsePolicy stateName=ControllerResponseState taskName=ControllerResponseTask outputType=DIRECT outputName=ControllerResponseOutput + +# +# ConfigureBlackWhiteListPolicy +# +policy create name=ConfigureBlackWhiteListPolicy template=Freestyle firstState=ConfigureBlackWhiteListState + +policy state create name=ConfigureBlackWhiteListPolicy stateName=ConfigureBlackWhiteListState triggerName=ConfigureBlackWhiteListEvent defaultTaskName=ConfigureBlackWhiteListTask +policy state output create name=ConfigureBlackWhiteListPolicy stateName=ConfigureBlackWhiteListState outputName=ConfigureBlackWhiteListOutput eventName=ConfigureBlackWhiteListResultEvent +policy state taskref create name=ConfigureBlackWhiteListPolicy stateName=ConfigureBlackWhiteListState taskName=ConfigureBlackWhiteListTask outputType=DIRECT outputName=ConfigureBlackWhiteListOutput + +validate diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/GuardDecisionAttributesType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/definitive/GuardDecisionAttributesType.avsc index bc25955fa..bc25955fa 100644 --- a/examples/examples-onap-vcpe/src/main/resources/schemas/GuardDecisionAttributesType.avsc +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/definitive/GuardDecisionAttributesType.avsc diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/definitive/VCPEClosedLoopStatusType.avsc index b02287d2a..b02287d2a 100644 --- a/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusType.avsc +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/definitive/VCPEClosedLoopStatusType.avsc diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/ControlLoopStatusType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/ControlLoopStatusType.avsc new file mode 100644 index 000000000..b02287d2a --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/ControlLoopStatusType.avsc @@ -0,0 +1,128 @@ +{ + "type": "record", + "name": "VCPEClosedLoopStatus", + "fields": [ + { + "name": "AAI", + "type": { + "type": "record", + "name": "VCPE_AAI_Type", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "genericVnfResourceVersion", + "type": "string" + }, + { + "name": "genericVnfVnfName", + "type": "string" + }, + { + "name": "genericVnfProvStatus", + "type": "string" + }, + { + "name": "genericVnfIsClosedLoopDisabled", + "type": "string" + }, + { + "name": "genericVnfOrchestrationStatus", + "type": "string" + }, + { + "name": "genericVnfVnfType", + "type": "string" + }, + { + "name": "genericVnfInMaint", + "type": "string" + }, + { + "name": "genericVnfServiceId", + "type": "string" + }, + { + "name": "genericVnfVnfId", + "type": "string" + }, + { + "name": "vserverIsClosedLoopDisabled", + "type": "string" + }, + { + "name": "vserverName", + "type": "string" + }, + { + "name": "vserverProvStatus", + "type": "string" + } + ] + } + }, + { + "name": "closedLoopAlarmStart", + "type": "long" + }, + { + "name": "closedLoopAlarmEnd", + "type": "long" + }, + { + "name": "closedLoopControlName", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "requestID", + "type": "string" + }, + { + "name": "closedLoopEventClient", + "type": "string" + }, + { + "name": "closedLoopEventStatus", + "type": "string" + }, + { + "name": "target_type", + "type": "string" + }, + { + "name": "target", + "type": "string" + }, + { + "name": "from", + "type": "string" + }, + { + "name": "policyScope", + "type": "string" + }, + { + "name": "policyName", + "type": "string" + }, + { + "name": "policyVersion", + "type": "string" + }, + { + "name": "notification", + "type": "string" + }, + { + "name": "notificationTime", + "type": "long" + }, + { + "name": "message", + "type": "string" + } + ] +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/ControllerRequestType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/ControllerRequestType.avsc new file mode 100644 index 000000000..41bbca4cb --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/ControllerRequestType.avsc @@ -0,0 +1,90 @@ +{ + "type": "record", + "name": "VCPEClosedLoopStatus", + "fields": [ + { + "name": "version", + "type": "string" + }, + { + "name": "rpc_DasH_name", + "type": "string" + }, + { + "name": "correlation_DasH_id", + "type": "string" + }, + { + "name": "type", + "type": "string" + }, + { + "name": "body", + "type": { + "type": "record", + "name": "Controller_Body_Type", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "input", + "type": { + "type": "record", + "name": "Controller_Body_Type_Input", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "action", + "type": "string" + }, + { + "name": "action_DasH_identifiers", + "type": { + "type": "map", + "values": "string" + } + }, + { + "name": "common_DasH_header", + "type": { + "type": "record", + "name": "Controller_Body_Type_Common_Header", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "timestamp", + "type": "long" + }, + { + "name": "api_DasH_ver", + "type": "string" + }, + { + "name": "originator_DasH_id", + "type": "string" + }, + { + "name": "request_DasH_id", + "type": "string" + }, + { + "name": "sub_DasH_request_DasH_id", + "type": "string" + }, + { + "name": "flags", + "type": { + "type": "map", + "values": "string" + } + } + ] + } + } + ] + } + } + ] + } + } + ] +} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/ControllerResponseType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/ControllerResponseType.avsc new file mode 100644 index 000000000..336c16143 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/ControllerResponseType.avsc @@ -0,0 +1,101 @@ +{ + "type": "record", + "name": "VCPEClosedLoopStatus", + "fields": [ + { + "name": "version", + "type": "string" + }, + { + "name": "rpc_DasH_name", + "type": "string" + }, + { + "name": "correlation_DasH_id", + "type": "string" + }, + { + "name": "type", + "type": "string" + }, + { + "name": "body", + "type": { + "type": "record", + "name": "Controller_Body_Type", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "output", + "type": { + "type": "record", + "name": "Controller_Body_Type_Output", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "payload", + "type": "string" + }, + { + "name": "common_DasH_header", + "type": { + "type": "record", + "name": "Controller_Body_Type_Common_Header", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "timestamp", + "type": "long" + }, + { + "name": "api_DasH_ver", + "type": "string" + }, + { + "name": "originator_DasH_id", + "type": "string" + }, + { + "name": "request_DasH_id", + "type": "string" + }, + { + "name": "sub_DasH_request_DasH_id", + "type": "string" + }, + { + "name": "flags", + "type": { + "type": "map", + "values": "string" + } + } + ] + } + }, + { + "name": "status", + "type": { + "type": "record", + "name": "Controller_Body_Type_Output_Status", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "code", + "type": "int" + }, + { + "name": "message", + "type": "string" + } + ] + } + } + ] + } + } + ] + } + } + ] +} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/VirtualControlLoopEventType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/VirtualControlLoopEventType.avsc new file mode 100644 index 000000000..e0e076483 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/VirtualControlLoopEventType.avsc @@ -0,0 +1,76 @@ +{ + "type": "record", + "name": "VirtualControlLoopEvent", + "fields": [ + { + "name": "requestID", + "type": "string" + }, + { + "name": "target_type", + "type": "string" + }, + { + "name": "closedLoopControlName", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "closedLoopEventClient", + "type": "string" + }, + { + "name": "target", + "type": "string" + }, + { + "name": "from", + "type": "string" + }, + { + "name": "policyScope", + "type": "string" + }, + { + "name": "policyName", + "type": "string" + }, + { + "name": "policyVersion", + "type": "string" + }, + { + "name": "closedLoopEventStatus", + "type": "string" + }, + { + "name": "additionalEventParams", + "type": { + "type": "map", + "values": "string" + } + }, + { + "name": "AAI", + "type": { + "type": "map", + "values": "string" + } + }, + { + "name": "payload", + "type": "string" + }, + { + "name": "closedLoopAlarmStart", + "type": "long" + }, + { + "name": "closedLoopAlarmEnd", + "type": "long" + } + ] +} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/VirtualControlLoopNotificationType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/VirtualControlLoopNotificationType.avsc new file mode 100644 index 000000000..0b7a80cb5 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/standalone/VirtualControlLoopNotificationType.avsc @@ -0,0 +1,77 @@ +{ + "type": "record", + "name": "VirtualControlLoopNotification", + "fields": [ + { + "name": "closedLoopControlName", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "requestID", + "type": "string" + }, + { + "name": "closedLoopEventClient", + "type": "string" + }, + { + "name": "targetType", + "type": "string" + }, + { + "name": "target", + "type": "string" + }, + { + "name": "from", + "type": "string" + }, + { + "name": "policyScope", + "type": "string" + }, + { + "name": "policyName", + "type": "string" + }, + { + "name": "policyVersion", + "type": "string" + }, + { + "name": "notification", + "type": "string" + }, + { + "name": "message", + "type": "string" + }, + { + "name": "notificationTime", + "type": "long" + }, + { + "name": "opsClTimer", + "type": "int" + }, + { + "name": "AAI", + "type": { + "type": "map", + "values": "string" + } + }, + { + "name": "closedLoopAlarmStart", + "type": "long" + }, + { + "name": "closedLoopAlarmEnd", + "type": "long" + } + ] +} diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AppcResponseCreator.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AppcResponseCreator.java index d989ba361..63ca3cd26 100644 --- a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AppcResponseCreator.java +++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AppcResponseCreator.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +49,9 @@ public class AppcResponseCreator { private final Timer appcTimer; private static final Gson gson = new GsonBuilder() - .registerTypeAdapter(Instant.class, new Serialization.GsonInstantAdapter()).create(); + .registerTypeAdapter(Instant.class, new Serialization.GsonInstantAdapter()).setPrettyPrinting().create(); + + private static Integer nextResponseCode = 400; /** * Respond to the given APPC request after the given amount of milliseconds. @@ -58,7 +61,7 @@ public class AppcResponseCreator { * @param milliSecondsToWait the number of milliseconds to wait */ public AppcResponseCreator(BlockingQueue<String> appcResponseQueue, String jsonRequestString, - long milliSecondsToWait) { + long milliSecondsToWait) { this.jsonRequestString = jsonRequestString; this.appcResponseQueue = appcResponseQueue; @@ -79,8 +82,20 @@ public class AppcResponseCreator { AppcLcmInput request = requestWrapper.getBody().getInput(); AppcLcmOutput response = new AppcLcmOutput(request); - response.getStatus().setCode(400); - response.getStatus().setMessage("Restart Successful"); + + response.getStatus().setCode(nextResponseCode); + if (nextResponseCode == 400) { + response.getStatus().setMessage("Restart Successful"); + nextResponseCode = 100; + } else if (nextResponseCode == 100) { + response.getStatus().setMessage("Restart Request Accepted"); + nextResponseCode = 200; + } else { + response.getStatus().setMessage("Error in Restart Operation"); + nextResponseCode = 400; + } + + response.setPayload(""); AppcLcmDmaapWrapper responseWrapper = new AppcLcmDmaapWrapper(); responseWrapper.setBody(new AppcLcmBody()); diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java index 5eb8fd338..8665f4a05 100644 --- a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java +++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +26,8 @@ import static org.junit.Assert.assertTrue; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; import java.io.IOException; import java.time.Instant; @@ -63,10 +66,13 @@ public class OnapVCpeSimEndpoint { private static AtomicInteger statMessagesReceived = new AtomicInteger(); private static AtomicInteger getMessagesReceived = new AtomicInteger(); + private static final Random randomDelayInc = new Random(); + private static final Gson gson = new GsonBuilder() - .registerTypeAdapter(Instant.class, new Serialization.GsonInstantAdapter()).create(); + .registerTypeAdapter(Instant.class, new Serialization.GsonInstantAdapter()).setPrettyPrinting().create(); private static final AtomicInteger nextVnfId = new AtomicInteger(0); + private static Boolean nextControlLoopMessageIsOnset = true; /** * Service get stats. @@ -77,9 +83,10 @@ public class OnapVCpeSimEndpoint { @GET public Response serviceGetStats() { statMessagesReceived.incrementAndGet(); + String returnString = "{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + ",\"POST\": " + + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}"; - return Response.status(200).entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived - + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); + return Response.status(200).entity(prettifyJsonString(returnString)).build(); } /** @@ -106,8 +113,10 @@ public class OnapVCpeSimEndpoint { responseJsonString = "{\"decision\": \"DENY\", \"details\": \"Decision Denied. NOK :-(\"}"; } + responseJsonString = prettifyJsonString(responseJsonString); + LOGGER.info("\n*** GUARD RESPONSE START ***\n" + target + "\n" + responseJsonString - + "\n*** GUARD RESPONSE END ***"); + + "\n*** GUARD RESPONSE END ***"); return Response.status(200).entity(responseJsonString).build(); } @@ -124,19 +133,21 @@ public class OnapVCpeSimEndpoint { @Path("aai/v16/search/nodes-query") @GET public Response aaiNamedQuerySearchRequest(@QueryParam("search-node-type") final String searchNodeType, - @QueryParam("filter") final String filter) throws IOException { + @QueryParam("filter") final String filter) throws IOException { getMessagesReceived.incrementAndGet(); LOGGER.info("\n*** AAI NODE QUERY GET START ***\nsearchNodeType=" + searchNodeType + "\nfilter=" + filter - + "\n *** AAI REQUEST END ***"); + + "\n *** AAI REQUEST END ***"); - String adjustedVserverUuid = "b4fe00ac-1da6-4b00-ac0d-8e8300db" - + String.format("%04d", nextVnfId.getAndIncrement()); + String adjustedVserverUuid = + "b4fe00ac-1da6-4b00-ac0d-8e8300db" + String.format("%04d", nextVnfId.getAndIncrement()); - String responseJsonString = TextFileUtils - .getTextFileAsString("src/test/resources/aai/SearchNodeTypeResponse.json") + String responseJsonString = + TextFileUtils.getTextFileAsString("src/test/resources/aai/SearchNodeTypeResponse.json") .replaceAll("b4fe00ac-1da6-4b00-ac0d-8e8300db0007", adjustedVserverUuid); + responseJsonString = prettifyJsonString(responseJsonString); + LOGGER.info("\n*** AAI RESPONSE START ***\n" + responseJsonString + "\n *** AAI RESPONSE END ***"); return Response.status(200).entity(responseJsonString).build(); @@ -154,18 +165,20 @@ public class OnapVCpeSimEndpoint { @Path("aai/v16/query") @PUT public Response aaiNamedQueryResourceRequest(@QueryParam("format") final String format, final String jsonString) - throws IOException { + throws IOException { putMessagesReceived.incrementAndGet(); LOGGER.info("\n*** AAI NODE RESOURE POST QUERY START ***\\nformat=" + format + "\njson=" + jsonString - + "\n *** AAI REQUEST END ***"); + + "\n *** AAI REQUEST END ***"); - int beginIndex = jsonString.indexOf("b4fe00ac-1da6-4b00-ac0d-8e8300db") - + "b4fe00ac-1da6-4b00-ac0d-8e8300db".length(); + int beginIndex = + jsonString.indexOf("b4fe00ac-1da6-4b00-ac0d-8e8300db") + "b4fe00ac-1da6-4b00-ac0d-8e8300db".length(); String nextVnfIdUrlEnding = jsonString.substring(beginIndex, beginIndex + 4); String responseJsonString = TextFileUtils.getTextFileAsString("src/test/resources/aai/NodeQueryResponse.json") - .replaceAll("bbb3cefd-01c8-413c-9bdd-2b92f9ca3d38", - "00000000-0000-0000-0000-00000000" + nextVnfIdUrlEnding); + .replaceAll("bbb3cefd-01c8-413c-9bdd-2b92f9ca3d38", + "00000000-0000-0000-0000-00000000" + nextVnfIdUrlEnding); + + responseJsonString = prettifyJsonString(responseJsonString); LOGGER.info("\n*** AAI RESPONSE START ***\n" + responseJsonString + "\n *** AAI RESPONSE END ***"); @@ -177,15 +190,32 @@ public class OnapVCpeSimEndpoint { * * @param timeout the timeout to wait for * @return the response + * @throws IOException on I/O errors */ @Path("events/unauthenticated.DCAE_CL_OUTPUT/APEX/1") @GET - public Response dcaeClOutput(@QueryParam("timeout") final int timeout) { + public Response dcaeClOutput(@QueryParam("timeout") final int timeout) throws IOException { getMessagesReceived.incrementAndGet(); ThreadUtilities.sleep(timeout - 500); - return Response.status(200).build(); + if (nextControlLoopMessageIsOnset) { + nextControlLoopMessageIsOnset = false; + + String clOnsetEvent = TextFileUtils + .getTextFileAsString("src/main/resources/examples/events/ONAPvCPEStandalone/CLOnsetEvent.json"); + LOGGER.info("\n*** CONTROL LOOP ONSET START ***\n" + clOnsetEvent + "\n *** CONTROL LOOP ONSET END ***"); + + return Response.status(200).entity(clOnsetEvent).build(); + } else { + nextControlLoopMessageIsOnset = true; + + String clAbatedEvent = TextFileUtils + .getTextFileAsString("src/main/resources/examples/events/ONAPvCPEStandalone/CLAbatedEvent.json"); + LOGGER.info("\n*** CONTROL LOOP ABATED START ***\n" + clAbatedEvent + "\n *** CONTROL LOOP ABATED END ***"); + + return Response.status(200).entity(clAbatedEvent).build(); + } } /** @@ -206,9 +236,9 @@ public class OnapVCpeSimEndpoint { String appcResponse = appcResponseQueue.poll(100, TimeUnit.MILLISECONDS); if (appcResponse != null) { - LOGGER.info("\n*** APPC RESPONSE START ***"); + LOGGER.info("\n*** CONTROLLER RESPONSE START ***"); System.err.println(appcResponse); - LOGGER.info("\n*** APPC RESPONSE END ***"); + LOGGER.info("\n*** CONTROLLER RESPONSE END ***"); return Response.status(200).entity(appcResponse).build(); } @@ -230,7 +260,9 @@ public class OnapVCpeSimEndpoint { public Response policyLogRequest(final String jsonString) { postMessagesReceived.incrementAndGet(); - LOGGER.info("\n*** POLICY LOG ENTRY START ***\n" + jsonString + "\n *** POLICY LOG ENTRY END ***"); + String logJsonString = prettifyJsonString(jsonString); + + LOGGER.info("\n*** POLICY LOG ENTRY START ***\n" + logJsonString + "\n *** POLICY LOG ENTRY END ***"); return Response.status(200).build(); } @@ -246,9 +278,29 @@ public class OnapVCpeSimEndpoint { public Response appcRequest(final String jsonString) { postMessagesReceived.incrementAndGet(); - LOGGER.info("\n*** APPC REQUEST START ***\n" + jsonString + "\n *** APPC REQUEST END ***"); + String appcJsonString = prettifyJsonString(jsonString); + + LOGGER.info("\n*** CONTROLLER REQUEST START ***\n" + appcJsonString + "\n *** CONTROLLER REQUEST END ***"); - new AppcResponseCreator(appcResponseQueue, jsonString, 10000); + new AppcResponseCreator(appcResponseQueue, appcJsonString, 10000 + randomDelayInc.nextInt(10000)); + + return Response.status(200).build(); + } + + /** + * Post to BLACK WHITE LIST READ (Simulation of DMaaP). + * + * @param jsonString the json string + * @return the response + */ + @Path("/events/BLACK-WHITE-LIST-READ") + @POST + public Response blackWhiteListRead(final String jsonString) { + postMessagesReceived.incrementAndGet(); + + String bwJsonString = prettifyJsonString(jsonString); + + LOGGER.info("\n*** BLACK WHITE LIST START ***\n" + bwJsonString + "\n *** BLACK WHITE LIST END ***"); return Response.status(200).build(); } @@ -266,11 +318,10 @@ public class OnapVCpeSimEndpoint { final String nextEventName = "Event0" + rand.nextInt(2) + "00"; final String eventString = "{\n" + "\"nameSpace\": \"org.onap.policy.apex.sample.events\",\n" + "\"name\": \"" - + nextEventName + "\",\n" + "\"version\": \"0.0.1\",\n" + "\"source\": \"REST_" - + getMessagesReceived + "\",\n" + "\"target\": \"apex\",\n" - + "\"TestSlogan\": \"Test slogan for External Event0\",\n" + "\"TestMatchCase\": " - + nextMatchCase + ",\n" + "\"TestTimestamp\": " + System.currentTimeMillis() + ",\n" - + "\"TestTemperature\": 9080.866\n" + "}"; + + nextEventName + "\",\n" + "\"version\": \"0.0.1\",\n" + "\"source\": \"REST_" + getMessagesReceived + + "\",\n" + "\"target\": \"apex\",\n" + "\"TestSlogan\": \"Test slogan for External Event0\",\n" + + "\"TestMatchCase\": " + nextMatchCase + ",\n" + "\"TestTimestamp\": " + System.currentTimeMillis() + + ",\n" + "\"TestTemperature\": 9080.866\n" + "}"; getMessagesReceived.incrementAndGet(); @@ -319,7 +370,7 @@ public class OnapVCpeSimEndpoint { assertEquals("Outside", jsonMap.get("target")); return Response.status(200).entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived - + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); + + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); } /** @@ -354,6 +405,12 @@ public class OnapVCpeSimEndpoint { assertEquals("Outside", jsonMap.get("target")); return Response.status(200).entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived - + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); + + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); + } + + private static final String prettifyJsonString(final String uglyJsonString) { + JsonParser jp = new JsonParser(); + JsonElement je = jp.parse(uglyJsonString); + return gson.toJson(je); } } diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVcpeStandaloneRunner.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVcpeStandaloneRunner.java new file mode 100644 index 000000000..f3bf30837 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVcpeStandaloneRunner.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.domains.onap.vcpe; + +import org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain; +import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; +import org.onap.policy.apex.model.basicmodel.concepts.ApexException; +import org.onap.policy.apex.service.engine.main.ApexMain; + +/** + * Test the ONAP vCPE use case. + */ +public class OnapVcpeStandaloneRunner { + + private OnapVcpeStandaloneRunner() throws ApexException { + + // @formatter:off + final String[] cliArgs = new String[] { + "-c", + "src/main/resources/policy/ONAPvCPEPolicyModelStandalone.apex", + "-l", + "target/ONAPvCPEPolicyModel.log", + "-o", + "target/classes/ONAPvCPEPolicyModelStandalone.json" + }; + // @formatter:on + + new ApexCommandLineEditorMain(cliArgs); + + // @formatter:off + final String[] apexArgs = { + "-rfr", + "target/classes", + "-c", + "src/main/resources/examples/config/ONAPvCPEStandalone/ApexConfig_Sim.json", + "-m", + "target/classes/ONAPvCPEPolicyModelStandalone.json" + }; + // @formatter:on + + final ApexMain apexMain = new ApexMain(apexArgs); + + ThreadUtilities.sleep(1000000); + apexMain.shutdown(); + } + + public static void main(String[] args) throws ApexException { + new OnapVcpeStandaloneRunner(); + } +} diff --git a/examples/examples-onap-vcpe/src/test/resources/etc/Notes.txt b/examples/examples-onap-vcpe/src/test/resources/etc/Notes.txt index 5db41a2a0..d0a5a698e 100644 --- a/examples/examples-onap-vcpe/src/test/resources/etc/Notes.txt +++ b/examples/examples-onap-vcpe/src/test/resources/etc/Notes.txt @@ -1,3 +1,24 @@ +#------------------------------------------------------------------------------- +# ============LICENSE_START======================================================= +# Copyright (C) 2016-2018 Ericsson. All rights reserved. +# Modifications Copyright (C) 2019-2020 Nordix Foundation. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= +#------------------------------------------------------------------------------- + Check out Draft Review Build the source |