diff options
Diffstat (limited to 'examples')
53 files changed, 1926 insertions, 1166 deletions
diff --git a/examples/examples-onap-vcpe/pom.xml b/examples/examples-onap-vcpe/pom.xml index 0196064d2..d60667bfe 100644 --- a/examples/examples-onap-vcpe/pom.xml +++ b/examples/examples-onap-vcpe/pom.xml @@ -18,7 +18,8 @@ SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.policy.apex-pdp.examples</groupId> @@ -54,6 +55,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.glassfish.jersey.inject</groupId> + <artifactId>jersey-hk2</artifactId> + <version>${version.jersey}</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-schema</groupId> <artifactId>plugins-context-schema-avro</artifactId> <version>${project.version}</version> @@ -68,6 +75,26 @@ <artifactId>plugins-event-carrier-restrequestor</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.onap.policy.apex-pdp.plugins.plugins-event.plugins-event-carrier</groupId> + <artifactId>plugins-event-carrier-restclient</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> + <artifactId>aai</artifactId> + <version>${version.policy.models}</version> + </dependency> + <dependency> + <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> + <artifactId>appclcm</artifactId> + <version>${version.policy.models}</version> + </dependency> + <dependency> + <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId> + <artifactId>events</artifactId> + <version>${version.policy.models}</version> + </dependency> </dependencies> <build> @@ -118,4 +145,4 @@ </distributionManagement> </profile> </profiles> -</project>
\ No newline at end of file +</project> diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/ApexConfig.json b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/ApexConfig.json index 4ea4c5633..862bba296 100644 --- a/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/ApexConfig.json +++ b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/ApexConfig.json @@ -5,7 +5,7 @@ "id": 45, "instanceCount": 4, "deploymentPort": 12561, - "policyModelFileName": "policy/ONAPvCPEPolicyModel.json", + "policyModelFileName": "/home/apexuser/examples/models/ONAPvCPE/ONAPvCPEPolicyModel.json", "engineParameters": { "executorParameters": { "JAVASCRIPT": { @@ -17,45 +17,69 @@ "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" + }, + "APPC_LCM_REQUEST": { + "adaptedClass": "org.onap.policy.appclcm.LcmRequest", + "adaptorClass": "org.onap.policy.appclcm.util.Serialization$RequestAdapter" + }, + "APPC_LCM_RESPONSE": { + "adaptedClass": "org.onap.policy.appclcm.LcmResponse", + "adaptorClass": "org.onap.policy.appclcm.util.Serialization$ResponseAdapter" + } + } } } } } }, "eventInputParameters": { - "VCPEInitConsumer": { + "GuardRequestorConsumer": { "carrierTechnologyParameters": { - "carrierTechnology": "FILE", + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", "parameters": { - "fileName": "config/VCPEInitiationEvent.json" + "url": "http://172.18.0.6:8081/pdp/api/getDecision", + "httpMethod": "POST", + "restRequestTimeout": 2000, + "httpHeader": "Authorization:dGVzdHBkcDphbHBoYTEyMw== ClientAuth:cHl0aG9uOnRlc3Q=" } }, "eventProtocolParameters": { - "eventProtocol": "JSON", - "parameters": { - "nameAlias": "closedLoopControlName", - "versionAlias": "version", - "sourceAlias": "from" - } - } + "eventProtocol": "JSON" + }, + "eventName": "GuardResponseEvent", + "eventNameFilter": "GuardResponseEvent", + "requestorMode": true, + "requestorPeer": "GuardRequestorProducer", + "requestorTimeout": 500 }, - "GuardRequestorConsumer": { + "AAIRequestorConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTREQUESTOR", "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", "parameters": { - "url": "http://192.168.144.235:54321/AAIAndGuardSim/sim/pdp/api/getDecision", + "url": "http://10.0.1.1:8443/aai/search/named-query", "httpMethod": "POST", "restRequestTimeout": 2000 } }, "eventProtocolParameters": { - "eventProtocol": "JSON" + "eventProtocol": "JSON", + "parameters": { + "pojoField": "AAINamedQueryResponse" + } }, - "eventName": "GuardResponseEvent", - "eventNameFilter": "GuardResponseEvent", + "eventName": "AAINamedQueryResponseEvent", + "eventNameFilter": "AAINamedQueryResponseEvent", "requestorMode": true, - "requestorPeer": "GuardRequestorProducer", + "requestorPeer": "AAIRequestorProducer", "requestorTimeout": 500 }, "DCAEConsumer": { @@ -63,7 +87,7 @@ "carrierTechnology": "RESTCLIENT", "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { - "url": "http://192.168.144.235:3904/events/unauthenticated.DCAE_CL_OUTPUT/APEX/1?timeout=60000" + "url": "http://10.0.11.1:3904/events/unauthenticated.DCAE_CL_OUTPUT/APEX/1?timeout=60000" } }, "eventProtocolParameters": { @@ -71,20 +95,26 @@ "parameters": { "nameAlias": "closedLoopControlName", "versionAlias": "version", - "sourceAlias": "from" + "sourceAlias": "from", + "pojoField": "VirtualControlLoopEvent" } - } + }, + "eventName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e" }, "APPCConsumer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { - "url": "http://192.168.144.235:3904/events/APPC_LCM_WRITE/APEX/1?timeout=60000" + "url": "http://10.0.11.1:3904/events/APPC-LCM-WRITE/APEX/1?timeout=60000" } }, "eventProtocolParameters": { - "eventProtocol": "JSON" + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "pojoField": "APPCLCMResponseEvent" + } }, "eventName": "APPCRestartVNFResponseEvent", "eventNameFilter": "APPCRestartVNFResponseEvent" @@ -115,16 +145,37 @@ "requestorPeer": "GuardRequestorConsumer", "requestorTimeout": 500 }, + "AAIRequestorProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "pojoField": "AAINamedQueryRequest" + } + }, + "eventNameFilter": "AAINamedQueryRequestEvent", + "requestorMode": true, + "requestorPeer": "AAIRequestorConsumer", + "requestorTimeout": 500 + }, "APPCProducer": { "carrierTechnologyParameters": { "carrierTechnology": "RESTCLIENT", "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { - "url": "http://192.168.144.235:3904/events/APPC-LCM-READ" + "url": "http://10.0.11.1:3904/events/APPC-LCM-READ" } }, "eventProtocolParameters": { - "eventProtocol": "JSON" + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "sourceAlias": "from", + "pojoField": "APPCLCMRequestEvent" + } }, "eventNameFilter": "APPCRestartVNFRequestEvent" }, @@ -133,11 +184,16 @@ "carrierTechnology": "RESTCLIENT", "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", "parameters": { - "url": "http://192.168.144.235:3904/events/POLICY_CL_MGT" + "url": "http://10.0.11.1:3904/events/POLICY-CL-MGT" } }, "eventProtocolParameters": { - "eventProtocol": "JSON" + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "sourceAlias": "from", + "pojoField": "VirtualControlLoopNotification" + } }, "eventNameFilter": "ControlLoopLogEvent" } diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/ApexConfigStdin.json b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/ApexConfigStdin.json new file mode 100644 index 000000000..12d72bccb --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/ApexConfigStdin.json @@ -0,0 +1,215 @@ +{ + "engineServiceParameters": { + "name": "MyApexEngine", + "version": "0.0.1", + "id": 45, + "instanceCount": 4, + "deploymentPort": 12561, + "policyModelFileName": "/home/apexuser/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" + }, + "APPC_LCM_REQUEST": { + "adaptedClass": "org.onap.policy.appclcm.LcmRequest", + "adaptorClass": "org.onap.policy.appclcm.util.Serialization$RequestAdapter" + }, + "APPC_LCM_RESPONSE": { + "adaptedClass": "org.onap.policy.appclcm.LcmResponse", + "adaptorClass": "org.onap.policy.appclcm.util.Serialization$ResponseAdapter" + } + } + } + } + } + } + }, + "eventInputParameters": { + "VCPEInitConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "standardIo": true + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "sourceAlias": "from", + "pojoField": "VirtualControlLoopEvent" + } + }, + "eventName": "VirtualControlLoopEvent" + }, + "GuardRequestorConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", + "parameters": { + "url": "http://172.16.5.238:54321/OnapVCpeSim/sim/pdp/api/getDecision", + "httpMethod": "POST", + "restRequestTimeout": 2000 + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + }, + "eventName": "GuardResponseEvent", + "eventNameFilter": "GuardResponseEvent", + "requestorMode": true, + "requestorPeer": "GuardRequestorProducer", + "requestorTimeout": 500 + }, + "AAIRequestorConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", + "parameters": { + "url": "http://172.16.5.238:54321/OnapVCpeSim/sim/aai/search/named-query", + "httpMethod": "POST", + "restRequestTimeout": 2000 + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "pojoField": "AAINamedQueryResponse" + } + }, + "eventName": "AAINamedQueryResponseEvent", + "eventNameFilter": "AAINamedQueryResponseEvent", + "requestorMode": true, + "requestorPeer": "AAIRequestorProducer", + "requestorTimeout": 500 + }, + "DCAEConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://172.16.5.238:54321/OnapVCpeSim/sim/events/unauthenticated.DCAE_CL_OUTPUT/APEX/1?timeout=60000" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "nameAlias": "closedLoopControlName", + "versionAlias": "version", + "sourceAlias": "from" + } + } + }, + "APPCConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://172.16.5.238:54321/OnapVCpeSim/sim/events/APPC_LCM_WRITE/APEX/1?timeout=60000" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "pojoField": "APPCLCMResponseEvent" + } + }, + "eventName": "APPCRestartVNFResponseEvent", + "eventNameFilter": "APPCRestartVNFResponseEvent" + } + }, + "eventOutputParameters": { + "logProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "/tmp/VCPEEventsOut.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + }, + "GuardRequestorProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + }, + "eventNameFilter": "GuardRequestEvent", + "requestorMode": true, + "requestorPeer": "GuardRequestorConsumer", + "requestorTimeout": 500 + }, + "AAIRequestorProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "pojoField": "AAINamedQueryRequest" + } + }, + "eventNameFilter": "AAINamedQueryRequestEvent", + "requestorMode": true, + "requestorPeer": "AAIRequestorConsumer", + "requestorTimeout": 500 + }, + "APPCProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://172.16.5.238:54321/OnapVCpeSim/sim/events/APPC-LCM-READ" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "sourceAlias": "from", + "pojoField": "APPCLCMRequestEvent" + } + }, + "eventNameFilter": "APPCRestartVNFRequestEvent" + }, + "PolicyLogProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTCLIENT", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters", + "parameters": { + "url": "http://172.16.5.238: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/ONAPvCPE/ApexConfig_Sim.json b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/ApexConfig_Sim.json new file mode 100644 index 000000000..5bae09e7e --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/ApexConfig_Sim.json @@ -0,0 +1,215 @@ +{ + "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" + }, + "APPC_LCM_REQUEST": { + "adaptedClass": "org.onap.policy.appclcm.LcmRequest", + "adaptorClass": "org.onap.policy.appclcm.util.Serialization$RequestAdapter" + }, + "APPC_LCM_RESPONSE": { + "adaptedClass": "org.onap.policy.appclcm.LcmResponse", + "adaptorClass": "org.onap.policy.appclcm.util.Serialization$ResponseAdapter" + } + } + } + } + } + } + }, + "eventInputParameters": { + "VCPEInitConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "examples/events/ONAPvCPE/MultiEvents.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "sourceAlias": "from", + "pojoField": "VirtualControlLoopEvent" + } + }, + "eventName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e" + }, + "GuardRequestorConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", + "parameters": { + "url": "http://localhost:54321/OnapVCpeSim/sim/pdp/api/getDecision", + "httpMethod": "POST", + "restRequestTimeout": 2000 + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + }, + "eventName": "GuardResponseEvent", + "eventNameFilter": "GuardResponseEvent", + "requestorMode": true, + "requestorPeer": "GuardRequestorProducer", + "requestorTimeout": 500 + }, + "AAIRequestorConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", + "parameters": { + "url": "http://localhost:54321/OnapVCpeSim/sim/aai/search/named-query", + "httpMethod": "POST", + "restRequestTimeout": 2000 + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "pojoField": "AAINamedQueryResponse" + } + }, + "eventName": "AAINamedQueryResponseEvent", + "eventNameFilter": "AAINamedQueryResponseEvent", + "requestorMode": true, + "requestorPeer": "AAIRequestorProducer", + "requestorTimeout": 500 + }, + "DCAEConsumer": { + "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=60000" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "nameAlias": "closedLoopControlName", + "versionAlias": "version", + "sourceAlias": "from" + } + } + }, + "APPCConsumer": { + "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": "APPCLCMResponseEvent" + } + }, + "eventName": "APPCRestartVNFResponseEvent", + "eventNameFilter": "APPCRestartVNFResponseEvent" + } + }, + "eventOutputParameters": { + "logProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "/tmp/VCPEEventsOut.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + }, + "GuardRequestorProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + }, + "eventNameFilter": "GuardRequestEvent", + "requestorMode": true, + "requestorPeer": "GuardRequestorConsumer", + "requestorTimeout": 500 + }, + "AAIRequestorProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "pojoField": "AAINamedQueryRequest" + } + }, + "eventNameFilter": "AAINamedQueryRequestEvent", + "requestorMode": true, + "requestorPeer": "AAIRequestorConsumer", + "requestorTimeout": 500 + }, + "APPCProducer": { + "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": "APPCLCMRequestEvent" + } + }, + "eventNameFilter": "APPCRestartVNFRequestEvent" + }, + "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/ONAPvCPE/ApexConfig_Sim_StdIO.json b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/ApexConfig_Sim_StdIO.json new file mode 100644 index 000000000..a903cb3c2 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/ApexConfig_Sim_StdIO.json @@ -0,0 +1,215 @@ +{ + "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" + }, + "APPC_LCM_REQUEST": { + "adaptedClass": "org.onap.policy.appclcm.LcmRequest", + "adaptorClass": "org.onap.policy.appclcm.util.Serialization$RequestAdapter" + }, + "APPC_LCM_RESPONSE": { + "adaptedClass": "org.onap.policy.appclcm.LcmResponse", + "adaptorClass": "org.onap.policy.appclcm.util.Serialization$ResponseAdapter" + } + } + } + } + } + } + }, + "eventInputParameters": { + "VCPEInitConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "standardIo": true + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "versionAlias": "version", + "sourceAlias": "from", + "pojoField": "VirtualControlLoopEvent" + } + }, + "eventName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e" + }, + "GuardRequestorConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", + "parameters": { + "url": "http://localhost:54321/OnapVCpeSim/sim/pdp/api/getDecision", + "httpMethod": "POST", + "restRequestTimeout": 2000 + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + }, + "eventName": "GuardResponseEvent", + "eventNameFilter": "GuardResponseEvent", + "requestorMode": true, + "requestorPeer": "GuardRequestorProducer", + "requestorTimeout": 500 + }, + "AAIRequestorConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters", + "parameters": { + "url": "http://localhost:54321/OnapVCpeSim/sim/aai/search/named-query", + "httpMethod": "POST", + "restRequestTimeout": 2000 + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "pojoField": "AAINamedQueryResponse" + } + }, + "eventName": "AAINamedQueryResponseEvent", + "eventNameFilter": "AAINamedQueryResponseEvent", + "requestorMode": true, + "requestorPeer": "AAIRequestorProducer", + "requestorTimeout": 500 + }, + "DCAEConsumer": { + "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=60000" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "nameAlias": "closedLoopControlName", + "versionAlias": "version", + "sourceAlias": "from" + } + } + }, + "APPCConsumer": { + "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": "APPCLCMResponseEvent" + } + }, + "eventName": "APPCRestartVNFResponseEvent", + "eventNameFilter": "APPCRestartVNFResponseEvent" + } + }, + "eventOutputParameters": { + "logProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "/tmp/VCPEEventsOut.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + }, + "GuardRequestorProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + }, + "eventNameFilter": "GuardRequestEvent", + "requestorMode": true, + "requestorPeer": "GuardRequestorConsumer", + "requestorTimeout": 500 + }, + "AAIRequestorProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RestRequestorCarrierTechnologyParameters" + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "pojoField": "AAINamedQueryRequest" + } + }, + "eventNameFilter": "AAINamedQueryRequestEvent", + "requestorMode": true, + "requestorPeer": "AAIRequestorConsumer", + "requestorTimeout": 500 + }, + "APPCProducer": { + "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": "APPCLCMRequestEvent" + } + }, + "eventNameFilter": "APPCRestartVNFRequestEvent" + }, + "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/ONAPvCPE/VCPEInitiationEvent0.json b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/VCPEInitiationEvent0.json deleted file mode 100644 index e46a2739c..000000000 --- a/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/VCPEInitiationEvent0.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", - "closedLoopAlarmStart": 1519638197324, - "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", - "closedLoopEventStatus": "ONSET", - "requestID": "4a68f8a5-0db9-4070-a132-adede51ebeef", - "target_type": "VNF", - "target": "generic-vnf.vnf-id", - "AAI": { - "generic-vnf.resource-version": "1", - "generic-vnf.vnf-name": "vCPEInfraVNF99", - "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-dfe4a03bf00f", - "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db001e" - }, - "from": "DCAE", - "version": "1.0.2" -} diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/VCPEInitiationEvent1.json b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/VCPEInitiationEvent1.json deleted file mode 100644 index 5fcece8ac..000000000 --- a/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/VCPEInitiationEvent1.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", - "closedLoopAlarmStart": 1519638197699, - "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", - "closedLoopEventStatus": "ONSET", - "requestID": "4a68f8a5-0db9-4070-a132-adede51ebeaf", - "target_type": "VNF", - "target": "generic-vnf.vnf-id", - "AAI": { - "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db001c" - }, - "from": "DCAE", - "version": "1.0.2" -} diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/VCPEInitiationEvent2.json b/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/VCPEInitiationEvent2.json deleted file mode 100644 index 7e3e33777..000000000 --- a/examples/examples-onap-vcpe/src/main/resources/examples/config/ONAPvCPE/VCPEInitiationEvent2.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", - "closedLoopAlarmStart": 1519638197699, - "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", - "closedLoopEventStatus": "ONSET", - "requestID": "4a68f8a5-0db9-4070-a132-adede51ebeaf", - "target_type": "VNF", - "target": "generic-vnf.vnf-id", - "AAI": { - "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db001c" - }, - "from": "DCAE", - "version": "1.0.2" -} -{ - "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", - "closedLoopAlarmStart": 1519638197324, - "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", - "closedLoopEventStatus": "ONSET", - "requestID": "4a68f8a5-0db9-4070-a132-adede51ebeef", - "target_type": "VNF", - "target": "generic-vnf.vnf-id", - "AAI": { - "generic-vnf.resource-version": "1", - "generic-vnf.vnf-name": "vCPEInfraVNF99", - "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-dfe4a03bf00f", - "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db001e" - }, - "from": "DCAE", - "version": "1.0.2" -} diff --git a/examples/examples-onap-vcpe/src/test/resources/events/AAIQuery.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/AAIQuery.json index 46b5dbe73..46b5dbe73 100644 --- a/examples/examples-onap-vcpe/src/test/resources/events/AAIQuery.json +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/AAIQuery.json diff --git a/examples/examples-onap-vcpe/src/test/resources/events/AAIResponse4Policy.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/AAIResponse4Policy.json index 5bcff1b4b..5bcff1b4b 100644 --- a/examples/examples-onap-vcpe/src/test/resources/events/AAIResponse4Policy.json +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/AAIResponse4Policy.json diff --git a/examples/examples-onap-vcpe/src/test/resources/events/AAIResponse4VNF.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/AAIResponse4VNF.json index 3e8391eaa..3e8391eaa 100644 --- a/examples/examples-onap-vcpe/src/test/resources/events/AAIResponse4VNF.json +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/AAIResponse4VNF.json diff --git a/examples/examples-onap-vcpe/src/test/resources/events/AAIResponseExample.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/AAIResponseExample.json index 1d3f64c78..1d3f64c78 100644 --- a/examples/examples-onap-vcpe/src/test/resources/events/AAIResponseExample.json +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/AAIResponseExample.json diff --git a/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartRequestEvent.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/APPCvCPERestartRequestEvent.json index 6e18a91b0..6e18a91b0 100644 --- a/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartRequestEvent.json +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/APPCvCPERestartRequestEvent.json diff --git a/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseNOKEvent.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/APPCvCPERestartResponseNOKEvent.json index 9a0ff9af1..9a0ff9af1 100644 --- a/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseNOKEvent.json +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/APPCvCPERestartResponseNOKEvent.json diff --git a/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseOKEvent.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/APPCvCPERestartResponseOKEvent.json index 4afc51d85..4afc51d85 100644 --- a/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseOKEvent.json +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/APPCvCPERestartResponseOKEvent.json diff --git a/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseOKInitialEvent.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/APPCvCPERestartResponseOKInitialEvent.json index 2f53a83bc..2f53a83bc 100644 --- a/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseOKInitialEvent.json +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/APPCvCPERestartResponseOKInitialEvent.json diff --git a/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/MultiEvents.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/MultiEvents.json new file mode 100644 index 000000000..09ace1ed6 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/MultiEvents.json @@ -0,0 +1,150 @@ +{ + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", + "closedLoopAlarmStart": 1519638197324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "4a68f8a5-0db9-4070-a132-adede51e0000", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "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": "b4fe00ac-1da6-4b00-ac0d-8e8300db0000" + }, + "from": "DCAE", + "version": "1.0.2" +} +{ + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", + "closedLoopAlarmStart": 1519638197324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "4a68f8a5-0db9-4070-a132-adede51e0001", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "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": "b4fe00ac-1da6-4b00-ac0d-8e8300db0001" + }, + "from": "DCAE", + "version": "1.0.2" +} +{ + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", + "closedLoopAlarmStart": 1519638197324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "664be3d2-6c12-4f4b-a3e7-c349acce0002", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "AAI": { + "vserver.is-closed-loop-disabled": "false", + "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db0002" + }, + "from": "DCAE", + "version": "1.0.2" +} +{ + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", + "closedLoopAlarmStart": 1519638197324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "664be3d2-6c12-4f4b-a3e7-c349acce0003", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "AAI": { + "vserver.is-closed-loop-disabled": "false", + "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db0003" + }, + "from": "DCAE", + "version": "1.0.2" +} +{ + "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", + "AAI": { + "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db39e1", + "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" + } +} +{ + "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", + "AAI": { + "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db39e1", + "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" + } +} +{ + "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", + "AAI": { + "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db0006" + } +} +{ + "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-adede51e0007", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "version": "1.0.2", + "from": "DCAE", + "AAI": { + "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db0007" + } +} diff --git a/examples/examples-onap-vcpe/src/test/resources/events/VCPEAbatedAAIInfoEvent.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/VCPEAbatedAAIInfoEvent.json index 5efbfef69..5efbfef69 100644 --- a/examples/examples-onap-vcpe/src/test/resources/events/VCPEAbatedAAIInfoEvent.json +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/VCPEAbatedAAIInfoEvent.json diff --git a/examples/examples-onap-vcpe/src/test/resources/events/VCPEAbatedNoAAIInfoEvent.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/VCPEAbatedNoAAIInfoEvent.json index 7cc910e96..7cc910e96 100644 --- a/examples/examples-onap-vcpe/src/test/resources/events/VCPEAbatedNoAAIInfoEvent.json +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/VCPEAbatedNoAAIInfoEvent.json diff --git a/examples/examples-onap-vcpe/src/test/resources/events/VCPEOnsetAAIInfoEvent.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/VCPEOnsetAAIInfoEvent.json index 405cc0b2b..49ba03d2c 100644 --- a/examples/examples-onap-vcpe/src/test/resources/events/VCPEOnsetAAIInfoEvent.json +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/VCPEOnsetAAIInfoEvent.json @@ -12,7 +12,7 @@ "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.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" diff --git a/examples/examples-onap-vcpe/src/test/resources/events/VCPEOnsetNoAAIInfoEvent.json b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/VCPEOnsetNoAAIInfoEvent.json index 342451a0c..5f351a985 100644 --- a/examples/examples-onap-vcpe/src/test/resources/events/VCPEOnsetNoAAIInfoEvent.json +++ b/examples/examples-onap-vcpe/src/main/resources/examples/events/ONAPvCPE/VCPEOnsetNoAAIInfoEvent.json @@ -1,5 +1,5 @@ { - "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", "closedLoopAlarmStart": 1519638197324, "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", "closedLoopEventStatus": "ONSET", diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js index bf66dbb22..cab75f6cd 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js @@ -24,17 +24,24 @@ executor.logger.info(executor.inFields); var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( executor.inFields.get("vnfID").toString()); -var guardDecisionAttributes = executor.subject.getOutFieldSchemaHelper("decisionAttributes").createNewInstance(); +var aaiRequest = new org.onap.policy.aai.AaiNqRequest; +aaiRequest.setQueryParameters(new org.onap.policy.aai.AaiNqQueryParameters); +aaiRequest.setInstanceFilters(new org.onap.policy.aai.AaiNqInstanceFilters); -guardDecisionAttributes.put("actor", "APPC"); -guardDecisionAttributes.put("recipe", "Restart"); -guardDecisionAttributes.put("target", executor.inFields.get("vnfID").toString()); -guardDecisionAttributes.put("clname", "APEXvCPEImplementation"); +aaiRequest.getQueryParameters().setNamedQuery(new org.onap.policy.aai.AaiNqNamedQuery); +aaiRequest.getQueryParameters().getNamedQuery().setNamedQueryUuid(executor.inFields.get("requestID")); -executor.logger.info(guardDecisionAttributes); +var genericVnfInstanceFilterMap = new java.util.HashMap(); +genericVnfInstanceFilterMap.put("vnf-id", vcpeClosedLoopStatus.get("AAI").get("genericVnfVnfId")); -executor.outFields.put("decisionAttributes", guardDecisionAttributes); -executor.outFields.put("onapName", "APEX"); +var genericVnfFilterMap = new java.util.HashMap(); +genericVnfFilterMap.put("generic-vnf", genericVnfInstanceFilterMap); + +aaiRequest.getInstanceFilters().getInstanceFilter().add(genericVnfFilterMap); + +executor.logger.info(aaiRequest); + +executor.outFields.put("AAINamedQueryRequest", aaiRequest); executor.getContextAlbum("ControlLoopExecutionIDAlbum").put(executor.executionId.toString(), executor.inFields.get("vnfID")); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js index 69cd03771..50961c214 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js @@ -28,17 +28,36 @@ executor.logger.info("Continuing execution with VNF ID: " + vnfID); var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfID.toString()); executor.logger.info(vcpeClosedLoopStatus); -var guardResult = executor.inFields.get("decision"); - -if (guardResult === "PERMIT") { - vcpeClosedLoopStatus.put("notification", "OPERATION: GUARD_PERMIT"); -} else if (guardResult === "DENY") { - vcpeClosedLoopStatus.put("notification", "OPERATION: GUARD_DENY"); -} else { - executor.message = "guard result must be either \"PERMIT\" or \"DENY\""; - returnValue = executor.isFalse; +var aaiResponse = executor.inFields.get("AAINamedQueryResponse"); + +for (var iterator = aaiResponse.getInventoryResponseItems().iterator(); iterator.hasNext(); ) { + var responseItem = iterator.next(); + + if (responseItem.getModelName() != "vCPE") { + continue; + } + + var aaiInfo = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewSubInstance("VCPE_AAI_Type"); + + aaiInfo.put("genericVnfResourceVersion", responseItem.getGenericVnf().getResourceVersion()); + aaiInfo.put("genericVnfVnfName", responseItem.getGenericVnf().getVnfName()); + aaiInfo.put("genericVnfProvStatus", responseItem.getGenericVnf().getProvStatus()); + aaiInfo.put("genericVnfIsClosedLoopDisabled", responseItem.getGenericVnf().getIsClosedLoopDisabled().toString()); + aaiInfo.put("genericVnfVnfType", responseItem.getGenericVnf().getVnfType()); + aaiInfo.put("genericVnfInMaint", responseItem.getGenericVnf().getInMaint().toString()); + aaiInfo.put("genericVnfServiceId", responseItem.getGenericVnf().getServiceId()); + aaiInfo.put("genericVnfVnfId", responseItem.getGenericVnf().getVnfId()); + + aaiInfo.put("genericVnfOrchestrationStatus", responseItem.getVfModule().getOrchestrationStatus()); + + vcpeClosedLoopStatus.put("AAI", aaiInfo); + + break; } +// We should check here for the case where AAI returns an error or no data for the query + + var uuidType = Java.type("java.util.UUID"); var requestID = uuidType.fromString(vcpeClosedLoopStatus.get("requestID")); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js index 184340288..7d17e25bc 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js @@ -21,55 +21,36 @@ executor.logger.info(executor.subject.id); executor.logger.info(executor.inFields); -var genericDataRecordType = Java.type("org.apache.avro.generic.GenericData.Record"); +var appcRequest = new org.onap.policy.appclcm.LcmRequestWrapper; +appcRequest.setBody(new org.onap.policy.appclcm.LcmRequest); +appcRequest.getBody().setCommonHeader(new org.onap.policy.appclcm.LcmCommonHeader); -var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( - executor.inFields.get("vnfID").toString()); +appcRequest.setVersion("2.0.0"); +appcRequest.setRpcName("restart"); +appcRequest.setCorrelationId(executor.inFields.get("requestID")); +appcRequest.setType("request"); -var appcBodyRecord = executor.subject.getOutFieldSchemaHelper("body").createNewInstance(); -var appcBodyRecordSchema = appcBodyRecord.getSchema(); +var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(executor.inFields.get("vnfID").toString()); -var inputRecord = new genericDataRecordType(appcBodyRecordSchema.getField("input").schema()); -var inputRecordRecordSchema = inputRecord.getSchema(); +appcRequest.getBody().getCommonHeader().setTimeStamp(java.time.Instant.now()); +appcRequest.getBody().getCommonHeader().setApiVer("2.00"); +appcRequest.getBody().getCommonHeader().setOriginatorId(executor.inFields.get("requestID").toString()); +appcRequest.getBody().getCommonHeader().setRequestId(executor.inFields.get("requestID")); +appcRequest.getBody().getCommonHeader().setSubRequestId("1"); +appcRequest.getBody().getCommonHeader().getFlags().put("ttl", "10000"); +appcRequest.getBody().getCommonHeader().getFlags().put("force", "TRUE"); +appcRequest.getBody().getCommonHeader().getFlags().put("mode", "EXCLUSIVE"); -var actionIndentifiersRecord = new genericDataRecordType(inputRecordRecordSchema.getField("action_DasH_identifiers") - .schema()); +appcRequest.getBody().setAction("Restart"); +appcRequest.getBody().setActionIdentifiers(new java.util.HashMap()); +appcRequest.getBody().getActionIdentifiers().put("vnf-id", executor.inFields.get("vnfID").toString()); -var commonHeaderRecord = new genericDataRecordType(inputRecordRecordSchema.getField("common_DasH_header").schema()); -var commonHeaderRecordSchema = commonHeaderRecord.getSchema(); +executor.getContextAlbum("RequestIDVNFIDAlbum").put(executor.inFields.get("requestID").toString(), executor.inFields.get("vnfID")); -var commonHeaderFlagsRecord = new genericDataRecordType(commonHeaderRecordSchema.getField("flags").schema()); +vcpeClosedLoopStatus.put("notification", "OPERATION"); +vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis()); -appcBodyRecord.put("input", inputRecord); -inputRecord.put("action_DasH_identifiers", actionIndentifiersRecord); -inputRecord.put("common_DasH_header", commonHeaderRecord); -commonHeaderRecord.put("flags", commonHeaderFlagsRecord); - -inputRecord.put("action", "Restart"); -inputRecord.put("payload", "{}"); - -actionIndentifiersRecord.put("vnf_DasH_id", executor.inFields.get("vnfID").toString()); - -commonHeaderRecord.put("timestamp", new Date().toISOString()); -commonHeaderRecord.put("api_DasH_ver", "2.00"); -commonHeaderRecord.put("originator_DasH_id", executor.inFields.get("requestID").toString()); -commonHeaderRecord.put("request_DasH_id", executor.inFields.get("requestID").toString()); -commonHeaderRecord.put("sub_DasH_request_DasH_id", "1"); - -commonHeaderFlagsRecord.put("ttl", "10000"); -commonHeaderFlagsRecord.put("force", "TRUE"); -commonHeaderFlagsRecord.put("mode", "EXCLUSIVE"); - -executor.outFields.put("version", "2.0"); -executor.outFields.put("rpc-name", "restart"); -executor.outFields.put("correlation-id", executor.inFields.get("vnfID")); -executor.outFields.put("type", "request"); -executor.outFields.put("body", appcBodyRecord); - -executor.getContextAlbum("RequestIDVNFIDAlbum").put(executor.inFields.get("requestID").toString(), - executor.inFields.get("vnfID")); - -vcpeClosedLoopStatus.put("notification", "OPERATION: RESTART REQUESTED"); +executor.outFields.put("APPCLCMRequestEvent", appcRequest); executor.logger.info(executor.outFields); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js index 5e20f1569..afaa72536 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js @@ -14,6 +14,13 @@ * 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========================================================= */ @@ -21,30 +28,43 @@ executor.logger.info(executor.subject.id); executor.logger.info(executor.inFields); -var uuidType = Java.type("java.util.UUID"); -var integerType = Java.type("java.lang.Integer"); +var appcResponse = executor.inFields.get("APPCLCMResponseEvent"); -var requestID = uuidType.fromString(executor.inFields.get("correlation-id")); -var vnfID = executor.getContextAlbum("RequestIDVNFIDAlbum").remove(requestID.toString()); +var requestIDString = appcResponse.getCorrelationId().substr(0, 36); +executor.logger.info("requestIDString = " + requestIDString); +var vnfID = executor.getContextAlbum("RequestIDVNFIDAlbum").get(requestIDString); +executor.logger.info("Size of RequestIDVNFIDAlbum = " + executor.getContextAlbum("RequestIDVNFIDAlbum").size()); +executor.logger.info("vnfID = " + vnfID); var returnValue = executor.isTrue; if (vnfID != null) { var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfID.toString()); + var requestId = java.util.UUID.fromString(vcpeClosedLoopStatus.get("requestID")); + + vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis()); - var notification = "OPERATION: VNF RESTART WITH RETURN CODE " - + executor.inFields.get("body").get("output").get("status").get("code") + ", " - + executor.inFields.get("body").get("output").get("status").get("message"); + executor.logger.info("Got from APPC code: " + org.onap.policy.appclcm.LcmResponseCode.toResponseValue(appcResponse.getBody().getStatus().getCode())); - vcpeClosedLoopStatus.put("notification", notification); - vcpeClosedLoopStatus.put("notificationTime", executor.inFields.get("body").get("output").get("common_DasH_header") - .get("timestamp")); + if (org.onap.policy.appclcm.LcmResponseCode.toResponseValue(appcResponse.getBody().getStatus().getCode()) == org.onap.policy.appclcm.LcmResponseCode.SUCCESS) { + vcpeClosedLoopStatus.put("notification", "OPERATION_SUCCESS"); + vcpeClosedLoopStatus.put("message", "vCPE restarted"); + executor.getContextAlbum("RequestIDVNFIDAlbum").remove(requestIDString); + } else if (org.onap.policy.appclcm.LcmResponseCode.toResponseValue(appcResponse.getBody().getStatus().getCode()) == "ACCEPTED" || + org.onap.policy.appclcm.LcmResponseCode.toResponseValue(appcResponse.getBody().getStatus().getCode()) == "REJECT" ) { + executor.logger.info("Got ACCEPTED 100 or REJECT 312, keep the context, wait for next response. Code is: " + org.onap.policy.appclcm.LcmResponseCode.toResponseValue(appcResponse.getBody().getStatus().getCode())); + } + else { + executor.getContextAlbum("RequestIDVNFIDAlbum").remove(requestIDString); + vcpeClosedLoopStatus.put("notification", "OPERATION_FAILURE"); + vcpeClosedLoopStatus.put("message", "vCPE restart failed"); + } - executor.outFields.put("requestID", requestID); + executor.outFields.put("requestID", requestId); executor.outFields.put("vnfID", vnfID); } else { - executor.message = "VNF ID not found in context album for request ID " + requestID; - returnValue = executor.isFalse + 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/AbatedTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/AbatedTask.js index a8b1fe8e4..f37b6f1b5 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/AbatedTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/AbatedTask.js @@ -21,11 +21,20 @@ executor.logger.info(executor.subject.id); executor.logger.info(executor.inFields); -var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( +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("VCPEClosedLoopStatusAlbum").get( + executor.inFields.get("vnfName")); +} else { + vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( executor.inFields.get("vnfID").toString()); +} -vcpeClosedLoopStatus.put("notification", "VCPE NOTIFICATION HAS BEEN ABATED"); -vcpeClosedLoopStatus.put("notificationTime", new Date().toISOString()); +vcpeClosedLoopStatus.put("notification", "FINAL_SUCCESS"); +vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis()); +vcpeClosedLoopStatus.put("message", "situation has been abated"); executor.logger.info(executor.outFields); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js index bceb628e2..d42aef9d0 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js @@ -21,27 +21,51 @@ executor.logger.info(executor.subject.id); executor.logger.info(executor.inFields); -var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( - executor.inFields.get("vnfID").toString()); - -executor.logger.info("Logging context information for VNF \"" + executor.inFields.get("vnfID") + "\""); - -executor.outFields.put("AAI", vcpeClosedLoopStatus.get("AAI")); -executor.outFields.put("closedLoopControlName", vcpeClosedLoopStatus.get("closedLoopControlName")); -executor.outFields.put("closedLoopAlarmStart", vcpeClosedLoopStatus.get("closedLoopAlarmStart")); -executor.outFields.put("closedLoopAlarmEnd", vcpeClosedLoopStatus.get("closedLoopAlarmEnd")); -executor.outFields.put("closedLoopEventClient", vcpeClosedLoopStatus.get("closedLoopEventClient")); -executor.outFields.put("closedLoopEventStatus", vcpeClosedLoopStatus.get("closedLoopEventStatus")); -executor.outFields.put("version", vcpeClosedLoopStatus.get("version")); -executor.outFields.put("requestID", vcpeClosedLoopStatus.get("requestID")); -executor.outFields.put("target_type", vcpeClosedLoopStatus.get("target_type")); -executor.outFields.put("target", vcpeClosedLoopStatus.get("target")); -executor.outFields.put("from", vcpeClosedLoopStatus.get("from")); -executor.outFields.put("policyScope", vcpeClosedLoopStatus.get("policyScope")); -executor.outFields.put("policyName", vcpeClosedLoopStatus.get("policyName")); -executor.outFields.put("policyVersion", vcpeClosedLoopStatus.get("policyVersion")); -executor.outFields.put("notification", vcpeClosedLoopStatus.get("notification")); -executor.outFields.put("notificationTime", vcpeClosedLoopStatus.get("notificationTime")); +var vnfID = executor.inFields.get("vnfID"); +if(vnfID == null) { + vnfID = executor.inFields.get("vnfName"); +} +executor.logger.info("vnfID=" + vnfID); + +var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfID.toString()); + +executor.logger.info("Logging context information for VNF \"" + vnfID + "\""); + +var clNotification = new org.onap.policy.controlloop.VirtualControlLoopNotification(); + +clNotification.setClosedLoopControlName(vcpeClosedLoopStatus.get("closedLoopControlName")); +clNotification.setClosedLoopAlarmStart(java.time.Instant.ofEpochMilli(vcpeClosedLoopStatus.get("closedLoopAlarmStart"))); +clNotification.setClosedLoopAlarmEnd(java.time.Instant.ofEpochMilli(vcpeClosedLoopStatus.get("closedLoopAlarmEnd"))); +clNotification.setClosedLoopEventClient(vcpeClosedLoopStatus.get("closedLoopEventClient")); +clNotification.setVersion(vcpeClosedLoopStatus.get("version")); +clNotification.setRequestId(java.util.UUID.fromString(vcpeClosedLoopStatus.get("requestID"))); +clNotification.setTargetType(org.onap.policy.controlloop.ControlLoopTargetType.toType(vcpeClosedLoopStatus.get("target_type"))); +clNotification.setTarget(org.onap.policy.controlloop.ControlLoopEventStatus.toStatus(vcpeClosedLoopStatus.get("target"))); +clNotification.setFrom(vcpeClosedLoopStatus.get("from")); +clNotification.setPolicyScope(vcpeClosedLoopStatus.get("policyScope")); +clNotification.setPolicyName(vcpeClosedLoopStatus.get("policyName")); +clNotification.setPolicyVersion(vcpeClosedLoopStatus.get("policyVersion")); +clNotification.setNotification(org.onap.policy.controlloop.ControlLoopNotificationType.toType(vcpeClosedLoopStatus.get("notification"))); +clNotification.setMessage(vcpeClosedLoopStatus.get("message")); + +var notificationInstant = java.time.Instant.ofEpochSecond(vcpeClosedLoopStatus.get("notificationTime")); +var notificationTime = java.time.ZonedDateTime.ofInstant(notificationInstant, java.time.ZoneOffset.UTC); +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")); +if(vnfID != null) { + clNotification.getAai().put("generic-vnf.vnf-id", aaiInfo.get("genericVnfVnfId")); +} +executor.outFields.put("VirtualControlLoopNotification", clNotification); executor.logger.info(executor.outFields); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js index 4ee73750d..353c21ef6 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js @@ -24,8 +24,8 @@ executor.logger.info(executor.inFields); var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( executor.inFields.get("vnfID").toString()); -vcpeClosedLoopStatus.put("notification", "VCPE VNF RESTART HAS BEEN DENIED BY GUARD"); -vcpeClosedLoopStatus.put("notificationTime", new Date().toISOString()); +vcpeClosedLoopStatus.put("notification", "REJECTED"); +vcpeClosedLoopStatus.put("notificationTime", java.lang.System.currentTimeMillis()); executor.logger.info(executor.outFields); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js index 18bd418bf..0ba3c0985 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js @@ -14,6 +14,10 @@ * 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========================================================= */ @@ -21,49 +25,122 @@ executor.logger.info(executor.subject.id); executor.logger.info(executor.inFields); -var uuidType = Java.type("java.util.UUID"); +var clEventType = Java.type("org.onap.policy.controlloop.VirtualControlLoopEvent"); var longType = Java.type("java.lang.Long"); +var uuidType = Java.type("java.util.UUID"); -var requestID = uuidType.fromString(executor.inFields.get("requestID")); -var vnfID = uuidType.fromString(executor.inFields.get("AAI").get("generic_DasH_vnf_DoT_vnf_DasH_id")); - -var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfID); - -if (vcpeClosedLoopStatus == null) { - executor.logger.info("Creating context information for new vCPE VNF \"" + vnfID.toString() + "\""); - - vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewInstance(); - - vcpeClosedLoopStatus.put("AAI", executor.inFields.get("AAI")); - vcpeClosedLoopStatus.put("closedLoopControlName", executor.inFields.get("closedLoopControlName")); - vcpeClosedLoopStatus.put("closedLoopAlarmStart", executor.inFields.get("closedLoopAlarmStart")); - vcpeClosedLoopStatus.put("closedLoopEventClient", executor.inFields.get("closedLoopEventClient")); - vcpeClosedLoopStatus.put("closedLoopEventStatus", executor.inFields.get("closedLoopEventStatus")); - vcpeClosedLoopStatus.put("version", executor.inFields.get("version")); - vcpeClosedLoopStatus.put("requestID", executor.inFields.get("requestID")); - vcpeClosedLoopStatus.put("target_type", executor.inFields.get("target_type")); - vcpeClosedLoopStatus.put("target", executor.inFields.get("target")); - vcpeClosedLoopStatus.put("from", executor.inFields.get("from")); - vcpeClosedLoopStatus.put("policyScope", "vCPE"); - vcpeClosedLoopStatus.put("policyName", "ONAPvCPEPolicyModel"); - vcpeClosedLoopStatus.put("policyVersion", "0.0.1"); - vcpeClosedLoopStatus.put("notification", ""); - vcpeClosedLoopStatus.put("notificationTime", ""); - - if (executor.inFields.get("closedLoopAlarmEnd") != null) { - vcpeClosedLoopStatus.put("closedLoopAlarmEnd", executor.inFields.get("closedLoopAlarmEnd")); - } else { - vcpeClosedLoopStatus.put("closedLoopAlarmEnd", longType.valueOf(0)); - } +var clEvent = executor.inFields.get("VirtualControlLoopEvent"); - executor.getContextAlbum("VCPEClosedLoopStatusAlbum").put(vnfID.toString(), vcpeClosedLoopStatus); +executor.logger.info(clEvent.toString()); +executor.logger.info(clEvent.getClosedLoopControlName()); - executor.logger.info("Created context information for new vCPE VNF \"" + vnfID.toString() + "\""); -} +var requestID = clEvent.getRequestId(); +executor.logger.info("requestID = " + requestID); +var vnfID = null; +var vcpeClosedLoopStatus = null; + +if (clEvent.getAai().get("generic-vnf.vnf-id") != null) { + vnfID = uuidType.fromString(clEvent.getAai().get("generic-vnf.vnf-id")); + executor.logger.info("vnfID = " + vnfID); + vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfID); + + if (vcpeClosedLoopStatus == null) { + executor.logger.info("Creating context information for new vCPE VNF \"" + vnfID.toString() + "\""); + + vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewInstance(); + + vcpeClosedLoopStatus.put("closedLoopControlName", clEvent.getClosedLoopControlName()); + vcpeClosedLoopStatus.put("closedLoopAlarmStart", clEvent.getClosedLoopAlarmStart().toEpochMilli()); + vcpeClosedLoopStatus.put("closedLoopEventClient", clEvent.getClosedLoopEventClient()); + vcpeClosedLoopStatus.put("closedLoopEventStatus", clEvent.getClosedLoopEventStatus().toString()); + vcpeClosedLoopStatus.put("version", clEvent.getVersion()); + vcpeClosedLoopStatus.put("requestID", clEvent.getRequestId().toString()); + vcpeClosedLoopStatus.put("target_type", clEvent.getTargetType().toString()); + vcpeClosedLoopStatus.put("target", clEvent.getTarget()); + vcpeClosedLoopStatus.put("from", clEvent.getFrom()); + 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", ""); -executor.outFields.put("requestID", requestID); -executor.outFields.put("vnfID", vnfID); + var aaiInfo = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewSubInstance("VCPE_AAI_Type"); -executor.logger.info(executor.outFields); + aaiInfo.put("genericVnfResourceVersion", clEvent.getAai().get("generic-vnf.resource-version")); + aaiInfo.put("genericVnfVnfName", clEvent.getAai().get("generic-vnf.vnf-name")); + aaiInfo.put("genericVnfProvStatus", clEvent.getAai().get("generic-vnf.prov-status")); + aaiInfo.put("genericVnfIsClosedLoopDisabled", clEvent.getAai().get("generic-vnf.is-closed-loop-disabled")); + aaiInfo.put("genericVnfOrchestrationStatus", clEvent.getAai().get("generic-vnf.orchestration-status")); + aaiInfo.put("genericVnfVnfType", clEvent.getAai().get("generic-vnf.vnf-type")); + aaiInfo.put("genericVnfInMaint", clEvent.getAai().get("generic-vnf.in-maint")); + aaiInfo.put("genericVnfServiceId", clEvent.getAai().get("generic-vnf.service-id")); + aaiInfo.put("genericVnfVnfId", clEvent.getAai().get("generic-vnf.vnf-id")); + + vcpeClosedLoopStatus.put("AAI", aaiInfo); + + if (clEvent.getClosedLoopAlarmEnd() != null) { + vcpeClosedLoopStatus.put("closedLoopAlarmEnd", clEvent.getClosedLoopAlarmEnd().toEpochMilli()); + } else { + vcpeClosedLoopStatus.put("closedLoopAlarmEnd", java.lang.Long.valueOf(0)); + } + + executor.getContextAlbum("VCPEClosedLoopStatusAlbum").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.getClosedLoopEventStatus().toString()); + var vnfName = clEvent.getAai().get("generic-vnf.vnf-name"); + executor.logger.info("No vnf-id in VirtualControlLoopEvent for " + vnfName); + + vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfName.toString()); + + if (vcpeClosedLoopStatus == null) { + executor.logger.info("Creating context information for new vCPE VNF \"" + vnfName.toString() + "\""); + + vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewInstance(); + + vcpeClosedLoopStatus.put("closedLoopControlName", clEvent.getClosedLoopControlName()); + vcpeClosedLoopStatus.put("closedLoopAlarmStart", clEvent.getClosedLoopAlarmStart().toEpochMilli()); + vcpeClosedLoopStatus.put("closedLoopEventClient", clEvent.getClosedLoopEventClient()); + vcpeClosedLoopStatus.put("closedLoopEventStatus", clEvent.getClosedLoopEventStatus().toString()); + vcpeClosedLoopStatus.put("version", clEvent.getVersion()); + vcpeClosedLoopStatus.put("requestID", clEvent.getRequestId().toString()); + vcpeClosedLoopStatus.put("target_type", clEvent.getTargetType().toString()); + vcpeClosedLoopStatus.put("target", clEvent.getTarget()); + vcpeClosedLoopStatus.put("from", clEvent.getFrom()); + 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("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewSubInstance("VCPE_AAI_Type"); + + aaiInfo.put("genericVnfVnfName", clEvent.getAai().get("generic-vnf.vnf-name")); + vcpeClosedLoopStatus.put("AAI", aaiInfo); + + if (clEvent.getClosedLoopAlarmEnd() != null) { + vcpeClosedLoopStatus.put("closedLoopAlarmEnd", clEvent.getClosedLoopAlarmEnd().toEpochMilli()); + } else { + vcpeClosedLoopStatus.put("closedLoopAlarmEnd", java.lang.Long.valueOf(0)); + } + + executor.getContextAlbum("VCPEClosedLoopStatusAlbum").put(vnfName.toString(), vcpeClosedLoopStatus); + + executor.logger.info("Created context information for new vCPE VNF \"" + vnfName.toString() + "\""); + } + executor.outFields.put("requestID", requestID); + executor.outFields.put("vnfName", vnfName); + executor.logger.info(executor.outFields); +} returnValue = executor.isTrue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js index bf66dbb22..d247f8a65 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js @@ -34,11 +34,11 @@ guardDecisionAttributes.put("clname", "APEXvCPEImplementation"); executor.logger.info(guardDecisionAttributes); executor.outFields.put("decisionAttributes", guardDecisionAttributes); -executor.outFields.put("onapName", "APEX"); +executor.outFields.put("onapName", "PDPD"); executor.getContextAlbum("ControlLoopExecutionIDAlbum").put(executor.executionId.toString(), executor.inFields.get("vnfID")); executor.logger.info(executor.outFields); -var returnValue = executor.isTrue;
\ No newline at end of file +var returnValue = executor.isTrue; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js index 69cd03771..2a9100b7f 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js @@ -36,7 +36,7 @@ if (guardResult === "PERMIT") { vcpeClosedLoopStatus.put("notification", "OPERATION: GUARD_DENY"); } else { executor.message = "guard result must be either \"PERMIT\" or \"DENY\""; - returnValue = executor.isFalse; + returnValue = executor.FALSE; } var uuidType = Java.type("java.util.UUID"); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyOnsetOrAbatedStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/OnsetOrAbatedStateTSL.js index b97fe5a0c..c8a3bfba8 100644 --- a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyOnsetOrAbatedStateTSL.js +++ b/examples/examples-onap-vcpe/src/main/resources/logic/OnsetOrAbatedStateTSL.js @@ -22,11 +22,19 @@ executor.logger.info(executor.subject.id); executor.logger.info(executor.inFields); var returnValue = executor.isTrue; +var status = null; -var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( +if( executor.inFields.get("vnfID") == null) { + executor.logger.info("OnsetOrAbatedStateTSL: vnfID is null"); + var vnfName = executor.inFields.get("vnfName"); + var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( + executor.inFields.get("vnfName")); + status = vcpeClosedLoopStatus.get("closedLoopEventStatus").toString(); +} else { + var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( executor.inFields.get("vnfID").toString()); - -var status = vcpeClosedLoopStatus.get("closedLoopEventStatus"); + status = vcpeClosedLoopStatus.get("closedLoopEventStatus").toString(); +} var returnValue = executor.isTrue; @@ -36,7 +44,7 @@ if (status === "ONSET") { executor.subject.getTaskKey("AbatedTask").copyTo(executor.selectedTask); onsetFlag = executor.isFalse; } else { - executor.message = "closedLoopEventStatus must be either \"ONSET\" or \"ABATED\""; + executor.message = "closedLoopEventStatus is \"" + status + "\", it must be either \"ONSET\" or \"ABATED\""; returnValue = executor.isFalse; } diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyAAILookupStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyAAILookupStateTSL.js deleted file mode 100644 index ce627950c..000000000 --- a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyAAILookupStateTSL.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -executor.logger.info(executor.subject.id); -executor.logger.info(executor.inFields); - -var returnValue = executor.isTrue; - -var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( - executor.inFields.get("vnfID").toString()); -var aaiInfo = vcpeClosedLoopStatus.get("AAI"); - -executor.logger.info(aaiInfo); - -if (aaiInfo.get("generic_DasH_vnf.resource_DasH_version") != null - && aaiInfo.get("generic_DasH_vnf.vnf_DasH_name") != null - && aaiInfo.get("generic_DasH_vnf.prov_DasH_status") != null - && aaiInfo.get("generic_DasH_vnf.is_DasH_closed_DasH_loop_DasH_disabled") != null - && aaiInfo.get("generic_DasH_vnf.orchestration_DasH_status") != null - && aaiInfo.get("generic_DasH_vnf.vnf_DasH_type") != null - && aaiInfo.get("generic_DasH_vnf.in_DasH_maint") != null - && aaiInfo.get("generic_DasH_vnf.service_DasH_id") != null - && aaiInfo.get("generic_DasH_vnf.vnf_DasH_id") != null) { - executor.subject.getTaskKey("AAILookupRequestTask").copyTo(executor.selectedTask); -} else { - executor.subject.getTaskKey("NoAAILookupTask").copyTo(executor.selectedTask); -} - -executor.logger.info("ReceiveEventPolicyOnsetOrAbatedStateTSL State Selected Task:" + executor.selectedTask); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyRequestAAIStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyRequestAAIStateTSL.js new file mode 100644 index 000000000..b397a5f7c --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyRequestAAIStateTSL.js @@ -0,0 +1,54 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 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("ReceiveEventPolicyRequestAAIStateTSL: vnfID is null"); + var vnfName = executor.inFields.get("vnfName"); + var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( + executor.inFields.get("vnfName")); + executor.logger.info("CL event status: " + vcpeClosedLoopStatus.get("closedLoopEventStatus")); + executor.subject.getTaskKey("NoAAILookupTask").copyTo(executor.selectedTask); + } else { + var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( + executor.inFields.get("vnfID").toString()); + var aaiInfo = vcpeClosedLoopStatus.get("AAI"); + + executor.logger.info(aaiInfo); + + if (aaiInfo.get("genericVnfResourceVersion") != null + && aaiInfo.get("genericVnfVnfName") != null + && aaiInfo.get("genericVnfProvStatus") != null + && aaiInfo.get("genericVnfIsClosedLoopDisabled") != null + && aaiInfo.get("genericVnfOrchestrationStatus") != null + && aaiInfo.get("genericVnfVnfType") != null + && aaiInfo.get("genericVnfInMaint") != null + && aaiInfo.get("genericVnfServiceId") != null + && aaiInfo.get("genericVnfVnfId") != null) { + executor.subject.getTaskKey("NoAAILookupTask").copyTo(executor.selectedTask); + } else { + executor.subject.getTaskKey("AAILookupRequestTask").copyTo(executor.selectedTask); + } +} +executor.logger.info("ReceiveEventPolicyOnsetOrAbatedStateTSL State Selected Task:" + executor.selectedTask); 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 22d0ddae0..490c4ad7c 100644 --- a/examples/examples-onap-vcpe/src/main/resources/policy/ONAPvCPEPolicyModel.apex +++ b/examples/examples-onap-vcpe/src/main/resources/policy/ONAPvCPEPolicyModel.apex @@ -25,20 +25,17 @@ 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=VCPEAAIInfoType flavour=Avro schema=LS -#MACROFILE:"src/main/resources/schemas/VCPEAAIInfoType.avsc" -LE +schema create name=VirtualControlLoopEventType flavour=Java schema=org.onap.policy.controlloop.VirtualControlLoopEvent +schema create name=VirtualControlLoopNotificationType flavour=Java schema=org.onap.policy.controlloop.VirtualControlLoopNotification -schema create name=GuardDecisionAttributesType flavour=Avro schema=LS -#MACROFILE:"src/main/resources/schemas/GuardDecisionAttributesType.avsc" -LE +schema create name=AAIServiceNamedQueryRequestType flavour=Java schema=org.onap.policy.aai.AaiNqRequest +schema create name=AAIServiceNamedQueryResponseType flavour=Java schema=org.onap.policy.aai.AaiNqResponse -schema create name=APPCInputBodyType flavour=Avro schema=LS -#MACROFILE:"src/main/resources/schemas/APPCInputBodyType.avsc" -LE +schema create name=APPCLCMRequestType flavour=Java schema=org.onap.policy.appclcm.LcmRequestWrapper +schema create name=APPCLCMResponseType flavour=Java schema=org.onap.policy.appclcm.LcmResponseWrapper -schema create name=APPCOutputBodyType flavour=Avro schema=LS -#MACROFILE:"src/main/resources/schemas/APPCOutputBodyType.avsc" +schema create name=GuardDecisionAttributesType flavour=Avro schema=LS +#MACROFILE:"src/main/resources/schemas/GuardDecisionAttributesType.avsc" LE schema create name=VCPEClosedLoopStatusType flavour=Avro schema=LS @@ -51,24 +48,13 @@ album create name=ControlLoopExecutionIDAlbum scope=policy writable=true schemaN album create name=RequestIDVNFIDAlbum scope=policy writable=true schemaName=UUIDType -event create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 version=1.0.2 nameSpace=org.onap.policy.apex.onap.vcpe source=DCAE target=APEX - -event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=closedLoopControlName schemaName=SimpleStringType -event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=closedLoopAlarmStart schemaName=SimpleLongType -event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=closedLoopAlarmEnd schemaName=SimpleLongType optional=true -event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=closedLoopEventClient schemaName=SimpleStringType -event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=closedLoopEventStatus schemaName=SimpleStringType -event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=requestID schemaName=SimpleStringType -event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=target_type schemaName=SimpleStringType -event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=target schemaName=SimpleStringType -event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=from schemaName=SimpleStringType -event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=version schemaName=SimpleStringType -event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=AAI schemaName=VCPEAAIInfoType +event create name=ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e version=1.0.2 nameSpace=org.onap.policy.apex.onap.vcpe source=DCAE target=APEX +event parameter create name=ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e parName=VirtualControlLoopEvent schemaName=VirtualControlLoopEventType event create name=VCPEStateUpdatedEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APEX - event parameter create name=VCPEStateUpdatedEvent parName=requestID schemaName=UUIDType event parameter create name=VCPEStateUpdatedEvent parName=vnfID schemaName=UUIDType +event parameter create name=VCPEStateUpdatedEvent parName=vnfName schemaName=SimpleStringType optional=true event create name=GuardRequestEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APEX @@ -80,60 +66,31 @@ event create name=GuardResponseEvent nameSpace=org.onap.policy.apex.onap.vcpe so event parameter create name=GuardResponseEvent parName=decision schemaName=SimpleStringType event parameter create name=GuardResponseEvent parName=details schemaName=SimpleStringType -event create name=APPCRestartVNFRequestEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APPC +event create name=APPCRestartVNFRequestEvent version="2.0.0" nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APPC +event parameter create name=APPCRestartVNFRequestEvent parName=APPCLCMRequestEvent schemaName=APPCLCMRequestType -event parameter create name=APPCRestartVNFRequestEvent parName=body schemaName=APPCInputBodyType -event parameter create name=APPCRestartVNFRequestEvent parName=version schemaName=SimpleStringType -event parameter create name=APPCRestartVNFRequestEvent parName=rpc-name schemaName=SimpleStringType -event parameter create name=APPCRestartVNFRequestEvent parName=correlation-id schemaName=SimpleStringType -event parameter create name=APPCRestartVNFRequestEvent parName=type schemaName=SimpleStringType - -event create name=APPCRestartVNFResponseEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APPC - -event parameter create name=APPCRestartVNFResponseEvent parName=body schemaName=APPCOutputBodyType -event parameter create name=APPCRestartVNFResponseEvent parName=version schemaName=SimpleStringType -event parameter create name=APPCRestartVNFResponseEvent parName=rpc-name schemaName=SimpleStringType -event parameter create name=APPCRestartVNFResponseEvent parName=correlation-id schemaName=SimpleStringType -event parameter create name=APPCRestartVNFResponseEvent parName=type schemaName=SimpleStringType +event create name=APPCRestartVNFResponseEvent version="2.0.0" nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APPC +event parameter create name=APPCRestartVNFResponseEvent parName=APPCLCMResponseEvent schemaName=APPCLCMResponseType 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 parameter create name=ControlLoopLogEvent parName=AAI schemaName=VCPEAAIInfoType -event parameter create name=ControlLoopLogEvent parName=closedLoopControlName schemaName=SimpleStringType -event parameter create name=ControlLoopLogEvent parName=closedLoopAlarmStart schemaName=SimpleLongType -event parameter create name=ControlLoopLogEvent parName=closedLoopAlarmEnd schemaName=SimpleLongType optional=true -event parameter create name=ControlLoopLogEvent parName=closedLoopEventClient schemaName=SimpleStringType -event parameter create name=ControlLoopLogEvent parName=closedLoopEventStatus schemaName=SimpleStringType -event parameter create name=ControlLoopLogEvent parName=version schemaName=SimpleStringType -event parameter create name=ControlLoopLogEvent parName=requestID schemaName=SimpleStringType -event parameter create name=ControlLoopLogEvent parName=target_type schemaName=SimpleStringType -event parameter create name=ControlLoopLogEvent parName=target schemaName=SimpleStringType -event parameter create name=ControlLoopLogEvent parName=from schemaName=SimpleStringType -event parameter create name=ControlLoopLogEvent parName=policyScope schemaName=SimpleStringType -event parameter create name=ControlLoopLogEvent parName=policyName schemaName=SimpleStringType -event parameter create name=ControlLoopLogEvent parName=policyVersion schemaName=SimpleStringType -event parameter create name=ControlLoopLogEvent parName=notification schemaName=SimpleStringType -event parameter create name=ControlLoopLogEvent parName=message schemaName=SimpleStringType -event parameter create name=ControlLoopLogEvent parName=notificationTime schemaName=SimpleStringType +event create name=AAINamedQueryRequestEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=AAI +event parameter create name=AAINamedQueryRequestEvent parName=AAINamedQueryRequest schemaName=AAIServiceNamedQueryRequestType -task create name=GetVCPEStateTask +event create name=AAINamedQueryResponseEvent nameSpace=org.onap.policy.apex.onap.vcpe source=AAI target=APEX +event parameter create name=AAINamedQueryResponseEvent parName=AAINamedQueryResponse schemaName=AAIServiceNamedQueryResponseType -task inputfield create name=GetVCPEStateTask fieldName=closedLoopControlName schemaName=SimpleStringType -task inputfield create name=GetVCPEStateTask fieldName=closedLoopAlarmStart schemaName=SimpleLongType -task inputfield create name=GetVCPEStateTask fieldName=closedLoopAlarmEnd schemaName=SimpleLongType optional=true -task inputfield create name=GetVCPEStateTask fieldName=closedLoopEventClient schemaName=SimpleStringType -task inputfield create name=GetVCPEStateTask fieldName=closedLoopEventStatus schemaName=SimpleStringType -task inputfield create name=GetVCPEStateTask fieldName=requestID schemaName=SimpleStringType -task inputfield create name=GetVCPEStateTask fieldName=target_type schemaName=SimpleStringType -task inputfield create name=GetVCPEStateTask fieldName=target schemaName=SimpleStringType -task inputfield create name=GetVCPEStateTask fieldName=from schemaName=SimpleStringType -task inputfield create name=GetVCPEStateTask fieldName=version schemaName=SimpleStringType -task inputfield create name=GetVCPEStateTask fieldName=AAI schemaName=VCPEAAIInfoType +task create name=GetVCPEStateTask -task contextref create name=GetVCPEStateTask albumName=VCPEClosedLoopStatusAlbum +task inputfield create name=GetVCPEStateTask fieldName=VirtualControlLoopEvent schemaName=VirtualControlLoopEventType task outputfield create name=GetVCPEStateTask fieldName=requestID schemaName=UUIDType task outputfield create name=GetVCPEStateTask fieldName=vnfID schemaName=UUIDType +task outputfield create name=GetVCPEStateTask fieldName=vnfName schemaName=SimpleStringType optional=true + +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" @@ -143,9 +100,11 @@ task create name=AbatedTask task inputfield create name=AbatedTask fieldName=requestID schemaName=UUIDType task inputfield create name=AbatedTask fieldName=vnfID schemaName=UUIDType +task inputfield create name=AbatedTask fieldName=vnfName schemaName=SimpleStringType optional=true task outputfield create name=AbatedTask fieldName=requestID schemaName=UUIDType task outputfield create name=AbatedTask fieldName=vnfID schemaName=UUIDType +task outputfield create name=AbatedTask fieldName=vnfName schemaName=SimpleStringType optional=true task contextref create name=AbatedTask albumName=VCPEClosedLoopStatusAlbum @@ -202,11 +161,7 @@ task create name=APPCRestartVNFRequestTask task inputfield create name=APPCRestartVNFRequestTask fieldName=requestID schemaName=UUIDType task inputfield create name=APPCRestartVNFRequestTask fieldName=vnfID schemaName=UUIDType -task outputfield create name=APPCRestartVNFRequestTask fieldName=body schemaName=APPCInputBodyType -task outputfield create name=APPCRestartVNFRequestTask fieldName=version schemaName=SimpleStringType -task outputfield create name=APPCRestartVNFRequestTask fieldName=rpc-name schemaName=SimpleStringType -task outputfield create name=APPCRestartVNFRequestTask fieldName=correlation-id schemaName=SimpleStringType -task outputfield create name=APPCRestartVNFRequestTask fieldName=type schemaName=SimpleStringType +task outputfield create name=APPCRestartVNFRequestTask fieldName=APPCLCMRequestEvent schemaName=APPCLCMRequestType task contextref create name=APPCRestartVNFRequestTask albumName=VCPEClosedLoopStatusAlbum task contextref create name=APPCRestartVNFRequestTask albumName=RequestIDVNFIDAlbum @@ -217,11 +172,7 @@ LE task create name=APPCRestartVNFResponseTask -task inputfield create name=APPCRestartVNFResponseTask fieldName=body schemaName=APPCOutputBodyType -task inputfield create name=APPCRestartVNFResponseTask fieldName=version schemaName=SimpleStringType -task inputfield create name=APPCRestartVNFResponseTask fieldName=rpc-name schemaName=SimpleStringType -task inputfield create name=APPCRestartVNFResponseTask fieldName=correlation-id schemaName=SimpleStringType -task inputfield create name=APPCRestartVNFResponseTask fieldName=type schemaName=SimpleStringType +task inputfield create name=APPCRestartVNFResponseTask fieldName=APPCLCMResponseEvent schemaName=APPCLCMResponseType task outputfield create name=APPCRestartVNFResponseTask fieldName=requestID schemaName=UUIDType task outputfield create name=APPCRestartVNFResponseTask fieldName=vnfID schemaName=UUIDType @@ -238,23 +189,7 @@ 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=AAI schemaName=VCPEAAIInfoType -task outputfield create name=ControlLoopLogTask fieldName=closedLoopControlName schemaName=SimpleStringType -task outputfield create name=ControlLoopLogTask fieldName=closedLoopAlarmStart schemaName=SimpleLongType -task outputfield create name=ControlLoopLogTask fieldName=closedLoopAlarmEnd schemaName=SimpleLongType optional=true -task outputfield create name=ControlLoopLogTask fieldName=closedLoopEventClient schemaName=SimpleStringType -task outputfield create name=ControlLoopLogTask fieldName=closedLoopEventStatus schemaName=SimpleStringType -task outputfield create name=ControlLoopLogTask fieldName=requestID schemaName=SimpleStringType -task outputfield create name=ControlLoopLogTask fieldName=version schemaName=SimpleStringType -task outputfield create name=ControlLoopLogTask fieldName=target_type schemaName=SimpleStringType -task outputfield create name=ControlLoopLogTask fieldName=target schemaName=SimpleStringType -task outputfield create name=ControlLoopLogTask fieldName=from schemaName=SimpleStringType -task outputfield create name=ControlLoopLogTask fieldName=policyScope schemaName=SimpleStringType -task outputfield create name=ControlLoopLogTask fieldName=policyName schemaName=SimpleStringType -task outputfield create name=ControlLoopLogTask fieldName=policyVersion schemaName=SimpleStringType -task outputfield create name=ControlLoopLogTask fieldName=notification schemaName=SimpleStringType -task outputfield create name=ControlLoopLogTask fieldName=message schemaName=SimpleStringType -task outputfield create name=ControlLoopLogTask fieldName=notificationTime schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=VirtualControlLoopNotification schemaName=VirtualControlLoopNotificationType task contextref create name=ControlLoopLogTask albumName=VCPEClosedLoopStatusAlbum @@ -262,6 +197,49 @@ task logic create name=ControlLoopLogTask logicFlavour=JAVASCRIPT logic=LS #MACROFILE:"src/main/resources/logic/ControlLoopLogTask.js" LE +task create name=AAILookupRequestTask + +task inputfield create name=AAILookupRequestTask fieldName=requestID schemaName=UUIDType +task inputfield create name=AAILookupRequestTask fieldName=vnfID schemaName=UUIDType + +task outputfield create name=AAILookupRequestTask fieldName=AAINamedQueryRequest schemaName=AAIServiceNamedQueryRequestType + +task contextref create name=AAILookupRequestTask albumName=VCPEClosedLoopStatusAlbum +task contextref create name=AAILookupRequestTask albumName=ControlLoopExecutionIDAlbum + +task logic create name=AAILookupRequestTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/AAILookupRequestTask.js" +LE + +task create name=AAILookupResponseTask + +task inputfield create name=AAILookupResponseTask fieldName=AAINamedQueryResponse schemaName=AAIServiceNamedQueryResponseType + +task outputfield create name=AAILookupResponseTask fieldName=requestID schemaName=UUIDType +task outputfield create name=AAILookupResponseTask fieldName=vnfID schemaName=UUIDType + +task contextref create name=AAILookupResponseTask albumName=VCPEClosedLoopStatusAlbum +task contextref create name=AAILookupResponseTask albumName=ControlLoopExecutionIDAlbum + +task logic create name=AAILookupResponseTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/AAILookupResponseTask.js" +LE + +task create name=NoAAILookupTask + +task inputfield create name=NoAAILookupTask fieldName=requestID schemaName=UUIDType +task inputfield create name=NoAAILookupTask fieldName=vnfID schemaName=UUIDType + +task outputfield create name=NoAAILookupTask fieldName=requestID schemaName=UUIDType +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" +LE + +# +# ReceiveEventPolicy +# policy create name=ReceiveEventPolicy template=Freestyle firstState=GetVCPEState policy state create name=ReceiveEventPolicy stateName=AbatedState triggerName=VCPEStateUpdatedEvent defaultTaskName=ControlLoopLogTask @@ -277,13 +255,53 @@ 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/ReceiveEventPolicyOnsetOrAbatedStateTSL.js" +#MACROFILE:"src/main/resources/logic/OnsetOrAbatedStateTSL.js" +LE + +policy state create name=ReceiveEventPolicy stateName=RequestAAIState triggerName=VCPEStateUpdatedEvent defaultTaskName=AAILookupRequestTask +policy state output create name=ReceiveEventPolicy stateName=RequestAAIState outputName=RequestAAIStateOutput eventName=AAINamedQueryRequestEvent +policy state taskref create name=ReceiveEventPolicy stateName=RequestAAIState taskName=AAILookupRequestTask outputType=DIRECT outputName=RequestAAIStateOutput +policy state output create name=ReceiveEventPolicy stateName=RequestAAIState outputName=DoNotRequestAAIStateOutput eventName=VCPEStateUpdatedEvent nextState=OnsetOrAbatedState +policy state taskref create name=ReceiveEventPolicy stateName=RequestAAIState taskName=NoAAILookupTask outputType=DIRECT outputName=DoNotRequestAAIStateOutput + +policy state contextref create name=ReceiveEventPolicy stateName=RequestAAIState albumName=VCPEClosedLoopStatusAlbum + +policy state selecttasklogic create name=ReceiveEventPolicy stateName=RequestAAIState logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/ReceiveEventPolicyRequestAAIStateTSL.js" LE -policy state create name=ReceiveEventPolicy stateName=GetVCPEState triggerName=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 defaultTaskName=GetVCPEStateTask -policy state output create name=ReceiveEventPolicy stateName=GetVCPEState outputName=GetVCPEStateOutput eventName=VCPEStateUpdatedEvent nextState=OnsetOrAbatedState +policy state create name=ReceiveEventPolicy stateName=GetVCPEState triggerName=ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e defaultTaskName=GetVCPEStateTask +policy state output create name=ReceiveEventPolicy stateName=GetVCPEState outputName=GetVCPEStateOutput eventName=VCPEStateUpdatedEvent nextState=RequestAAIState policy state taskref create name=ReceiveEventPolicy stateName=GetVCPEState taskName=GetVCPEStateTask outputType=DIRECT outputName=GetVCPEStateOutput +# +# AAIResponsePolicy +# +policy create name=AAIResponsePolicy template=Freestyle firstState=AAIResponseState + +policy state create name=AAIResponsePolicy stateName=AbatedState triggerName=VCPEStateUpdatedEvent defaultTaskName=ControlLoopLogTask +policy state output create name=AAIResponsePolicy stateName=AbatedState outputName=AbatedOutput eventName=ControlLoopLogEvent +policy state taskref create name=AAIResponsePolicy stateName=AbatedState taskName=ControlLoopLogTask outputType=DIRECT outputName=AbatedOutput + +policy state create name=AAIResponsePolicy stateName=OnsetOrAbatedState triggerName=VCPEStateUpdatedEvent defaultTaskName=AbatedTask +policy state output create name=AAIResponsePolicy stateName=OnsetOrAbatedState outputName=OnsetOutput eventName=GuardRequestEvent +policy state taskref create name=AAIResponsePolicy stateName=OnsetOrAbatedState taskName=GuardRequestTask outputType=DIRECT outputName=OnsetOutput +policy state output create name=AAIResponsePolicy stateName=OnsetOrAbatedState outputName=AbatedOutput eventName=VCPEStateUpdatedEvent nextState=AbatedState +policy state taskref create name=AAIResponsePolicy stateName=OnsetOrAbatedState taskName=AbatedTask outputType=DIRECT outputName=AbatedOutput + +policy state contextref create name=AAIResponsePolicy stateName=OnsetOrAbatedState albumName=VCPEClosedLoopStatusAlbum + +policy state selecttasklogic create name=AAIResponsePolicy stateName=OnsetOrAbatedState logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/OnsetOrAbatedStateTSL.js" +LE + +policy state create name=AAIResponsePolicy stateName=AAIResponseState triggerName=AAINamedQueryResponseEvent defaultTaskName=AAILookupResponseTask +policy state output create name=AAIResponsePolicy stateName=AAIResponseState outputName=AAIResponseStateOutput eventName=VCPEStateUpdatedEvent nextState=OnsetOrAbatedState +policy state taskref create name=AAIResponsePolicy stateName=AAIResponseState taskName=AAILookupResponseTask outputType=DIRECT outputName=AAIResponseStateOutput + +# +# RestartAPPCRequestPolicy +# policy create name=RestartAPPCRequestPolicy template=Freestyle firstState=PolicyGuardResponseState policy state create name=RestartAPPCRequestPolicy stateName=DeniedState triggerName=VCPEStateUpdatedEvent defaultTaskName=ControlLoopLogTask @@ -306,6 +324,9 @@ policy state selecttasklogic create name=RestartAPPCRequestPolicy stateName=Perm #MACROFILE:"src/main/resources/logic/RestartAPPCRequestPolicyPermitOrDenyTSL.js" LE +# +# RestartAPPCResponsePolicy +# policy create name=RestartAPPCResponsePolicy template=Freestyle firstState=RestartAPPCResponseState policy state create name=RestartAPPCResponsePolicy stateName=ResponseLogState triggerName=VCPEStateUpdatedEvent defaultTaskName=ControlLoopLogTask diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/AAIInstanceFiltersType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/AAIInstanceFiltersType.avsc deleted file mode 100644 index 621372d2f..000000000 --- a/examples/examples-onap-vcpe/src/main/resources/schemas/AAIInstanceFiltersType.avsc +++ /dev/null @@ -1,30 +0,0 @@ -{ - "type": "record", - "name": "AAIInstanceFilters_Type", - "namespace": "org.onap.policy.apex.onap.vcpe", - "fields": [ - { - "type": "record", - "name": "instance_DasH_filters", - "namespace": "org.onap.policy.apex.onap.vcpe", - "fields": [ - { - "name": "instance_DasH_filter", - "type": { - "type": "array", - "items": { - "type": "record", - "name": "generic_DasH_vnf", - "fields": [ - { - "name": "vnf_DasH_id", - "type": "string" - } - ] - } - } - } - ] - } - ] -} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/AAIInventoryResponseItemType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/AAIInventoryResponseItemType.avsc deleted file mode 100644 index e64d0e36a..000000000 --- a/examples/examples-onap-vcpe/src/main/resources/schemas/AAIInventoryResponseItemType.avsc +++ /dev/null @@ -1,70 +0,0 @@ -{ - "type": "array", - "items": { - "type": "record", - "name": "AAIInventoryResponseItem_Type", - "fields": [ - { - "name": "model_DasH_name", - "type": "string" - }, - { - "name": "extra_DasH_properties", - "type": { - "type": "record", - "name": "AAIInventoryResponseItemExtraProperties_Type", - "fields": [] - } - }, - { - "name": "generic_DasH_vnf", - "type": { - "type": "record", - "name": "AAIInventoryResponseItemGenericVNF_Type", - "fields": [ - { - "name": "vnf_DasH_id", - "type": "string" - }, - { - "name": "vnf_DasH_name", - "type": "string" - }, - { - "name": "vnf_DasH_type", - "type": "string" - }, - { - "name": "service_DasH_id", - "type": "string" - }, - { - "name": "orchestration_DasH_status", - "type": "string" - }, - { - "name": "in_DasH_maint", - "type": "boolean" - }, - { - "name": "is_DasH_closed_DasH_loop_DasH_disabled", - "type": "boolean" - }, - { - "name": "resource_DasH_version", - "type": "string" - }, - { - "name": "model_DasH_invariant_DasH_id", - "type": "string" - }, - { - "name": "model_DasH_version_DasH_id", - "type": "string" - } - ] - } - } - ] - } -} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/AAINamedQueryType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/AAINamedQueryType.avsc deleted file mode 100644 index ffa3ca534..000000000 --- a/examples/examples-onap-vcpe/src/main/resources/schemas/AAINamedQueryType.avsc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "type": "record", - "name": "AAINamedQuery_Type", - "namespace": "org.onap.policy.apex.onap.vcpe", - "fields": [ - { - "name": "named_DasH_query_DasH_uuid", - "type": "string" - } - ] -} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/APPCInputBodyType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/APPCInputBodyType.avsc deleted file mode 100644 index 3acf96e7f..000000000 --- a/examples/examples-onap-vcpe/src/main/resources/schemas/APPCInputBodyType.avsc +++ /dev/null @@ -1,76 +0,0 @@ -{ - "type" : "record", - "name" : "APPCInputBody_Type", - "namespace" : "org.onap.policy.apex.onap.vcpe", - "fields" : [ - { - "name": "input", - "type": { - "type" : "record", - "name" : "InputRecord", - "fields" : [ - { - "name": "action", "type": "string" - }, - { - "name": "action_DasH_identifiers", - "type": { - "type" : "record", - "name" : "ActionIdentifiersRecord", - "fields" : [ - { - "name": "vnf_DasH_id", "type": "string" - } - ] - } - }, - { - "name": "common_DasH_header", - "type": { - "type" : "record", - "name" : "InputCommonHeaderRecord", - "fields" : [ - { - "name": "request_DasH_id", "type": "string" - }, - { - "name": "originator_DasH_id", "type": "string" - }, - { - "name": "api_DasH_ver", "type": "string" - }, - { - "name": "sub_DasH_request_DasH_id", "type": "string" - }, - { - "name": "timestamp", "type": "string" - }, - { - "name": "flags", - "type": { - "type" : "record", - "name" : "FlagsRecord", - "fields" : [ - { - "name": "ttl", "type": "string" - }, - { - "name": "force", "type": "string" - }, - { - "name": "mode", "type": "string" - } - ] - } - } - ] - } - }, - { - "name": "payload", "type": "string" - } - ] - } - } - ] -} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/APPCOutputBodyType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/APPCOutputBodyType.avsc deleted file mode 100644 index 2c110170a..000000000 --- a/examples/examples-onap-vcpe/src/main/resources/schemas/APPCOutputBodyType.avsc +++ /dev/null @@ -1,55 +0,0 @@ -{ - "type" : "record", - "name" : "APPCOutputBody_Type", - "namespace" : "org.onap.policy.apex.onap.vcpe", - "fields" : [ - { - "name": "output", - "type": { - "type" : "record", - "name" : "OutputRecord", - "fields" : [ - { - "name": "status", - "type": { - "type" : "record", - "name" : "StatusRecord", - "fields" : [ - { - "name": "code", "type": "int" - }, - { - "name": "message", "type": "string" - } - ] - } - }, - { - "name": "common_DasH_header", - "type": { - "type" : "record", - "name" : "OutputCommonHeaderRecord", - "fields" : [ - { - "name": "request_DasH_id", "type": "string" - }, - { - "name": "originator_DasH_id", "type": "string" - }, - { - "name": "api_DasH_ver", "type": "string" - }, - { - "name": "sub_DasH_request_DasH_id", "type": "string" - }, - { - "name": "timestamp", "type": "string" - } - ] - } - } - ] - } - } - ] -} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEAAIInfoType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEAAIInfoType.avsc deleted file mode 100644 index ff7cad18a..000000000 --- a/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEAAIInfoType.avsc +++ /dev/null @@ -1,43 +0,0 @@ -{ - "type": "record", - "name": "AAI_Type", - "namespace": "org.onap.policy.apex.onap.vcpe", - "fields": [ - { - "name": "generic_DasH_vnf_DoT_resource_DasH_version", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_vnf_DasH_name", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_prov_DasH_status", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_is_DasH_closed_DasH_loop_DasH_disabled", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_orchestration_DasH_status", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_vnf_DasH_type", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_in_DasH_maint", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_service_DasH_id", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_vnf_DasH_id", - "type": "string" - } - ] -} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusType.avsc index e628c23d9..cc83c5219 100644 --- a/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusType.avsc +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusType.avsc @@ -10,39 +10,39 @@ "namespace": "org.onap.policy.apex.onap.vcpe", "fields": [ { - "name": "generic_DasH_vnf_DoT_resource_DasH_version", + "name": "genericVnfResourceVersion", "type": "string" }, { - "name": "generic_DasH_vnf_DoT_vnf_DasH_name", + "name": "genericVnfVnfName", "type": "string" }, { - "name": "generic_DasH_vnf_DoT_prov_DasH_status", + "name": "genericVnfProvStatus", "type": "string" }, { - "name": "generic_DasH_vnf_DoT_is_DasH_closed_DasH_loop_DasH_disabled", + "name": "genericVnfIsClosedLoopDisabled", "type": "string" }, { - "name": "generic_DasH_vnf_DoT_orchestration_DasH_status", + "name": "genericVnfOrchestrationStatus", "type": "string" }, { - "name": "generic_DasH_vnf_DoT_vnf_DasH_type", + "name": "genericVnfVnfType", "type": "string" }, { - "name": "generic_DasH_vnf_DoT_in_DasH_maint", + "name": "genericVnfInMaint", "type": "string" }, { - "name": "generic_DasH_vnf_DoT_service_DasH_id", + "name": "genericVnfServiceId", "type": "string" }, { - "name": "generic_DasH_vnf_DoT_vnf_DasH_id", + "name": "genericVnfVnfId", "type": "string" } ] @@ -106,6 +106,10 @@ }, { "name": "notificationTime", + "type": "long" + }, + { + "name": "message", "type": "string" } ] diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusTypeWithHistory.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusTypeWithHistory.avsc deleted file mode 100644 index 9b76f9440..000000000 --- a/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusTypeWithHistory.avsc +++ /dev/null @@ -1,152 +0,0 @@ -{ - "type": "record", - "name": "VCPEClosedLoopStatus", - "fields": [ - { - "name": "AAI", - "type": { - "type": "record", - "name": "VCPE_AAI_Type", - "namespace": "org.onap.policy.apex.onap.vcpe", - "fields": [ - { - "name": "generic_DasH_vnf_DoT_resource_DasH_version", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_vnf_DasH_name", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_prov_DasH_status", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_is_DasH_closed_DasH_loop_DasH_disabled", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_orchestration_DasH_status", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_vnf_DasH_type", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_in_DasH_maint", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_service_DasH_id", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_vnf_DasH_id", - "type": "string" - } - ] - } - }, - { - "name": "closedLoopAlarmStart", - "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": "history", - "type": [ - { - "type": "record", - "name": "VCPE_History_Type", - "namespace": "org.onap.policy.apex.onap.vcpe", - "fields": [ - { - "name": "generic_DasH_vnf_DoT_resource_DasH_version", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_vnf_DasH_name", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_prov_DasH_status", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_is_DasH_closed_DasH_loop_DasH_disabled", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_orchestration_DasH_status", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_vnf_DasH_type", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_in_DasH_maint", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_service_DasH_id", - "type": "string" - }, - { - "name": "generic_DasH_vnf_DoT_vnf_DasH_id", - "type": "string" - } - ] - } - ] - } - ] -}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AaiAndGuardSimEndpointTest.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AaiAndGuardSimEndpointTest.java deleted file mode 100644 index 5b9040f95..000000000 --- a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AaiAndGuardSimEndpointTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.apex.domains.onap.vcpe; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import com.google.gson.Gson; - -import java.util.Map; -import java.util.Random; - -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.core.Response; - -/** - * The Class AaiAndGuardSimEndpoint. - */ -@Path("/sim") -public class AaiAndGuardSimEndpointTest { - - private static int postMessagesReceived = 0; - private static int putMessagesReceived = 0; - private static int statMessagesReceived = 0; - private static int getMessagesReceived = 0; - - /** - * Service get stats. - * - * @return the response - */ - @Path("/pdp/api/Stats") - @GET - public Response serviceGetStats() { - statMessagesReceived++; - return Response.status(200).entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived - + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); - } - - /** - * Service guard post request. - * - * @param jsonString the json string - * @return the response - */ - @Path("/pdp/api/getDecision") - @POST - public Response serviceGuardPostRequest(final String jsonString) { - postMessagesReceived++; - - if (postMessagesReceived % 2 == 0) { - return Response.status(200).entity("{\"decision\": \"PERMIT\", \"details\": \"Decision Permit. OK!\"}") - .build(); - } else { - return Response.status(200).entity("{\"decision\": \"DENY\", \"details\": \"Decision Denied. NOK :-(\"}") - .build(); - } - } - - /** - * Service get event. - * - * @return the response - */ - @Path("/event/GetEvent") - @GET - public Response serviceGetEvent() { - final Random rand = new Random(); - final int nextMatchCase = rand.nextInt(4); - 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" + "}"; - - getMessagesReceived++; - - return Response.status(200).entity(eventString).build(); - } - - /** - * Service get empty event. - * - * @return the response - */ - @Path("/event/GetEmptyEvent") - @GET - public Response serviceGetEmptyEvent() { - return Response.status(200).build(); - } - - /** - * Service get event bad response. - * - * @return the response - */ - @Path("/event/GetEventBadResponse") - @GET - public Response serviceGetEventBadResponse() { - return Response.status(400).build(); - } - - /** - * Service post request. - * - * @param jsonString the json string - * @return the response - */ - @Path("/event/PostEvent") - @POST - public Response servicePostRequest(final String jsonString) { - postMessagesReceived++; - - @SuppressWarnings("unchecked") - final Map<String, Object> jsonMap = new Gson().fromJson(jsonString, Map.class); - assertTrue(jsonMap.containsKey("name")); - assertEquals("0.0.1", jsonMap.get("version")); - assertEquals("org.onap.policy.apex.sample.events", jsonMap.get("nameSpace")); - assertEquals("Act", jsonMap.get("source")); - assertEquals("Outside", jsonMap.get("target")); - - return Response.status(200).entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived - + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); - } - - /** - * Service post request bad response. - * - * @param jsonString the json string - * @return the response - */ - @Path("/event/PostEventBadResponse") - @POST - public Response servicePostRequestBadResponse(final String jsonString) { - return Response.status(400).build(); - } - - /** - * Service put request. - * - * @param jsonString the json string - * @return the response - */ - @Path("/event/PutEvent") - @PUT - public Response servicePutRequest(final String jsonString) { - putMessagesReceived++; - - @SuppressWarnings("unchecked") - final Map<String, Object> jsonMap = new Gson().fromJson(jsonString, Map.class); - assertTrue(jsonMap.containsKey("name")); - assertEquals("0.0.1", jsonMap.get("version")); - assertEquals("org.onap.policy.apex.sample.events", jsonMap.get("nameSpace")); - assertEquals("Act", jsonMap.get("source")); - assertEquals("Outside", jsonMap.get("target")); - - return Response.status(200).entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived - + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); - } -} 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 new file mode 100644 index 000000000..f5f2b2792 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AppcResponseCreator.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.domains.onap.vcpe; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.BlockingQueue; + +import org.onap.policy.appclcm.LcmRequest; +import org.onap.policy.appclcm.LcmRequestWrapper; +import org.onap.policy.appclcm.LcmResponse; +import org.onap.policy.appclcm.LcmResponseWrapper; +import org.onap.policy.appclcm.util.Serialization; + +/** + * Respond to an APPC request with a given delay. + */ +public class AppcResponseCreator { + // The request from APPC + private final String jsonRequestString; + + // The queue for APPC responses + private final BlockingQueue<String> appcResponseQueue; + + // The timer task for response generation + private final Timer appcTimer; + + /** + * Respond to the given APPC request after the given amount of milliseconds. + * + * @param appcResponseQueue the queue into which to put the APPC response + * @param jsonRequestString the request JSON string + * @param milliSecondsToWait the number of milliseconds to wait + */ + public AppcResponseCreator(BlockingQueue<String> appcResponseQueue, String jsonRequestString, + long milliSecondsToWait) { + this.jsonRequestString = jsonRequestString; + this.appcResponseQueue = appcResponseQueue; + + appcTimer = new Timer(); + appcTimer.schedule(new AppcTimerTask(), milliSecondsToWait); + } + + private class AppcTimerTask extends TimerTask { + /* + * (non-Javadoc) + * + * @see java.util.TimerTask#run() + */ + @Override + public void run() { + Gson gson = new GsonBuilder().registerTypeAdapter(LcmRequest.class, new Serialization.RequestAdapter()) + .registerTypeAdapter(LcmResponse.class, new Serialization.ResponseAdapter()) + .setPrettyPrinting().create(); + + LcmRequestWrapper requestWrapper = gson.fromJson(jsonRequestString, LcmRequestWrapper.class); + + LcmResponse response = new LcmResponse(requestWrapper.getBody()); + response.getStatus().setCode(400); + response.getStatus().setMessage("Restart Successful"); + + LcmResponseWrapper responseWrapper = new LcmResponseWrapper(); + responseWrapper.setBody(response); + + responseWrapper.setVersion(requestWrapper.getVersion()); + responseWrapper.setRpcName(requestWrapper.getRpcName()); + responseWrapper.setCorrelationId(requestWrapper.getCorrelationId()); + responseWrapper.setType(requestWrapper.getType()); + + appcResponseQueue.add(gson.toJson(responseWrapper, LcmResponseWrapper.class)); + } + } +} diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AaiAndGuardSim.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSim.java index 93b587a41..671f333d9 100644 --- a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AaiAndGuardSim.java +++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSim.java @@ -30,17 +30,18 @@ import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; /** * The Class AaiAndGuardSim. */ -public class AaiAndGuardSim { - private static final String BASE_URI = "http://localhost:54321/AAIAndGuardSim"; +public class OnapVCpeSim { private static final int MAX_LOOPS = 100000; private HttpServer server; /** * Instantiates a new aai and guard sim. */ - public AaiAndGuardSim() { - final ResourceConfig rc = new ResourceConfig(AaiAndGuardSimEndpointTest.class); - server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc); + public OnapVCpeSim(final String[] args) { + final String baseUri = "http://" + args[0] + ':' + args[1] + "/OnapVCpeSim"; + + final ResourceConfig rc = new ResourceConfig(OnapVCpeSimEndpoint.class); + server = GrizzlyHttpServerFactory.createHttpServer(URI.create(baseUri), rc); while (!server.isStarted()) { ThreadUtilities.sleep(50); @@ -63,7 +64,7 @@ public class AaiAndGuardSim { * @throws Exception the exception */ public static void main(final String[] args) throws Exception { - final AaiAndGuardSim sim = new AaiAndGuardSim(); + final OnapVCpeSim sim = new OnapVCpeSim(args); for (int index = 0; index < MAX_LOOPS; index++) { ThreadUtilities.sleep(100); 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 new file mode 100644 index 000000000..936c319a9 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java @@ -0,0 +1,343 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.domains.onap.vcpe; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +import java.util.Map; +import java.util.Random; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + +import org.onap.policy.aai.AaiNqGenericVnf; +import org.onap.policy.aai.AaiNqInventoryResponseItem; +import org.onap.policy.aai.AaiNqRequest; +import org.onap.policy.aai.AaiNqResponse; +import org.onap.policy.aai.AaiNqVfModule; +import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; +import org.slf4j.ext.XLogger; +import org.slf4j.ext.XLoggerFactory; + +/** + * The Class AaiAndGuardSimEndpoint. + */ +@Path("/sim") +public class OnapVCpeSimEndpoint { + private static final XLogger LOGGER = XLoggerFactory.getXLogger(OnapVCpeSimEndpoint.class); + + private static BlockingQueue<String> appcResponseQueue = new LinkedBlockingQueue<>(); + + private static AtomicInteger guardMessagesReceived = new AtomicInteger(); + private static AtomicInteger postMessagesReceived = new AtomicInteger(); + private static AtomicInteger putMessagesReceived = new AtomicInteger(); + private static AtomicInteger statMessagesReceived = new AtomicInteger(); + private static AtomicInteger getMessagesReceived = new AtomicInteger(); + + /** + * Service get stats. + * + * @return the response + */ + @Path("/pdp/api/Stats") + @GET + public Response serviceGetStats() { + statMessagesReceived.incrementAndGet(); + + return Response.status(200).entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); + } + + /** + * Service guard post request. + * + * @param jsonString the json string + * @return the response + */ + @Path("/pdp/api/getDecision") + @POST + public Response serviceGuardPostRequest(final String jsonString) { + LOGGER.info("\n*** GUARD REQUEST START ***\n" + jsonString + "\n *** GUARD REQUEST END ***"); + + String target = jsonString.substring(jsonString.indexOf("b4fe00ac")); + target = target.substring(0, target.indexOf('"')); + + int thisGuardMessageNumber = guardMessagesReceived.incrementAndGet(); + postMessagesReceived.incrementAndGet(); + + String responseJsonString = null; + if (thisGuardMessageNumber % 2 == 0) { + responseJsonString = "{\"decision\": \"PERMIT\", \"details\": \"Decision Permit. OK!\"}"; + } else { + responseJsonString = "{\"decision\": \"DENY\", \"details\": \"Decision Denied. NOK :-(\"}"; + } + + LOGGER.info("\n*** GUARD RESPONSE START ***\n" + target + "\n" + responseJsonString + + "\n*** GUARD RESPONSE END ***"); + + return Response.status(200).entity(responseJsonString).build(); + } + + /** + * AAI named query request. + * + * @param jsonString the json string + * @return the response + */ + @Path("aai/search/named-query") + @POST + public Response aaiNamedQueryRequest(final String jsonString) { + postMessagesReceived.incrementAndGet(); + + LOGGER.info("\n*** AAI REQUEST START ***\n" + jsonString + "\n *** AAI REQUEST END ***"); + + AaiNqRequest request = new Gson().fromJson(jsonString, AaiNqRequest.class); + String vnfId = request.getInstanceFilters().getInstanceFilter().iterator().next().get("generic-vnf") + .get("vnf-id"); + String vnfSuffix = vnfId.substring(vnfId.length() - 4); + + AaiNqInventoryResponseItem responseItem = new AaiNqInventoryResponseItem(); + responseItem.setModelName("vCPE"); + + AaiNqGenericVnf genericVnf = new AaiNqGenericVnf(); + genericVnf.setResourceVersion("1"); + genericVnf.setVnfName("vCPEInfraVNF" + vnfSuffix); + genericVnf.setProvStatus("PREPROV"); + genericVnf.setIsClosedLoopDisabled(false); + genericVnf.setVnfType("vCPEInfraService10/vCPEInfraService10 0"); + genericVnf.setInMaint(false); + genericVnf.setServiceId("5585fd2c-ad0d-4050-b0cf-dfe4a03bd01f"); + genericVnf.setVnfId(vnfId); + + responseItem.setGenericVnf(genericVnf); + + AaiNqVfModule vfModule = new AaiNqVfModule(); + vfModule.setOrchestrationStatus("Created"); + + responseItem.setVfModule(vfModule); + + AaiNqResponse response = new AaiNqResponse(); + response.getInventoryResponseItems().add(responseItem); + + String responseJsonString = new GsonBuilder().setPrettyPrinting().create().toJson(response); + + LOGGER.info("\n*** AAI RESPONSE START ***\n" + responseJsonString + "\n *** AAI RESPONSE END ***"); + + return Response.status(200).entity(responseJsonString).build(); + } + + /** + * DCAE input of events (simulation of DMaaP). + * + * @param timeout the timeout to wait for + * @return the response + */ + @Path("events/unauthenticated.DCAE_CL_OUTPUT/APEX/1") + @GET + public Response dcaeClOutput(@QueryParam("timeout") final int timeout) { + getMessagesReceived.incrementAndGet(); + + ThreadUtilities.sleep(timeout - 500); + + return Response.status(200).build(); + } + + /** + * APPC response events (simulation of DMaaP). + * + * @param timeout the timeout to wait for + * @return the response + * @throws InterruptedException on queue interrupts + */ + @Path("events/APPC_LCM_WRITE/APEX/1") + @GET + public Response appcResponseOutput(@QueryParam("timeout") final int timeout) throws InterruptedException { + getMessagesReceived.incrementAndGet(); + + int timeLeft = timeout - 500; + + do { + String appcResponse = appcResponseQueue.poll(100, TimeUnit.MILLISECONDS); + + if (appcResponse != null) { + LOGGER.info("\n*** APPC RESPONSE START ***"); + System.err.println(appcResponse); + LOGGER.info("\n*** APPC RESPONSE END ***"); + + return Response.status(200).entity(appcResponse).build(); + } + timeLeft -= 100; + } + while (timeLeft > 0); + + return Response.status(200).build(); + } + + /** + * Post to Policy management log (Simulation of DMaaP). + * + * @param jsonString the json string + * @return the response + */ + @Path("/events/POLICY_CL_MGT") + @POST + public Response policyLogRequest(final String jsonString) { + postMessagesReceived.incrementAndGet(); + + LOGGER.info("\n*** POLICY LOG ENTRY START ***\n" + jsonString + "\n *** POLICY LOG ENTRY END ***"); + + return Response.status(200).build(); + } + + /** + * Post to APPC LCM (Simulation of DMaaP). + * + * @param jsonString the json string + * @return the response + */ + @Path("/events/APPC-LCM-READ") + @POST + public Response appcRequest(final String jsonString) { + postMessagesReceived.incrementAndGet(); + + LOGGER.info("\n*** APPC REQUEST START ***\n" + jsonString + "\n *** APPC REQUEST END ***"); + + new AppcResponseCreator(appcResponseQueue, jsonString, 10000); + + return Response.status(200).build(); + } + + /** + * Service get event. + * + * @return the response + */ + @Path("/event/GetEvent") + @GET + public Response serviceGetEvent() { + final Random rand = new Random(); + final int nextMatchCase = rand.nextInt(4); + 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" + "}"; + + getMessagesReceived.incrementAndGet(); + + return Response.status(200).entity(eventString).build(); + } + + /** + * Service get empty event. + * + * @return the response + */ + @Path("/event/GetEmptyEvent") + @GET + public Response serviceGetEmptyEvent() { + return Response.status(200).build(); + } + + /** + * Service get event bad response. + * + * @return the response + */ + @Path("/event/GetEventBadResponse") + @GET + public Response serviceGetEventBadResponse() { + return Response.status(400).build(); + } + + /** + * Service post request. + * + * @param jsonString the json string + * @return the response + */ + @Path("/event/PostEvent") + @POST + public Response servicePostRequest(final String jsonString) { + postMessagesReceived.incrementAndGet(); + + @SuppressWarnings("unchecked") + final Map<String, Object> jsonMap = new Gson().fromJson(jsonString, Map.class); + assertTrue(jsonMap.containsKey("name")); + assertEquals("0.0.1", jsonMap.get("version")); + assertEquals("org.onap.policy.apex.sample.events", jsonMap.get("nameSpace")); + assertEquals("Act", jsonMap.get("source")); + assertEquals("Outside", jsonMap.get("target")); + + return Response.status(200).entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); + } + + /** + * Service post request bad response. + * + * @param jsonString the json string + * @return the response + */ + @Path("/event/PostEventBadResponse") + @POST + public Response servicePostRequestBadResponse(final String jsonString) { + return Response.status(400).build(); + } + + /** + * Service put request. + * + * @param jsonString the json string + * @return the response + */ + @Path("/event/PutEvent") + @PUT + public Response servicePutRequest(final String jsonString) { + putMessagesReceived.incrementAndGet(); + + @SuppressWarnings("unchecked") + final Map<String, Object> jsonMap = new Gson().fromJson(jsonString, Map.class); + assertTrue(jsonMap.containsKey("name")); + assertEquals("0.0.1", jsonMap.get("version")); + assertEquals("org.onap.policy.apex.sample.events", jsonMap.get("nameSpace")); + assertEquals("Act", jsonMap.get("source")); + assertEquals("Outside", jsonMap.get("target")); + + return Response.status(200).entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); + } +} diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVcpeRunner.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVcpeRunner.java new file mode 100644 index 000000000..4f6b6101c --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVcpeRunner.java @@ -0,0 +1,68 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 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 OnapVcpeRunner { + + private OnapVcpeRunner() throws ApexException { + + // @formatter:off + final String[] cliArgs = new String[] { + "-c", + "src/main/resources/policy/ONAPvCPEPolicyModel.apex", + "-l", + "target/ONAPvCPEPolicyModel.log", + "-o", + "target/classes/ONAPvCPEPolicyModel.json" + }; + // @formatter:on + + new ApexCommandLineEditorMain(cliArgs); + + // @formatter:off + final String[] apexArgs = { + "-rfr", + "target/classes", + "-c", + "src/main/resources/examples/config/ONAPvCPE/ApexConfig_Sim.json", + "-m", + "target/classes/ONAPvCPEPolicyModel.json" + }; + // @formatter:on + + final ApexMain apexMain = new ApexMain(apexArgs); + + ThreadUtilities.sleep(1000000); + apexMain.shutdown(); + } + + public static void main(String[] args) throws ApexException { + new OnapVcpeRunner(); + } +} diff --git a/examples/examples-onap-vcpe/src/test/resources/config/ApexConfigFileOnly.json b/examples/examples-onap-vcpe/src/test/resources/config/ApexConfigFileOnly.json deleted file mode 100644 index ae365c39b..000000000 --- a/examples/examples-onap-vcpe/src/test/resources/config/ApexConfigFileOnly.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "engineServiceParameters": { - "name": "MyApexEngine", - "version": "0.0.1", - "id": 45, - "instanceCount": 4, - "deploymentPort": 12561, - "policyModelFileName": "policy/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" - } - } - } - } - }, - "eventInputParameters": { - "VCPEInitConsumer": { - "carrierTechnologyParameters": { - "carrierTechnology": "FILE", - "parameters": { - "fileName": "src/main/resources/config/VCPEInitiationEvents.txt" - } - }, - "eventProtocolParameters": { - "eventProtocol": "JSON", - "parameters": { - "nameAlias": "closedLoopControlName", - "versionAlias": "version", - "sourceAlias": "from" - } - } - }, - "GuardRequestorConsumer": { - "carrierTechnologyParameters": { - "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters", - "parameters": { - "url": "http://localhost:54321/AAIAndGuardSim/sim/pdp/api/getDecision", - "httpMethod": "POST", - "restRequestTimeout": 2000 - } - }, - "eventProtocolParameters": { - "eventProtocol": "JSON" - }, - "eventName": "GuardResponseEvent", - "eventNameFilter": "GuardResponseEvent", - "requestorMode": true, - "requestorPeer": "GuardRequestorProducer", - "requestorTimeout": 500 - } - }, - "eventOutputParameters": { - "GuardRequestorProducer": { - "carrierTechnologyParameters": { - "carrierTechnology": "RESTREQUESTOR", - "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters" - }, - "eventProtocolParameters": { - "eventProtocol": "JSON" - }, - "eventNameFilter": "GuardRequestEvent", - "requestorMode": true, - "requestorPeer": "GuardRequestorConsumer", - "requestorTimeout": 500 - }, - "logProducer": { - "carrierTechnologyParameters": { - "carrierTechnology": "FILE", - "parameters": { - "fileName": "/tmp/VCPEEventsOut.json" - } - }, - "eventProtocolParameters": { - "eventProtocol": "JSON" - } - } - } -} diff --git a/examples/examples-onap-vcpe/src/test/resources/config/appc.lcm.success.json b/examples/examples-onap-vcpe/src/test/resources/config/appc.lcm.success.json deleted file mode 100644 index 2d2005d98..000000000 --- a/examples/examples-onap-vcpe/src/test/resources/config/appc.lcm.success.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "body": { - "output": { - "common-header": { - "timestamp": "2017-08-25T21:06:23.037Z", - "api-ver": "5.00", - "originator-id": "664be3d2-6c12-4f4b-a3e7-c349acced200", - "request-id": "664be3d2-6c12-4f4b-a3e7-c349acced200", - "sub-request-id": "1", - "flags": {} - }, - "status": { - "code": 400, - "message": "Restart Successful" - } - } - }, - "version": "2.0", - "rpc-name": "restart", - "correlation-id": "664be3d2-6c12-4f4b-a3e7-c349acced200-1", - "type": "response" -}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/test/resources/config/dcae.vcpe.abatement.json b/examples/examples-onap-vcpe/src/test/resources/config/dcae.vcpe.abatement.json deleted file mode 100644 index 729451191..000000000 --- a/examples/examples-onap-vcpe/src/test/resources/config/dcae.vcpe.abatement.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "closedLoopControlName": "${closedLoopControlName}", - "closedLoopAlarmStart": 1463679805324, - "closedLoopAlarmEnd": 1463699805324, - "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", - "closedLoopEventStatus": "ABATED", - "requestID": "664be3d2-6c12-4f4b-a3e7-c349acced200", - "target_type": "VNF", - "target": "generic-vnf.vnf-id", - "AAI": { - "vserver.is-closed-loop-disabled": "false", - "generic-vnf.vnf-id": "vCPE_Infrastructure_vGMUX_demo_app" - }, - "from": "DCAE", - "version": "1.0.2" -} diff --git a/examples/examples-onap-vcpe/src/test/resources/config/dcae.vcpe.onset.json b/examples/examples-onap-vcpe/src/test/resources/config/dcae.vcpe.onset.json deleted file mode 100644 index feb15c153..000000000 --- a/examples/examples-onap-vcpe/src/test/resources/config/dcae.vcpe.onset.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "closedLoopControlName": "${closedLoopControlName}", - "closedLoopAlarmStart": 1463679805324, - "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", - "closedLoopEventStatus": "ONSET", - "requestID": "664be3d2-6c12-4f4b-a3e7-c349acced200", - "target_type": "VNF", - "target": "generic-vnf.vnf-id", - "AAI": { - "vserver.is-closed-loop-disabled": "false", - "generic-vnf.vnf-id": "vCPE_Infrastructure_vGMUX_demo_app" - }, - "from": "DCAE", - "version": "1.0.2" -} diff --git a/examples/examples-onap-vcpe/src/test/resources/etc/Notes.txt b/examples/examples-onap-vcpe/src/test/resources/etc/Notes.txt new file mode 100644 index 000000000..5db41a2a0 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/etc/Notes.txt @@ -0,0 +1,31 @@ +Check out Draft Review + +Build the source +mvn clean install + +Build the docker image for the demo +cd packages/apex-pdp-docker/src/main/ +cp ../../../apex-pdp-package-full/target/apex-pdp-package-full-2.0.0-SNAPSHOT-tarball.tar.gz docker/apex-pdp-package-full.tar.gz +docker build -t apex-onap-vcpe docker + +Run the Docker container +docker run -it --rm -p 12561:12561 apex-onap-vcpe + +Find the address of the host containter +ip route list + +Update the configuration file REST URLs with the IP address of the source container +vi examples/config/ONAPvCPE/ApexConfig.json +examples/config/ONAPvCPE/ApexConfigStdin.json + +Run simulator from command line on host machine using Maven, replacing xxx.xxx.xxx.xxx with the IP address of the local host +mvn exec:java -Dexec.classpathScope="test" -Dexec.mainClass=org.onap.policy.apex.domains.onap.vcpe.OnapVCpeSim -Dexec.args="xxx.xxx.xxx.xxx 54321" + +Run the engine in Docker, running the full example +/opt/app/policy/apex-pdp/bin/apexApps.sh engine -c examples/config/ONAPvCPE/ApexConfig.json + +Run the engine in Docker, running with pasting into console using standard input +/opt/app/policy/apex-pdp/bin/apexApps.sh engine -c examples/config/ONAPvCPE/ApexConfigStdin.json + +On an extraction of the Apex tarball, run the Apex client +bin/apexApps.sh full-client |